org.pf.text
Class MatchRulePrinter

java.lang.Object
  extended by org.pf.text.MatchRulePrinter
All Implemented Interfaces:
MatchRuleVisitor

public class MatchRulePrinter
extends java.lang.Object
implements MatchRuleVisitor

Converts a MatchRule to a String using the default syntax. The only necessary method to call is:

asString( matchRule )

Version:
1.2
Author:
Manfred Duchrow

Constructor Summary
MatchRulePrinter()
          Initialize the new instance with default values.
MatchRulePrinter(MatchRuleChars ruleCharacters)
          Initialize the new instance with match rule characters.
 
Method Summary
 java.lang.String asString(MatchRule matchRule)
          Returns the specified match rule as a string.
 void attribute(java.lang.String name, int compareOperator, java.lang.String[] values, boolean andOperator, boolean notOperator)
          This method will be called for each attribute.
 void endGroup()
          This method will be called for each group end occurence.
 void startGroup(boolean andOperator, boolean notOperator)
          This method will be called for each start of a new group.
 boolean useNewSyntax()
          Returns true, if the printer uses the new syntax which is using an equals character rather than the curly brackets for single values.
 void useNewSyntax(boolean newValue)
          Sets if the printer uses the new syntax.
 void walkThroughFinished()
          This method will be called when the MatchRule has finished to walk through its elements.
 void walkThroughInit()
          This method will be called right before the MatchRule walks through its elements.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatchRulePrinter

public MatchRulePrinter()
Initialize the new instance with default values.


MatchRulePrinter

public MatchRulePrinter(MatchRuleChars ruleCharacters)
Initialize the new instance with match rule characters.

Method Detail

useNewSyntax

public boolean useNewSyntax()
Returns true, if the printer uses the new syntax which is using an equals character rather than the curly brackets for single values.
The default is NOT to use the new syntax to be compatible to old usage.


useNewSyntax

public void useNewSyntax(boolean newValue)
Sets if the printer uses the new syntax.


walkThroughInit

public void walkThroughInit()
This method will be called right before the MatchRule walks through its elements.

Specified by:
walkThroughInit in interface MatchRuleVisitor

walkThroughFinished

public void walkThroughFinished()
This method will be called when the MatchRule has finished to walk through its elements.

Specified by:
walkThroughFinished in interface MatchRuleVisitor

startGroup

public void startGroup(boolean andOperator,
                       boolean notOperator)
This method will be called for each start of a new group.

Specified by:
startGroup in interface MatchRuleVisitor
Parameters:
andOperator - If true it is an AND combination otherwise it is OR
notOperator - Is only true for a NOT operation

endGroup

public void endGroup()
This method will be called for each group end occurence.

Specified by:
endGroup in interface MatchRuleVisitor

attribute

public void attribute(java.lang.String name,
                      int compareOperator,
                      java.lang.String[] values,
                      boolean andOperator,
                      boolean notOperator)
This method will be called for each attribute.

Specified by:
attribute in interface MatchRuleVisitor
Parameters:
name - The attribute's name
compareOperator - The operator used to compare values
values - All values the attrubute my match (implicit OR combination !)
andOperator - If true it is an AND combination otherwise it is OR
notOperator - Is only true for a NOT operation

asString

public java.lang.String asString(MatchRule matchRule)
Returns the specified match rule as a string.