## gate.jape
Class PatternElement

    java.lang.Object
      |
      +--gate.jape.PatternElement

All Implemented Interfaces:
  Cloneable, JapeConstants, Matcher, Serializable

Direct Known Subclasses:
  BasicPatternElement, ComplexPatternElement, ConstraintGroup

public abstract class PatternElement
extends Object
implements Cloneable, Matcher, JapeConstants, Serializable

Superclass of the various types of pattern element, and of ConstraintGroup. Inherits from Matcher, providing matches and reset. Provides access to the annotations that are cached by subclasses, and multilevel rollback of those caches. Stores the match history.

See Also:
  Serialized Form

Field Summary
`private static boolean` `DEBUG` Debug flag
`protected Stack` `matchHistory` Match history stack, for use in rollback.

Fields inherited from interface gate.jape.JapeConstants
`APPELT_STYLE, BRILL_STYLE, DEFAULT_PRIORITY, FIRST_STYLE, INDENT_PADDING, KLEENE_PLUS, KLEENE_QUERY, KLEENE_STAR, MULTI_SPAN_BINDING, NO_BINDING, NO_KLEENE_OP, SINGLE_SPAN_BINDING`

Constructor Summary
`PatternElement()` Anonymous construction.

Method Summary
`Object` `clone()` Cloning for processing of macro references.
`abstract AnnotationSet` `getMatchedAnnots()` Access to the annotations that have been matched.
`void` `reset()` Reset: clear annotation caches etc.
`abstract void` `rollback(int arity)` Multilevel rollback of annotation caches.
`abstract String` `toString(String pad)` Create a string representation of the object with padding.

Methods inherited from class java.lang.Object
`<clinit>, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait`

Methods inherited from interface gate.jape.Matcher
`finish, matches`

Field Detail

### DEBUG

    private static final boolean DEBUG

  Debug flag

### matchHistory

    protected Stack matchHistory

  Match history stack, for use in rollback. In BasicPatternElements the objects on the stack are Integers giving the number of annots that were cached at that point in the history. In ComplexPatternElements the objects are Integers giving the number of times the component ConstraintGroup was successfully matched. In ConstraintGroups the elements are arrays representing conjunctions of PatternElement that succeeded at that point in the history.

Constructor Detail

### PatternElement

    public PatternElement()

  Anonymous construction.

Method Detail

### clone

    public Object clone()

  Cloning for processing of macro references. Note that it doesn't really clone the match history, just set it to a new Stack. This is because a) JGL doesn't have real clone methods and b) we don't actually need it anywhere but during parsing the .jape, where there is no match history yet.
  Overrides:
    `clone` in class `Object`

### getMatchedAnnots

    public abstract AnnotationSet getMatchedAnnots()

  Access to the annotations that have been matched.

### rollback

    public abstract void rollback(int arity)

  Multilevel rollback of annotation caches.

### reset

    public void reset()

  Reset: clear annotation caches etc. Most of the behaviour of this method is the responsibility of subclasses.
  Specified by:
    `reset` in interface `Matcher`

### toString

    public abstract String toString(String pad)

  Create a string representation of the object with padding.