Class JsonCasSerializer.JsonDocSerializer

    • Field Detail

      • jg

        private final com.fasterxml.jackson.core.JsonGenerator jg
      • serializedStrings

        private final java.util.Map<java.lang.String,​com.fasterxml.jackson.core.io.SerializedString> serializedStrings
      • usedTypeName2XmlElementName

        private final java.util.Map<java.lang.String,​XmlElementName> usedTypeName2XmlElementName
      • parentTypesWithNoInstances

        private final java.util.List<TypeImpl> 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
    • Method Detail

      • sortByViewType

        private java.util.List<TOP>[] sortByViewType()
        Returns:
        the List[] returned by cds.indexedFSs, but with each view sorted by type
      • writeViewForDeltas

        private void writeViewForDeltas​(com.fasterxml.jackson.core.io.SerializedString kind,
                                        java.util.Collection<TOP> deltaMembers)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeViewMembers

        private void writeViewMembers​(java.util.Collection<TOP> members)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeViewMembers

        private void writeViewMembers​(java.util.List<java.lang.String> members)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • serializeJsonLdContext

        private void serializeJsonLdContext()
                                     throws java.io.IOException

        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:

        1. _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.
        2. _id - the fully qualified UIMA type name
        3. @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.
        RANGE_IDs specify the type of the value of a feature. There are currently 2 kinds:
        • "@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:
        java.io.IOException
      • addJsonFeatContext

        private void addJsonFeatContext​(TypeImpl type)
                                 throws java.io.IOException
        _feature_types : { "featName" : "_ref" or "_byte_array, ... }
        Parameters:
        type - the type for which to generate the feature context info
        Throws:
        java.io.IOException
      • maybeDoStartFeatureTypes

        private void maybeDoStartFeatureTypes()
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • getShortFeatureName

        private com.fasterxml.jackson.core.io.SerializedString getShortFeatureName​(FeatureImpl feat)
      • addJsonSubtypes

        private void addJsonSubtypes​(TypeImpl ti)
                              throws java.io.IOException
        Add subtype information for used types limited to used subtypes
        Throws:
        java.io.IOException
      • collectUsedSubtypes

        private void collectUsedSubtypes()
      • getSerializedTypeName

        private com.fasterxml.jackson.core.io.SerializedString getSerializedTypeName​(TypeImpl ti)
      • getSerializedString

        private com.fasterxml.jackson.core.io.SerializedString getSerializedString​(java.lang.String s)
      • maybeWriteTypeFeat

        private void maybeWriteTypeFeat​(TypeImpl ti)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeFsOrLists

        private void writeFsOrLists​(TOP fs,
                                    TypeImpl ti,
                                    boolean isListAsFSs)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • writeNumeric

        private void writeNumeric​(FeatureImpl fi,
                                  long v)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • writeArray

        private void writeArray​(TOP fs,
                                FeatureImpl fi,
                                int featureClass)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • writeList

        private void writeList​(TOP fs,
                               FeatureImpl fi,
                               int featureClass,
                               boolean isListAsFSs)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeFsOrRef

        private void writeFsOrRef​(TOP fs)
                           throws java.io.IOException
        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:
        java.io.IOException
      • writeEmbeddedFs

        private void writeEmbeddedFs​(TOP fs)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeFsOrRef

        private void writeFsOrRef​(TOP fs,
                                  FeatureImpl fi)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • writeJsonArrayValues

        private void writeJsonArrayValues​(TOP array,
                                          int arrayType)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • writeArrayElements

        private void writeArrayElements​(int size,
                                        IntConsumer_withIOException ic)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeFSArray

        private void writeFSArray​(TOP array,
                                  int array_size)
                           throws java.lang.NumberFormatException,
                                  java.io.IOException
        Throws:
        java.lang.NumberFormatException
        java.io.IOException
      • writeJsonListValues

        private void writeJsonListValues​(TOP curNode)
                                  throws java.io.IOException
        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:
        java.io.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 feature
        featCode - the feature code
        Returns:
        _ref, _array, _byte_array, or null
      • uimaTypeName2XmiElementName

        protected XmlElementName uimaTypeName2XmiElementName​(java.lang.String uimaTypeName)
        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 class CasSerializerSupport.CasSerializerSupportSerialize
        Parameters:
        uimaTypeName - a UIMA-style dotted type name
        Returns:
        a data structure holding the three components of the XML element name
      • isDynamicOrStaticMultiRef

        private boolean isDynamicOrStaticMultiRef​(FeatureImpl fi,
                                                  TOP fs)
      • isDynamicOrStaticMultiRef

        private boolean isDynamicOrStaticMultiRef​(FeatureImpl fi,
                                                  TOP fs,
                                                  boolean isListAsFSs)