in lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonInstanceAnnotationSerializer.java [180:229]
protected void writePrimitiveValue(final String name, final EdmPrimitiveType type, final Object primitiveValue,
final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
final Boolean isUnicode, final JsonGenerator json)
throws EdmPrimitiveTypeException, IOException {
final String value = type.valueToString(
primitiveValue, isNullable, maxLength, precision, scale, isUnicode);
if (value == null) {
json.writeNull();
} else if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean)) {
json.writeBoolean(Boolean.parseBoolean(value));
} else if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Byte)
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Double)
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int16)
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32)
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.SByte)
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Single)
|| (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Decimal)
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int64))
&& !isIEEE754Compatible) {
json.writeNumber(value);
} else if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Stream)) {
if (primitiveValue instanceof Link) {
Link stream = (Link) primitiveValue;
if (!isODataMetadataNone) {
if (stream.getMediaETag() != null) {
json.writeStringField(name + constants.getMediaEtag(),
stream.getMediaETag());
}
if (stream.getType() != null) {
json.writeStringField(name + constants.getMediaContentType(),
stream.getType());
}
}
if (isODataMetadataFull) {
if (stream.getRel() != null &&
stream.getRel().equals(Constants.NS_MEDIA_READ_LINK_REL)) {
json.writeStringField(name + constants.getMediaReadLink(),
stream.getHref());
}
if (stream.getRel() == null ||
stream.getRel().equals(Constants.NS_MEDIA_EDIT_LINK_REL)) {
json.writeStringField(name + constants.getMediaEditLink(),
stream.getHref());
}
}
}
} else {
json.writeString(value);
}
}