org.activemath.omdocjdom.rephrase
Class OMMatcher

java.lang.Object
  extended by org.activemath.omdocjdom.rephrase.OMMatcher

public class OMMatcher
extends Object

Simple class to describe a matcher deduced from an OpenMath expresion where a match involves XML-tree equality except for variables which can be replaced by anything.

Such a matcher uses an XPath matcher and is, thus, stateful and not thread-safe.


Constructor Summary
OMMatcher(org.jdom.Element pattern)
           
OMMatcher(List patterns)
           
 
Method Summary
 String getVariableCoord(String varName)
           
 Iterator getVariableNames()
          Returns the names of the variables used in the pattern in appearance order.
 String getXpathString()
           
 List match(OJElement omobj)
          Finds all occurrences of the pattern as a descendent of the given element.
 OJElement selectVariableMatch(org.jdom.Element matchedTerm, String varName)
          Finds the sub-term matched as the term at the variable whose name is provided.
 List selectVariableMatches(org.jdom.Element matchedTerm, String varName)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OMMatcher

public OMMatcher(org.jdom.Element pattern)

OMMatcher

public OMMatcher(List patterns)
Method Detail

getXpathString

public String getXpathString()

getVariableCoord

public String getVariableCoord(String varName)

getVariableNames

public Iterator getVariableNames()
Returns the names of the variables used in the pattern in appearance order.


match

public List match(OJElement omobj)
Finds all occurrences of the pattern as a descendent of the given element.

Parameters:
omobj - the formulae where to search
Returns:
the elements that are root of the matched term

selectVariableMatch

public OJElement selectVariableMatch(org.jdom.Element matchedTerm,
                                     String varName)
Finds the sub-term matched as the term at the variable whose name is provided.

Parameters:
matchedTerm - the result of match(org.activemath.omdocjdom.OJElement)
varName - the name of the variable which has allowed a sub-term to match
Returns:
the sub-term

selectVariableMatches

public List selectVariableMatches(org.jdom.Element matchedTerm,
                                  String varName)

toString

public String toString()
Overrides:
toString in class Object