Package org.apache.uima.cas.impl
Class XmiCasSerializer.XmiDocSerializer
java.lang.Object
org.apache.uima.cas.impl.CasSerializerSupport.CasSerializerSupportSerialize
org.apache.uima.cas.impl.XmiCasSerializer.XmiDocSerializer
- Enclosing class:
XmiCasSerializer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CasSerializerSupport.CasDocSerializer
private final ContentHandler
private final AttributesImpl
private final AttributesImpl
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
XmiDocSerializer
(ContentHandler ch, CASImpl cas, XmiSerializationSharedData sharedData, MarkerImpl marker) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addAttribute
(AttributesImpl attrs, String attrName, String attrValue) private void
addAttribute
(AttributesImpl attrs, String attrName, String attrValue, String type) protected void
addNameSpace
(XmlElementName xmlElementName) private void
private String
arrayToString
(int addr, int arrayType) Create a string to represent array values, embedded formatprotected void
checkForNameCollision
(XmlElementName xmlElementName) private void
computeNamespaceDeclarationAttrs
(AttributesImpl workAttrs2) private List
<XmlElementNameAndContents> encodeFeatures
(int addr, AttributesImpl attrs, boolean insideListNode) Encode features of a regular (non-array) FS.private void
endElement
(XmlElementName name) private void
protected void
private String
listToString
(int curNode) Converts a CAS List of Int, Float, or FsRefs to its string representation for use in multi-valued XMI properties.private void
sendElementEvents
(List<? extends XmlElementNameAndContents> elements) Generate startElement, characters, and endElement SAX events.private void
Serializes all of the out-of-typesystem elements that were recorded in the XmiSerializationSharedData during the last deserialization.private void
startElement
(XmlElementName name, Attributes attrs, int aNumChildren) private void
stringArrayToElementList
(String featName, int addr, List<? super XmlElementNameAndContents> resultList) protected XmlElementName
uimaTypeName2XmiElementName
(String uimaTypeName) Converts a UIMA-style dotted type name to the element name that should be used in the XMI serialization.protected void
writeArrays
(int addr, int typeCode, int typeClass) protected void
protected void
protected void
writeFeatureStructures
(int iElementCount) protected void
writeFs
(int addr, int typeCode) private void
writeFsOrLists
(int addr, int typeCode, boolean isListAsFSs) protected void
writeFsRef
(int addr) protected boolean
writeFsStart
(int addr, int typeCode) protected void
writeListsAsIndividualFSs
(int addr, int typeCode) (package private) void
Writes a special instance of dummy type uima.cas.NULL, having xmi:id=0.protected void
writeView
(int sofaAddr, int[] members) protected void
writeView
(int sofaAddr, int[] added, int[] deleted, int[] reindexed) private void
writeViewForDeltas
(String kind, int[] deltaMembers) private boolean
writeViewMembers
(StringBuilder sb, int[] members) private StringBuilder
writeViewMembers
(StringBuilder sb, List<String> members, boolean isPastFirstElement) version for out-of-type-system data being merged back in not currently supported for JSONprotected void
-
Field Details
-
cds
-
ch
-
emptyAttrs
-
workAttrs
-
-
Constructor Details
-
Method Details
-
initializeNamespaces
protected void initializeNamespaces()- Specified by:
initializeNamespaces
in classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFeatureStructures
- Specified by:
writeFeatureStructures
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
Exception
-
writeViews
- Specified by:
writeViews
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
Exception
-
writeEndOfSerialization
- Specified by:
writeEndOfSerialization
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
SAXException
-
writeView
- Specified by:
writeView
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
Exception
-
writeViewMembers
private StringBuilder writeViewMembers(StringBuilder sb, List<String> members, boolean isPastFirstElement) version for out-of-type-system data being merged back in not currently supported for JSON- Parameters:
sb
- - where output goesmembers
- string representations of the out of type system idsisPastFirstElement
- -- Returns:
-
writeViewMembers
- Throws:
SAXException
-
writeViewForDeltas
- Throws:
SAXException
-
writeView
protected void writeView(int sofaAddr, int[] added, int[] deleted, int[] reindexed) throws SAXException - Specified by:
writeView
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
SAXException
-
writeNullObject
Writes a special instance of dummy type uima.cas.NULL, having xmi:id=0. This is needed to represent nulls in multi-valued references, which aren't natively supported in Ecore.- Throws:
SAXException
-
writeFs
- Specified by:
writeFs
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
SAXException
-
writeListsAsIndividualFSs
- Specified by:
writeListsAsIndividualFSs
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
SAXException
-
writeFsOrLists
- Throws:
SAXException
-
writeArrays
- Specified by:
writeArrays
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
SAXException
-
endPrefixMappings
- Throws:
SAXException
-
computeNamespaceDeclarationAttrs
- Throws:
SAXException
-
serializeOutOfTypeSystemElements
Serializes all of the out-of-typesystem elements that were recorded in the XmiSerializationSharedData during the last deserialization.- Throws:
SAXException
-
encodeFeatures
private List<XmlElementNameAndContents> encodeFeatures(int addr, AttributesImpl attrs, boolean insideListNode) throws SAXException Encode features of a regular (non-array) FS.- Parameters:
addr
- Address of the FSattrs
- SAX Attributes object, to which we will add attributesinsideListNode
- true iff this FS is a List type.- Returns:
- a List of XmlElementNameAndContents objects, each of which represents an element that should be added as a child of the FS
- Throws:
SAXException
- passthru
-
arrayToString
Create a string to represent array values, embedded format- Parameters:
addr
-arrayType
-- Returns:
- Throws:
SAXException
-
stringArrayToElementList
private void stringArrayToElementList(String featName, int addr, List<? super XmlElementNameAndContents> resultList) -
listToString
Converts a CAS List of Int, Float, or FsRefs to its string representation for use in multi-valued XMI properties. Only called if no sharing of list nodes exists. Only called for list nodes referred to by Feature value slots in some non-list FS.- Parameters:
curNode
- address of the CAS ListFS- Returns:
- String representation of the array, or null if passed in CASImpl.NULL
- Throws:
SAXException
- passthru
-
sendElementEvents
private void sendElementEvents(List<? extends XmlElementNameAndContents> elements) throws SAXException Generate startElement, characters, and endElement SAX events. Only for StringArray and StringList kinds of things Only called for XMI (not JSON)- Parameters:
elements
- a list of XmlElementNameAndContents objects representing the elements to generate- Throws:
SAXException
- passthru
-
startElement
private void startElement(XmlElementName name, Attributes attrs, int aNumChildren) throws SAXException - Throws:
SAXException
-
endElement
- Throws:
SAXException
-
addAttribute
-
addAttribute
-
addText
- Throws:
SAXException
-
checkForNameCollision
- Specified by:
checkForNameCollision
in classCasSerializerSupport.CasSerializerSupportSerialize
-
addNameSpace
- Specified by:
addNameSpace
in classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFsStart
protected boolean writeFsStart(int addr, int typeCode) - Specified by:
writeFsStart
in classCasSerializerSupport.CasSerializerSupportSerialize
- Parameters:
addr
- -typeCode
- -- Returns:
- true if writing out referenced items (JSON)
-
uimaTypeName2XmiElementName
Converts a UIMA-style dotted type name to the element name that should be used in the XMI serialization. The XMI element name consists of three parts - the Namespace URI, the Local Name, and the QName (qualified name). Namespace URI = http:///uima/noNamespace.ecore or http:///uima/package/name/with/slashes.ecore- Specified by:
uimaTypeName2XmiElementName
in classCasSerializerSupport.CasSerializerSupportSerialize
- Parameters:
uimaTypeName
- a UIMA-style dotted type name- Returns:
- a data structure holding the three components of the XML element name
-
writeEndOfIndividualFs
protected void writeEndOfIndividualFs()- Specified by:
writeEndOfIndividualFs
in classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFsRef
- Specified by:
writeFsRef
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
Exception
-