org.apache.uima.cas.impl

## Class XCASSerializer

- java.lang.Object
- - org.apache.uima.cas.impl.XCASSerializer

-     public class XCASSerializer
      extends 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. *

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `ARRAY_ELEMENT_TAG`
    `static String` | `ARRAY_SIZE_ATTR`
    `static String` | `casTagName`
    `static String` | `CONTENT_ATTR_NAME`
    `static String` | `CURRENT_VERSION`
    `static String` | `DEFAULT_DOC_TEXT_FEAT`
    `static String` | `DEFAULT_DOC_TYPE_NAME`
    `static String` | `ID_ATTR_NAME`
    `static String` | `INDEXED_ATTR_NAME`
    `static String` | `REF_PREFIX`
    `static String` | `TRUE_VALUE`
    `static String` | `VERSION_ATTR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XCASSerializer(TypeSystem ts)`
    `XCASSerializer(TypeSystem ts, UimaContext uimaContext)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getDocumentTextFeature()` Gets the name of the feature holding the documeng text.
    `String` | `getDocumentTypeName()` Gets the name of the type representing the document.
    `int` | `getNumChildren()`
    `void` | `serialize(CAS cas, ContentHandler contentHandler)` Write the CAS data to a SAX content handler.
    `void` | `serialize(CAS cas, ContentHandler contentHandler, boolean encodeDoc)` Write the CAS data to a SAX content handler.
    `void` | `serialize(CAS cas, ContentHandler contentHandler, boolean encodeDoc, OutOfTypeSystemData outOfTypeSystemData)` Write the CAS data to a SAX content handler.
    `static void` | `serialize(CAS aCAS, OutputStream aStream)` Serializes an XCAS to a stream.
    `static void` | `serialize(CAS aCAS, OutputStream aStream, boolean isFormattedOutput)` Serializes an XCAS to a stream.
    `static void` | `serialize(CAS aCAS, OutputStream aStream, boolean isFormattedOutput, boolean useXml_1_1)` Serializes an XCAS to a stream.
    `void` | `setDocumentTextFeature(String aDocTextFeature)` Sets the name of the feature holding the documeng text.
    `void` | `setDocumentTypeName(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`

- - ### Field Detail

    - #### casTagName

          public static final String casTagName

      See Also:
        Constant Field Values

    - #### VERSION_ATTR

          public static final String VERSION_ATTR

      See Also:
        Constant Field Values

    - #### CURRENT_VERSION

          public static final String CURRENT_VERSION

      See Also:
        Constant Field Values

    - #### DEFAULT_DOC_TYPE_NAME

          public static final String DEFAULT_DOC_TYPE_NAME

      See Also:
        Constant Field Values

    - #### DEFAULT_DOC_TEXT_FEAT

          public static final String DEFAULT_DOC_TEXT_FEAT

      See Also:
        Constant Field Values

    - #### INDEXED_ATTR_NAME

          public static final String INDEXED_ATTR_NAME

      See Also:
        Constant Field Values

    - #### REF_PREFIX

          public static final String REF_PREFIX

      See Also:
        Constant Field Values

    - #### ID_ATTR_NAME

          public static final String ID_ATTR_NAME

      See Also:
        Constant Field Values

    - #### CONTENT_ATTR_NAME

          public static final String CONTENT_ATTR_NAME

      See Also:
        Constant Field Values

    - #### ARRAY_SIZE_ATTR

          public static final String ARRAY_SIZE_ATTR

      See Also:
        Constant Field Values

    - #### ARRAY_ELEMENT_TAG

          public static final String ARRAY_ELEMENT_TAG

      See Also:
        Constant Field Values

    - #### TRUE_VALUE

          public static final String TRUE_VALUE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### XCASSerializer

          public XCASSerializer(TypeSystem ts,
                                UimaContext uimaContext)

    - #### XCASSerializer

          public XCASSerializer(TypeSystem ts)

  - ### Method Detail

    - #### getNumChildren

          public int getNumChildren()

    - #### serialize

          public void serialize(CAS cas,
                                ContentHandler contentHandler)
                         throws IOException,
                                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:
        `IOException` - passed thru
        `SAXException` - passed thru

    - #### serialize

          public void serialize(CAS cas,
                                ContentHandler contentHandler,
                                boolean encodeDoc)
                         throws IOException,
                                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:
        `IOException` - passed thru
        `SAXException` - passed thru

    - #### serialize

          public void serialize(CAS cas,
                                ContentHandler contentHandler,
                                boolean encodeDoc,
                                OutOfTypeSystemData outOfTypeSystemData)
                         throws IOException,
                                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:
        `IOException` - passed thru
        `SAXException` - passed thru

    - #### getDocumentTypeName

          public 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(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 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(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,
                                       OutputStream aStream)
                                throws SAXException,
                                       IOException

      Serializes an XCAS to a stream.
      Parameters:
        `aCAS` - CAS to serialize.
        `aStream` - output stream to which to write the XCAS XML document
      Throws:
        `SAXException` - if a problem occurs during XCAS serialization
        `IOException` - if an I/O failure occurs

    - #### serialize

          public static void serialize(CAS aCAS,
                                       OutputStream aStream,
                                       boolean isFormattedOutput)
                                throws SAXException,
                                       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:
        `SAXException` - if a problem occurs during XCAS serialization
        `IOException` - if an I/O failure occurs

    - #### serialize

          public static void serialize(CAS aCAS,
                                       OutputStream aStream,
                                       boolean isFormattedOutput,
                                       boolean useXml_1_1)
                                throws SAXException,
                                       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 *
        `useXml_1_1` - if true, the output serializer is set with the OutputKeys.VERSION to "1.1".
      Throws:
        `SAXException` - if a problem occurs during XCAS serialization
        `IOException` - if an I/O failure occurs

Copyright © 2006–2022 The Apache Software Foundation. All rights reserved.