Package org.apache.uima.json
Class JsonCasSerializer.JsonDocSerializer
java.lang.Object
org.apache.uima.cas.impl.CasSerializerSupport.CasSerializerSupportSerialize
org.apache.uima.json.JsonCasSerializer.JsonDocSerializer
- Enclosing class:
JsonCasSerializer
class JsonCasSerializer.JsonDocSerializer
extends CasSerializerSupport.CasSerializerSupportSerialize
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CasSerializerSupport.CasDocSerializer
private boolean
private boolean
private boolean
private final boolean
private final boolean
private final boolean
private final boolean
private final JsonContentHandlerJacksonWrapper
private final com.fasterxml.jackson.core.JsonGenerator
private int
private final JsonCasSerializer.MapType2Subtypes
private final IntVector
private boolean
private boolean
private final String
private final Map
<String, XmlElementName> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
JsonDocSerializer
(ContentHandler ch, CASImpl cas, XmiSerializationSharedData sharedData, MarkerImpl marker) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addJsonFeatContext
(int typeCode) private void
addJsonFeatContext
(TypeImpl type) _feature_types : { "featName" : "_ref" or "_byte_array, ...private void
addJsonSubtypes
(int aTypeCode) private void
Add subtype information for used types limited to used subtypesprotected void
addNameSpace
(XmlElementName xmlElementName) Called to generate a new namespace prefix and add it to this element - due to a collisionprotected void
checkForNameCollision
(XmlElementName xmlElementName) private void
private com.fasterxml.jackson.core.io.SerializedString
featureTypeLabel
(int fsClass, int featCode) Return null or a string representing the type of the featureprivate com.fasterxml.jackson.core.io.SerializedString
private com.fasterxml.jackson.core.io.SerializedString
getSerializedTypeName
(int typeCode) private com.fasterxml.jackson.core.io.SerializedString
getShortFeatureName
(int featCode) protected void
private boolean
isDynamicOrStaticMultiRef
(int featCode, int addr) private boolean
isDynamicOrStaticMultiRef
(int featCode, int addr, boolean isListAsFSs) private void
private void
maybeWriteTypeFeat
(int typeCode) private void
JSON: serialize context infoprivate Integer[][]
protected XmlElementName
uimaTypeName2XmiElementName
(String uimaTypeName) Converts a UIMA-style dotted type name to the element name that should be used in the serialization.protected void
writeArrays
(int addr, int typeCode, int typeClass) Write FSArraysprivate void
writeEmbeddedFs
(int addr) protected void
protected void
protected void
writeFeatureStructures
(int elementCount) protected void
writeFs
(int addr, int typeCode) private void
writeFsOrLists
(int addr, int typeCode, boolean isListAsFSs) private void
writeFsOrRef
(int addr) for arrays and lists, recursively write one FS, as actual FS, if dynamic embedding and single ref OR, just write the reference id If trying to write the null FS (due to filtering for instance), write 0private void
writeFsOrRef
(int addr, int featCode) protected void
writeFsRef
(int addr) protected boolean
writeFsStart
(int addr, int typeCode) private void
writeJsonArrayValues
(int addr, int arrayType) private void
writeJsonListValues
(int curNode) Only called if no sharing of list nodes exists (except for non-dynamic case) Only called for list nodes referred to by Feature value slots in some FS.protected void
writeListsAsIndividualFSs
(int addr, int typeCode) protected void
writeView
(int sofaAddr, int[] members) protected void
writeView
(int sofaAddr, int[] added, int[] deleted, int[] reindexed) private void
writeViewForDeltas
(com.fasterxml.jackson.core.io.SerializedString kind, int[] deltaMembers) private void
writeViewMembers
(int[] members) private void
writeViewMembers
(List<String> members) protected void
-
Field Details
-
cds
-
jch
-
jg
private final com.fasterxml.jackson.core.JsonGenerator jg -
typeSystemReference
-
serializedStrings
-
usedTypeName2XmlElementName
-
mapType2Subtypes
-
parentTypesWithNoInstances
-
lastEncodedTypeCode
private int lastEncodedTypeCode -
startedReferencedFSs
private boolean startedReferencedFSs -
isOmitDefaultValues
private final boolean isOmitDefaultValues -
isWithContext
private final boolean isWithContext -
isWithExpandedTypeNames
private final boolean isWithExpandedTypeNames -
isWithSubtypes
private final boolean isWithSubtypes -
indexId
private boolean indexId -
isEmbedded
private boolean isEmbedded -
isEmbeddedFromFsFeature
private boolean isEmbeddedFromFsFeature -
startedFeatureTypes
private boolean startedFeatureTypes
-
-
Constructor Details
-
Method Details
-
initializeNamespaces
protected void initializeNamespaces()- Specified by:
initializeNamespaces
in classCasSerializerSupport.CasSerializerSupportSerialize
-
writeViews
- Specified by:
writeViews
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
Exception
-
writeFeatureStructures
- Specified by:
writeFeatureStructures
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
Exception
-
writeEndOfSerialization
- Specified by:
writeEndOfSerialization
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
IOException
-
sortByViewType
-
writeView
- Specified by:
writeView
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
IOException
-
writeViewForDeltas
private void writeViewForDeltas(com.fasterxml.jackson.core.io.SerializedString kind, int[] deltaMembers) throws IOException - Throws:
IOException
-
writeView
protected void writeView(int sofaAddr, int[] added, int[] deleted, int[] reindexed) throws IOException - Specified by:
writeView
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
IOException
-
writeViewMembers
- Throws:
IOException
-
writeViewMembers
- Throws:
IOException
-
serializeJsonLdContext
JSON: serialize context info
The context has several parts.
The typeSystemReference is an optional URI to a type system that is written out.
The types part is organized by the type hierarchy, starting with the uima.cas.TOP type. There is an entry for each type which has 1 or more serailized instances, and also for all supertypes of those types. The entry is a JSON key-value pair "short-type-name" : {...}.
The information for each type has 3 sections:
- _subtypes - a JSON map of key-value pairs, keyed by the short type-name of used subtypes of this type. If this type has no used subtypes, this element is omitted. The value is an instance of this structure, for that type.
- _id - the fully qualified UIMA type name
- @featureTypes - a map with keys being specific features of the type that need extra information about their contents, and the value being that extra information.
- "@featureByteArray" - indicates the string value should be decoded as a base64 binary encoded byte array
- "{ "@featureRef" : "short_type_name" } - indicates the number or array of numbers should be interpreted as a reference to a FS having this number (or array of numbers) as its id(s). 0 is interpreted as a null reference. The type of the FS being referred to is of type "short_type_name" or a subtype.
- Throws:
IOException
-
addJsonFeatContext
_feature_types : { "featName" : "_ref" or "_byte_array, ... }- Parameters:
type
- the type for which to generate the feature context info- Throws:
IOException
-
addJsonFeatContext
- Throws:
IOException
-
maybeDoStartFeatureTypes
- Throws:
IOException
-
getShortFeatureName
private com.fasterxml.jackson.core.io.SerializedString getShortFeatureName(int featCode) -
addJsonSubtypes
Add subtype information for used types limited to used subtypes- Throws:
IOException
-
addJsonSubtypes
- Throws:
IOException
-
collectUsedSubtypes
private void collectUsedSubtypes() -
getSerializedTypeName
private com.fasterxml.jackson.core.io.SerializedString getSerializedTypeName(int typeCode) -
getSerializedString
-
checkForNameCollision
- Specified by:
checkForNameCollision
in classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFsStart
- Specified by:
writeFsStart
in classCasSerializerSupport.CasSerializerSupportSerialize
- Parameters:
addr
- -typeCode
- -- Returns:
- true if writing out referenced items (JSON)
- Throws:
IOException
-
writeFsRef
- Specified by:
writeFsRef
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
Exception
-
maybeWriteTypeFeat
- Throws:
IOException
-
writeFs
- Specified by:
writeFs
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
IOException
-
writeListsAsIndividualFSs
- Specified by:
writeListsAsIndividualFSs
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
IOException
-
writeFsOrLists
- Throws:
IOException
-
writeFsOrRef
for arrays and lists, recursively write one FS, as actual FS, if dynamic embedding and single ref OR, just write the reference id If trying to write the null FS (due to filtering for instance), write 0- Parameters:
addr
-- Throws:
IOException
-
writeEmbeddedFs
- Throws:
IOException
-
writeFsOrRef
- Throws:
IOException
-
writeArrays
Write FSArrays- Specified by:
writeArrays
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
IOException
-
writeEndOfIndividualFs
- Specified by:
writeEndOfIndividualFs
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
IOException
-
writeJsonArrayValues
- Throws:
IOException
-
writeJsonListValues
Only called if no sharing of list nodes exists (except for non-dynamic case) Only called for list nodes referred to by Feature value slots in some FS.- Parameters:
curNode
- the address of the start of the list- Throws:
IOException
-
featureTypeLabel
private com.fasterxml.jackson.core.io.SerializedString featureTypeLabel(int fsClass, int featCode) Return null or a string representing the type of the feature- Parameters:
fsClass
- the class of the featurefeatCode
- the feature code- Returns:
- _ref, _array, _byte_array, or null
-
uimaTypeName2XmiElementName
Converts a UIMA-style dotted type name to the element name that should be used in the serialization. The XMI element name consists of three parts - the Namespace URI, the Local Name, and the QName (qualified name).- Specified by:
uimaTypeName2XmiElementName
in classCasSerializerSupport.CasSerializerSupportSerialize
- Parameters:
uimaTypeName
- a UIMA-style dotted type name- Returns:
- a data structure holding the three components of the XML element name
-
addNameSpace
Called to generate a new namespace prefix and add it to this element - due to a collision- Specified by:
addNameSpace
in classCasSerializerSupport.CasSerializerSupportSerialize
- Parameters:
xmlElementName
-
-
isDynamicOrStaticMultiRef
private boolean isDynamicOrStaticMultiRef(int featCode, int addr) -
isDynamicOrStaticMultiRef
private boolean isDynamicOrStaticMultiRef(int featCode, int addr, boolean isListAsFSs)
-