Class XCASDeserializer


  • public class XCASDeserializer
    extends java.lang.Object
    XCAS Deserializer. Takes an XCAS and reads it into a CAS.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void deserialize​(java.io.InputStream aStream, CAS aCAS)
      Deserializes an XCAS from a stream.
      static void deserialize​(java.io.InputStream aStream, CAS aCAS, boolean aLenient)
      Deserializes an XCAS from a stream.
      java.lang.String getDocumentTypeName()
      Gets the name of the type representing the document.
      org.xml.sax.helpers.DefaultHandler getXCASHandler​(CAS cas)
      Create a default handler for deserializing an XCAS into the cas parameter.
      org.xml.sax.helpers.DefaultHandler getXCASHandler​(CAS cas, OutOfTypeSystemData outOfTypeSystemData)
      Create a default handler for deserializing an XCAS into the cas parameter.
      void setDocumentTypeName​(java.lang.String aDocTypeName)
      Gets the name of the type representing the document.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XCASDeserializer

        public XCASDeserializer​(TypeSystem ts,
                                UimaContext uimaContext)
        Create a new deserializer from a type system. Note: all CAS arguments later supplied to getXCASHandler() must have this type system as their type system.
        Parameters:
        ts - The type system of the CASes to be deserialized.
        uimaContext - the UIMA Context for the deserialization
      • XCASDeserializer

        public XCASDeserializer​(TypeSystem ts)
    • Method Detail

      • getXCASHandler

        public org.xml.sax.helpers.DefaultHandler getXCASHandler​(CAS cas)
        Create a default handler for deserializing an XCAS into the cas parameter.

        Warning: for efficiency reasons, the deserializer does not do much type checking for features and their values. It is expected that the incoming XCAS conforms to the type system provided. If it doesn't, the results are undefined.

        Parameters:
        cas - This CAS will be used to hold the data of the serialized XCAS.
        Returns:
        The DefaultHandler to pass to the SAX parser.
      • getXCASHandler

        public org.xml.sax.helpers.DefaultHandler getXCASHandler​(CAS cas,
                                                                 OutOfTypeSystemData outOfTypeSystemData)
        Create a default handler for deserializing an XCAS into the cas parameter. This version causes the deserializer to store out-of-typesystem data for later use. (APL)

        Warning: for efficiency reasons, the deserializer does not do much type checking for features and their values. It is expected that the incoming XCAS conforms to the type system provided. If it doesn't, the results are undefined.

        Parameters:
        cas - This CAS will be used to hold the data of the serialized XCAS.
        outOfTypeSystemData - An object that stores FSs that do not conform to the CAS's type system
        Returns:
        The DefaultHandler to pass to the SAX parser.
      • getDocumentTypeName

        public java.lang.String getDocumentTypeName()
        Gets the name of the type representing the document. This will become the name of the XML element that will hold the document text.
        Returns:
        the document type name
      • setDocumentTypeName

        public void setDocumentTypeName​(java.lang.String aDocTypeName)
        Gets the name of the type representing the document. This will become the name of the XML element that will hold the document text. If not set, defaults to XCASSerializer.DEFAULT_DOC_TYPE_NAME.
        Parameters:
        aDocTypeName - the document type name
      • deserialize

        public static void deserialize​(java.io.InputStream aStream,
                                       CAS aCAS)
                                throws org.xml.sax.SAXException,
                                       java.io.IOException
        Deserializes an XCAS from a stream. By default this is not lenient, meaning that if the XCAS references Types that are not in the Type System, an Exception will be thrown. Use deserialize(InputStream,CAS,boolean) to turn on lenient mode and ignore any unknown types.
        Parameters:
        aStream - input stream from which to read the XCAS XML document
        aCAS - CAS into which to deserialize. This CAS must be set up with a type system that is compatible with that in the XCAS
        Throws:
        org.xml.sax.SAXException - if an XML Parsing error occurs
        java.io.IOException - if an I/O failure occurs
      • deserialize

        public static void deserialize​(java.io.InputStream aStream,
                                       CAS aCAS,
                                       boolean aLenient)
                                throws org.xml.sax.SAXException,
                                       java.io.IOException
        Deserializes an XCAS from a stream.
        Parameters:
        aStream - input stream from which to read the XCAS XML document
        aCAS - CAS into which to deserialize. This CAS must be set up with a type system that is compatible with that in the XCAS.
        aLenient - if true, unknown Types will be ignored. If false, unknown Types will cause an exception. The default is false.
        Throws:
        org.xml.sax.SAXException - if an XML Parsing error occurs
        java.io.IOException - if an I/O failure occurs