Class XCASSerializer.XCASDocSerializer

  • Enclosing class:
    XCASSerializer

    private class XCASSerializer.XCASDocSerializer
    extends java.lang.Object
    Use an inner class to hold the data for serializing a CAS. Each call to serialize() creates its own instance.
    • Field Detail

      • ch

        private org.xml.sax.ContentHandler ch
      • queued

        private final java.util.Map<TOP,​java.lang.Integer> queued
        Any FS reference we've touched goes in here. value is index repo (first one?), or MULTIPLY_INDEXED
      • duplicates

        private final java.util.Map<TOP,​java.lang.Integer> duplicates
        Any FS indexed in more than one IR goes in here, the value is the associated duplicate key, Key is used to index into dupVectors
      • numDuplicates

        int numDuplicates
        A key identifying a particular FS indexed in multiple indexes. Starts a 0, incr by 1 for each new FS discovered to be indexed in more than one IR
      • dupVectors

        final java.util.List<IntVector> dupVectors
        list of IntVectors holding lists of repo numbers. Indexed by the key above, for fss that are in multiple index repos
      • indexedFSs

        private final java.util.List<TOP> indexedFSs
        list of FSs that are in an index somewhere.
      • indexReps

        private final IntVector indexReps
        Specific IndexRepository for indexed FSs
      • queue

        private final java.util.Deque<TOP> queue
        The current queue for FSs to write out.
      • emptyAttrs

        private final org.xml.sax.helpers.AttributesImpl emptyAttrs
      • workAttrs

        private org.xml.sax.helpers.AttributesImpl workAttrs
      • fsCount

        private int fsCount
    • Constructor Detail

      • XCASDocSerializer

        private XCASDocSerializer​(org.xml.sax.ContentHandler ch,
                                  CASImpl cas)
    • Method Detail

      • enqueue

        private boolean enqueue​(TOP fs)
        Add an address to the queue.
        Parameters:
        fs_id - The address.
        Returns:
        false iff we've seen this address before.
      • enqueueIndexed

        private void enqueueIndexed​(TOP fs,
                                    int indexRep)
        Same as enqueue, but for indexed FSs.
        Parameters:
        fs_id - The address to enqueue.
      • isQueued

        private int isQueued​(TOP fs,
                             int value)
        Bad name; check if we've seen this (address, value) before.
        Parameters:
        fs - The Feature Structure.
        value - The index repository
        Returns:
        KEY_AND_VALUE_MATCH iff we've seen (address, value) before. KEY_NOT_FOUND iff the address has not been seen before. KEY_ONLY_MATCH iff the address has been seen before with a different value.
      • serialize

        private void serialize​(boolean encodeDoc,
                               OutOfTypeSystemData outOfTypeSystemData)
                        throws java.io.IOException,
                               org.xml.sax.SAXException
        Throws:
        java.io.IOException
        org.xml.sax.SAXException
      • addText

        private void addText​(java.lang.String text)
                      throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • replaceInvalidXmlChars

        private java.lang.String replaceInvalidXmlChars​(java.lang.String aString)
      • isValidXmlChar

        private boolean isValidXmlChar​(char c)
      • addAttribute

        private void addAttribute​(org.xml.sax.helpers.AttributesImpl attrs,
                                  java.lang.String attrName,
                                  java.lang.String attrValue)
      • startElement

        private void startElement​(java.lang.String tag,
                                  org.xml.sax.Attributes attrs,
                                  int num)
                           throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • endElement

        private void endElement​(java.lang.String tag)
                         throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • encodeIndexed

        private void encodeIndexed()
                            throws java.io.IOException,
                                   org.xml.sax.SAXException
        Throws:
        java.io.IOException
        org.xml.sax.SAXException
      • enqueueIndexed

        private void enqueueIndexed()
        Push the indexed FSs onto the queue.
      • enqueueArray

        private void enqueueArray​(TOP[] fss,
                                  int sofaNum)
      • enqueueCollection

        private void enqueueCollection​(java.util.Collection<TOP> fss,
                                       int sofaNum)
      • enqueueFeaturesOfIndexed

        private void enqueueFeaturesOfIndexed()
      • encodeQueued

        private void encodeQueued()
                           throws java.io.IOException,
                                  org.xml.sax.SAXException
        Throws:
        java.io.IOException
        org.xml.sax.SAXException
      • encodeFS

        private void encodeFS​(TOP fs,
                              IntVector indexRep)
                       throws java.io.IOException,
                              org.xml.sax.SAXException
        Encode an individual FS.
        Parameters:
        fs_id - The address to be encoded.
        isIndexed - If the FS is indexed or not.
        Throws:
        java.io.IOException - passthru
        org.xml.sax.SAXException - passthru
      • encodePrimitiveTypeArrayFS

        private void encodePrimitiveTypeArrayFS​(java.lang.String[] data,
                                                java.lang.String typeName,
                                                org.xml.sax.helpers.AttributesImpl attrs)
                                         throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • encodeFSArray

        private void encodeFSArray​(FSArray fs,
                                   org.xml.sax.helpers.AttributesImpl attrs)
                            throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException
      • enqueueFSArray

        private void enqueueFSArray​(FSArray fs)
      • encodeFeatures

        private void encodeFeatures​(TOP fs,
                                    org.xml.sax.helpers.AttributesImpl attrs)
      • enqueueFeatures

        private void enqueueFeatures​(TOP fs,
                                     int heapValue)
      • encodeOutOfTypeSystemFeatures

        private void encodeOutOfTypeSystemFeatures​(TOP fs,
                                                   org.xml.sax.helpers.AttributesImpl attrs)
      • enqueueOutOfTypeSystemFeatures

        private void enqueueOutOfTypeSystemFeatures​(TOP fs)
      • getTypeName

        private final java.lang.String getTypeName​(TOP fs)
      • classifyType

        private final int classifyType​(TypeImpl ti)
        classify the type, without distinguishng list types
        Parameters:
        ti - the type
        Returns:
        the classification
      • enqueueOutOfTypeSystemData

        private void enqueueOutOfTypeSystemData​(OutOfTypeSystemData aData)
      • serializeOutOfTypeSystemData

        private void serializeOutOfTypeSystemData​(OutOfTypeSystemData aData)
                                           throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException