Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.uima.cas
Class ConstraintFactory

    java.lang.Object
      org.apache.uima.cas.ConstraintFactory

    public abstract class ConstraintFactory

extends Object

Methods to create `FSMatchConstraint`s for filtered iterators or other use. A constraint is an object which represents a test or a series of tests joined with "and" or "or". Each test consists of a test predicate plus an optional "path" which specifies how to walk through a chain of references, starting from a feature structure being tested, to reach the value to be tested.

Tests include

- type subsumption --(satisfied if the CAS feature structure being tested is of a specified type (or is a subtype of that type).
- value equality
- for numeric values - range testing

Constraints can be used by calling their "match" method, passing as an argument the value to test. If the constraint includes the "path", the argument is a feature structure; the path specifies how to reach the value to test, starting with the feature structure. Otherwise, the value to test depends on the constraint; for an `FSIntConstraint`, for instance, the value would be an integer.

Constructor Summary
`ConstraintFactory()`

Method Summary
`abstract FSMatchConstraint` | `and(FSMatchConstraint c1, FSMatchConstraint c2)` Conjoin two constraints.
`abstract FSFloatConstraint` | `createFloatConstraint()` Create a new float constraint.
`abstract FSIntConstraint` | `createIntConstraint()` Create a new int constraint.
`abstract FSStringConstraint` | `createStringConstraint()` Create a new String constraint.
`abstract FSTypeConstraint` | `createTypeConstraint()` Create a new type constraint.
`abstract FSMatchConstraint` | `embedConstraint(ArrayList path, FSConstraint constraint)` Embed a constraint under a path.
`abstract FSMatchConstraint` | `embedConstraint(FeaturePath path, FSConstraint constraint)` Combine a constraint test with a path from a feature structure instance to the value to be tested.
`static ConstraintFactory` | `instance()` Create a new constraint factory.
`abstract FSMatchConstraint` | `or(FSMatchConstraint c1, FSMatchConstraint c2)` Disjoin two constraints.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ConstraintFactory

    public ConstraintFactory()

Method Detail

### createTypeConstraint

    public abstract FSTypeConstraint createTypeConstraint()

  Create a new type constraint. A type constraint contains one or more types to test against. A type constraint must be initialized by adding one or more types to it. The match is true if any of the types are the same or a super type of the feature structure being tested by the constraint.

  Returns:
    A new type constraint with the type set to the top type.

### createIntConstraint

    public abstract FSIntConstraint createIntConstraint()

  Create a new int constraint. An int constraint must be initialized after it's created by adding one or more tests to it.

  Returns:
    A new int constraint, completely unconstrained.

### createFloatConstraint

    public abstract FSFloatConstraint createFloatConstraint()

  Create a new float constraint. A float constraint must be initialized after it's created by adding one or more tests to it.

  Returns:
    A new float constraint, completely unconstrained.

### createStringConstraint

    public abstract FSStringConstraint createStringConstraint()

  Create a new String constraint. A String constraint must be initialized after it's created by adding one or more tests to it.

  Returns:
    A new String constraint, completely unconstrained.

### embedConstraint

    public abstract FSMatchConstraint embedConstraint(FeaturePath path,
                                                      FSConstraint constraint)

  Combine a constraint test with a path from a feature structure instance to the value to be tested. This is called "embedding" a constraint under a path. For example, create an int constraint, and then embed it under some int valued feature, such as the start feature of an annotation.

  Parameters:
    `path` - The path to embed the constraint under. Create a new path with `CAS.createFeaturePath()`.
    `constraint` - The constraint to be embedded.
  Returns:
    A new FSMatchConstraint.

### embedConstraint

    public abstract FSMatchConstraint embedConstraint(ArrayList path,
                                                      FSConstraint constraint)

  Embed a constraint under a path. For example, create an int constraint, and then embed it under some int valued feature, such as the start feature of an annotation.

  Parameters:
    `path` - The path to embed the constraint under. This is a list of `features`.
    `constraint` - The constraint to be embedded.
  Returns:
    A new FSMatchConstraint.

### and

    public abstract FSMatchConstraint and(FSMatchConstraint c1,
                                          FSMatchConstraint c2)

  Conjoin two constraints.

  Parameters:
    `c1` - The first conjunct.
    `c2` - The second conjunct.
  Returns:
    A new FSMatchConstraint, representing the conjunction of `c1` and `c2`.

### or

    public abstract FSMatchConstraint or(FSMatchConstraint c1,
                                         FSMatchConstraint c2)

  Disjoin two constraints.

  Parameters:
    `c1` - The first disjunct.
    `c2` - The second disjunct.
  Returns:
    A new FSMatchConstraint, representing the disjunction of `c1` and `c2`.

### instance

    public static ConstraintFactory instance()

  Create a new constraint factory.

  Returns:
    A new ConstraintFactory instance.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 The Apache Software Foundation. All Rights Reserved.