Package org.apache.uima.cas.impl
Class CasTypeSystemMapper
java.lang.Object
org.apache.uima.cas.impl.CasTypeSystemMapper
This class gets initialized with two type systems, and then provides
resources to map type and feature codes between them.
It is used by some Binary serialization/ deserialization
code to allow non-exact matched type systems to send and
receive CASes in a binary-like format.
Use cases:
Serializing: Source ts -%gt; generate serialized form in Target ts
Deserializing: Target ts -%gt; generate deserialized form in Source ts
- either from remote or
- from disk-stored-form
Mapping details:
Types are mapped by name.
Same-named types do not need to have the same number of features.
Same-named features must have same Range - otherwise, not mapped.
Types with 0 features mapped allowed.
LifeCycle:
Instance of this are created for a CAS when needed, and then
kept in the (source) TypeSystemImpl, in a map indexed by
the target type system (identity map)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final boolean[]
private final boolean[][]
First index is src type code, 2nd index is src feature offset, 0 is 1st feature.private final int[][]
First index is src type code, 2nd index is tgt feature offset, 0 is 1st feature.private static final int[]
private final int[]
Map from source type codes to target type codes.final TypeSystemImpl
final WeakReference
<TypeSystemImpl> private final int[]
Same as tSrc2Tgt, but reversed used when deserializing a target back into a sourceprivate final boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
addFeatures
(TypeSystemImpl tsSrc, TypeSystemImpl tsTgt, boolean[][] localFSrcInTgt, int[][] localFTgt2Src, int[] temptSrc2Tgt) private static int[]
addTypes
(TypeSystemImpl tsSrc, TypeSystemImpl tsTgt) boolean[]
getFSrcInTgt
(int tCode) int[]
getTgtFeatOffsets2Src
(int tCode) boolean
isEqual()
int
mapTypeCode2Other
(int c, boolean src2tgt) int
mapTypeCodeSrc2Tgt
(int c) int
mapTypeCodeTgt2Src
(int c)
-
Field Details
-
INT0
private static final int[] INT0 -
BOOLEAN0
private static final boolean[] BOOLEAN0 -
tsSrc
-
tsTgt
-
tSrc2Tgt
private final int[] tSrc2TgtMap from source type codes to target type codes. Source type code used as index, value is target type code -
fSrcInTgt
private final boolean[][] fSrcInTgtFirst index is src type code, 2nd index is src feature offset, 0 is 1st feature. Value is true if target has source feature -
fTgt2Src
private final int[][] fTgt2SrcFirst index is src type code, 2nd index is tgt feature offset, 0 is 1st feature. Value is -1 if src doesn't have feature, else it is the feature offset in source. Only used for type codes that are not arrays. Use: When serializing a source type that exists in the target, have to output the slots in the target feature order Also, when comparing the slots in the target with a given source -
tTgt2Src
private final int[] tTgt2SrcSame as tSrc2Tgt, but reversed used when deserializing a target back into a source -
typeSystemsSame
private final boolean typeSystemsSame
-
-
Constructor Details
-
CasTypeSystemMapper
public CasTypeSystemMapper(TypeSystemImpl tsSrc, TypeSystemImpl tsTgt) throws ResourceInitializationException - Throws:
ResourceInitializationException
-
-
Method Details
-
isEqual
public boolean isEqual() -
mapTypeCodeSrc2Tgt
public int mapTypeCodeSrc2Tgt(int c) - Parameters:
c
- -- Returns:
- 0 if type doesn't have corresponding code in other type system
-
mapTypeCodeTgt2Src
public int mapTypeCodeTgt2Src(int c) - Parameters:
c
- -- Returns:
- 0 if type doesn't have corresponding code in other type system
-
mapTypeCode2Other
public int mapTypeCode2Other(int c, boolean src2tgt) - Parameters:
c
- -src2tgt
- -- Returns:
- 0 if type doesn't have corresponding code in other type system
-
getTgtFeatOffsets2Src
public int[] getTgtFeatOffsets2Src(int tCode) - Parameters:
tCode
- - source type code- Returns:
- int vec of 0-based feat offsets in src of feats in tgt, in the order of the target
-
getFSrcInTgt
public boolean[] getFSrcInTgt(int tCode) -
addTypes
-
addFeatures
private boolean addFeatures(TypeSystemImpl tsSrc, TypeSystemImpl tsTgt, boolean[][] localFSrcInTgt, int[][] localFTgt2Src, int[] temptSrc2Tgt) throws ResourceInitializationException - Throws:
ResourceInitializationException
-