Class XCASDeserializer.XCASDeserializerHandler

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
    Enclosing class:
    XCASDeserializer

    private class XCASDeserializer.XCASDeserializerHandler
    extends org.xml.sax.helpers.DefaultHandler
    • Field Detail

      • ARRAY_ELE_CONTENT_STATE

        private static final int ARRAY_ELE_CONTENT_STATE
        See Also:
        Constant Field Values
      • DEFAULT_CONTENT_FEATURE

        private static final java.lang.String DEFAULT_CONTENT_FEATURE
        See Also:
        Constant Field Values
      • reservedAttrPrefix

        private static final java.lang.String reservedAttrPrefix
        See Also:
        Constant Field Values
      • unknownXMLSource

        private static final java.lang.String unknownXMLSource
        See Also:
        Constant Field Values
      • locator

        private org.xml.sax.Locator locator
      • fixupToDos

        private final java.util.List<java.lang.Runnable> fixupToDos
      • uimaSerializableFixups

        private final java.util.List<java.lang.Runnable> uimaSerializableFixups
      • state

        private int state
      • buffer

        private java.lang.StringBuffer buffer
      • currentFs

        private TOP currentFs
      • currentContentFeat

        private java.lang.String currentContentFeat
      • arrayPos

        private int arrayPos
      • currentOotsFs

        private FSData currentOotsFs
      • indexRepositories

        private final java.util.List<FSIndexRepository> indexRepositories
        map from index -> indexRepository, [0] = base view, [1] initial view, [2 +] other views
      • views

        private final java.util.List<CAS> views
        map for index -> cas views,
      • sofaRefMap

        private final IntVector sofaRefMap
      • indexMap

        private final IntVector indexMap
        Map external SofaNum -> internal sofaNum internal sofaNums also used to index indexRepositories -> ref to FsIndexRepositoryImpl
      • nextIndex

        private int nextIndex
      • highestIdFs

        private TOP highestIdFs
      • fsId

        private int fsId
        the fsId read from the _id attribute
    • Method Detail

      • resetBuffer

        private final void resetBuffer()
      • startDocument

        public void startDocument()
                           throws org.xml.sax.SAXException
        Specified by:
        startDocument in interface org.xml.sax.ContentHandler
        Overrides:
        startDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • startElement

        public void startElement​(java.lang.String nameSpaceURI,
                                 java.lang.String localName,
                                 java.lang.String qualifiedName,
                                 org.xml.sax.Attributes attrs)
                          throws org.xml.sax.SAXException
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • readDocument

        private void readDocument​(org.xml.sax.Attributes attrs)
      • readArrayElement

        private void readArrayElement​(java.lang.String eleName,
                                      org.xml.sax.Attributes attrs)
                               throws org.xml.sax.SAXParseException
        Throws:
        org.xml.sax.SAXParseException
      • readFS

        private void readFS​(java.lang.String qualifiedName,
                            org.xml.sax.Attributes attrs)
                     throws org.xml.sax.SAXParseException
        Throws:
        org.xml.sax.SAXParseException
      • readFS

        private void readFS​(TypeImpl type,
                            org.xml.sax.Attributes attrs,
                            boolean toIndex)
                     throws org.xml.sax.SAXParseException
        Parameters:
        addr -
        attrs -
        toIndex - Special hack to accommodate document annotation, which is already in the index.
        Throws:
        org.xml.sax.SAXParseException - passthru
      • readArray

        private void readArray​(TypeImpl type,
                               org.xml.sax.Attributes attrs)
                        throws org.xml.sax.SAXParseException
        Throws:
        org.xml.sax.SAXParseException
      • emptyVal

        private final boolean emptyVal​(java.lang.String val)
      • handleFeature

        private void handleFeature​(TOP fs,
                                   java.lang.String featName,
                                   java.lang.String featVal,
                                   boolean lenient)
                            throws org.xml.sax.SAXParseException
        Throws:
        org.xml.sax.SAXParseException
      • handleFeature

        private void handleFeature​(Type type,
                                   TOP fs,
                                   java.lang.String featName,
                                   java.lang.String featValIn,
                                   boolean lenient)
                            throws org.xml.sax.SAXParseException
        Throws:
        org.xml.sax.SAXParseException
      • getRealFeatName

        private java.lang.String getRealFeatName​(java.lang.String featName)
      • characters

        public void characters​(char[] chars,
                               int start,
                               int length)
                        throws org.xml.sax.SAXException
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • isAllWhitespace

        boolean isAllWhitespace​(java.lang.StringBuffer b)
      • endElement

        public void endElement​(java.lang.String nsURI,
                               java.lang.String localName,
                               java.lang.String qualifiedName)
                        throws org.xml.sax.SAXException
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • addArrayElement

        private void addArrayElement​(java.lang.String content)
                              throws org.xml.sax.SAXParseException
        Throws:
        org.xml.sax.SAXParseException
      • endDocument

        public void endDocument()
                         throws org.xml.sax.SAXException
        Specified by:
        endDocument in interface org.xml.sax.ContentHandler
        Overrides:
        endDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • finalizeRefValue

        private void finalizeRefValue​(int extId,
                                      TOP fs,
                                      FeatureImpl fi)
        Common code run at finalize time, to set ref values and handle out-of-typesystem data
        Parameters:
        extId - the external ID identifying either a deserialized FS or an out-of-typesystem instance
        fs - Feature Structure whose fi reference feature is to be set with a value derived from extId and FSinfo
        fi - the featureImpl
      • finalizeArrayRefValue

        private void finalizeArrayRefValue​(int extId,
                                           int pos,
                                           FSArray fs)
        Same as above, but specialized for array values, not feature slot values
        Parameters:
        extId -
        extId - the external ID identifying either a deserialized FS or an out-of-typesystem instance
        pos - the index in the array
      • finalizeOutOfTypeSystemFS

        private void finalizeOutOfTypeSystemFS​(FSData aFS)
      • finalizeOutOfTypeSystemFeatures

        private void finalizeOutOfTypeSystemFeatures()
      • createException

        private XCASParsingException createException​(int code,
                                                     java.lang.String arg)
      • error

        public void error​(org.xml.sax.SAXParseException e)
                   throws org.xml.sax.SAXException
        Specified by:
        error in interface org.xml.sax.ErrorHandler
        Overrides:
        error in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • fatalError

        public void fatalError​(org.xml.sax.SAXParseException e)
                        throws org.xml.sax.SAXException
        Specified by:
        fatalError in interface org.xml.sax.ErrorHandler
        Overrides:
        fatalError in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • ignorableWhitespace

        public void ignorableWhitespace​(char[] arg0,
                                        int arg1,
                                        int arg2)
                                 throws org.xml.sax.SAXException
        Specified by:
        ignorableWhitespace in interface org.xml.sax.ContentHandler
        Overrides:
        ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • setDocumentLocator

        public void setDocumentLocator​(org.xml.sax.Locator loc)
        Specified by:
        setDocumentLocator in interface org.xml.sax.ContentHandler
        Overrides:
        setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
      • warning

        public void warning​(org.xml.sax.SAXParseException e)
                     throws org.xml.sax.SAXException
        Specified by:
        warning in interface org.xml.sax.ErrorHandler
        Overrides:
        warning in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • parseArray

        private java.lang.String[] parseArray​(java.lang.String val)
        Parse a multi-valued attribute into a String array, by splitting on whitespace.
        Parameters:
        val - attribute value
        Returns:
        an array with each array value as an element
      • getCasTypeName

        private java.lang.String getCasTypeName​(java.lang.String aTagName)
        Gets the CAS type name corresponding to an XCAS tag name. The type name is usually equal to the tag name, but the characters : and - are translated into the sequences _colon_ and _dash_, respectively.
        Parameters:
        aTagName - XCAS tag name
        Returns:
        CAS type name corresponding to this tag
      • maybeCreateWithV2Id

        TOP maybeCreateWithV2Id​(int id,
                                java.util.function.Supplier<TOP> create)