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.Object
Use 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 CASImpl
cas
private static java.lang.String
cdataType
private org.xml.sax.ContentHandler
ch
private 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(package private) java.util.List<IntVector>
dupVectors
list of IntVectors holding lists of repo numbers.private org.xml.sax.helpers.AttributesImpl
emptyAttrs
private int
fsCount
private java.util.List<TOP>
indexedFSs
list of FSs that are in an index somewhere.private IntVector
indexReps
Specific IndexRepository for indexed FSsprivate static int
INVALID_INDEX
private static int
KEY_AND_VALUE_MATCH
private static int
KEY_NOT_FOUND
private static int
KEY_ONLY_MATCH
private OutOfTypeSystemData
mOutOfTypeSystemData
private static int
MULTIPLY_INDEXED
private static int
NOT_INDEXED
(package private) int
numDuplicates
A key identifying a particular FS indexed in multiple indexes.private java.util.Deque<TOP>
queue
The current queue for FSs to write out.private java.util.Map<TOP,java.lang.Integer>
queued
Any FS reference we've touched goes in here.private org.xml.sax.helpers.AttributesImpl
workAttrs
-
Constructor Summary
Constructors Modifier Constructor Description private
XCASDocSerializer(org.xml.sax.ContentHandler ch, CASImpl cas)
-
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
addText(java.lang.String text)
private int
classifyType(TypeImpl ti)
classify the type, without distinguishng list typesprivate void
encodeFeatures(TOP fs, org.xml.sax.helpers.AttributesImpl attrs)
private void
encodeFS(TOP fs, IntVector indexRep)
Encode an individual FS.private void
encodeFSArray(FSArray fs, org.xml.sax.helpers.AttributesImpl attrs)
private void
encodeIndexed()
private void
encodeOutOfTypeSystemFeatures(TOP fs, org.xml.sax.helpers.AttributesImpl attrs)
private void
encodePrimitiveTypeArrayFS(java.lang.String[] data, java.lang.String typeName, org.xml.sax.helpers.AttributesImpl attrs)
private void
encodeQueued()
private void
endElement(java.lang.String tag)
private boolean
enqueue(TOP fs)
Add an address to the queue.private void
enqueueArray(TOP[] fss, int sofaNum)
private void
enqueueCollection(java.util.Collection<TOP> fss, int sofaNum)
private void
enqueueFeatures(TOP fs, int heapValue)
private void
enqueueFeaturesOfIndexed()
private void
enqueueFSArray(FSArray fs)
private void
enqueueIndexed()
Push the indexed FSs onto the queue.private void
enqueueIndexed(TOP fs, int indexRep)
Same as enqueue, but for indexed FSs.private void
enqueueOutOfTypeSystemData(OutOfTypeSystemData aData)
private void
enqueueOutOfTypeSystemFeatures(TOP fs)
private java.lang.String
getTypeName(TOP fs)
private int
isQueued(TOP fs, int value)
Bad name; check if we've seen this (address, value) before.private boolean
isValidXmlChar(char c)
private java.lang.String
replaceInvalidXmlChars(java.lang.String aString)
private void
serialize(boolean encodeDoc, OutOfTypeSystemData outOfTypeSystemData)
private void
serializeOutOfTypeSystemData(OutOfTypeSystemData aData)
private void
startElement(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:
false
iff 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.IOException
org.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.IOException
org.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.IOException
org.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
-
-