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.CasDocSerializerprivate booleanprivate booleanprivate booleanprivate final booleanprivate final booleanprivate final booleanprivate final JsonContentHandlerJacksonWrapperprivate final com.fasterxml.jackson.core.JsonGeneratorprivate intprivate final JsonCasSerializer.MapType2Subtypesprivate booleanprivate booleanprivate final Map<String, XmlElementName> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateJsonDocSerializer(ContentHandler ch, CASImpl cas, XmiSerializationSharedData sharedData, MarkerImpl marker) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddJsonFeatContext(TypeImpl type) _feature_types : { "featName" : "_ref" or "_byte_array, ...private voidAdd subtype information for used types limited to used subtypesprotected voidaddNameSpace(XmlElementName xmlElementName) Called to generate a new namespace prefix and add it to this element - due to a collisionprotected voidcheckForNameCollision(XmlElementName xmlElementName) private voidprivate com.fasterxml.jackson.core.io.SerializedStringfeatureTypeLabel(int fsClass) Return null or a string representing the type of the featureprivate com.fasterxml.jackson.core.io.SerializedStringprivate com.fasterxml.jackson.core.io.SerializedStringprivate com.fasterxml.jackson.core.io.SerializedStringprotected voidprivate booleanisDynamicOrStaticMultiRef(FeatureImpl fi, TOP fs) private booleanisDynamicOrStaticMultiRef(FeatureImpl fi, TOP fs, boolean isListAsFSs) private voidprivate voidprivate voidJSON: serialize context infoprotected XmlElementNameuimaTypeName2XmiElementName(String uimaTypeName) Converts a UIMA-style dotted type name to the element name that should be used in the serialization.private voidwriteArray(TOP fs, FeatureImpl fi, int featureClass) private voidwriteArrayElements(int size, IntConsumer_withIOException ic) protected voidwriteArrays(TOP fs, int typeCode, int typeClass) Write FSArraysprivate voidwriteEmbeddedFs(TOP fs) protected voidprotected voidprotected voidwriteFeatureStructures(int elementCount) protected voidprivate voidwriteFSArray(TOP array, int array_size) private voidwriteFsOrLists(TOP fs, TypeImpl ti, boolean isListAsFSs) private voidwriteFsOrRef(TOP fs) 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 voidwriteFsOrRef(TOP fs, FeatureImpl fi) protected voidwriteFsRef(TOP fs) protected booleanwriteFsStart(TOP fs, int typeCode) private voidwriteJsonArrayValues(TOP array, int arrayType) private voidwriteJsonListValues(TOP 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.private voidwriteList(TOP fs, FeatureImpl fi, int featureClass, boolean isListAsFSs) protected voidwriteListsAsIndividualFSs(TOP fs, int typeCode) private voidwriteNumeric(FeatureImpl fi, long v) protected voidwriteView(Sofa sofa, Collection<TOP> members) protected voidwriteView(Sofa sofa, Collection<TOP> added, Collection<TOP> deleted, Collection<TOP> reindexed) private voidwriteViewForDeltas(com.fasterxml.jackson.core.io.SerializedString kind, Collection<TOP> deltaMembers) private voidwriteViewMembers(Collection<TOP> members) private voidwriteViewMembers(List<String> members) protected void
-
Field Details
-
cds
-
jch
-
jg
private final com.fasterxml.jackson.core.JsonGenerator jg -
serializedStrings
-
usedTypeName2XmlElementName
-
mapType2Subtypes
-
parentTypesWithNoInstances
-
lastEncodedTypeCode
private int lastEncodedTypeCode -
startedReferencedFSs
private boolean startedReferencedFSs -
isOmitDefaultValues
private final boolean isOmitDefaultValues -
isWithContext
private final boolean isWithContext -
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:
initializeNamespacesin classCasSerializerSupport.CasSerializerSupportSerialize
-
writeViews
- Specified by:
writeViewsin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
Exception
-
writeFeatureStructures
- Specified by:
writeFeatureStructuresin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
Exception
-
writeEndOfSerialization
- Specified by:
writeEndOfSerializationin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
IOException
-
sortByViewType
- Returns:
- the List
[] returned by cds.indexedFSs, but with each view sorted by type
-
writeView
- Specified by:
writeViewin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
IOException
-
writeViewForDeltas
private void writeViewForDeltas(com.fasterxml.jackson.core.io.SerializedString kind, Collection<TOP> deltaMembers) throws IOException - Throws:
IOException
-
writeView
protected void writeView(Sofa sofa, Collection<TOP> added, Collection<TOP> deleted, Collection<TOP> reindexed) throws IOException - Specified by:
writeViewin 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
-
maybeDoStartFeatureTypes
- Throws:
IOException
-
getShortFeatureName
-
addJsonSubtypes
Add subtype information for used types limited to used subtypes- Throws:
IOException
-
collectUsedSubtypes
private void collectUsedSubtypes() -
getSerializedTypeName
-
getSerializedString
-
checkForNameCollision
- Specified by:
checkForNameCollisionin classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFsStart
- Specified by:
writeFsStartin classCasSerializerSupport.CasSerializerSupportSerialize- Parameters:
fs- -typeCode- -- Returns:
- true if writing out referenced items (JSON)
- Throws:
IOException
-
writeFsRef
- Specified by:
writeFsRefin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
Exception
-
maybeWriteTypeFeat
- Throws:
IOException
-
writeFs
- Specified by:
writeFsin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
IOException
-
writeListsAsIndividualFSs
- Specified by:
writeListsAsIndividualFSsin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
IOException
-
writeFsOrLists
- Throws:
IOException
-
writeNumeric
- Throws:
IOException
-
writeArray
- Throws:
IOException
-
writeList
private void writeList(TOP fs, FeatureImpl fi, int featureClass, boolean isListAsFSs) throws IOException - 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:
writeArraysin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
IOException
-
writeEndOfIndividualFs
- Specified by:
writeEndOfIndividualFsin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
IOException
-
writeJsonArrayValues
- Throws:
IOException
-
writeArrayElements
- Throws:
IOException
-
writeFSArray
- Throws:
NumberFormatExceptionIOException
-
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) 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:
uimaTypeName2XmiElementNamein 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:
addNameSpacein classCasSerializerSupport.CasSerializerSupportSerialize- Parameters:
xmlElementName-
-
isDynamicOrStaticMultiRef
-
isDynamicOrStaticMultiRef
-