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:
org.xml.sax.ContentHandler
,org.xml.sax.DTDHandler
,org.xml.sax.EntityResolver
,org.xml.sax.ErrorHandler
- Enclosing class:
- XCASDeserializer
private class XCASDeserializer.XCASDeserializerHandler extends org.xml.sax.helpers.DefaultHandler
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ARRAY_ELE_CONTENT_STATE
private static int
ARRAY_ELE_STATE
private int
arrayPos
private java.lang.StringBuffer
buffer
private CASImpl
cas
private static int
CONTENT_STATE
private java.lang.String
currentContentFeat
private TOP
currentFs
private FSData
currentOotsFs
private static java.lang.String
DEFAULT_CONTENT_FEATURE
private static int
DOC_STATE
private static int
DOC_TEXT_STATE
private static int
FEAT_CONTENT_STATE
private static int
FEAT_STATE
private java.util.List<java.lang.Runnable>
fixupToDos
private static int
FS_STATE
private int
fsId
the fsId read from the _id attributeprivate RedBlackTree<XCASDeserializer.FSInfo>
fsTree
Map from extId to FSInfo (including fs)private TOP
highestIdFs
private java.util.List<XCASDeserializer.FSInfo>
idLess
private IntVector
indexMap
Map external SofaNum -> internal sofaNum internal sofaNums also used to index indexRepositories -> ref to FsIndexRepositoryImplprivate java.util.List<FSIndexRepository>
indexRepositories
map from index -> indexRepository, [0] = base view, [1] initial view, [2 +] other viewsprivate org.xml.sax.Locator
locator
private int
nextIndex
private static int
OOTS_CONTENT_STATE
private static int
OOTS_FEAT_STATE
private OutOfTypeSystemData
outOfTypeSystemData
private static java.lang.String
reservedAttrPrefix
private IntVector
sofaRefMap
private static int
sofaTypeCode
private int
state
private java.util.List<java.lang.Runnable>
uimaSerializableFixups
private static java.lang.String
unknownXMLSource
private java.util.List<CAS>
views
map for index -> cas views,
-
Constructor Summary
Constructors Modifier Constructor Description private
XCASDeserializerHandler(CASImpl aCAS, OutOfTypeSystemData ootsData)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addArrayElement(java.lang.String content)
private void
addToOutOfTypeSystemData(java.lang.String typeName, org.xml.sax.Attributes attrs)
void
characters(char[] chars, int start, int length)
private XCASParsingException
createException(int code)
private XCASParsingException
createException(int code, java.lang.String arg)
private boolean
emptyVal(java.lang.String val)
void
endDocument()
void
endElement(java.lang.String nsURI, java.lang.String localName, java.lang.String qualifiedName)
void
error(org.xml.sax.SAXParseException e)
void
fatalError(org.xml.sax.SAXParseException e)
private void
finalizeAddToIndexes(XCASDeserializer.FSInfo fsInfo)
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
finalizeOutOfTypeSystemFeatures()
private void
finalizeOutOfTypeSystemFS(FSData aFS)
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 java.lang.String
getCasTypeName(java.lang.String aTagName)
Gets the CAS type name corresponding to an XCAS tag name.private java.lang.String
getRealFeatName(java.lang.String featName)
private void
handleFeature(Type type, TOP fs, java.lang.String featName, java.lang.String featValIn, boolean lenient)
private void
handleFeature(TOP fs, java.lang.String featName, java.lang.String featVal, boolean lenient)
void
ignorableWhitespace(char[] arg0, int arg1, int arg2)
(package private) boolean
isAllWhitespace(java.lang.StringBuffer b)
(package private) TOP
maybeCreateWithV2Id(int id, java.util.function.Supplier<TOP> create)
private java.lang.String[]
parseArray(java.lang.String val)
Parse a multi-valued attribute into a String array, by splitting on whitespace.private void
readArray(TypeImpl type, org.xml.sax.Attributes attrs)
private void
readArrayElement(java.lang.String eleName, org.xml.sax.Attributes attrs)
private void
readDocument(org.xml.sax.Attributes attrs)
private void
readFS(java.lang.String qualifiedName, org.xml.sax.Attributes attrs)
private void
readFS(TypeImpl type, org.xml.sax.Attributes attrs, boolean toIndex)
private void
resetBuffer()
void
setDocumentLocator(org.xml.sax.Locator loc)
void
startDocument()
void
startElement(java.lang.String nameSpaceURI, java.lang.String localName, java.lang.String qualifiedName, org.xml.sax.Attributes attrs)
void
warning(org.xml.sax.SAXParseException e)
-
-
-
Field Detail
-
DOC_STATE
private static final int DOC_STATE
- See Also:
- Constant Field Values
-
FS_STATE
private static final int FS_STATE
- See Also:
- Constant Field Values
-
FEAT_STATE
private static final int FEAT_STATE
- See Also:
- Constant Field Values
-
CONTENT_STATE
private static final int CONTENT_STATE
- See Also:
- Constant Field Values
-
FEAT_CONTENT_STATE
private static final int FEAT_CONTENT_STATE
- See Also:
- Constant Field Values
-
ARRAY_ELE_CONTENT_STATE
private static final int ARRAY_ELE_CONTENT_STATE
- See Also:
- Constant Field Values
-
ARRAY_ELE_STATE
private static final int ARRAY_ELE_STATE
- See Also:
- Constant Field Values
-
DOC_TEXT_STATE
private static final int DOC_TEXT_STATE
- See Also:
- Constant Field Values
-
OOTS_FEAT_STATE
private static final int OOTS_FEAT_STATE
- See Also:
- Constant Field Values
-
OOTS_CONTENT_STATE
private static final int OOTS_CONTENT_STATE
- See Also:
- Constant Field Values
-
DEFAULT_CONTENT_FEATURE
private static final java.lang.String DEFAULT_CONTENT_FEATURE
- See Also:
- Constant Field Values
-
reservedAttrPrefix
private static final java.lang.String reservedAttrPrefix
- See Also:
- Constant Field Values
-
unknownXMLSource
private static final java.lang.String unknownXMLSource
- See Also:
- Constant Field Values
-
sofaTypeCode
private static final int sofaTypeCode
- See Also:
- Constant Field Values
-
locator
private org.xml.sax.Locator locator
-
cas
private final CASImpl cas
-
fsTree
private final RedBlackTree<XCASDeserializer.FSInfo> fsTree
Map from extId to FSInfo (including fs)
-
idLess
private final java.util.List<XCASDeserializer.FSInfo> idLess
-
fixupToDos
private final java.util.List<java.lang.Runnable> fixupToDos
-
uimaSerializableFixups
private final java.util.List<java.lang.Runnable> uimaSerializableFixups
-
state
private int state
-
buffer
private java.lang.StringBuffer buffer
-
currentFs
private TOP currentFs
-
currentContentFeat
private java.lang.String currentContentFeat
-
arrayPos
private int arrayPos
-
outOfTypeSystemData
private OutOfTypeSystemData outOfTypeSystemData
-
currentOotsFs
private FSData currentOotsFs
-
indexRepositories
private final java.util.List<FSIndexRepository> indexRepositories
map from index -> indexRepository, [0] = base view, [1] initial view, [2 +] other views
-
views
private final java.util.List<CAS> views
map for index -> cas views,
-
sofaRefMap
private final IntVector sofaRefMap
-
indexMap
private final IntVector indexMap
Map external SofaNum -> internal sofaNum internal sofaNums also used to index indexRepositories -> ref to FsIndexRepositoryImpl
-
nextIndex
private int nextIndex
-
highestIdFs
private TOP highestIdFs
-
fsId
private int fsId
the fsId read from the _id attribute
-
-
Constructor Detail
-
XCASDeserializerHandler
private XCASDeserializerHandler(CASImpl aCAS, OutOfTypeSystemData ootsData)
-
-
Method Detail
-
resetBuffer
private final void resetBuffer()
-
startDocument
public void startDocument() throws org.xml.sax.SAXException
- Specified by:
startDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startDocument
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
startElement
public void startElement(java.lang.String nameSpaceURI, java.lang.String localName, java.lang.String qualifiedName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startElement
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
readDocument
private void readDocument(org.xml.sax.Attributes attrs)
-
readArrayElement
private void readArrayElement(java.lang.String eleName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXParseException
- Throws:
org.xml.sax.SAXParseException
-
readFS
private void readFS(java.lang.String qualifiedName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXParseException
- Throws:
org.xml.sax.SAXParseException
-
readFS
private void readFS(TypeImpl type, org.xml.sax.Attributes attrs, boolean toIndex) throws org.xml.sax.SAXParseException
- Parameters:
addr
-attrs
-toIndex
- Special hack to accommodate document annotation, which is already in the index.- Throws:
org.xml.sax.SAXParseException
- passthru
-
readArray
private void readArray(TypeImpl type, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXParseException
- Throws:
org.xml.sax.SAXParseException
-
emptyVal
private final boolean emptyVal(java.lang.String val)
-
handleFeature
private void handleFeature(TOP fs, java.lang.String featName, java.lang.String featVal, boolean lenient) throws org.xml.sax.SAXParseException
- Throws:
org.xml.sax.SAXParseException
-
handleFeature
private void handleFeature(Type type, TOP fs, java.lang.String featName, java.lang.String featValIn, boolean lenient) throws org.xml.sax.SAXParseException
- Throws:
org.xml.sax.SAXParseException
-
getRealFeatName
private java.lang.String getRealFeatName(java.lang.String featName)
-
characters
public void characters(char[] chars, int start, int length) throws org.xml.sax.SAXException
- Specified by:
characters
in interfaceorg.xml.sax.ContentHandler
- Overrides:
characters
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
isAllWhitespace
boolean isAllWhitespace(java.lang.StringBuffer b)
-
endElement
public void endElement(java.lang.String nsURI, java.lang.String localName, java.lang.String qualifiedName) throws org.xml.sax.SAXException
- Specified by:
endElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endElement
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
addArrayElement
private void addArrayElement(java.lang.String content) throws org.xml.sax.SAXParseException
- Throws:
org.xml.sax.SAXParseException
-
endDocument
public void endDocument() throws org.xml.sax.SAXException
- Specified by:
endDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endDocument
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
finalizeFS
private void finalizeFS(XCASDeserializer.FSInfo fsInfo)
-
finalizeRefValue
private void finalizeRefValue(int extId, TOP fs, FeatureImpl fi)
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
private void finalizeArrayRefValue(int extId, int pos, FSArray fs)
Same as above, but specialized for array values, not feature slot values- Parameters:
extId
-extId
- the external ID identifying either a deserialized FS or an out-of-typesystem instancepos
- the index in the array
-
finalizeAddToIndexes
private void finalizeAddToIndexes(XCASDeserializer.FSInfo fsInfo)
-
finalizeOutOfTypeSystemFS
private void finalizeOutOfTypeSystemFS(FSData aFS)
-
finalizeOutOfTypeSystemFeatures
private void finalizeOutOfTypeSystemFeatures()
-
createException
private XCASParsingException createException(int code)
-
createException
private XCASParsingException createException(int code, java.lang.String arg)
-
error
public void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
- Specified by:
error
in interfaceorg.xml.sax.ErrorHandler
- Overrides:
error
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
fatalError
public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
- Specified by:
fatalError
in interfaceorg.xml.sax.ErrorHandler
- Overrides:
fatalError
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws org.xml.sax.SAXException
- Specified by:
ignorableWhitespace
in interfaceorg.xml.sax.ContentHandler
- Overrides:
ignorableWhitespace
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator loc)
- Specified by:
setDocumentLocator
in interfaceorg.xml.sax.ContentHandler
- Overrides:
setDocumentLocator
in classorg.xml.sax.helpers.DefaultHandler
-
warning
public void warning(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
- Specified by:
warning
in interfaceorg.xml.sax.ErrorHandler
- Overrides:
warning
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
addToOutOfTypeSystemData
private void addToOutOfTypeSystemData(java.lang.String typeName, org.xml.sax.Attributes attrs) throws XCASParsingException
- Throws:
XCASParsingException
-
parseArray
private java.lang.String[] parseArray(java.lang.String val)
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
private java.lang.String getCasTypeName(java.lang.String aTagName)
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
-
-