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 intARRAY_ELE_CONTENT_STATEprivate static intARRAY_ELE_STATEprivate intarrayPosprivate java.lang.StringBufferbufferprivate CASImplcasprivate static intCONTENT_STATEprivate java.lang.StringcurrentContentFeatprivate TOPcurrentFsprivate FSDatacurrentOotsFsprivate static java.lang.StringDEFAULT_CONTENT_FEATUREprivate static intDOC_STATEprivate static intDOC_TEXT_STATEprivate static intFEAT_CONTENT_STATEprivate static intFEAT_STATEprivate java.util.List<java.lang.Runnable>fixupToDosprivate static intFS_STATEprivate intfsIdthe fsId read from the _id attributeprivate RedBlackTree<XCASDeserializer.FSInfo>fsTreeMap from extId to FSInfo (including fs)private TOPhighestIdFsprivate java.util.List<XCASDeserializer.FSInfo>idLessprivate IntVectorindexMapMap external SofaNum -> internal sofaNum internal sofaNums also used to index indexRepositories -> ref to FsIndexRepositoryImplprivate java.util.List<FSIndexRepository>indexRepositoriesmap from index -> indexRepository, [0] = base view, [1] initial view, [2 +] other viewsprivate org.xml.sax.Locatorlocatorprivate intnextIndexprivate static intOOTS_CONTENT_STATEprivate static intOOTS_FEAT_STATEprivate OutOfTypeSystemDataoutOfTypeSystemDataprivate static java.lang.StringreservedAttrPrefixprivate IntVectorsofaRefMapprivate static intsofaTypeCodeprivate intstateprivate java.util.List<java.lang.Runnable>uimaSerializableFixupsprivate static java.lang.StringunknownXMLSourceprivate java.util.List<CAS>viewsmap for index -> cas views,
-
Constructor Summary
Constructors Modifier Constructor Description privateXCASDeserializerHandler(CASImpl aCAS, OutOfTypeSystemData ootsData)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddArrayElement(java.lang.String content)private voidaddToOutOfTypeSystemData(java.lang.String typeName, org.xml.sax.Attributes attrs)voidcharacters(char[] chars, int start, int length)private XCASParsingExceptioncreateException(int code)private XCASParsingExceptioncreateException(int code, java.lang.String arg)private booleanemptyVal(java.lang.String val)voidendDocument()voidendElement(java.lang.String nsURI, java.lang.String localName, java.lang.String qualifiedName)voiderror(org.xml.sax.SAXParseException e)voidfatalError(org.xml.sax.SAXParseException e)private voidfinalizeAddToIndexes(XCASDeserializer.FSInfo fsInfo)private voidfinalizeArrayRefValue(int extId, int pos, FSArray fs)Same as above, but specialized for array values, not feature slot valuesprivate voidfinalizeFS(XCASDeserializer.FSInfo fsInfo)private voidfinalizeOutOfTypeSystemFeatures()private voidfinalizeOutOfTypeSystemFS(FSData aFS)private voidfinalizeRefValue(int extId, TOP fs, FeatureImpl fi)Common code run at finalize time, to set ref values and handle out-of-typesystem dataprivate java.lang.StringgetCasTypeName(java.lang.String aTagName)Gets the CAS type name corresponding to an XCAS tag name.private java.lang.StringgetRealFeatName(java.lang.String featName)private voidhandleFeature(Type type, TOP fs, java.lang.String featName, java.lang.String featValIn, boolean lenient)private voidhandleFeature(TOP fs, java.lang.String featName, java.lang.String featVal, boolean lenient)voidignorableWhitespace(char[] arg0, int arg1, int arg2)(package private) booleanisAllWhitespace(java.lang.StringBuffer b)(package private) TOPmaybeCreateWithV2Id(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 voidreadArray(TypeImpl type, org.xml.sax.Attributes attrs)private voidreadArrayElement(java.lang.String eleName, org.xml.sax.Attributes attrs)private voidreadDocument(org.xml.sax.Attributes attrs)private voidreadFS(java.lang.String qualifiedName, org.xml.sax.Attributes attrs)private voidreadFS(TypeImpl type, org.xml.sax.Attributes attrs, boolean toIndex)private voidresetBuffer()voidsetDocumentLocator(org.xml.sax.Locator loc)voidstartDocument()voidstartElement(java.lang.String nameSpaceURI, java.lang.String localName, java.lang.String qualifiedName, org.xml.sax.Attributes attrs)voidwarning(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:
startDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
startDocumentin 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:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin 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:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin 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:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin 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:
endDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
endDocumentin 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:
errorin interfaceorg.xml.sax.ErrorHandler- Overrides:
errorin 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:
fatalErrorin interfaceorg.xml.sax.ErrorHandler- Overrides:
fatalErrorin 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:
ignorableWhitespacein interfaceorg.xml.sax.ContentHandler- Overrides:
ignorableWhitespacein classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator loc)
- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler- Overrides:
setDocumentLocatorin classorg.xml.sax.helpers.DefaultHandler
-
warning
public void warning(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException- Specified by:
warningin interfaceorg.xml.sax.ErrorHandler- Overrides:
warningin 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
-
-