org.activemath.omdocjdom.rephrase
Class RephraseRule

java.lang.Object
  extended by org.activemath.omdocjdom.rephrase.RephraseRule
All Implemented Interfaces:
Serializable

public class RephraseRule
extends Object
implements Serializable

A class to model an OpenMath rephrase rule built by a pair of OpenMath expressions with matching variable names. E.g. if one replaces a^3+5 along the rule x+y -> x-y, the result replacement will be a^3-5.

See Also:
Serialized Form

Constructor Summary
RephraseRule(OJElement rephraseElement)
           
RephraseRule(OJElement fromOmobj, OJElement toOmobj)
           
 
Method Summary
 OJElement apply(OJElement elt)
          Walks the tree and tries to find a term matching fromOmobj (with variables being replaced by anything) and apply the replacement.
 OJElement getFromOmobj()
           
 Set getFromSymbolsTargets()
           
 OJElement getToOmobj()
           
 boolean mayWorkOnOmobj(OJElement omobj)
           
 boolean mayWorkOnSymbol(ID symbolId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RephraseRule

public RephraseRule(OJElement rephraseElement)

RephraseRule

public RephraseRule(OJElement fromOmobj,
                    OJElement toOmobj)
Method Detail

getFromOmobj

public OJElement getFromOmobj()

getToOmobj

public OJElement getToOmobj()

getFromSymbolsTargets

public Set getFromSymbolsTargets()
Returns:
a list of ID objects that are the target of each OMS inside the expressions.

mayWorkOnSymbol

public boolean mayWorkOnSymbol(ID symbolId)

mayWorkOnOmobj

public boolean mayWorkOnOmobj(OJElement omobj)

apply

public OJElement apply(OJElement elt)
Walks the tree and tries to find a term matching fromOmobj (with variables being replaced by anything) and apply the replacement.

Parameters:
elt - the source term, please make sure an OMOBJ surrounds it at least in the case the replacement can include the whole term.
Returns:
the replaced element if a replacement occurred or null if no replacement occurred.