org.jscience.ml.openmath
Class OMApplication

java.lang.Object
  extended by org.jscience.ml.openmath.OMObject
      extended by org.jscience.ml.openmath.OMApplication
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class OMApplication
extends OMObject

Models an OpenMath application object.

See Also:
"The OpenMath standard 2.0, 2.1.3", Serialized Form

Field Summary
protected  java.util.Vector elements
          Stores the elements.
 
Fields inherited from class org.jscience.ml.openmath.OMObject
attributes
 
Constructor Summary
OMApplication()
          Constructor.
 
Method Summary
 void addElement(OMObject object)
          Adds an element.
 java.lang.Object clone()
          Clones the object performing a shallow copy.
 java.lang.Object copy()
          Copies the object performing a full copy.
 OMObject firstElement()
          Gets the first element.
 OMObject getElementAt(int index)
          Gets the element at the given index.
 java.util.Vector getElements()
          Get the elements.
 int getLength()
          Get the length of the application (aka the number of elements).
 java.lang.String getType()
          Gets the type.
 void insertElementAt(OMObject object, int index)
          Inserts an element at.
 boolean isAtom()
          Are we an atom object.
 boolean isComposite()
          Are we a composite object.
 boolean isSame(OMObject object)
          Determines if this is the same object.
 boolean isValid()
          Determines if this is a valid object.
 OMObject lastElement()
          Gets the last element.
 void removeAllElements()
          Remove all elements.
 boolean removeElement(OMObject object)
          Removes an element.
 void removeElementAt(int index)
          Removes an element at.
 OMObject replace(OMObject source, OMObject dest)
          Replace any occurrence of source to destination.
 void setElementAt(OMObject object, int index)
          Sets an element.
 void setElements(java.util.Vector newElements)
          Set the elements.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class org.jscience.ml.openmath.OMObject
getAttribute, getAttributes, removeAttribute, setAttribute, setAttributes
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

elements

protected java.util.Vector elements
Stores the elements.

Constructor Detail

OMApplication

public OMApplication()
Constructor.

Method Detail

getType

public java.lang.String getType()
Gets the type.

Specified by:
getType in class OMObject
Returns:
the type as a String.

toString

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

Note: this is quite similar to the OpenMath XML-encoding, but it is not complete. It returns the OpenMath object without the outer OMOBJ element.

Specified by:
toString in class OMObject
Returns:
a string representation of the OpenMath application.

clone

public java.lang.Object clone()
Clones the object performing a shallow copy.

Note: a shallow does not create separate copies of the child elements. So if you change anything in one of the child elements you are possibly changing some other object as well.

Specified by:
clone in class OMObject
Returns:
a clone of the object.

copy

public java.lang.Object copy()
Copies the object performing a full copy.

Note: a full copy will create separate copies of all its child elements as well.

Specified by:
copy in class OMObject
Returns:
a copy of the object.

isComposite

public boolean isComposite()
Are we a composite object.

Specified by:
isComposite in class OMObject
Returns:
true if we are a composite object, false if we are not.

isAtom

public boolean isAtom()
Are we an atom object.

Specified by:
isAtom in class OMObject
Returns:
true if we are an atom object, false if we are not.

getLength

public int getLength()
Get the length of the application (aka the number of elements).

Returns:
the number of elements.

getElements

public java.util.Vector getElements()
Get the elements.

Returns:
the vector of elements.

setElements

public void setElements(java.util.Vector newElements)
Set the elements.

Parameters:
newElements - a vector with elements.

getElementAt

public OMObject getElementAt(int index)
Gets the element at the given index.

Parameters:
index - the index of the elements to get.
Returns:
the element at the given index.

setElementAt

public void setElementAt(OMObject object,
                         int index)
Sets an element.

Parameters:
object - the object.
index - the index.

insertElementAt

public void insertElementAt(OMObject object,
                            int index)
Inserts an element at.

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

removeElementAt

public void removeElementAt(int index)
Removes an element at.

Parameters:
index - the index to remove the object.

addElement

public void addElement(OMObject object)
Adds an element.

Parameters:
object - adds an object (at the end).

removeElement

public boolean removeElement(OMObject object)
Removes an element.

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

Parameters:
object - removes the first occurence of the given object.
Returns:
true if the object was found (and removed), false otherwise.

removeAllElements

public void removeAllElements()
Remove all elements.


firstElement

public OMObject firstElement()
Gets the first element.

Returns:
the first element.

lastElement

public OMObject lastElement()
Gets the last element.

Returns:
the last element.

isSame

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

Specified by:
isSame in class OMObject
Parameters:
object - the object to compare against.
Returns:
true if this is the same object, 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 this is valid object, false if it is not.

replace

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

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