Class OMBinding
java.lang.Object
org.episteme.core.mathematics.loaders.openmath.OMObject
org.episteme.core.mathematics.loaders.openmath.OMBinding
- All Implemented Interfaces:
Serializable, Cloneable
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 Summary
FieldsModifier and TypeFieldDescriptionprotected OMObjectStores the binder.protected OMObjectStores the body.Stores the variables.Fields inherited from class OMObject
attributes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddVariable(OMObject object) Add variable.alphaConvert(OMObject source, OMObject dest) Perform Alpha conversion on the binding and its children.betaReduce(OMObject var, OMObject reduction) Performs light-weight Beta reduction.clone()Clones the object (shallow copy).copy()Copies the object (full copy).Get the first variable.Get the binder.getBody()Get the body.getType()Gets the type.getVariableAt(int index) Get variable at i-place.Get the variables.voidinsertVariableAt(OMObject object, int index) Insert variable at i-place.booleanisAtom()Are we an atom object.booleanAre we a composite object.booleanDetermines if this is the same object.booleanisValid()Determines if this is a valid object.Get the last variable.voidRemove all variables.booleanremoveVariable(OMObject object) Remove variable.voidremoveVariableAt(int index) Remove variable at i-place.Replace any occurrence of source to destination.voidSets the binder.voidSet the body.voidsetVariableAt(OMObject object, int index) Set variable at i-place.voidsetVariables(Vector<OMObject> newVariables) Set the variables.toString()Returns a string representation of the object.Methods inherited from class OMObject
getAttribute, getAttributes, removeAttribute, setAttribute, setAttributes
-
Field Details
-
binder
Stores the binder. -
variables
-
body
Stores the body.
-
-
Constructor Details
-
OMBinding
public OMBinding()Constructor. -
OMBinding
-
-
Method Details
-
getType
-
getBinder
-
setBinder
-
getVariables
-
setVariables
-
getBody
-
setBody
-
getVariableAt
Get variable at i-place.- Parameters:
index- the index of the variable.- Returns:
- the variable.
-
setVariableAt
Set variable at i-place.- Parameters:
object- the object to set.index- the index to set at.
-
insertVariableAt
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
Add variable.- Parameters:
object- adds a variable (at the end).
-
removeVariable
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
-
lastVariable
-
toString
-
clone
-
copy
-
isComposite
public boolean isComposite()Are we a composite object.- Specified by:
isCompositein classOMObject- Returns:
- true if it is composite, false if it is not.
-
isAtom
-
isSame
-
isValid
-
replace
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
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
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 objectdest- the destination object- Returns:
- the converted object
-