Jet.Pat
Class PatternApplication

java.lang.Object
  extended byJet.Pat.PatternApplication

public class PatternApplication
extends java.lang.Object

records information about the matching of a pattern graph against a segment of a Document.


Field Summary
 java.util.Vector bestActions
          the sequence of actions associated with the best pattern match found so far.
 java.util.HashMap bestBindings
          the bindings of variables to values associated with the best pattern match found so far.
 java.lang.String bestPatternName
          the name of the best pattern match found so far.
 int bestPosition
          if a match has been found, the document position matching the end of the pattern.
 boolean matchFound
          true if a match has been found between the pattern graph and the Document.
static boolean patternApplyTrace
          if true, write a trace message to the console whenever a the actions associated with a pattern are applied.
static boolean patternMatchTrace
          if true, write a trace message to the console whenever a pattern is successfully matched.
 int startPosition
          the position in the Document where the matching starts.
 
Constructor Summary
PatternApplication(Document doc, int start)
           
 
Method Summary
static javax.swing.JMenu applySubmenu()
          Returns the "Pattern Apply Trace" submenu used in the Console's "Patterns" menu.
static javax.swing.JMenu matchSubmenu()
          Returns the "Pattern Match Trace" submenu used in the Console's "Patterns" menu.
static javax.swing.JMenu patternMenu()
          Returns a menu for controlling the pattern matcher (part of the Console menu bar).
 int performActions()
          perform the actions associated with this pattern application.
 void recordMatch(int position, java.lang.String patternName, java.util.HashMap bindings, java.util.Vector actions)
          invoked for a successful match of a pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

matchFound

public boolean matchFound
true if a match has been found between the pattern graph and the Document.


startPosition

public int startPosition
the position in the Document where the matching starts.


bestPosition

public int bestPosition
if a match has been found, the document position matching the end of the pattern. If several matches were found, the best (furthest) end position.


bestPatternName

public java.lang.String bestPatternName
the name of the best pattern match found so far.


bestBindings

public java.util.HashMap bestBindings
the bindings of variables to values associated with the best pattern match found so far.


bestActions

public java.util.Vector bestActions
the sequence of actions associated with the best pattern match found so far.


patternMatchTrace

public static boolean patternMatchTrace
if true, write a trace message to the console whenever a pattern is successfully matched.


patternApplyTrace

public static boolean patternApplyTrace
if true, write a trace message to the console whenever a the actions associated with a pattern are applied.

Constructor Detail

PatternApplication

public PatternApplication(Document doc,
                          int start)
Method Detail

recordMatch

public void recordMatch(int position,
                        java.lang.String patternName,
                        java.util.HashMap bindings,
                        java.util.Vector actions)
invoked for a successful match of a pattern. If the end position, position, is further than any prior match, record the new position, variable bindings, and actions. Note that the actions are not performed immediately, but are saved in case there are subsequent better (longer) matchings of this pattern graph.

Parameters:
position - position in document reached by end of pattern
bindings - variable bindings for this pattern
actions - actions to be performed if this is best pattern match

performActions

public int performActions()
perform the actions associated with this pattern application. If no match has been found, no actions are performed; otherwise, perform the actions associated with the best (longest) pattern match. This method is invoked when all possible matches of the pattern graph against the document, starting at the current position, have been exhausted.

Returns:
the last position in the document matched by the pattern; -1 if no match was found.

patternMenu

public static javax.swing.JMenu patternMenu()
Returns a menu for controlling the pattern matcher (part of the Console menu bar). Includes menu items for patternMatchTrace and patternApplyTrace. DEPRECATED as of 4/25/2001. Use matchSubmenu() and applySubMenu() instead.


matchSubmenu

public static javax.swing.JMenu matchSubmenu()
Returns the "Pattern Match Trace" submenu used in the Console's "Patterns" menu.


applySubmenu

public static javax.swing.JMenu applySubmenu()
Returns the "Pattern Apply Trace" submenu used in the Console's "Patterns" menu.