Class OMBinding

java.lang.Object
org.episteme.core.mathematics.loaders.openmath.OMObject
org.episteme.core.mathematics.loaders.openmath.OMBinding
All Implemented Interfaces:
Serializable, Cloneable

public class OMBinding extends OMObject
Models an OpenMath binding object.

Version:
$Revision: 1.2 $
Author:
Manfred Riem (mriem@manorrock.org), Wouter Wiersma (W.T.Wiersma@stud.tue.nl)
See Also:
  • Field Details

    • binder

      protected OMObject binder
      Stores the binder.

    • variables

      protected Vector<OMObject> variables
      Stores the variables.

    • body

      protected OMObject body
      Stores the body.

  • Constructor Details

    • OMBinding

      public OMBinding()
      Constructor.

    • OMBinding

      public OMBinding(OMObject newBinder, Vector<OMObject> newVariables, OMObject newBody)
      Constructor.

      Parameters:
      newBinder - the binder.
      newVariables - a Vector with the bound variables.
      newBody - the body.
  • Method Details

    • getType

      public String getType()
      Gets the type.

      Specified by:
      getType in class OMObject
      Returns:
      the type of the OMObject.
    • getBinder

      public OMObject getBinder()
      Get the binder.

      Returns:
      the binder, or null if not set.
    • setBinder

      public void setBinder(OMObject newBinder)
      Sets the binder.

      Parameters:
      newBinder - sets the binder.
    • getVariables

      public Vector<OMObject> getVariables()
      Get the variables.

      Returns:
      the variables, or null if not set.
    • setVariables

      public void setVariables(Vector<OMObject> newVariables)
      Set the variables.

      Parameters:
      newVariables - the variables.
    • getBody

      public OMObject getBody()
      Get the body.

      Returns:
      the body, or null if not set.
    • setBody

      public void setBody(OMObject newBody)
      Set the body.

      Parameters:
      newBody - the body
    • getVariableAt

      public OMObject getVariableAt(int index)
      Get variable at i-place.

      Parameters:
      index - the index of the variable.
      Returns:
      the variable.
    • setVariableAt

      public void setVariableAt(OMObject object, int index)
      Set variable at i-place.

      Parameters:
      object - the object to set.
      index - the index to set at.
    • insertVariableAt

      public void insertVariableAt(OMObject object, int index)
      Insert variable at i-place.

      Parameters:
      object - the object to insert.
      index - the index to insert at.
    • removeVariableAt

      public void removeVariableAt(int index)
      Remove variable at i-place.

      Parameters:
      index - the index to remove from.
    • addVariable

      public void addVariable(OMObject object)
      Add variable.

      Parameters:
      object - adds a variable (at the end).
    • removeVariable

      public boolean removeVariable(OMObject object)
      Remove variable.

      Note: This removes the first occurence of the given variable. If you want to remove all the references to the given object, continue remove until this returns false.

      Parameters:
      object - the variable to remove.
      Returns:
      true if there are more occurrences, false if not.
    • removeAllVariables

      public void removeAllVariables()
      Remove all variables.

    • firstVariable

      public OMObject firstVariable()
      Get the first variable.

      Returns:
      the first variable.
    • lastVariable

      public OMObject lastVariable()
      Get the last variable.

      Returns:
      the last variable.
    • toString

      public String toString()
      Returns a string representation of the object.

      Specified by:
      toString in class OMObject
      Returns:
      the string representation.
    • clone

      public Object clone()
      Clones the object (shallow copy).
      Specified by:
      clone in class OMObject
      Returns:
      a copy of the object.
    • copy

      public Object copy()
      Copies the object (full copy).
      Specified by:
      copy in class OMObject
      Returns:
      a deep copy of the object.
    • isComposite

      public boolean isComposite()
      Are we a composite object.
      Specified by:
      isComposite in class OMObject
      Returns:
      true if it is composite, false if it is not.
    • isAtom

      public boolean isAtom()
      Are we an atom object.
      Specified by:
      isAtom in class OMObject
      Returns:
      true if it is an atom, false if it is not.
    • isSame

      public boolean isSame(OMObject object)
      Determines if this is the same object.

      Specified by:
      isSame in class OMObject
      Parameters:
      object - the object to test against.
      Returns:
      true if it is the same, false if it is not.
    • isValid

      public boolean isValid()
      Determines if this is a valid object.

      Specified by:
      isValid in class OMObject
      Returns:
      true if it is valid, false if it is not.
    • replace

      public OMObject replace(OMObject source, OMObject dest)
      Replace any occurrence of source to destination.

      Note: this method will not replace bound variables inside a binding. This will be the responsibility of the alphaConvert method. So if the given source is a bound variable the replacing will NOT occur, use the alphaConvert method instead!

      Parameters:
      source - the source object.
      dest - the destination object.
      Returns:
      the application with the replacing.
    • betaReduce

      public OMObject betaReduce(OMObject var, OMObject reduction)
      Performs light-weight Beta reduction.

      Note: While reducing name-capturing might occur. This method does NOT do alpha conversion to avoid this problem. So consider this to be light-weight Beta reduction.

      Parameters:
      var - the variable to reduce.
      reduction - the object to reduce it to.
      Returns:
      the beta reduced object.
    • alphaConvert

      public OMObject alphaConvert(OMObject source, OMObject dest)
      Perform Alpha conversion on the binding and its children.

      Note: the renaming is done by means of the replace method, this will ensure that any bound variable lower in the tree with the same name as the variable in this binding will not be replaced .

      Parameters:
      source - the source object
      dest - the destination object
      Returns:
      the converted object