Package org.apache.uima.cas.impl
Class XmiCasDeserializer.XmiCasDeserializerHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.uima.cas.impl.XmiCasDeserializer.XmiCasDeserializerHandler
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
- Enclosing class:
- XmiCasDeserializer
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) AllowPreexistingFS
private StringBuffer
private CASImpl
private int
private int
private TypeImpl
private IntVector
(package private) boolean
private static final int
private static final int
private static final int
(package private) IntVector
private int[]
private static final int
private IntVector
private String
private int
private static final int
private List<FSIndexRepository>
(package private) boolean
private ListUtils
private IntRedBlackTree
local map from xmi:id to FS address, used when merging multiple XMI CASes into one CAS object.private Locator
private int
private int
private static final int
private XmiSerializationSharedData
private int
private int
private int
private int
private final DeferredIndexUpdates
a list by view of FSs to be added to the indexesprivate final DeferredIndexUpdates
a list by view of FSs to be removed from the indexesprivate static final String
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
XmiCasDeserializerHandler
(CASImpl aCAS, boolean lenient, XmiSerializationSharedData sharedData, int mergePoint, AllowPreexistingFS allowPreexistingFS) Creates a SAX handler used for deserializing an XMI CAS. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addFsAddrXmiIdMapping
(int fsAddr, int xmiId) private void
addNonsharedFSToEncompassingFSMapping
(int nonsharedFS, int encompassingFS) private void
addOutOfTypeSystemFeature
(XmiSerializationSharedData.OotsElementData ootsElem, String featName, List<String> featVals) private void
addToOutOfTypeSystemData
(XmlElementName xmlElementName, Attributes attrs) void
characters
(char[] chars, int start, int length) private final int
classifyType
(int type) Classifies a type.private int
createArray
(int arrayType, List<String> values, int xmiId, int addr) Create or update an array in the CASprivate int
createByteArray
(String hexString, int xmiId, int addr) Create a byte array in the CAS.private XCASParsingException
createException
(int code) private XCASParsingException
createException
(int code, String arg) private int
createNewArray
(int arrayType, List<String> values) Create an array in the CAS.private final boolean
void
void
endElement
(String nsURI, String localName, String qualifiedName) void
void
private void
finalizeArray
(int type, int addr) Walk an array, remapping IDs.private void
finalizeFS
(int addr) private int
getFsAddrForXmiId
(int xmiId) private FSIndexRepositoryImpl
getIndexRepo
(String sofa, int sofaXmiId) private void
handleFeature
(int addr, int featCode, String featVal) private void
handleFeature
(int addr, int featCode, List<String> featVals) private int
handleFeature
(Type type, int fsAddr, String featName, String featVal, boolean isNewFS) Deserialize one featureprivate int
handleFeature
(Type type, int addr, String featName, List<String> featVals) private byte
hexCharToByte
(char c) void
ignorableWhitespace
(char[] arg0, int arg1, int arg2) (package private) boolean
private boolean
isNewFS
(int id) private String[]
parseArray
(String val) Parse an XMI multi-valued attribute into a String array, by splitting on whitespace.private void
processView
(String sofa, String membersString) Handles the processing of a cas:View element in the XMI.private void
processView
(String sofa, String addmembersString, String delmemberString, String reindexmemberString) Handles the processing of a cas:View element in the XMI.private void
readFS
(int fsAddr, Attributes attrs, boolean isNewFs) private void
readFS
(String nameSpaceURI, String localName, String qualifiedName, Attributes attrs) Read one FS, create a new FS or update an existing oneprivate void
remapFSListHeads
(int addr) private final void
void
void
void
startElement
(String nameSpaceURI, String localName, String qualifiedName, Attributes attrs) private void
updateExistingArray
(int arrayType, List<String> values, int casArray) 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:
-
FEAT_CONTENT_STATE
private static final int FEAT_CONTENT_STATE- See Also:
-
IGNORING_XMI_ELEMENTS_STATE
private static final int IGNORING_XMI_ELEMENTS_STATE- See Also:
-
REF_FEAT_STATE
private static final int REF_FEAT_STATE- See Also:
-
unknownXMLSource
- See Also:
-
ID_ATTR_NAME
-
locator
-
casBeingFilled
-
deserializedFsAddrs
-
fsListNodesFromMultivaluedProperties
-
state
private int state -
buffer
-
currentAddr
private int currentAddr -
currentType
-
currentArrayId
private int currentArrayId -
currentArrayElements
-
multiValuedFeatures
-
sofaTypeCode
private int sofaTypeCode -
sofaNumFeatCode
private int sofaNumFeatCode -
sofaFeatCode
private int sofaFeatCode -
indexRepositories
-
views
-
listUtils
-
featureType
private int[] featureType -
lenient
boolean lenient -
ignoreDepth
private int ignoreDepth -
nsPrefixToUriMap
-
nextSofaNum
private int nextSofaNum -
mergePoint
private int mergePoint -
outOfTypeSystemElement
-
localXmiIdToFsAddrMap
local map from xmi:id to FS address, used when merging multiple XMI CASes into one CAS object. -
allowPreexistingFS
AllowPreexistingFS allowPreexistingFS -
featsSeen
IntVector featsSeen -
disallowedViewMemberEncountered
boolean disallowedViewMemberEncountered -
toBeAdded
a list by view of FSs to be added to the indexes -
toBeRemoved
a list by view of FSs to be removed from the indexes
-
-
Constructor Details
-
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
-
readFS
private void readFS(String nameSpaceURI, String localName, String qualifiedName, Attributes attrs) throws SAXException Read one FS, create a new FS or update an existing one- Parameters:
nameSpaceURI
- -localName
- -qualifiedName
- -attrs
- -- Throws:
SAXException
- -
-
processView
Handles the processing of a cas:View element in the XMI. The cas:View element encodes indexed FSs.- Parameters:
sofa
- xmi:id of the sofa for this view, null indicates base CAS "view"membersString
- whitespace-separated string of FS addresses. Each FS is to be added to the specified sofa's index repository The adding takes place after FSs are finalized, to enable checking the sofa refs are OK https://issues.apache.org/jira/browse/UIMA-4099- Throws:
SAXParseException
-
getIndexRepo
- Parameters:
sofaNum
- 1 if sofa null, or the sofa Xmi Id- Returns:
- the FS Repository associated with the sofa xmiId
- Throws:
XCASParsingException
-
processView
private void processView(String sofa, String addmembersString, String delmemberString, String reindexmemberString) throws SAXParseException Handles the processing of a cas:View element in the XMI. The cas:View element encodes indexed FSs.- Parameters:
sofa
- xmi:id of the sofa for this view, null indicates base CAS "view"membersString
- whitespace-separated string of FS addresses. Each FS is to be added to the specified sofa's index repository- Throws:
SAXParseException
-
readFS
- Throws:
SAXException
-
emptyVal
-
handleFeature
private int handleFeature(Type type, int fsAddr, String featName, String featVal, boolean isNewFS) throws SAXException Deserialize one feature- Parameters:
type
- -fsAddr
- the address of the FSfeatName
- the feature namefeatVal
- the value of the featureisNewFS
- true if this is a new FS- Returns:
- feature code or -1 if no feature in this type system
- Throws:
SAXException
- if Type doesn't have the feature, and we're not in lenient mode
-
handleFeature
private int handleFeature(Type type, int addr, String featName, List<String> featVals) throws SAXException - Throws:
SAXException
-
handleFeature
- Throws:
SAXException
-
parseArray
Parse an XMI multi-valued attribute into a String array, by splitting on whitespace.- Parameters:
val
- XMI attribute value- Returns:
- an array with each array value as an element
-
handleFeature
- Throws:
SAXException
-
createArray
Create or update an array in the CAS- Parameters:
arrayType
- CAS type code for the arrayvalues
- List of strings, each representing an element in the arrayxmiId
- xmi:id assigned to the array object.addr
- address of preexisting non-shared array- Returns:
-
createNewArray
Create an array in the CAS.- Parameters:
arrayType
- CAS type code for the arrayvalues
- List of strings, each containing the value of an element of the array.- Returns:
- a reference to the array FS
-
updateExistingArray
-
createByteArray
Create a byte array in the CAS.- Parameters:
hexString
- value of the byte array as a hex stringxmiId
- xmiId - this will be -1 if this is a non-shared byte array FS.addr
- the current address of the non-shared ByteArrayFS used when processing a Delta CAS.- Returns:
- a reference to the Feature Structure in the CAS
-
hexCharToByte
private byte hexCharToByte(char c) -
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
-
endDocument
- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classDefaultHandler
- Throws:
SAXException
-
finalizeFS
- Throws:
SAXParseException
-
remapFSListHeads
- Throws:
SAXParseException
-
finalizeArray
Walk an array, remapping IDs. If called on a primitive array,this method does nothing.- Parameters:
type
- CAS type code for the arrayaddr
- address of the array- Throws:
SAXParseException
-
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
-
classifyType
private final int classifyType(int type) Classifies a type. This returns an integer code identifying the type as one of the primitive types, one of the array types, one of the list types, or a generic FS type (anything else).The
LowLevelCAS.ll_getTypeClass(int)
method classifies primitives and array types, but does not have a special classification for list types, which we need for XMI serialization. Therefore, in addition to the type codes defined onLowLevelCAS
, this method can return one of the type codes TYPE_CLASS_INTLIST, TYPE_CLASS_FLOATLIST, TYPE_CLASS_STRINGLIST, or TYPE_CLASS_FSLIST defined onXmiCasSerializer
interface.- Parameters:
type
- the type to classify- Returns:
- one of the TYPE_CLASS codes defined on
LowLevelCAS
or on theXmiCasSerializer
interface.
-
addFsAddrXmiIdMapping
private void addFsAddrXmiIdMapping(int fsAddr, int xmiId) -
getFsAddrForXmiId
private int getFsAddrForXmiId(int xmiId) -
addToOutOfTypeSystemData
private void addToOutOfTypeSystemData(XmlElementName xmlElementName, Attributes attrs) throws XCASParsingException - Throws:
XCASParsingException
-
isNewFS
private boolean isNewFS(int id)
-