Class CasTypeSystemMapper

java.lang.Object
org.apache.uima.cas.impl.CasTypeSystemMapper

public class CasTypeSystemMapper extends Object
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 Details

    • INT0

      private static final int[] INT0
    • BOOLEAN0

      private static final boolean[] BOOLEAN0
    • tsSrc

      public final TypeSystemImpl tsSrc
    • tsTgt

      public final WeakReference<TypeSystemImpl> tsTgt
    • tSrc2Tgt

      private final int[] tSrc2Tgt
      Map from source type codes to target type codes. Source type code used as index, value is target type code
    • fSrcInTgt

      private final boolean[][] fSrcInTgt
      First 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[][] fTgt2Src
      First 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[] tTgt2Src
      Same as tSrc2Tgt, but reversed used when deserializing a target back into a source
    • typeSystemsSame

      private final boolean typeSystemsSame
  • Constructor Details

  • 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

      private static int[] addTypes(TypeSystemImpl tsSrc, TypeSystemImpl tsTgt)
    • addFeatures

      private boolean addFeatures(TypeSystemImpl tsSrc, TypeSystemImpl tsTgt, boolean[][] localFSrcInTgt, int[][] localFTgt2Src, int[] temptSrc2Tgt) throws ResourceInitializationException
      Throws:
      ResourceInitializationException