Class ODataJsonSerializer
java.lang.Object
org.apache.olingo.server.core.serializer.json.ODataJsonSerializer
- All Implemented Interfaces:
ODataSerializer
-
Field Summary
Fields inherited from interface org.apache.olingo.server.api.serializer.ODataSerializer
DEFAULT_CHARSET -
Constructor Summary
ConstructorsConstructorDescriptionODataJsonSerializer(ContentType contentType) ODataJsonSerializer(ContentType contentType, IConstants constants) -
Method Summary
Modifier and TypeMethodDescriptionprotected ContextURLcheckContextURL(ContextURL contextURL) complex(ServiceMetadata metadata, EdmComplexType type, Property property, ComplexSerializerOptions options) Writes complex-type instance data into an InputStream.complexCollection(ServiceMetadata metadata, EdmComplexType type, Property property, ComplexSerializerOptions options) Writes data of a collection of complex-type instances into an InputStream.entity(ServiceMetadata metadata, EdmEntityType entityType, Entity entity, EntitySerializerOptions options) Writes entity data into an InputStream.entityCollection(ServiceMetadata metadata, EdmEntityType entityType, AbstractEntityCollection entitySet, EntityCollectionSerializerOptions options) Writes entity-collection data into an InputStream.voidentityCollectionIntoStream(ServiceMetadata metadata, EdmEntityType entityType, AbstractEntityCollectionObject entitySet, EntityCollectionSerializerOptions options, OutputStream outputStream) entityCollectionStreamed(ServiceMetadata metadata, EdmEntityType entityType, AbstractEntityCollectionObject entities, EntityCollectionSerializerOptions options) Writes entity-collection data into an InputStream.error(ODataServerError error) Writes an ODataError into an InputStream.protected StringgetEntityId(Entity entity, EdmEntityType entityType, String name) Get the ascii representation of the entity id or thrown anSerializerExceptionif id isnull.metadataDocument(ServiceMetadata serviceMetadata) Writes the metadata document into an InputStream.primitive(ServiceMetadata metadata, EdmPrimitiveType type, Property property, PrimitiveSerializerOptions options) Writes primitive-type instance data into an InputStream.primitiveCollection(ServiceMetadata metadata, EdmPrimitiveType type, Property property, PrimitiveSerializerOptions options) Writes data of a collection of primitive-type instances into an InputStream.reference(ServiceMetadata metadata, EdmEntitySet edmEntitySet, Entity entity, ReferenceSerializerOptions options) Writes a single entity reference into an InputStream.referenceCollection(ServiceMetadata metadata, EdmEntitySet edmEntitySet, AbstractEntityCollection entityCollection, ReferenceCollectionSerializerOptions options) Writes entity-collection references into an InputStream.protected EdmComplexTyperesolveComplexType(ServiceMetadata metadata, EdmComplexType baseType, String derivedTypeName) protected EdmEntityTyperesolveEntityType(ServiceMetadata metadata, EdmEntityType baseType, String derivedTypeName) serviceDocument(ServiceMetadata metadata, String serviceRoot) Writes the service document into an InputStream.protected voidwriteComplexValue(ServiceMetadata metadata, EdmComplexType type, List<Property> properties, Set<List<String>> selectedPaths, com.fasterxml.jackson.core.JsonGenerator json, Set<List<String>> expandedPaths, Linked linked, ExpandOption expand, String complexPropName) protected voidwriteContextURL(ContextURL contextURL, com.fasterxml.jackson.core.JsonGenerator json) protected voidwriteEntity(ServiceMetadata metadata, EdmEntityType entityType, Entity entity, ContextURL contextURL, ExpandOption expand, Integer toDepth, SelectOption select, boolean onlyReference, Set<String> ancestors, String name, com.fasterxml.jackson.core.JsonGenerator json) protected voidwriteEntitySet(ServiceMetadata metadata, EdmEntityType entityType, AbstractEntityCollectionObject entitySet, ExpandOption expand, Integer toDepth, SelectOption select, boolean onlyReference, Set<String> ancestors, String name, com.fasterxml.jackson.core.JsonGenerator json) protected voidwriteExpandedNavigationProperty(ServiceMetadata metadata, EdmNavigationProperty property, Link navigationLink, ExpandOption innerExpand, Integer toDepth, SelectOption innerSelect, CountOption innerCount, boolean writeOnlyCount, boolean writeOnlyRef, Set<String> ancestors, String name, com.fasterxml.jackson.core.JsonGenerator json) protected voidwriteExpandedStreamProperties(ServiceMetadata metadata, EdmStructuredType type, Linked linked, ExpandOption expand, Integer toDepth, Set<String> ancestors, String name, com.fasterxml.jackson.core.JsonGenerator json) protected voidwriteGeoValue(String name, EdmPrimitiveType type, Geospatial geoValue, Boolean isNullable, com.fasterxml.jackson.core.JsonGenerator json, SRID parentSrid) Writes a geospatial value following the GeoJSON specification defined in RFC 7946.protected voidwriteInlineCount(String propertyName, Integer count, com.fasterxml.jackson.core.JsonGenerator json) protected voidwriteMetadataETag(ServiceMetadata metadata, com.fasterxml.jackson.core.JsonGenerator json) protected voidwriteNavigationProperties(ServiceMetadata metadata, EdmStructuredType type, Linked linked, ExpandOption expand, Integer toDepth, Set<String> ancestors, String name, com.fasterxml.jackson.core.JsonGenerator json) protected voidwriteNextLink(AbstractEntityCollectionObject entitySet, com.fasterxml.jackson.core.JsonGenerator json) protected voidwritePrimitiveValue(String name, EdmPrimitiveType type, Object primitiveValue, Boolean isNullable, Integer maxLength, Integer precision, Integer scale, Boolean isUnicode, com.fasterxml.jackson.core.JsonGenerator json) protected voidwriteProperties(ServiceMetadata metadata, EdmStructuredType type, List<Property> properties, SelectOption select, com.fasterxml.jackson.core.JsonGenerator json, Linked linked, ExpandOption expand) protected voidwriteProperty(ServiceMetadata metadata, EdmProperty edmProperty, Property property, Set<List<String>> selectedPaths, com.fasterxml.jackson.core.JsonGenerator json, Set<List<String>> expandedPaths, Linked linked, ExpandOption expand)
-
Constructor Details
-
ODataJsonSerializer
-
ODataJsonSerializer
-
-
Method Details
-
serviceDocument
public SerializerResult serviceDocument(ServiceMetadata metadata, String serviceRoot) throws SerializerException Description copied from interface:ODataSerializerWrites the service document into an InputStream.- Specified by:
serviceDocumentin interfaceODataSerializer- Parameters:
metadata- the metadata information for the serviceserviceRoot- the service-root URI of this OData service- Throws:
SerializerException
-
metadataDocument
public SerializerResult metadataDocument(ServiceMetadata serviceMetadata) throws SerializerException Description copied from interface:ODataSerializerWrites the metadata document into an InputStream.- Specified by:
metadataDocumentin interfaceODataSerializer- Parameters:
serviceMetadata- the metadata information for the service- Throws:
SerializerException
-
error
Description copied from interface:ODataSerializerWrites an ODataError into an InputStream.- Specified by:
errorin interfaceODataSerializer- Parameters:
error- the main error- Throws:
SerializerException
-
entityCollection
public SerializerResult entityCollection(ServiceMetadata metadata, EdmEntityType entityType, AbstractEntityCollection entitySet, EntityCollectionSerializerOptions options) throws SerializerException Description copied from interface:ODataSerializerWrites entity-collection data into an InputStream.- Specified by:
entityCollectionin interfaceODataSerializer- Parameters:
metadata- metadata for the serviceentityType- theEdmEntityTypeentitySet- the data of the entity setoptions- options for the serializer- Throws:
SerializerException
-
entityCollectionStreamed
public SerializerStreamResult entityCollectionStreamed(ServiceMetadata metadata, EdmEntityType entityType, AbstractEntityCollectionObject entities, EntityCollectionSerializerOptions options) throws SerializerException Description copied from interface:ODataSerializerWrites entity-collection data into an InputStream.- Specified by:
entityCollectionStreamedin interfaceODataSerializer- Parameters:
metadata- metadata for the serviceentityType- theEdmEntityTypeentities- the data of the entity setoptions- options for the serializer- Throws:
SerializerException
-
entityCollectionIntoStream
public void entityCollectionIntoStream(ServiceMetadata metadata, EdmEntityType entityType, AbstractEntityCollectionObject entitySet, EntityCollectionSerializerOptions options, OutputStream outputStream) throws SerializerException - Throws:
SerializerException
-
entity
public SerializerResult entity(ServiceMetadata metadata, EdmEntityType entityType, Entity entity, EntitySerializerOptions options) throws SerializerException Description copied from interface:ODataSerializerWrites entity data into an InputStream.- Specified by:
entityin interfaceODataSerializer- Parameters:
metadata- metadata for the serviceentityType- theEdmEntityTypeentity- the data of the entityoptions- options for the serializer- Throws:
SerializerException
-
checkContextURL
- Throws:
SerializerException
-
writeEntitySet
protected void writeEntitySet(ServiceMetadata metadata, EdmEntityType entityType, AbstractEntityCollectionObject entitySet, ExpandOption expand, Integer toDepth, SelectOption select, boolean onlyReference, Set<String> ancestors, String name, com.fasterxml.jackson.core.JsonGenerator json) throws IOException, SerializerException, org.apache.commons.codec.DecoderException - Throws:
IOExceptionSerializerExceptionorg.apache.commons.codec.DecoderException
-
getEntityId
protected String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException Get the ascii representation of the entity id or thrown anSerializerExceptionif id isnull.- Parameters:
entity- the entityentityType-name-- Returns:
- ascii representation of the entity id
- Throws:
SerializerException
-
writeEntity
protected void writeEntity(ServiceMetadata metadata, EdmEntityType entityType, Entity entity, ContextURL contextURL, ExpandOption expand, Integer toDepth, SelectOption select, boolean onlyReference, Set<String> ancestors, String name, com.fasterxml.jackson.core.JsonGenerator json) throws IOException, SerializerException, org.apache.commons.codec.DecoderException - Throws:
IOExceptionSerializerExceptionorg.apache.commons.codec.DecoderException
-
resolveEntityType
protected EdmEntityType resolveEntityType(ServiceMetadata metadata, EdmEntityType baseType, String derivedTypeName) throws SerializerException - Throws:
SerializerException
-
resolveComplexType
protected EdmComplexType resolveComplexType(ServiceMetadata metadata, EdmComplexType baseType, String derivedTypeName) throws SerializerException - Throws:
SerializerException
-
writeProperties
protected void writeProperties(ServiceMetadata metadata, EdmStructuredType type, List<Property> properties, SelectOption select, com.fasterxml.jackson.core.JsonGenerator json, Linked linked, ExpandOption expand) throws IOException, SerializerException, org.apache.commons.codec.DecoderException - Throws:
IOExceptionSerializerExceptionorg.apache.commons.codec.DecoderException
-
writeExpandedStreamProperties
protected void writeExpandedStreamProperties(ServiceMetadata metadata, EdmStructuredType type, Linked linked, ExpandOption expand, Integer toDepth, Set<String> ancestors, String name, com.fasterxml.jackson.core.JsonGenerator json) throws SerializerException, IOException, org.apache.commons.codec.DecoderException - Throws:
SerializerExceptionIOExceptionorg.apache.commons.codec.DecoderException
-
writeProperty
protected void writeProperty(ServiceMetadata metadata, EdmProperty edmProperty, Property property, Set<List<String>> selectedPaths, com.fasterxml.jackson.core.JsonGenerator json, Set<List<String>> expandedPaths, Linked linked, ExpandOption expand) throws IOException, SerializerException, org.apache.commons.codec.DecoderException - Throws:
IOExceptionSerializerExceptionorg.apache.commons.codec.DecoderException
-
writePrimitiveValue
protected void writePrimitiveValue(String name, EdmPrimitiveType type, Object primitiveValue, Boolean isNullable, Integer maxLength, Integer precision, Integer scale, Boolean isUnicode, com.fasterxml.jackson.core.JsonGenerator json) throws EdmPrimitiveTypeException, IOException - Throws:
EdmPrimitiveTypeExceptionIOException
-
writeGeoValue
protected void writeGeoValue(String name, EdmPrimitiveType type, Geospatial geoValue, Boolean isNullable, com.fasterxml.jackson.core.JsonGenerator json, SRID parentSrid) throws EdmPrimitiveTypeException, IOException, SerializerException Writes a geospatial value following the GeoJSON specification defined in RFC 7946. -
writeComplexValue
protected void writeComplexValue(ServiceMetadata metadata, EdmComplexType type, List<Property> properties, Set<List<String>> selectedPaths, com.fasterxml.jackson.core.JsonGenerator json, Set<List<String>> expandedPaths, Linked linked, ExpandOption expand, String complexPropName) throws IOException, SerializerException, org.apache.commons.codec.DecoderException - Throws:
IOExceptionSerializerExceptionorg.apache.commons.codec.DecoderException
-
primitive
public SerializerResult primitive(ServiceMetadata metadata, EdmPrimitiveType type, Property property, PrimitiveSerializerOptions options) throws SerializerException Description copied from interface:ODataSerializerWrites primitive-type instance data into an InputStream.- Specified by:
primitivein interfaceODataSerializer- Parameters:
metadata- metadata for the servicetype- primitive typeproperty- property valueoptions- options for the serializer- Throws:
SerializerException
-
complex
public SerializerResult complex(ServiceMetadata metadata, EdmComplexType type, Property property, ComplexSerializerOptions options) throws SerializerException Description copied from interface:ODataSerializerWrites complex-type instance data into an InputStream.- Specified by:
complexin interfaceODataSerializer- Parameters:
metadata- metadata for the servicetype- complex typeproperty- property valueoptions- options for the serializer- Throws:
SerializerException
-
primitiveCollection
public SerializerResult primitiveCollection(ServiceMetadata metadata, EdmPrimitiveType type, Property property, PrimitiveSerializerOptions options) throws SerializerException Description copied from interface:ODataSerializerWrites data of a collection of primitive-type instances into an InputStream.- Specified by:
primitiveCollectionin interfaceODataSerializer- Parameters:
metadata- metadata for the servicetype- primitive typeproperty- property valueoptions- options for the serializer- Throws:
SerializerException
-
complexCollection
public SerializerResult complexCollection(ServiceMetadata metadata, EdmComplexType type, Property property, ComplexSerializerOptions options) throws SerializerException Description copied from interface:ODataSerializerWrites data of a collection of complex-type instances into an InputStream.- Specified by:
complexCollectionin interfaceODataSerializer- Parameters:
metadata- metadata for the servicetype- complex typeproperty- property valueoptions- options for the serializer- Throws:
SerializerException
-
reference
public SerializerResult reference(ServiceMetadata metadata, EdmEntitySet edmEntitySet, Entity entity, ReferenceSerializerOptions options) throws SerializerException Description copied from interface:ODataSerializerWrites a single entity reference into an InputStream.- Specified by:
referencein interfaceODataSerializer- Parameters:
metadata- metadata for the serviceedmEntitySet-EdmEntitySetentity- data of the entityoptions-ReferenceSerializerOptions- Throws:
SerializerException
-
referenceCollection
public SerializerResult referenceCollection(ServiceMetadata metadata, EdmEntitySet edmEntitySet, AbstractEntityCollection entityCollection, ReferenceCollectionSerializerOptions options) throws SerializerException Description copied from interface:ODataSerializerWrites entity-collection references into an InputStream.- Specified by:
referenceCollectionin interfaceODataSerializer- Parameters:
metadata- metadata for the serviceedmEntitySet-EdmEntitySetentityCollection- data of the entity collectionoptions-ReferenceCollectionSerializerOptions- Throws:
SerializerException
-
writeContextURL
protected void writeContextURL(ContextURL contextURL, com.fasterxml.jackson.core.JsonGenerator json) throws IOException - Throws:
IOException
-
writeMetadataETag
protected void writeMetadataETag(ServiceMetadata metadata, com.fasterxml.jackson.core.JsonGenerator json) throws IOException - Throws:
IOException
-
writeInlineCount
protected void writeInlineCount(String propertyName, Integer count, com.fasterxml.jackson.core.JsonGenerator json) throws IOException - Throws:
IOException
-
writeNextLink
protected void writeNextLink(AbstractEntityCollectionObject entitySet, com.fasterxml.jackson.core.JsonGenerator json) throws IOException - Throws:
IOException
-