Package org.apache.uima.cas.impl
Class XCASDeserializer.XCASDeserializerHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.uima.cas.impl.XCASDeserializer.XCASDeserializerHandler
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
- Enclosing class:
XCASDeserializer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private int
private StringBuffer
private final CASImpl
private static final int
private String
private TOP
private FSData
private static final String
private static final int
private static final int
private static final int
private static final int
private static final int
private int
the fsId read from the _id attributeprivate final RedBlackTree
<XCASDeserializer.FSInfo> Map from extId to FSInfo (including fs)private TOP
private final List
<XCASDeserializer.FSInfo> private final IntVector
Map external SofaNum -> internal sofaNum internal sofaNums also used to index indexRepositories -> ref to FsIndexRepositoryImplprivate final List
<FSIndexRepository> map from index -> indexRepository, [0] = base view, [1] initial view, [2 +] other viewsprivate Locator
private int
private static final int
private static final int
private OutOfTypeSystemData
private static final String
private final IntVector
private static final int
private int
private static final String
map for index -> cas views, -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
XCASDeserializerHandler
(CASImpl aCAS, OutOfTypeSystemData ootsData) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addArrayElement
(String content) private void
addToOutOfTypeSystemData
(String typeName, Attributes attrs) void
characters
(char[] chars, int start, int length) private XCASParsingException
createException
(int code) private XCASParsingException
createException
(int code, String arg) private final boolean
void
void
endElement
(String nsURI, String localName, String qualifiedName) void
void
private void
private void
finalizeArrayRefValue
(int extId, int pos, FSArray fs) Same as above, but specialized for array values, not feature slot valuesprivate void
finalizeFS
(XCASDeserializer.FSInfo fsInfo) private void
private void
private void
finalizeRefValue
(int extId, TOP fs, FeatureImpl fi) Common code run at finalize time, to set ref values and handle out-of-typesystem dataprivate String
getCasTypeName
(String aTagName) Gets the CAS type name corresponding to an XCAS tag name.private String
getRealFeatName
(String featName) private void
handleFeature
(Type type, TOP fs, String featName, String featValIn, boolean lenient) private void
handleFeature
(TOP fs, String featName, String featVal, boolean lenient) void
ignorableWhitespace
(char[] arg0, int arg1, int arg2) (package private) boolean
(package private) TOP
maybeCreateWithV2Id
(int id, Supplier<TOP> create) private String[]
parseArray
(String val) Parse a multi-valued attribute into a String array, by splitting on whitespace.private void
readArray
(TypeImpl type, Attributes attrs) private void
readArrayElement
(String eleName, Attributes attrs) private void
readDocument
(Attributes attrs) private void
readFS
(String qualifiedName, Attributes attrs) private void
readFS
(TypeImpl type, Attributes attrs, boolean toIndex) private final void
void
void
void
startElement
(String nameSpaceURI, String localName, String qualifiedName, Attributes attrs) void
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
-
Field Details
-
DOC_STATE
private static final int DOC_STATE- See Also:
-
FS_STATE
private static final int FS_STATE- See Also:
-
FEAT_STATE
private static final int FEAT_STATE- See Also:
-
CONTENT_STATE
private static final int CONTENT_STATE- See Also:
-
FEAT_CONTENT_STATE
private static final int FEAT_CONTENT_STATE- See Also:
-
ARRAY_ELE_CONTENT_STATE
private static final int ARRAY_ELE_CONTENT_STATE- See Also:
-
ARRAY_ELE_STATE
private static final int ARRAY_ELE_STATE- See Also:
-
DOC_TEXT_STATE
private static final int DOC_TEXT_STATE- See Also:
-
OOTS_FEAT_STATE
private static final int OOTS_FEAT_STATE- See Also:
-
OOTS_CONTENT_STATE
private static final int OOTS_CONTENT_STATE- See Also:
-
DEFAULT_CONTENT_FEATURE
- See Also:
-
reservedAttrPrefix
- See Also:
-
unknownXMLSource
- See Also:
-
sofaTypeCode
private static final int sofaTypeCode- See Also:
-
locator
-
cas
-
fsTree
Map from extId to FSInfo (including fs) -
idLess
-
fixupToDos
-
uimaSerializableFixups
-
state
private int state -
buffer
-
currentFs
-
currentContentFeat
-
arrayPos
private int arrayPos -
outOfTypeSystemData
-
currentOotsFs
-
indexRepositories
map from index -> indexRepository, [0] = base view, [1] initial view, [2 +] other views -
views
map for index -> cas views, -
sofaRefMap
-
indexMap
Map external SofaNum -> internal sofaNum internal sofaNums also used to index indexRepositories -> ref to FsIndexRepositoryImpl -
nextIndex
private int nextIndex -
highestIdFs
-
fsId
private int fsIdthe fsId read from the _id attribute
-
-
Constructor Details
-
XCASDeserializerHandler
-
-
Method Details
-
resetBuffer
private final void resetBuffer() -
startDocument
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
- Throws:
SAXException
-
startElement
public void startElement(String nameSpaceURI, String localName, String qualifiedName, Attributes attrs) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
readDocument
-
readArrayElement
- Throws:
SAXParseException
-
readFS
- Throws:
SAXParseException
-
readFS
- Parameters:
attrs
-toIndex
- Special hack to accommodate document annotation, which is already in the index.addr
-- Throws:
SAXParseException
- passthru
-
readArray
- Throws:
SAXParseException
-
emptyVal
-
handleFeature
private void handleFeature(TOP fs, String featName, String featVal, boolean lenient) throws SAXParseException - Throws:
SAXParseException
-
handleFeature
private void handleFeature(Type type, TOP fs, String featName, String featValIn, boolean lenient) throws SAXParseException - Throws:
SAXParseException
-
getRealFeatName
-
characters
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
isAllWhitespace
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
addArrayElement
- Throws:
SAXParseException
-
endDocument
- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classDefaultHandler
- Throws:
SAXException
-
finalizeFS
-
finalizeRefValue
Common code run at finalize time, to set ref values and handle out-of-typesystem data- Parameters:
extId
- the external ID identifying either a deserialized FS or an out-of-typesystem instancefs
- Feature Structure whose fi reference feature is to be set with a value derived from extId and FSinfofi
- the featureImpl
-
finalizeArrayRefValue
Same as above, but specialized for array values, not feature slot values- Parameters:
extId
-pos
- the index in the arrayextId
- the external ID identifying either a deserialized FS or an out-of-typesystem instance
-
finalizeAddToIndexes
-
finalizeOutOfTypeSystemFS
-
finalizeOutOfTypeSystemFeatures
private void finalizeOutOfTypeSystemFeatures() -
createException
-
createException
-
error
- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
- Throws:
SAXException
-
fatalError
- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classDefaultHandler
- Throws:
SAXException
-
ignorableWhitespace
- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Overrides:
ignorableWhitespace
in classDefaultHandler
- Throws:
SAXException
-
setDocumentLocator
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
warning
- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
- Throws:
SAXException
-
addToOutOfTypeSystemData
private void addToOutOfTypeSystemData(String typeName, Attributes attrs) throws XCASParsingException - Throws:
XCASParsingException
-
parseArray
Parse a multi-valued attribute into a String array, by splitting on whitespace.- Parameters:
val
- attribute value- Returns:
- an array with each array value as an element
-
getCasTypeName
Gets the CAS type name corresponding to an XCAS tag name. The type name is usually equal to the tag name, but the characters : and - are translated into the sequences _colon_ and _dash_, respectively.- Parameters:
aTagName
- XCAS tag name- Returns:
- CAS type name corresponding to this tag
-
maybeCreateWithV2Id
-