Package org.apache.uima.cas.impl
Class XCASSerializer
java.lang.Object
org.apache.uima.cas.impl.XCASSerializer
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the name of the feature holding the documeng text.Gets the name of the type representing the document.int
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
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.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.
-
Field Details
-
casTagName
- See Also:
-
VERSION_ATTR
- See Also:
-
CURRENT_VERSION
- See Also:
-
DEFAULT_DOC_TYPE_NAME
- See Also:
-
DEFAULT_DOC_TEXT_FEAT
- See Also:
-
INDEXED_ATTR_NAME
- See Also:
-
REF_PREFIX
- See Also:
-
ID_ATTR_NAME
- See Also:
-
CONTENT_ATTR_NAME
- See Also:
-
ARRAY_SIZE_ATTR
- See Also:
-
ARRAY_ELEMENT_TAG
- See Also:
-
TRUE_VALUE
- See Also:
-
-
Constructor Details
-
XCASSerializer
-
XCASSerializer
-
-
Method Details
-
getNumChildren
public int getNumChildren() -
serialize
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 thruSAXException
- 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 thruSAXException
- 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 thruSAXException
- passed thru
-
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
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 toDEFAULT_DOC_TYPE_NAME
.- Parameters:
aDocTypeName
- the document type name
-
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
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 toDEFAULT_DOC_TEXT_FEAT
. If set to null, no _content attribute will be emitted.- Parameters:
aDocTextFeature
- the document text feature
-
serialize
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 serializationIOException
- 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 documentisFormattedOutput
- if true the XCAS will be serialized formatted- Throws:
SAXException
- if a problem occurs during XCAS serializationIOException
- 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 documentisFormattedOutput
- 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 serializationIOException
- if an I/O failure occurs
-