Java Code Examples for org.apache.olingo.commons.api.data.Property#isEnum()

The following examples show how to use org.apache.olingo.commons.api.data.Property#isEnum() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ODataJsonSerializer.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
private void writePrimitive(final EdmPrimitiveType type, final Property property,
    final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
    final Boolean isUnicode, final JsonGenerator json)
    throws EdmPrimitiveTypeException, IOException, SerializerException {
  if (property.isPrimitive()) {
    writePrimitiveValue(property.getName(), type, property.asPrimitive(),
        isNullable, maxLength, precision, scale, isUnicode, json);
  } else if (property.isGeospatial()) {
    writeGeoValue(property.getName(), type, property.asGeospatial(), isNullable, json, null);
  } else if (property.isEnum()) {
    writePrimitiveValue(property.getName(), type, property.asEnum(),
        isNullable, maxLength, precision, scale, isUnicode, json);
  } else {
    throw new SerializerException("Inconsistent property type!",
        SerializerException.MessageKeys.INCONSISTENT_PROPERTY_TYPE, property.getName());
  }
}
 
Example 2
Source File: JsonDeltaSerializerWithNavigations.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
private void writePrimitive(final EdmPrimitiveType type, final Property property,
    final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
    final Boolean isUnicode, final JsonGenerator json)
    throws EdmPrimitiveTypeException, IOException, SerializerException {
  if (property.isPrimitive()) {
    writePrimitiveValue(property.getName(), type, property.asPrimitive(),
        isNullable, maxLength, precision, scale, isUnicode, json);
  } else if (property.isGeospatial()) {
    throw new SerializerException("Property type not yet supported!",
        SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, property.getName());
  } else if (property.isEnum()) {
    writePrimitiveValue(property.getName(), type, property.asEnum(),
        isNullable, maxLength, precision, scale, isUnicode, json);
  } else {
    throw new SerializerException("Inconsistent property type!",
        SerializerException.MessageKeys.INCONSISTENT_PROPERTY_TYPE, property.getName());
  }
}
 
Example 3
Source File: JsonDeltaSerializer.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
private void writePrimitive(final EdmPrimitiveType type, final Property property,
    final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
    final Boolean isUnicode, final JsonGenerator json)
    throws EdmPrimitiveTypeException, IOException, SerializerException {
  if (property.isPrimitive()) {
    writePrimitiveValue(property.getName(), type, property.asPrimitive(),
        isNullable, maxLength, precision, scale, isUnicode, json);
  } else if (property.isGeospatial()) {
    throw new SerializerException("Property type not yet supported!",
        SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, property.getName());
  } else if (property.isEnum()) {
    writePrimitiveValue(property.getName(), type, property.asEnum(),
        isNullable, maxLength, precision, scale, isUnicode, json);
  } else {
    throw new SerializerException("Inconsistent property type!",
        SerializerException.MessageKeys.INCONSISTENT_PROPERTY_TYPE, property.getName());
  }
}
 
Example 4
Source File: ODataXmlSerializer.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
private void writePrimitive(final EdmPrimitiveType type, final Property property,
    final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
    final Boolean isUnicode, final String xml10InvalidCharReplacement, final XMLStreamWriter writer)
    throws EdmPrimitiveTypeException, XMLStreamException, SerializerException {
  if (property.isPrimitive()) {
    if (type != EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.String)) {
      writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE,
          type.getKind() == EdmTypeKind.DEFINITION ?
              "#" + type.getFullQualifiedName().getFullQualifiedNameAsString() :
              type.getName());
    }
    writePrimitiveValue(type, property.asPrimitive(),
        isNullable, maxLength, precision, scale, isUnicode, xml10InvalidCharReplacement, writer);
  } else if (property.isGeospatial()) {
    throw new SerializerException("Property type not yet supported!",
        SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, property.getName());
  } else if (property.isEnum()) {
    writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE,
        "#" + type.getFullQualifiedName().getFullQualifiedNameAsString());
    writePrimitiveValue(type, property.asEnum(),
        isNullable, maxLength, precision, scale, isUnicode, xml10InvalidCharReplacement, writer);
  } else {
    throw new SerializerException("Inconsistent property type!",
        SerializerException.MessageKeys.INCONSISTENT_PROPERTY_TYPE, property.getName());
  }
}