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) private void
addIdAttribute
(AttributesImpl attrs, String attrValue) protected void
addNameSpace
(XmlElementName xmlElementName) private void
private String
arrayToString
(TOP fsIn, int arrayType) Not called for StringArrayprotected void
checkForNameCollision
(XmlElementName xmlElementName) private void
computeNamespaceDeclarationAttrs
(AttributesImpl workAttrs2) private List
<XmlElementNameAndContents> encodeFeatures
(TOP fs, AttributesImpl attrs, boolean insideListNode) Encode features of a regular (non-array) FS.private void
endElement
(XmlElementName name) private void
protected void
private String
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, StringArray stringArray, 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
(TOP fsArray, int typeCode, int typeClass) protected void
protected void
protected void
writeFeatureStructures
(int iElementCount) protected void
private void
writeFsOrLists
(TOP fs, int typeCode, boolean isListAsFSs) protected void
writeFsRef
(TOP fs) protected boolean
writeFsStart
(TOP fs, int typeCode) protected void
writeListsAsIndividualFSs
(TOP fs, int typeCode) (package private) void
Writes a special instance of dummy type uima.cas.NULL, having xmi:id=0.protected void
writeView
(Sofa sofa, Collection<TOP> members) protected void
writeView
(Sofa sofa, Collection<TOP> added, Collection<TOP> deleted, Collection<TOP> reindexed) private void
writeViewForDeltas
(String kind, Collection<TOP> deltaMembers) private StringBuilder
writeViewMembers
(StringBuilder sb, Collection<String> members, boolean isPastFirstElement) version for out-of-type-system data being merged back in not currently supported for JSONprivate boolean
writeViewMembers
(StringBuilder sb, Collection<TOP> members) protected 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, Collection<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(Sofa sofa, Collection<TOP> added, Collection<TOP> deleted, Collection<TOP> 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(TOP fs, AttributesImpl attrs, boolean insideListNode) throws SAXException Encode features of a regular (non-array) FS.- Parameters:
attrs
- SAX Attributes object, to which we will add attributesinsideListNode
- true iff this FS is a List type.addr
- Address of the FS- 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
Not called for StringArray- Parameters:
fsIn
- -arrayType
- -- Returns:
- -
- Throws:
SAXException
- -
-
stringArrayToElementList
private void stringArrayToElementList(String featName, StringArray stringArray, 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
-
addIdAttribute
-
addText
- Throws:
SAXException
-
checkForNameCollision
- Specified by:
checkForNameCollision
in classCasSerializerSupport.CasSerializerSupportSerialize
-
addNameSpace
- Specified by:
addNameSpace
in classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFsStart
- Specified by:
writeFsStart
in classCasSerializerSupport.CasSerializerSupportSerialize
- Parameters:
fs
- -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
-