in lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java [340:490]
private void appendDynamicExpression(final XMLStreamWriter writer, final EdmDynamicExpression dynExp)
throws XMLStreamException {
writer.writeStartElement(dynExp.getExpressionName());
switch (dynExp.getExpressionType()) {
// Logical
case And:
appendLogicalOrComparisonExpression(writer, dynExp.asAnd());
break;
case Or:
appendLogicalOrComparisonExpression(writer, dynExp.asOr());
break;
case Not:
appendNotExpression(writer, dynExp.asNot());
break;
// Comparison
case Eq:
appendLogicalOrComparisonExpression(writer, dynExp.asEq());
break;
case Ne:
appendLogicalOrComparisonExpression(writer, dynExp.asNe());
break;
case Gt:
appendLogicalOrComparisonExpression(writer, dynExp.asGt());
break;
case Ge:
appendLogicalOrComparisonExpression(writer, dynExp.asGe());
break;
case Lt:
appendLogicalOrComparisonExpression(writer, dynExp.asLt());
break;
case Le:
appendLogicalOrComparisonExpression(writer, dynExp.asLe());
break;
case AnnotationPath:
writer.writeCharacters(dynExp.asAnnotationPath().getValue());
break;
case Apply:
EdmApply asApply = dynExp.asApply();
writer.writeAttribute(XML_FUNCTION, asApply.getFunction());
for (EdmExpression parameter : asApply.getParameters()) {
appendExpression(writer, parameter);
}
appendAnnotations(writer, asApply);
break;
case Cast:
EdmCast asCast = dynExp.asCast();
writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(asCast.getType(), false));
if (asCast.getMaxLength() != null) {
writer.writeAttribute(XML_MAX_LENGTH, "" + asCast.getMaxLength());
}
if (asCast.getPrecision() != null) {
writer.writeAttribute(XML_PRECISION, "" + asCast.getPrecision());
}
if (asCast.getScale() != null) {
writer.writeAttribute(XML_SCALE, "" + asCast.getScale());
}
appendExpression(writer, asCast.getValue());
appendAnnotations(writer, asCast);
break;
case Collection:
for (EdmExpression item : dynExp.asCollection().getItems()) {
appendExpression(writer, item);
}
break;
case If:
EdmIf asIf = dynExp.asIf();
appendExpression(writer, asIf.getGuard());
appendExpression(writer, asIf.getThen());
appendExpression(writer, asIf.getElse());
appendAnnotations(writer, asIf);
break;
case IsOf:
EdmIsOf asIsOf = dynExp.asIsOf();
writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(asIsOf.getType(), false));
if (asIsOf.getMaxLength() != null) {
writer.writeAttribute(XML_MAX_LENGTH, "" + asIsOf.getMaxLength());
}
if (asIsOf.getPrecision() != null) {
writer.writeAttribute(XML_PRECISION, "" + asIsOf.getPrecision());
}
if (asIsOf.getScale() != null) {
writer.writeAttribute(XML_SCALE, "" + asIsOf.getScale());
}
appendExpression(writer, asIsOf.getValue());
appendAnnotations(writer, asIsOf);
break;
case LabeledElement:
EdmLabeledElement asLabeledElement = dynExp.asLabeledElement();
writer.writeAttribute(XML_NAME, asLabeledElement.getName());
appendExpression(writer, asLabeledElement.getValue());
appendAnnotations(writer, asLabeledElement);
break;
case LabeledElementReference:
EdmLabeledElementReference asLabeledElementReference = dynExp.asLabeledElementReference();
writer.writeCharacters(asLabeledElementReference.getValue());
break;
case Null:
appendAnnotations(writer, dynExp.asNull());
break;
case NavigationPropertyPath:
EdmNavigationPropertyPath asNavigationPropertyPath = dynExp.asNavigationPropertyPath();
writer.writeCharacters(asNavigationPropertyPath.getValue());
break;
case Path:
EdmPath asPath = dynExp.asPath();
writer.writeCharacters(asPath.getValue());
break;
case PropertyPath:
EdmPropertyPath asPropertyPath = dynExp.asPropertyPath();
writer.writeCharacters(asPropertyPath.getValue());
break;
case Record:
EdmRecord asRecord = dynExp.asRecord();
try {
EdmStructuredType structuredType = asRecord.getType();
if (structuredType != null) {
writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(structuredType, false));
}
} catch (EdmException e) {
FullQualifiedName type = asRecord.getTypeFQN();
if (type != null) {
writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(type, false));
}
}
for (EdmPropertyValue propValue : asRecord.getPropertyValues()) {
writer.writeStartElement(XML_PROPERTY_VALUE);
writer.writeAttribute(XML_PROPERTY, propValue.getProperty());
appendExpression(writer, propValue.getValue());
appendAnnotations(writer, propValue);
writer.writeEndElement();
}
appendAnnotations(writer, asRecord);
break;
case UrlRef:
EdmUrlRef asUrlRef = dynExp.asUrlRef();
appendExpression(writer, asUrlRef.getValue());
appendAnnotations(writer, asUrlRef);
break;
default:
throw new IllegalArgumentException("Unkown ExpressionType for dynamic expression: " + dynExp.getExpressionType());
}
writer.writeEndElement();
}