Package org.apache.uima.cas.impl
Class XCASSerializer.XCASDocSerializer
- java.lang.Object
-
- org.apache.uima.cas.impl.XCASSerializer.XCASDocSerializer
-
- Enclosing class:
- XCASSerializer
private class XCASSerializer.XCASDocSerializer extends java.lang.ObjectUse an inner class to hold the data for serializing a CAS. Each call to serialize() creates its own instance.
-
-
Field Summary
Fields Modifier and Type Field Description private CASImplcasprivate static java.lang.StringcdataTypeprivate org.xml.sax.ContentHandlerchprivate java.util.Map<TOP,java.lang.Integer>duplicatesAny FS indexed in more than one IR goes in here, the value is the associated duplicate key, Key is used to index into dupVectors(package private) java.util.List<IntVector>dupVectorslist of IntVectors holding lists of repo numbers.private org.xml.sax.helpers.AttributesImplemptyAttrsprivate intfsCountprivate java.util.List<TOP>indexedFSslist of FSs that are in an index somewhere.private IntVectorindexRepsSpecific IndexRepository for indexed FSsprivate static intINVALID_INDEXprivate static intKEY_AND_VALUE_MATCHprivate static intKEY_NOT_FOUNDprivate static intKEY_ONLY_MATCHprivate OutOfTypeSystemDatamOutOfTypeSystemDataprivate static intMULTIPLY_INDEXEDprivate static intNOT_INDEXED(package private) intnumDuplicatesA key identifying a particular FS indexed in multiple indexes.private java.util.Deque<TOP>queueThe current queue for FSs to write out.private java.util.Map<TOP,java.lang.Integer>queuedAny FS reference we've touched goes in here.private org.xml.sax.helpers.AttributesImplworkAttrs
-
Constructor Summary
Constructors Modifier Constructor Description privateXCASDocSerializer(org.xml.sax.ContentHandler ch, CASImpl cas)
-
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 voidaddText(java.lang.String text)private intclassifyType(TypeImpl ti)classify the type, without distinguishng list typesprivate voidencodeFeatures(TOP fs, org.xml.sax.helpers.AttributesImpl attrs)private voidencodeFS(TOP fs, IntVector indexRep)Encode an individual FS.private voidencodeFSArray(FSArray fs, org.xml.sax.helpers.AttributesImpl attrs)private voidencodeIndexed()private voidencodeOutOfTypeSystemFeatures(TOP fs, org.xml.sax.helpers.AttributesImpl attrs)private voidencodePrimitiveTypeArrayFS(java.lang.String[] data, java.lang.String typeName, org.xml.sax.helpers.AttributesImpl attrs)private voidencodeQueued()private voidendElement(java.lang.String tag)private booleanenqueue(TOP fs)Add an address to the queue.private voidenqueueArray(TOP[] fss, int sofaNum)private voidenqueueCollection(java.util.Collection<TOP> fss, int sofaNum)private voidenqueueFeatures(TOP fs, int heapValue)private voidenqueueFeaturesOfIndexed()private voidenqueueFSArray(FSArray fs)private voidenqueueIndexed()Push the indexed FSs onto the queue.private voidenqueueIndexed(TOP fs, int indexRep)Same as enqueue, but for indexed FSs.private voidenqueueOutOfTypeSystemData(OutOfTypeSystemData aData)private voidenqueueOutOfTypeSystemFeatures(TOP fs)private java.lang.StringgetTypeName(TOP fs)private intisQueued(TOP fs, int value)Bad name; check if we've seen this (address, value) before.private booleanisValidXmlChar(char c)private java.lang.StringreplaceInvalidXmlChars(java.lang.String aString)private voidserialize(boolean encodeDoc, OutOfTypeSystemData outOfTypeSystemData)private voidserializeOutOfTypeSystemData(OutOfTypeSystemData aData)private voidstartElement(java.lang.String tag, org.xml.sax.Attributes attrs, int num)
-
-
-
Field Detail
-
ch
private org.xml.sax.ContentHandler ch
-
cas
private CASImpl cas
-
queued
private final java.util.Map<TOP,java.lang.Integer> queued
Any FS reference we've touched goes in here. value is index repo (first one?), or MULTIPLY_INDEXED
-
NOT_INDEXED
private static final int NOT_INDEXED
- See Also:
- Constant Field Values
-
MULTIPLY_INDEXED
private static final int MULTIPLY_INDEXED
- See Also:
- Constant Field Values
-
INVALID_INDEX
private static final int INVALID_INDEX
- See Also:
- Constant Field Values
-
duplicates
private final java.util.Map<TOP,java.lang.Integer> duplicates
Any FS indexed in more than one IR goes in here, the value is the associated duplicate key, Key is used to index into dupVectors
-
numDuplicates
int numDuplicates
A key identifying a particular FS indexed in multiple indexes. Starts a 0, incr by 1 for each new FS discovered to be indexed in more than one IR
-
dupVectors
final java.util.List<IntVector> dupVectors
list of IntVectors holding lists of repo numbers. Indexed by the key above, for fss that are in multiple index repos
-
indexedFSs
private final java.util.List<TOP> indexedFSs
list of FSs that are in an index somewhere.
-
indexReps
private final IntVector indexReps
Specific IndexRepository for indexed FSs
-
queue
private final java.util.Deque<TOP> queue
The current queue for FSs to write out.
-
emptyAttrs
private final org.xml.sax.helpers.AttributesImpl emptyAttrs
-
workAttrs
private org.xml.sax.helpers.AttributesImpl workAttrs
-
cdataType
private static final java.lang.String cdataType
- See Also:
- Constant Field Values
-
fsCount
private int fsCount
-
mOutOfTypeSystemData
private OutOfTypeSystemData mOutOfTypeSystemData
-
KEY_AND_VALUE_MATCH
private static final int KEY_AND_VALUE_MATCH
- See Also:
- Constant Field Values
-
KEY_ONLY_MATCH
private static final int KEY_ONLY_MATCH
- See Also:
- Constant Field Values
-
KEY_NOT_FOUND
private static final int KEY_NOT_FOUND
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XCASDocSerializer
private XCASDocSerializer(org.xml.sax.ContentHandler ch, CASImpl cas)
-
-
Method Detail
-
enqueue
private boolean enqueue(TOP fs)
Add an address to the queue.- Parameters:
fs_id- The address.- Returns:
falseiff we've seen this address before.
-
enqueueIndexed
private void enqueueIndexed(TOP fs, int indexRep)
Same as enqueue, but for indexed FSs.- Parameters:
fs_id- The address to enqueue.
-
isQueued
private int isQueued(TOP fs, int value)
Bad name; check if we've seen this (address, value) before.- Parameters:
fs- The Feature Structure.value- The index repository- Returns:
- KEY_AND_VALUE_MATCH iff we've seen (address, value) before. KEY_NOT_FOUND iff the address has not been seen before. KEY_ONLY_MATCH iff the address has been seen before with a different value.
-
serialize
private void serialize(boolean encodeDoc, OutOfTypeSystemData outOfTypeSystemData) throws java.io.IOException, org.xml.sax.SAXException- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
addText
private void addText(java.lang.String text) throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException
-
replaceInvalidXmlChars
private java.lang.String replaceInvalidXmlChars(java.lang.String aString)
-
isValidXmlChar
private boolean isValidXmlChar(char c)
-
addAttribute
private void addAttribute(org.xml.sax.helpers.AttributesImpl attrs, java.lang.String attrName, java.lang.String attrValue)
-
startElement
private void startElement(java.lang.String tag, org.xml.sax.Attributes attrs, int num) throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException
-
endElement
private void endElement(java.lang.String tag) throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException
-
encodeIndexed
private void encodeIndexed() throws java.io.IOException, org.xml.sax.SAXException- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
enqueueIndexed
private void enqueueIndexed()
Push the indexed FSs onto the queue.
-
enqueueArray
private void enqueueArray(TOP[] fss, int sofaNum)
-
enqueueCollection
private void enqueueCollection(java.util.Collection<TOP> fss, int sofaNum)
-
enqueueFeaturesOfIndexed
private void enqueueFeaturesOfIndexed()
-
encodeQueued
private void encodeQueued() throws java.io.IOException, org.xml.sax.SAXException- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
encodeFS
private void encodeFS(TOP fs, IntVector indexRep) throws java.io.IOException, org.xml.sax.SAXException
Encode an individual FS.- Parameters:
fs_id- The address to be encoded.isIndexed- If the FS is indexed or not.- Throws:
java.io.IOException- passthruorg.xml.sax.SAXException- passthru
-
encodePrimitiveTypeArrayFS
private void encodePrimitiveTypeArrayFS(java.lang.String[] data, java.lang.String typeName, org.xml.sax.helpers.AttributesImpl attrs) throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException
-
encodeFSArray
private void encodeFSArray(FSArray fs, org.xml.sax.helpers.AttributesImpl attrs) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
enqueueFSArray
private void enqueueFSArray(FSArray fs)
-
encodeFeatures
private void encodeFeatures(TOP fs, org.xml.sax.helpers.AttributesImpl attrs)
-
enqueueFeatures
private void enqueueFeatures(TOP fs, int heapValue)
-
encodeOutOfTypeSystemFeatures
private void encodeOutOfTypeSystemFeatures(TOP fs, org.xml.sax.helpers.AttributesImpl attrs)
-
enqueueOutOfTypeSystemFeatures
private void enqueueOutOfTypeSystemFeatures(TOP fs)
-
getTypeName
private final java.lang.String getTypeName(TOP fs)
-
classifyType
private final int classifyType(TypeImpl ti)
classify the type, without distinguishng list types- Parameters:
ti- the type- Returns:
- the classification
-
enqueueOutOfTypeSystemData
private void enqueueOutOfTypeSystemData(OutOfTypeSystemData aData)
-
serializeOutOfTypeSystemData
private void serializeOutOfTypeSystemData(OutOfTypeSystemData aData) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
-