Class FeatureStructureImplC

java.lang.Object
org.apache.uima.cas.impl.FeatureStructureImplC
All Implemented Interfaces:
Cloneable, FeatureStructure, FeatureStructureImpl
Direct Known Subclasses:
TOP

public class FeatureStructureImplC extends Object implements FeatureStructureImpl
Feature structure implementation (for non JCas and JCas) Each FS has - int data - used for boolean, byte, short, int, long, float, double data -- long and double use 2 int slots - may be null if all slots are in JCas cover objects as fields - ref data - used for references to other Java objects, such as -- strings -- other feature structures -- arbitrary Java Objects - may be null if all slots are in JCas cover objects as fields - an id: an incrementing integer, starting at 1, per CAS, of all FSs created for that CAS - a ref to the casView where this FS was created - a ref to the TypeImpl for this class -- can't be static - may be multiple type systems in use
  • Field Details

    • DISABLE_RUNTIME_FEATURE_VALIDATION

      public static final String DISABLE_RUNTIME_FEATURE_VALIDATION
      See Also:
    • IS_ENABLE_RUNTIME_FEATURE_VALIDATION

      public static final boolean IS_ENABLE_RUNTIME_FEATURE_VALIDATION
    • DISABLE_RUNTIME_FEATURE_VALUE_VALIDATION

      public static final String DISABLE_RUNTIME_FEATURE_VALUE_VALIDATION
      See Also:
    • IS_ENABLE_RUNTIME_FEATURE_VALUE_VALIDATION

      public static final boolean IS_ENABLE_RUNTIME_FEATURE_VALUE_VALIDATION
    • V2_PRETTY_PRINT

      public static final String V2_PRETTY_PRINT
      See Also:
    • IS_V2_PRETTY_PRINT

      public static final boolean IS_V2_PRETTY_PRINT
    • _id

      protected final int _id
    • _casView

      public final CASImpl _casView
      The view this Feature Structure was originally created in. Feature Structures may be indexed in multiple views, or in no views. Also used to access other metadata including the type system
  • Constructor Details

    • FeatureStructureImplC

      public FeatureStructureImplC()
    • FeatureStructureImplC

      protected FeatureStructureImplC(int id)
      For use in creating search keys
      Parameters:
      id - -
    • FeatureStructureImplC

      protected FeatureStructureImplC(TypeImpl type, CASImpl casView)
      For non-JCas use, Internal Use Only, called by cas.createFS via generators
    • FeatureStructureImplC

      protected FeatureStructureImplC(JCasImpl jcasImpl)
      For JCas use (done this way to allow "final") The TypeImpl is derived from the JCas cover class name
      Parameters:
      jcasImpl - - the view this is being created in
    • FeatureStructureImplC

      protected FeatureStructureImplC(JCasImpl jcasImpl, int aId)
      For temporary marker annotations. Does not assign an ID from the CAS ID generator and never retains the annotation. We also do not trace this annotation.
  • Method Details

    • addToIndexes

      public void addToIndexes()
      add the corresponding FeatureStructure to all Cas indexes in the view where this FS was created
    • addToIndexes

      public void addToIndexes(JCas jcas)
      add this FS to indexes in a specific view, perhaps different from the creation view
      Parameters:
      jcas - the JCas
    • addToIndexes

      public void addToIndexes(CAS cas)
    • removeFromIndexes

      public void removeFromIndexes()
      remove the corresponding FeatureStructure from all Cas indexes in the view where this FS was created
    • removeFromIndexes

      public void removeFromIndexes(CAS cas)
      remove this FS from indexes in a specific view, perhaps different from the view where this was created.
      Parameters:
      cas - the Cas
    • removeFromIndexes

      public void removeFromIndexes(JCas jcas)
      remove this FS from indexes in a specific view, perhaps different from the view where this was created.
      Parameters:
      jcas - the Cas
    • getLowLevelCas

      public LowLevelCAS getLowLevelCas()
    • getAddress

      public final int getAddress()
      NOTE: Possible name collision
      Specified by:
      getAddress in interface FeatureStructure
      Returns:
      the internal id of this fs - unique to this CAS, a positive int
    • _id

      public final int _id()
      Description copied from interface: FeatureStructure
      return the unique (to this CAS) id of this feature structure
      Specified by:
      _id in interface FeatureStructure
      Returns:
      the id
    • getType

      public Type getType()
      Returns the UIMA TypeImpl value
      Specified by:
      getType in interface FeatureStructure
      Returns:
      The type.
    • _getTypeCode

      public int _getTypeCode()
      starts with _
      Specified by:
      _getTypeCode in interface FeatureStructure
      Returns:
      the UIMA TypeImpl for this Feature Structure
    • _getView

      public CASImpl _getView()
    • setBooleanValue

      public void setBooleanValue(Feature feat, boolean v)
      Description copied from interface: FeatureStructure
      Set the boolean value of a feature.
      Specified by:
      setBooleanValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to set.
      v - The boolean value we're setting the feature to.
    • _setBooleanValueNfc

      public void _setBooleanValueNfc(int adjOffset, boolean v)
    • _setBooleanValueNcNj

      public final void _setBooleanValueNcNj(FeatureImpl fi, boolean v)
    • _setBooleanValueNcNj

      public final void _setBooleanValueNcNj(int adjOffset, boolean v)
    • setByteValue

      public void setByteValue(Feature feat, byte v)
      Description copied from interface: FeatureStructure
      Set the byte (8 bit) value of a feature.
      Specified by:
      setByteValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to set.
      v - The 8bit value we're setting the feature to.
    • _setByteValueNfc

      public void _setByteValueNfc(int adjOffset, byte v)
    • _setByteValueNcNj

      public void _setByteValueNcNj(FeatureImpl fi, byte v)
    • _setByteValueNcNj

      public void _setByteValueNcNj(int adjOffset, byte v)
    • setShortValue

      public void setShortValue(Feature feat, short v)
      Description copied from interface: FeatureStructure
      Set the short (16 bit) value of a feature.
      Specified by:
      setShortValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to set.
      v - The short (16bit) value we're setting the feature to.
    • _setShortValueNfc

      public void _setShortValueNfc(int adjOffset, short v)
    • _setShortValueNcNj

      public void _setShortValueNcNj(FeatureImpl fi, short v)
    • _setShortValueNcNj

      public void _setShortValueNcNj(int adjOffset, short v)
    • setIntValue

      public void setIntValue(Feature feat, int v)
      Description copied from interface: FeatureStructure
      Set the int value of a feature.
      Specified by:
      setIntValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to set.
      v - The int we're setting the feature to.
    • _setIntValueNfc

      public void _setIntValueNfc(int adjOffset, int v)
    • _setIntValueNcNj

      public void _setIntValueNcNj(FeatureImpl fi, int v)
    • _setIntValueNcNj

      public void _setIntValueNcNj(int adjOffset, int v)
    • setLongValue

      public void setLongValue(Feature feat, long v)
      Description copied from interface: FeatureStructure
      Set the long (64 bit) value of a feature.
      Specified by:
      setLongValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to set.
      v - The long (64bit) value we're setting the feature to.
    • _setLongValueNfc

      public void _setLongValueNfc(int adjOffset, long v)
    • _setLongValueNcNj

      public void _setLongValueNcNj(FeatureImpl fi, long v)
    • _setLongValueNcNj

      public void _setLongValueNcNj(int adjOffset, long v)
    • setFloatValue

      public void setFloatValue(Feature feat, float v)
      Description copied from interface: FeatureStructure
      Set the float value of a feature.
      Specified by:
      setFloatValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to set.
      v - The float we're setting the feature to.
    • _setFloatValueNfc

      protected void _setFloatValueNfc(int adjOffset, float v)
    • _setFloatValueNcNj

      public void _setFloatValueNcNj(FeatureImpl fi, float v)
    • _setFloatValueNcNj

      public void _setFloatValueNcNj(int adjOffset, float v)
    • setDoubleValue

      public void setDoubleValue(Feature feat, double v)
      Description copied from interface: FeatureStructure
      Set the double value of a feature.
      Specified by:
      setDoubleValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to set.
      v - The double value we're setting the feature to.
    • _setDoubleValueNfc

      protected void _setDoubleValueNfc(int adjOffset, double v)
    • _setDoubleValueNcNj

      public void _setDoubleValueNcNj(FeatureImpl fi, double v)
    • _setDoubleValueNcNj

      public void _setDoubleValueNcNj(int adjOffset, double v)
    • setStringValue

      public void setStringValue(Feature feat, String v)
      Description copied from interface: FeatureStructure
      Set the string value of a feature.
      Specified by:
      setStringValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to set.
      v - The string we're setting the feature to.
    • _setStringValueNfc

      public void _setStringValueNfc(int adjOffset, String v)
    • _setStringValueNcNj

      public void _setStringValueNcNj(FeatureImpl fi, String v)
    • _setStringValueNcWj

      public void _setStringValueNcWj(int adjOffset, String v)
      Skips substring range checking, but maybe does journalling
      Parameters:
      adjOffset - offset
      v - to set
    • setFeatureValue

      public void setFeatureValue(Feature feat, FeatureStructure v)
      Description copied from interface: FeatureStructure
      Set a feature value to another FS.
      Specified by:
      setFeatureValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value should be set.
      v - The value FS.
    • _setFeatureValueNcNj

      public void _setFeatureValueNcNj(FeatureImpl fi, Object v)
    • _setFeatureValueNcNj

      public void _setFeatureValueNcNj(int adjOffset, Object v)
    • _maybeGetBaseForPearFs

      protected <N extends TOP> N _maybeGetBaseForPearFs(N v)
      Called when setting a FS value which might be a trampoline
      Type Parameters:
      N - the type of the FS
      Parameters:
      v - the FS to check
      Returns:
      the FS or if it was a trampoline, the base FS
    • _maybeGetBaseForPearFs

      public <N extends TOP> N _maybeGetBaseForPearFs()
      Called to convert to the base FS from a Pear version
      Type Parameters:
      N - the type of the FS
      Returns:
      the FS or if it was a trampoline, the base FS
    • _maybeGetPearFs

      protected <N extends TOP> N _maybeGetPearFs(N v)
      Called when getting a FS value which might need to return a Pear context's trampoline
      Type Parameters:
      N - the type of the FS
      Parameters:
      v - the FS to check
      Returns:
      the FS or if we're in a Pear context, perhaps the trampoline (only some classes might have trampolines)
    • _maybeGetPearFs

      public <N extends TOP> N _maybeGetPearFs()
      Type Parameters:
      N - the type of the FS
      Returns:
      the FS or if we're in a Pear context and the PEAR defines a different version, the PEAR version.
    • _setFeatureValueNcWj

      public void _setFeatureValueNcWj(int adjOffset, FeatureStructure v)
      Nc - no check, Wj = with journaling if needed
      Parameters:
      adjOffset - -
      v - -
    • setFeatureValueFromString

      public void setFeatureValueFromString(Feature feat, String s) throws CASRuntimeException
      Description copied from interface: FeatureStructure
      Sets the value of a feature from a string input if the feature type is one of the primitive types.
      Specified by:
      setFeatureValueFromString in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to set.
      s - The string value that the feature will be set to.
      Throws:
      CASRuntimeException - If feat is not a primitive type or the value cannot be converted to this type.
    • _setIntValueCJ

      protected void _setIntValueCJ(FeatureImpl fi, int v)
      All 3 checks
      Parameters:
      fi - - the feature
      v - - the value
    • _setLongValueCJ

      protected void _setLongValueCJ(FeatureImpl fi, long v)
      All 3 checks for long
      Parameters:
      fi - - the feature
      v - - the value
    • _setIntValueNfcCJ

      protected void _setIntValueNfcCJ(int adjOffset, int v)
      2 checks, no feature check
      Parameters:
      adjOffset - - the feature offset
      v - - the value
    • _setLongValueNfcCJ

      protected void _setLongValueNfcCJ(FeatureImpl fi, long v)
      2 checks, no feature check
      Parameters:
      fi - - the feature
      v - - the value
    • _setRefValueCJ

      protected void _setRefValueCJ(FeatureImpl fi, Object v)
    • _setRefValueNfcCJ

      protected void _setRefValueNfcCJ(FeatureImpl fi, Object v)
      2 checks, no feature check
      Parameters:
      fi - - the feature
      v - - the value
    • getBooleanValue

      public boolean getBooleanValue(Feature feat)
      G E T T E R S (The array getters are part of the Classes for the built-in arrays, here are only the non-array ones) getXyzValue(Feature feat) - this is the standard from V2 plain API - it does validity checking (normally) that the feature belongs to the type getXyzValueNc(FeatureImpl feat) - skips the validity checking that the feature belongs to the type.
      Specified by:
      getBooleanValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to get.
      Returns:
      The value int; 0 if the value has not been set.
    • _getBooleanValueNc

      public boolean _getBooleanValueNc(FeatureImpl fi)
    • _getBooleanValueNc

      public boolean _getBooleanValueNc(int adjOffset)
    • getByteValue

      public byte getByteValue(Feature feat)
      Description copied from interface: FeatureStructure
      Get the byte value of a feature. This method will throw an exception if the feature is not byte valued.
      Specified by:
      getByteValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to set.
      Returns:
      The value byte; 0 if the value has not been set.
    • _getByteValueNc

      public byte _getByteValueNc(FeatureImpl feat)
    • _getByteValueNc

      public byte _getByteValueNc(int adjOffset)
    • getShortValue

      public short getShortValue(Feature feat)
      Description copied from interface: FeatureStructure
      Get the short value of a feature. This method will throw an exception if the feature is not short valued.
      Specified by:
      getShortValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to get.
      Returns:
      The value int; 0 if the value has not been set.
    • _getShortValueNc

      public short _getShortValueNc(FeatureImpl feat)
    • _getShortValueNc

      public short _getShortValueNc(int adjOffset)
    • getIntValue

      public int getIntValue(Feature feat)
      Description copied from interface: FeatureStructure
      Get the int value of a feature. This method will throw an exception if the feature is not int valued.
      Specified by:
      getIntValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to get.
      Returns:
      The value int; 0 if the value has not been set.
    • _getIntValueNc

      public int _getIntValueNc(FeatureImpl feat)
    • _getIntValueNc

      public int _getIntValueNc(int adjOffset)
    • getLongValue

      public long getLongValue(Feature feat)
      Description copied from interface: FeatureStructure
      Get the long value of a feature. This method will throw an exception if the feature is not long valued.
      Specified by:
      getLongValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to get.
      Returns:
      The value int; 0 if the value has not been set.
    • _getLongValueNc

      public long _getLongValueNc(FeatureImpl feat)
    • _getLongValueNc

      public long _getLongValueNc(int adjOffset)
    • getFloatValue

      public float getFloatValue(Feature feat)
      Description copied from interface: FeatureStructure
      Get the float value of a feature. This method will throw an exception if the feature is not float valued.
      Specified by:
      getFloatValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to get.
      Returns:
      The value float; 0.0 if the value has not been set.
    • _getFloatValueNc

      public float _getFloatValueNc(FeatureImpl fi)
    • _getFloatValueNc

      public float _getFloatValueNc(int adjOffset)
    • getDoubleValue

      public double getDoubleValue(Feature feat)
      Description copied from interface: FeatureStructure
      Get the double value of a feature. This method will throw an exception if the feature is not double valued.
      Specified by:
      getDoubleValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to get.
      Returns:
      The value int; 0 if the value has not been set.
    • _getDoubleValueNc

      public double _getDoubleValueNc(FeatureImpl fi)
    • _getDoubleValueNc

      public double _getDoubleValueNc(int adjOffset)
    • getStringValue

      public String getStringValue(Feature feat)
      Description copied from interface: FeatureStructure
      Get the string value under a feature.
      Specified by:
      getStringValue in interface FeatureStructure
      Parameters:
      feat - The feature for which we want the value.
      Returns:
      The value of this feature; may be null if the value has not been set.
    • _getStringValueNc

      public String _getStringValueNc(FeatureImpl feat)
    • _getStringValueNc

      public String _getStringValueNc(int adjOffset)
    • getFeatureValue

      public TOP getFeatureValue(Feature feat)
      Description copied from interface: FeatureStructure
      Get a feature value.
      Specified by:
      getFeatureValue in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to get.
      Returns:
      The value; may be null if the value has not been set.
    • _getFeatureValueNc

      public TOP _getFeatureValueNc(FeatureImpl feat)
    • _getFeatureValueNc

      public TOP _getFeatureValueNc(int adjOffset)
    • getCAS

      public CAS getCAS()
      Specified by:
      getCAS in interface FeatureStructure
      Returns:
      the CAS view where this FS was created
    • getCASImpl

      public CASImpl getCASImpl()
    • clone

      See http://www.javaworld.com/article/2076332/java-se/how-to-avoid-traps-and-correctly-override-methods-from-java-lang-object.html for suggestions on avoiding bugs in implementing clone Because we have final fields for _intData, _refData, and _id, we can't use clone. Instead, we use the createFS to create the FS of the right type. This will use the generators. Strategy for cloning: Goal is to create an independent instance of some subtype of this class, with all the fields properly copied from this instance. - some fields could be in the _intData and _refData - some fields could be stored as features Subcases to handle: - arrays - these have no features. Note: CasCopier doesn't call this because it needs to do a deep copy This is not used by the framework
      Specified by:
      clone in interface FeatureStructure
      Overrides:
      clone in class Object
      Returns:
      a new Feature Structure as a new instance of the same class, with a new _id field, with its features set to the values of the features in this Feature Structure
      Throws:
      CASRuntimeException - (different from Object.clone()) if an exception occurs
    • hashCode

      public int hashCode()
      Description copied from interface: FeatureStructure
      Will return a hash code that's consistent with equality, i.e., if two FSs are equal, they will also return the same hash code.
      Specified by:
      hashCode in interface FeatureStructure
      Overrides:
      hashCode in class Object
      Returns:
      The hash code.
    • equals

      public boolean equals(Object obj)
      Description copied from interface: FeatureStructure
      A feature structure is equal to another feature structure iff it is identical in the underlying representation.
      Specified by:
      equals in interface FeatureStructure
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(int indent)
      Specified by:
      toString in interface FeatureStructureImpl
    • prettyPrint

      public void prettyPrint(int indent, int incr, StringBuilder buf, boolean useShortNames)
      Specified by:
      prettyPrint in interface FeatureStructureImpl
    • prettyPrint

      public void prettyPrint(int indent, int incr, StringBuffer buf, boolean useShortNames)
      Specified by:
      prettyPrint in interface FeatureStructureImpl
    • prettyPrint

      @Deprecated public void prettyPrint(int indent, int incr, StringBuffer buf, boolean useShortNames, String s)
      Deprecated.
      use form with StringBuilder (not StringBuffer)
      Top level, does computation of self-ref Pretty prints this Feature Structure, no trailing nl Old form - uses string buffer.
      Specified by:
      prettyPrint in interface FeatureStructureImpl
      Parameters:
      indent - the indent amount
      incr - the amount the indent is increased for a level
      buf - where the resulting string is built
      useShortNames - true to use short name
      s - extra string to print
    • prettyPrint

      public void prettyPrint(int indent, int incr, StringBuilder buf, boolean useShortNames, String s)
      Top level, does computation of self-ref Pretty prints this Feature Structure, no trailing nl
      Specified by:
      prettyPrint in interface FeatureStructureImpl
      Parameters:
      indent - the indent amount
      incr - the amount the indent is increased for a level
      buf - where the resulting string is built
      useShortNames - true to use short name
      s - extra string to print
    • prettyPrint

      @Deprecated public void prettyPrint(int indent, int incr, StringBuffer buf, boolean useShortNames, String s, FeatureStructureImplC.PrintReferences printRefs)
      Deprecated.
      because uses StringBuffer, not builder, for version 2 compatibility only
      Internal Use Only, public only for backwards compatibility
      Parameters:
      indent - -
      incr - -
      buf - -
      useShortNames - -
      s - -
      printRefs - -
    • prettyPrint

      public void prettyPrint(int indent, int incr, StringBuilder buf, boolean useShortNames, String s, FeatureStructureImplC.PrintReferences printRefs)
    • prettyPrintShort

      public void prettyPrintShort(StringBuilder sb)
      Parameters:
      sb - -
    • addStringOrPrimitive

      public StringBuilder addStringOrPrimitive(StringBuilder sb, FeatureImpl fi)
    • getTypeIndexID

      public int getTypeIndexID()
    • _setIntLikeValue

      public void _setIntLikeValue(SlotKinds.SlotKind slotKind, FeatureImpl fi, int v)
      Internal Use only
      Parameters:
      slotKind - -
      fi - -
      v - -
    • _setIntLikeValueNcNj

      public void _setIntLikeValueNcNj(SlotKinds.SlotKind slotKind, FeatureImpl fi, int v)
      Internal Use only - no feature check, no journaling
      Parameters:
      slotKind - -
      fi - -
      v - -
    • _getIntLikeValue

      public int _getIntLikeValue(SlotKinds.SlotKind slotKind, FeatureImpl f)
      for compressed form 4 - for getting the prev value of int-like slots Uses unchecked forms for feature access
      Parameters:
      slotKind - -
      f - -
      Returns:
      -
    • getFeatureValueAsString

      public String getFeatureValueAsString(Feature feat)
      Description copied from interface: FeatureStructure
      Get the value of the feature as a string if the type of the feature is one of the primitive type.
      Specified by:
      getFeatureValueAsString in interface FeatureStructure
      Parameters:
      feat - The feature whose value we want to get and whose type is one of the primitive types.
      Returns:
      A string representation of the feature value.
    • _inSetSortedIndex

      protected boolean _inSetSortedIndex()
    • _setInSetSortedIndexed

      protected void _setInSetSortedIndexed()
    • _resetInSetSortedIndex

      protected void _resetInSetSortedIndex()
      All callers of this must insure fs is not indexed in **Any** View
    • _setJCasHashMapReserve

      protected void _setJCasHashMapReserve()
    • _isJCasHashMapReserve

      public boolean _isJCasHashMapReserve()
    • _setPearTrampoline

      protected void _setPearTrampoline()
    • _isPearTrampoline

      protected boolean _isPearTrampoline()
    • _getFeatFromAdjOffset

      protected FeatureImpl _getFeatFromAdjOffset(int adjOffset, boolean isInInt)
    • _getRefValueCommon

      public Object _getRefValueCommon(int adjOffset)
    • _setRefValueCommon

      public void _setRefValueCommon(int adjOffset, Object v)
    • _setRefValueCommonWj

      protected void _setRefValueCommonWj(FeatureImpl fi, Object v)
    • _copyIntAndRefArraysFrom

      public void _copyIntAndRefArraysFrom(FeatureStructureImplC src)
      Parameters:
      src - the FS to copy features from
    • _copyIntAndRefArraysEqTypesFrom

      public void _copyIntAndRefArraysEqTypesFrom(FeatureStructureImplC src)
      copy int and ref data for two instances, each having the exact same type
      Parameters:
      src - the FS to copy features from
    • _copyIntArrayEqTypesFrom

      public void _copyIntArrayEqTypesFrom(FeatureStructureImplC src)
      Parameters:
      src - the FS to copy features from
    • toShortString

      public String toShortString()
    • _getTypeImpl

      public final TypeImpl _getTypeImpl()
    • _setTypeImpl

      protected final void _setTypeImpl(TypeImpl ti)
    • compare

      public static int compare(FeatureStructureImplC a, FeatureStructureImplC b)
    • wrapGetIntCatchException

      protected static final int wrapGetIntCatchException(MethodHandle mh)