Class FeaturePathImpl

java.lang.Object
org.apache.uima.cas.impl.FeaturePathImpl
All Implemented Interfaces:
FeaturePath

class FeaturePathImpl extends Object implements FeaturePath
Implementation of the feature path interface.
  • Field Details

  • Constructor Details

    • FeaturePathImpl

      public FeaturePathImpl()
      Constructor to create a new featurePath object
  • Method Details

    • addFeature

      public void addFeature(Feature feat)
      Description copied from interface: FeaturePath
      Add a new feature at the end of the path.
      Specified by:
      addFeature in interface FeaturePath
      Parameters:
      feat - The feature to be added.
    • getFeature

      public Feature getFeature(int i)
      Description copied from interface: FeaturePath
      Get feature at position.
      Specified by:
      getFeature in interface FeaturePath
      Parameters:
      i - The position in the path (starting at 0).
      Returns:
      The feature, or null if there is no such feature.
    • size

      public int size()
      Description copied from interface: FeaturePath
      Get length of path.
      Specified by:
      size in interface FeaturePath
      Returns:
      An integer >= 0.
    • initialize

      public void initialize(String featurePath) throws CASException
      Description copied from interface: FeaturePath
      Initialize the feature path object with the given feature path string.
      Specified by:
      initialize in interface FeaturePath
      Parameters:
      featurePath - The featurePath that is used for this feature path object.
      Throws:
      CASException - Throws an exception if the feature path syntax is invalid.
    • typeInit

      public void typeInit(Type featurePathType) throws CASException
      Description copied from interface: FeaturePath
      Check the feature path for the given type and initialize internal structures for faster access to the feature path value.
      Specified by:
      typeInit in interface FeaturePath
      Parameters:
      featurePathType - The type the feature path should be used on.
      Throws:
      CASException - Throws an exception if the feature path is not valid for the given type
    • getFeaturePath

      public String getFeaturePath()
      Description copied from interface: FeaturePath
      Returns the feature path as string.
      Specified by:
      getFeaturePath in interface FeaturePath
      Returns:
      Returns the feature path as string.
    • getBooleanValue

      public Boolean getBooleanValue(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the Boolean value of a boolean valued feature path.
      Specified by:
      getBooleanValue in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path value
      Returns:
      Returns the Boolean value of a boolean valued feature path or null if the feature path was not set
    • getByteValue

      public Byte getByteValue(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the Byte value of a byte valued feature path.
      Specified by:
      getByteValue in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path value
      Returns:
      Returns the Byte value of a byte valued feature path or null if the feature path was not set
    • getDoubleValue

      public Double getDoubleValue(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the Double value of a double valued feature path.
      Specified by:
      getDoubleValue in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path value
      Returns:
      Returns the Double value of a double valued feature path or null if the feature path was not set
    • getFloatValue

      public Float getFloatValue(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the Float value of a float valued feature path.
      Specified by:
      getFloatValue in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path value
      Returns:
      Returns the Float value of a float valued feature path or null if the feature path was not set
    • getFSValue

      public FeatureStructure getFSValue(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the FeatureStructure of a FeatureStructure valued feature path.
      Specified by:
      getFSValue in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path value
      Returns:
      Returns the FeatureStructure value of a FeatureStructure valued feature path or null if the feature path was not set
    • getIntValue

      public Integer getIntValue(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the Integer value of an integer valued feature path.
      Specified by:
      getIntValue in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path value
      Returns:
      Returns the Integer value of a integer valued feature path or null if the feature path was not set
    • getLongValue

      public Long getLongValue(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the Long value of a long valued feature path.
      Specified by:
      getLongValue in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path value
      Returns:
      Returns the Long value of a long valued feature path or null if the feature path was not set
    • getShortValue

      public Short getShortValue(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the Short value of a short valued feature path.
      Specified by:
      getShortValue in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path value
      Returns:
      Returns the Short value of a short valued feature path or null if the feature path was not set
    • getStringValue

      public String getStringValue(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the String value of a string valued feature path.
      Specified by:
      getStringValue in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path value
      Returns:
      Returns the String value of a string valued feature path or null if the feature path was not set
    • getType

      public Type getType(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the type of the feature path.
      Specified by:
      getType in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path type
      Returns:
      Returns the type of the feature path or null if the feature path is not set.
    • getTypClass

      public TypeClass getTypClass(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the type class of the feature path.
      Specified by:
      getTypClass in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path type class
      Returns:
      Returns the type class of the feature path or null if the feature path is not set
    • getValueAsString

      public String getValueAsString(FeatureStructure fs)
      Description copied from interface: FeaturePath
      Returns the feature path value as string for the given FeatureStructure. If the feature path contains a built-in function it is evaluated and the built-in function value is returned. If the feature path ends with an array the array is converted to a comma separated string.
      Specified by:
      getValueAsString in interface FeaturePath
      Parameters:
      fs - FeatureStructure to evaluate the feature path value
      Returns:
      Returns the value of the feature path as String or null if the feature path was not set
    • ll_getValueAsString

      public String ll_getValueAsString(int fsRef, LowLevelCAS llCas)
      Description copied from interface: FeaturePath
      Returns the feature path value as string for the given FeatureStructure. If the feature path contains a built-in function it is evaluated and the built-in function value is returned. If the feature path ends with an array the array is converted to a comma separated string.
      Specified by:
      ll_getValueAsString in interface FeaturePath
      Parameters:
      fsRef - FeatureStructure reference (LowLevel API) to evaluate the feature path value
      llCas - LowLevelCAS for the fsRef
      Returns:
      Returns the value of the feature path as String
    • throwBuiltInFunctionException

      private void throwBuiltInFunctionException(String typeName)
      Method that throws the CASRuntimeException for an unsupported built-in function
      Parameters:
      typeName - type name that does not support the built-in function
    • evaluateBuiltInFunction

      private String evaluateBuiltInFunction(FeatureStructure returnFS)
      evaluate the built-in function for the returned FeatureStructure
      Parameters:
      returnFS - FeatureStructure that is returned
      Returns:
      Returns the built-in function value for the given FS.
    • convertToString

      private static String convertToString(String[] array)
      Converts a string array to a comma separated string.
      Parameters:
      array - array to convert
      Returns:
      returns comma separated string of the given string array
    • getValue

      private FeaturePathValue getValue(int fsRef, LowLevelCAS llCas)
      evaluates the internal feature path for the given FeatureStructure data. It returns the FeaturePathValue object that contains the value of the feature path with some meta data information.
      Parameters:
      fsRef - FeatureStructure to evaluate the feature path
      llCas - LowLevelCAS for the fsRef
      Returns:
      Returns a featurePathValue object or null if the feature path value was not set