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.CasDocSerializercdsprivate org.xml.sax.ContentHandlerchprivate org.xml.sax.helpers.AttributesImplemptyAttrsprivate org.xml.sax.helpers.AttributesImplworkAttrs
-
Constructor Summary
Constructors Modifier Constructor Description privateXmiDocSerializer(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 voidaddAttribute(org.xml.sax.helpers.AttributesImpl attrs, java.lang.String attrName, java.lang.String attrValue)private voidaddAttribute(org.xml.sax.helpers.AttributesImpl attrs, java.lang.String attrName, java.lang.String attrValue, java.lang.String type)private voidaddIdAttribute(org.xml.sax.helpers.AttributesImpl attrs, java.lang.String attrValue)protected voidaddNameSpace(XmlElementName xmlElementName)private voidaddText(java.lang.String text)private java.lang.StringarrayToString(TOP fsIn, int arrayType)Not called for StringArrayprotected voidcheckForNameCollision(XmlElementName xmlElementName)private voidcomputeNamespaceDeclarationAttrs(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 voidendElement(XmlElementName name)private voidendPrefixMappings()protected voidinitializeNamespaces()private java.lang.StringlistToString(CommonList fs)Converts a CAS List of Int, Float, or FsRefs to its string representation for use in multi-valued XMI properties.private voidsendElementEvents(java.util.List<? extends XmlElementNameAndContents> elements)Generate startElement, characters, and endElement SAX events.private voidserializeOutOfTypeSystemElements()Serializes all of the out-of-typesystem elements that were recorded in the XmiSerializationSharedData during the last deserialization.private voidstartElement(XmlElementName name, org.xml.sax.Attributes attrs, int aNumChildren)private voidstringArrayToElementList(java.lang.String featName, StringArray stringArray, java.util.List<? super XmlElementNameAndContents> resultList)protected XmlElementNameuimaTypeName2XmiElementName(java.lang.String uimaTypeName)Converts a UIMA-style dotted type name to the element name that should be used in the XMI serialization.protected voidwriteArrays(TOP fsArray, int typeCode, int typeClass)protected voidwriteEndOfIndividualFs()protected voidwriteEndOfSerialization()protected voidwriteFeatureStructures(int iElementCount)protected voidwriteFs(TOP fs, int typeCode)private voidwriteFsOrLists(TOP fs, int typeCode, boolean isListAsFSs)protected voidwriteFsRef(TOP fs)protected booleanwriteFsStart(TOP fs, int typeCode)protected voidwriteListsAsIndividualFSs(TOP fs, int typeCode)(package private) voidwriteNullObject()Writes a special instance of dummy type uima.cas.NULL, having xmi:id=0.protected voidwriteView(Sofa sofa, java.util.Collection<TOP> members)protected voidwriteView(Sofa sofa, java.util.Collection<TOP> added, java.util.Collection<TOP> deleted, java.util.Collection<TOP> reindexed)private voidwriteViewForDeltas(java.lang.String kind, java.util.Collection<TOP> deltaMembers)private java.lang.StringBuilderwriteViewMembers(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 booleanwriteViewMembers(java.lang.StringBuilder sb, java.util.Collection<TOP> members)protected voidwriteViews()
-
-
-
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:
initializeNamespacesin classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFeatureStructures
protected void writeFeatureStructures(int iElementCount) throws java.lang.Exception- Specified by:
writeFeatureStructuresin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
java.lang.Exception
-
writeViews
protected void writeViews() throws java.lang.Exception- Specified by:
writeViewsin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
java.lang.Exception
-
writeEndOfSerialization
protected void writeEndOfSerialization() throws org.xml.sax.SAXException- Specified by:
writeEndOfSerializationin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
org.xml.sax.SAXException
-
writeView
protected void writeView(Sofa sofa, java.util.Collection<TOP> members) throws java.lang.Exception
- Specified by:
writeViewin 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:
writeViewin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
org.xml.sax.SAXException
-
writeNullObject
void writeNullObject() throws org.xml.sax.SAXExceptionWrites 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:
writeFsin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
org.xml.sax.SAXException
-
writeListsAsIndividualFSs
protected void writeListsAsIndividualFSs(TOP fs, int typeCode) throws org.xml.sax.SAXException
- Specified by:
writeListsAsIndividualFSsin 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:
writeArraysin 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.SAXExceptionSerializes 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:
checkForNameCollisionin classCasSerializerSupport.CasSerializerSupportSerialize
-
addNameSpace
protected void addNameSpace(XmlElementName xmlElementName)
- Specified by:
addNameSpacein classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFsStart
protected boolean writeFsStart(TOP fs, int typeCode)
- Specified by:
writeFsStartin 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:
uimaTypeName2XmiElementNamein 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:
writeEndOfIndividualFsin classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFsRef
protected void writeFsRef(TOP fs) throws java.lang.Exception
- Specified by:
writeFsRefin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
java.lang.Exception
-
-