org.activemath.abstractcontent
Class MBaseID

java.lang.Object
  extended by org.activemath.abstractcontent.MBaseID
All Implemented Interfaces:
Serializable, Comparable

public final class MBaseID
extends Object
implements Comparable, Serializable

Objects of this class denote the reference to an element within an MBase as can be reached using MBaseRef, it provides parsing and resolution mechanisms. Objects of this class, currently, use an underlying MBaseID.NullMBaseID object which provides the parsing and resolution facilities. It is meant as a more abstract construction than the very concrete MBaseID.NullMBaseID object.

See Also:
Serialized Form

Nested Class Summary
static class MBaseID.NullMBaseID
           
 
Constructor Summary
MBaseID(ID id)
          Constructs an MBaseID from an OmdocJdom MBaseID.NullMBaseID object.
MBaseID(MBaseID baseID, String stringID)
          Contructs an ID that will be resolved relative to the baseID.
MBaseID(String stringID)
          Constructs an ID using a string expected to contain all information to create an absolute one.
 
Method Summary
 int compareTo(Object o)
           
 boolean equals(Object obj)
          Compares to MBaseIDs comparing their OmdocJdom ID versions.
 String getAbsoluteForm()
          Constructs the string containing all information so as to be reparsed into a an MBaseID.
 ID getOJID()
          Returns the stored ojID or computes it if needed.
 String getRelativeForm(MBaseID base)
          Constructs the string containing the fewest necessary information for an element to be used as attribute if child of an object of id base.
 int hashCode()
          Returns a hashcode for the MBaseID computed from the absolute form.
static void main(String[] args)
           
 String toString()
          Returns a string representation of this ID useful for debugging only.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MBaseID

public MBaseID(MBaseID baseID,
               String stringID)
Contructs an ID that will be resolved relative to the baseID.

Parameters:
baseID - The base-ID from where to interpret the ID
stringID - The relative part expressing the difference with the base.

MBaseID

public MBaseID(String stringID)
Constructs an ID using a string expected to contain all information to create an absolute one.

Parameters:
stringID - The MBaseID

MBaseID

public MBaseID(ID id)
Constructs an MBaseID from an OmdocJdom MBaseID.NullMBaseID object.

Parameters:
id - From this object will be extracted all information.
Method Detail

getAbsoluteForm

public String getAbsoluteForm()
Constructs the string containing all information so as to be reparsed into a an MBaseID.

Returns:
The absolute form of this ID, computed if necessary.

getRelativeForm

public String getRelativeForm(MBaseID base)
Constructs the string containing the fewest necessary information for an element to be used as attribute if child of an object of id base.


getOJID

public ID getOJID()
Returns the stored ojID or computes it if needed.

Returns:
Returns the stored ojID or computes it if needed.

hashCode

public int hashCode()
Returns a hashcode for the MBaseID computed from the absolute form.

Overrides:
hashCode in class Object
Returns:
the MBaseID's hashcode

equals

public boolean equals(Object obj)
Compares to MBaseIDs comparing their OmdocJdom ID versions.

Overrides:
equals in class Object
Parameters:
obj - The MBaseID to compare to.

toString

public String toString()
Returns a string representation of this ID useful for debugging only.

Overrides:
toString in class Object
Returns:
a string like [mbase://myCollection/blip/blop]

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception