diva.sketch.parser2d
Class BasicRule

java.lang.Object
  |
  +--diva.sketch.parser2d.BasicRule

public class BasicRule
extends java.lang.Object
implements Rule

Basic rule is the implementation of the rule interface that is filled in declaratively by a user-defined grammar. This rule implementation has a type, which is equivalent to the left side of a production. The right side consists of a root object and a set of relative objects which are spatially related to the root object under a system of constraints.

A rule tries to find sets of constituents within its input constituent set that match the criteria of types and spatial constraints specified in the constructor. It returns a list of all possible interpretations of the input constituent set where there is a match.

Version:
$Revision: 1.1 $

Constructor Summary
BasicRule(java.lang.String ruleType, java.lang.String rootName, java.lang.String rootType, java.lang.String[] relativeNames, java.lang.String[] relativeTypes, RelationConstraint[] constraints)
          Construct a new basic rule with the given LHS and RHS structure.
 
Method Summary
static void debug(java.lang.String s)
          Debugging output.
 java.lang.String getRuleType()
          Return the type of the LHS.
 java.util.Iterator matchRule(ConstituentSet in)
          Return an iterator over the possible applications of this rule to the given constituent set.
 java.lang.String toString()
          Print out the contents of this rule.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicRule

public BasicRule(java.lang.String ruleType,
                 java.lang.String rootName,
                 java.lang.String rootType,
                 java.lang.String[] relativeNames,
                 java.lang.String[] relativeTypes,
                 RelationConstraint[] constraints)
Construct a new basic rule with the given LHS and RHS structure. The structure is a declarative set of relations that need to be satisfied for a match to occur. A "root" type is specified, as well as a set of adjacent and contained constituent types and their locations relative to the root.
Method Detail

getRuleType

public java.lang.String getRuleType()
Return the type of the LHS.
Specified by:
getRuleType in interface Rule

debug

public static void debug(java.lang.String s)
Debugging output.

matchRule

public java.util.Iterator matchRule(ConstituentSet in)
Return an iterator over the possible applications of this rule to the given constituent set.
Specified by:
matchRule in interface Rule

toString

public java.lang.String toString()
Print out the contents of this rule.
Overrides:
toString in class java.lang.Object