org.jscience.ml.openmath
Class OMObject

java.lang.Object
  extended by org.jscience.ml.openmath.OMObject
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
OMApplication, OMAttribution, OMBinding, OMByteArray, OMError, OMFloat, OMForeign, OMInteger, OMReference, OMRoot, OMString, OMSymbol, OMVariable

public abstract class OMObject
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Models an abstract OpenMath object.

Note: every other OpenMath object inherits from this object. So each OpenMath object will have a hashtable of attributes.

See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable attributes
          Stores the attribute table.
 
Constructor Summary
OMObject()
          Constructor.
 
Method Summary
abstract  java.lang.Object clone()
          This will perform a shallow copy of the object.
abstract  java.lang.Object copy()
          Creates a copy of the OMObject.
 java.lang.Object getAttribute(java.lang.String name)
          Get an attribute.
 java.util.Hashtable getAttributes()
          Gets the attributes.
abstract  java.lang.String getType()
          Get the type of this element.
abstract  boolean isAtom()
          Is this an atom.
abstract  boolean isComposite()
          Is this a composite object.
abstract  boolean isSame(OMObject object)
          Is this the same object.
abstract  boolean isValid()
          Is this a valid object.
 void removeAttribute(java.lang.String name)
          Remove an attribute.
 void setAttribute(java.lang.String name, java.lang.String value)
          Set an attribute.
 void setAttributes(java.util.Hashtable newAttributes)
          Sets the attributes.
abstract  java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

attributes

protected java.util.Hashtable attributes
Stores the attribute table.

Constructor Detail

OMObject

public OMObject()
Constructor.

Method Detail

getType

public abstract java.lang.String getType()
Get the type of this element.

Returns:
the type.

isAtom

public abstract boolean isAtom()
Is this an atom.

Returns:
true if it is an atom, false if it is not.

isComposite

public abstract boolean isComposite()
Is this a composite object.

Returns:
true if it is composite, false if it is not.

isSame

public abstract boolean isSame(OMObject object)
Is this the same object.

Parameters:
object - the object to test against.
Returns:
true if it is the same, false if it is not.

isValid

public abstract boolean isValid()
Is this a valid object.

Returns:
true if it is valid, false if it is not.

clone

public abstract java.lang.Object clone()
This will perform a shallow copy of the object.

Overrides:
clone in class java.lang.Object
Returns:
a copy of the object.

toString

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

Overrides:
toString in class java.lang.Object
Returns:
the string representation.

copy

public abstract java.lang.Object copy()
Creates a copy of the OMObject.

Returns:
a deep copy of the object.

getAttributes

public java.util.Hashtable getAttributes()
Gets the attributes.

Note: this is an extension to the OpenMath standard 1.0. For the OpenMath standard 2.0 this is needed. So if you want 1.0 compliant code do not use attributes.

Returns:
the hashtable with attributes.

setAttributes

public void setAttributes(java.util.Hashtable newAttributes)
Sets the attributes.

Note: this is an extension to the OpenMath standard 1.0. For the OpenMath standard 2.0 this is needed. So if you want 1.0 compliant code do not use attributes.

Parameters:
newAttributes - the attributes to set.

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Get an attribute.

Note: this is an extension to the OpenMath standard 1.0. For the OpenMath standard 2.0 this is needed. So if you want 1.0 compliant code do not use attributes.

Parameters:
name - the name of the attribute to get.
Returns:
the value of the attribute.

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
Set an attribute.

Note: this is an extension to the OpenMath standard 1.0. For the OpenMath standard 2.0 this is needed. So if you want 1.0 compliant code do not use attributes.

Parameters:
name - the name of the attribute to set.
value - the value of the attribute.

removeAttribute

public void removeAttribute(java.lang.String name)
Remove an attribute.

Note: this is an extension to the OpenMath standard 1.0. For the OpenMath standard 2.0 this is needed. So if you want 1.0 compliant code do not use attributes.

Parameters:
name - the name of the attribute to remove.