Class TypeSystemUtils

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

public abstract class TypeSystemUtils extends Object
Type Utilities - all static, so class is abstract to prevent creation Used by Feature Path
  • Field Details

  • Constructor Details

    • TypeSystemUtils

      public TypeSystemUtils()
  • Method Details

    • isIdentifier

      public static boolean isIdentifier(String s)
    • isNonQualifiedName

      static boolean isNonQualifiedName(String s)
    • isIdentifierStart

      static boolean isIdentifierStart(char c)
    • isIdentifierChar

      static boolean isIdentifierChar(char c)
    • isTypeName

      static boolean isTypeName(String name)
      Check if name is a possible type name. Does not check if this type actually exists!
      Parameters:
      name - The name to check.
      Returns:
      true iff name is a possible type name.
    • isTypeNameSpaceName

      static boolean isTypeNameSpaceName(String name)
    • isPathValid

      public static final TypeSystemUtils.PathValid isPathValid(Type type, List<String> path)

      Given a starting Type and a list of features representing a feature path, checks if a feature path is valid for a given type.

      We distinguish three cases:

      1. PathValid.NEVER: there is no object of type on which path can ever be defined.
      2. PathValid.ALWAYS: if all intermediate objects are non-null, this path will always be defined on any object of type.
      3. PathValid.POSSIBLE: some objects of type will have path defined, while others may not.
      Note: In computing validity, we always assume that all references are not null. A return value of ALWAYS can of course not guarantee that all intermediate objects will always exist; only that if they exist, the path will be defined.
      Parameters:
      type - The type.
      path - The path to check.
      Returns:
      One of ALWAYS, POSSIBLE, or NEVER.
    • isPathValid

      private static final TypeSystemUtils.PathValid isPathValid(TypeImpl type, Deque<String> path, TypeSystemUtils.PathValid status)
      Recursively called on each successive path element. Pops a feature name off the path, and checks if it exists for the type. -- if exists, gets its range type and iterates via recursion. Stops when the queue of feature names is empty.
      Parameters:
      type -
      path -
      status - the returned value if the feature is found.
      Returns:
    • isPathValidInSubtypes

      private static final TypeSystemUtils.PathValid isPathValidInSubtypes(TypeImpl type, String fName, Deque<String> nextPath)
      Called when the Feature Name is not a valid feature of the current type. It examines all the subtypes to see if it can find one for which the feature is valid. If the feature name is found in any subtype (recursively) of the type - given one subtype is found having the feature, continue the checking of subsequent features in the path - to see if there's some path where all the features are found. -- if so, return PathValid.POSSIBLE. -- if not, loop to try other subtypes. - if no subtypes have all the features, return PathValid.NEVER. The subtypes are descended when the feature name isn't a feature of a subtype, to see if a sub-sub-type might define the feature. The subtypes for one type are iterated while they have no match at any depth for the feature name
      Parameters:
      type - the type whose subtypes should be checked
      fName -
      nextPath -
      Returns:
    • classifyType

      public static final int classifyType(Type type)
      Classify types into FS type, array type etc. For the full list of return types, see the LowLevelCAS.TYPE_CLASS* constants, as well as the documentation for LowLevelCAS.ll_getTypeClass(int).
      Parameters:
      type - The type to classify.
      Returns:
      An integer encoding the the type class. See above.