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.CasDocSerializerprivate final ContentHandlerprivate final AttributesImplprivate final AttributesImpl -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateXmiDocSerializer(ContentHandler ch, CASImpl cas, XmiSerializationSharedData sharedData, MarkerImpl marker) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddAttribute(AttributesImpl attrs, String attrName, String attrValue) private voidaddAttribute(AttributesImpl attrs, String attrName, String attrValue, String type) private voidaddIdAttribute(AttributesImpl attrs, String attrValue) protected voidaddNameSpace(XmlElementName xmlElementName) private voidprivate StringarrayToString(TOP fsIn, int arrayType) Not called for StringArrayprotected voidcheckForNameCollision(XmlElementName xmlElementName) private voidcomputeNamespaceDeclarationAttrs(AttributesImpl workAttrs2) private List<XmlElementNameAndContents> encodeFeatures(TOP fs, AttributesImpl attrs, boolean insideListNode) Encode features of a regular (non-array) FS.private voidendElement(XmlElementName name) private voidprotected voidprivate StringConverts a CAS List of Int, Float, or FsRefs to its string representation for use in multi-valued XMI properties.private voidsendElementEvents(List<? extends XmlElementNameAndContents> elements) Generate startElement, characters, and endElement SAX events.private voidSerializes all of the out-of-typesystem elements that were recorded in the XmiSerializationSharedData during the last deserialization.private voidstartElement(XmlElementName name, Attributes attrs, int aNumChildren) private voidstringArrayToElementList(String featName, StringArray stringArray, List<? super XmlElementNameAndContents> resultList) protected XmlElementNameuimaTypeName2XmiElementName(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 voidprotected voidprotected voidwriteFeatureStructures(int iElementCount) protected voidprivate 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) voidWrites a special instance of dummy type uima.cas.NULL, having xmi:id=0.protected voidwriteView(Sofa sofa, Collection<TOP> members) protected voidwriteView(Sofa sofa, Collection<TOP> added, Collection<TOP> deleted, Collection<TOP> reindexed) private voidwriteViewForDeltas(String kind, Collection<TOP> deltaMembers) private StringBuilderwriteViewMembers(StringBuilder sb, Collection<String> members, boolean isPastFirstElement) version for out-of-type-system data being merged back in not currently supported for JSONprivate booleanwriteViewMembers(StringBuilder sb, Collection<TOP> members) protected void
-
Field Details
-
cds
-
ch
-
emptyAttrs
-
workAttrs
-
-
Constructor Details
-
Method Details
-
initializeNamespaces
protected void initializeNamespaces()- Specified by:
initializeNamespacesin classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFeatureStructures
- Specified by:
writeFeatureStructuresin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
Exception
-
writeViews
- Specified by:
writeViewsin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
Exception
-
writeEndOfSerialization
- Specified by:
writeEndOfSerializationin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
SAXException
-
writeView
- Specified by:
writeViewin 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:
writeViewin 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:
writeFsin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
SAXException
-
writeListsAsIndividualFSs
- Specified by:
writeListsAsIndividualFSsin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
SAXException
-
writeFsOrLists
- Throws:
SAXException
-
writeArrays
- Specified by:
writeArraysin 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:
checkForNameCollisionin classCasSerializerSupport.CasSerializerSupportSerialize
-
addNameSpace
- Specified by:
addNameSpacein classCasSerializerSupport.CasSerializerSupportSerialize
-
writeFsStart
- Specified by:
writeFsStartin 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:
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
- Specified by:
writeFsRefin classCasSerializerSupport.CasSerializerSupportSerialize- Throws:
Exception
-