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
class XmiCasSerializer.XmiDocSerializer extends CasSerializerSupport.CasSerializerSupportSerialize
-
-
Field Summary
Fields Modifier and Type Field Description private CasSerializerSupport.CasDocSerializer
cds
private org.xml.sax.ContentHandler
ch
private org.xml.sax.helpers.AttributesImpl
emptyAttrs
private org.xml.sax.helpers.AttributesImpl
workAttrs
-
Constructor Summary
Constructors Modifier Constructor Description private
XmiDocSerializer(org.xml.sax.ContentHandler ch, CASImpl cas, XmiSerializationSharedData sharedData, MarkerImpl marker)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addAttribute(org.xml.sax.helpers.AttributesImpl attrs, java.lang.String attrName, java.lang.String attrValue)
private void
addAttribute(org.xml.sax.helpers.AttributesImpl attrs, java.lang.String attrName, java.lang.String attrValue, java.lang.String type)
private void
addIdAttribute(org.xml.sax.helpers.AttributesImpl attrs, java.lang.String attrValue)
protected void
addNameSpace(XmlElementName xmlElementName)
private void
addText(java.lang.String text)
private java.lang.String
arrayToString(TOP fsIn, int arrayType)
Not called for StringArrayprotected void
checkForNameCollision(XmlElementName xmlElementName)
private void
computeNamespaceDeclarationAttrs(org.xml.sax.helpers.AttributesImpl workAttrs2)
private java.util.List<XmlElementNameAndContents>
encodeFeatures(TOP fs, org.xml.sax.helpers.AttributesImpl attrs, boolean insideListNode)
Encode features of a regular (non-array) FS.private void
endElement(XmlElementName name)
private void
endPrefixMappings()
protected void
initializeNamespaces()
private java.lang.String
listToString(CommonList fs)
Converts a CAS List of Int, Float, or FsRefs to its string representation for use in multi-valued XMI properties.private void
sendElementEvents(java.util.List<? extends XmlElementNameAndContents> elements)
Generate startElement, characters, and endElement SAX events.private void
serializeOutOfTypeSystemElements()
Serializes all of the out-of-typesystem elements that were recorded in the XmiSerializationSharedData during the last deserialization.private void
startElement(XmlElementName name, org.xml.sax.Attributes attrs, int aNumChildren)
private void
stringArrayToElementList(java.lang.String featName, StringArray stringArray, java.util.List<? super XmlElementNameAndContents> resultList)
protected XmlElementName
uimaTypeName2XmiElementName(java.lang.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
writeEndOfIndividualFs()
protected void
writeEndOfSerialization()
protected void
writeFeatureStructures(int iElementCount)
protected void
writeFs(TOP fs, int typeCode)
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
writeNullObject()
Writes a special instance of dummy type uima.cas.NULL, having xmi:id=0.protected void
writeView(Sofa sofa, java.util.Collection<TOP> members)
protected void
writeView(Sofa sofa, java.util.Collection<TOP> added, java.util.Collection<TOP> deleted, java.util.Collection<TOP> reindexed)
private void
writeViewForDeltas(java.lang.String kind, java.util.Collection<TOP> deltaMembers)
private java.lang.StringBuilder
writeViewMembers(java.lang.StringBuilder sb, java.util.Collection<java.lang.String> members, boolean isPastFirstElement)
version for out-of-type-system data being merged back in not currently supported for JSONprivate boolean
writeViewMembers(java.lang.StringBuilder sb, java.util.Collection<TOP> members)
protected void
writeViews()
-
-
-
Field Detail
-
cds
private final CasSerializerSupport.CasDocSerializer cds
-
ch
private final org.xml.sax.ContentHandler ch
-
emptyAttrs
private final org.xml.sax.helpers.AttributesImpl emptyAttrs
-
workAttrs
private final org.xml.sax.helpers.AttributesImpl workAttrs
-
-
Constructor Detail
-
XmiDocSerializer
private XmiDocSerializer(org.xml.sax.ContentHandler ch, CASImpl cas, XmiSerializationSharedData sharedData, MarkerImpl marker)
-
-
Method Detail
-
initializeNamespaces
protected void initializeNamespaces()
- Specified by:
initializeNamespaces
in classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFeatureStructures
protected void writeFeatureStructures(int iElementCount) throws java.lang.Exception
- Specified by:
writeFeatureStructures
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
java.lang.Exception
-
writeViews
protected void writeViews() throws java.lang.Exception
- Specified by:
writeViews
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
java.lang.Exception
-
writeEndOfSerialization
protected void writeEndOfSerialization() throws org.xml.sax.SAXException
- Specified by:
writeEndOfSerialization
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
org.xml.sax.SAXException
-
writeView
protected void writeView(Sofa sofa, java.util.Collection<TOP> members) throws java.lang.Exception
- Specified by:
writeView
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
java.lang.Exception
-
writeViewMembers
private java.lang.StringBuilder writeViewMembers(java.lang.StringBuilder sb, java.util.Collection<java.lang.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
private boolean writeViewMembers(java.lang.StringBuilder sb, java.util.Collection<TOP> members) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
writeViewForDeltas
private void writeViewForDeltas(java.lang.String kind, java.util.Collection<TOP> deltaMembers) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
writeView
protected void writeView(Sofa sofa, java.util.Collection<TOP> added, java.util.Collection<TOP> deleted, java.util.Collection<TOP> reindexed) throws org.xml.sax.SAXException
- Specified by:
writeView
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
org.xml.sax.SAXException
-
writeNullObject
void writeNullObject() throws org.xml.sax.SAXException
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:
org.xml.sax.SAXException
- -
-
writeFs
protected void writeFs(TOP fs, int typeCode) throws org.xml.sax.SAXException
- Specified by:
writeFs
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
org.xml.sax.SAXException
-
writeListsAsIndividualFSs
protected void writeListsAsIndividualFSs(TOP fs, int typeCode) throws org.xml.sax.SAXException
- Specified by:
writeListsAsIndividualFSs
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
org.xml.sax.SAXException
-
writeFsOrLists
private void writeFsOrLists(TOP fs, int typeCode, boolean isListAsFSs) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
writeArrays
protected void writeArrays(TOP fsArray, int typeCode, int typeClass) throws org.xml.sax.SAXException
- Specified by:
writeArrays
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
org.xml.sax.SAXException
-
endPrefixMappings
private void endPrefixMappings() throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
computeNamespaceDeclarationAttrs
private void computeNamespaceDeclarationAttrs(org.xml.sax.helpers.AttributesImpl workAttrs2) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
serializeOutOfTypeSystemElements
private void serializeOutOfTypeSystemElements() throws org.xml.sax.SAXException
Serializes all of the out-of-typesystem elements that were recorded in the XmiSerializationSharedData during the last deserialization.- Throws:
org.xml.sax.SAXException
-
encodeFeatures
private java.util.List<XmlElementNameAndContents> encodeFeatures(TOP fs, org.xml.sax.helpers.AttributesImpl attrs, boolean insideListNode) throws org.xml.sax.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:
org.xml.sax.SAXException
- passthru
-
arrayToString
private java.lang.String arrayToString(TOP fsIn, int arrayType) throws org.xml.sax.SAXException
Not called for StringArray- Parameters:
fsIn
- -arrayType
- -- Returns:
- -
- Throws:
org.xml.sax.SAXException
- -
-
stringArrayToElementList
private void stringArrayToElementList(java.lang.String featName, StringArray stringArray, java.util.List<? super XmlElementNameAndContents> resultList)
-
listToString
private java.lang.String listToString(CommonList fs) throws org.xml.sax.SAXException
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:
org.xml.sax.SAXException
- passthru
-
sendElementEvents
private void sendElementEvents(java.util.List<? extends XmlElementNameAndContents> elements) throws org.xml.sax.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:
org.xml.sax.SAXException
- passthru
-
startElement
private void startElement(XmlElementName name, org.xml.sax.Attributes attrs, int aNumChildren) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
endElement
private void endElement(XmlElementName name) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
addAttribute
private void addAttribute(org.xml.sax.helpers.AttributesImpl attrs, java.lang.String attrName, java.lang.String attrValue)
-
addAttribute
private void addAttribute(org.xml.sax.helpers.AttributesImpl attrs, java.lang.String attrName, java.lang.String attrValue, java.lang.String type)
-
addIdAttribute
private void addIdAttribute(org.xml.sax.helpers.AttributesImpl attrs, java.lang.String attrValue)
-
addText
private void addText(java.lang.String text) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
checkForNameCollision
protected void checkForNameCollision(XmlElementName xmlElementName)
- Specified by:
checkForNameCollision
in classCasSerializerSupport.CasSerializerSupportSerialize
-
addNameSpace
protected void addNameSpace(XmlElementName xmlElementName)
- Specified by:
addNameSpace
in classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFsStart
protected boolean writeFsStart(TOP fs, int typeCode)
- Specified by:
writeFsStart
in classCasSerializerSupport.CasSerializerSupportSerialize
- Parameters:
fs
- -typeCode
- -- Returns:
- true if writing out referenced items (JSON)
-
uimaTypeName2XmiElementName
protected XmlElementName uimaTypeName2XmiElementName(java.lang.String uimaTypeName)
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
protected void writeFsRef(TOP fs) throws java.lang.Exception
- Specified by:
writeFsRef
in classCasSerializerSupport.CasSerializerSupportSerialize
- Throws:
java.lang.Exception
-
-