Class XCASSerializer


  • public class XCASSerializer
    extends java.lang.Object
    XCAS serializer. Create a serializer from a type system, then encode individual CASes by writing to a SAX content handler. This class is thread safe.
    • Method Detail

      • getNumChildren

        public int getNumChildren()
      • serialize

        public void serialize​(CAS cas,
                              org.xml.sax.ContentHandler contentHandler)
                       throws java.io.IOException,
                              org.xml.sax.SAXException
        Write the CAS data to a SAX content handler.
        Parameters:
        cas - The CAS to be serialized.
        contentHandler - The SAX content handler the data is written to.
        Throws:
        java.io.IOException - passed thru
        org.xml.sax.SAXException - passed thru
      • serialize

        public void serialize​(CAS cas,
                              org.xml.sax.ContentHandler contentHandler,
                              boolean encodeDoc)
                       throws java.io.IOException,
                              org.xml.sax.SAXException
        Write the CAS data to a SAX content handler.
        Parameters:
        cas - The CAS to be serialized.
        contentHandler - The SAX content handler the data is written to.
        encodeDoc - If set to false, no uima.tcas.Document structure will be created, and the document text will not be serialized.
        Throws:
        java.io.IOException - passed thru
        org.xml.sax.SAXException - passed thru
      • serialize

        public void serialize​(CAS cas,
                              org.xml.sax.ContentHandler contentHandler,
                              boolean encodeDoc,
                              OutOfTypeSystemData outOfTypeSystemData)
                       throws java.io.IOException,
                              org.xml.sax.SAXException
        Write the CAS data to a SAX content handler.
        Parameters:
        cas - The CAS to be serialized.
        contentHandler - The SAX content handler the data is written to.
        encodeDoc - If set to false, no uima.tcas.Document structure will be created, and the document text will not be serialized.
        outOfTypeSystemData - data not part of the CAS type system, which should be inserted into the XCAS output
        Throws:
        java.io.IOException - passed thru
        org.xml.sax.SAXException - passed thru
      • 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 DEFAULT_DOC_TYPE_NAME.
        Parameters:
        aDocTypeName - the document type name
      • getDocumentTextFeature

        public java.lang.String getDocumentTextFeature()
        Gets the name of the feature holding the documeng text. This will become the value of the _content attribute on the document element.
        Returns:
        the document text feature
      • setDocumentTextFeature

        public void setDocumentTextFeature​(java.lang.String aDocTextFeature)
        Sets the name of the feature holding the documeng text. This will become the value of the _content attribute on the document element. If not set, defaults to DEFAULT_DOC_TEXT_FEAT. If set to null, no _content attribute will be emitted.
        Parameters:
        aDocTextFeature - the document text feature
      • serialize

        public static void serialize​(CAS aCAS,
                                     java.io.OutputStream aStream)
                              throws org.xml.sax.SAXException,
                                     java.io.IOException
        Serializes an XCAS to a stream.
        Parameters:
        aCAS - CAS to serialize.
        aStream - output stream to which to write the XCAS XML document
        Throws:
        org.xml.sax.SAXException - if a problem occurs during XCAS serialization
        java.io.IOException - if an I/O failure occurs
      • serialize

        public static void serialize​(CAS aCAS,
                                     java.io.OutputStream aStream,
                                     boolean isFormattedOutput)
                              throws org.xml.sax.SAXException,
                                     java.io.IOException
        Serializes an XCAS to a stream.
        Parameters:
        aCAS - CAS to serialize.
        aStream - output stream to which to write the XCAS XML document
        isFormattedOutput - if true the XCAS will be serialized formatted
        Throws:
        org.xml.sax.SAXException - if a problem occurs during XCAS serialization
        java.io.IOException - if an I/O failure occurs