mro.util
Class UniqueIdentifier

java.lang.Object
  extended by mro.util.UniqueIdentifier
All Implemented Interfaces:
XMLPartIO

public class UniqueIdentifier
extends java.lang.Object
implements XMLPartIO

A UniqueIdentifier for an object based on the Class name and two longs: the current system time and the current thread ID. Note: it is only the name of the class that is stored, not the entire object.

See Also:
Thread

Field Summary
private  java.lang.String ownerClassName
          A String containing the full name of the class of the owner object.
private  long threadID
          The Thread in which the UniqueIdentifier was created.
private  long time
          The creation time of the UniqueIdentifier.
 
Constructor Summary
UniqueIdentifier()
          Constructor.
UniqueIdentifier(long time, long threadID, java.lang.Object o)
          Constructor.
UniqueIdentifier(long time, long threadID, java.lang.String ownerClassName)
          Constructor.
UniqueIdentifier(java.lang.Object o)
          Constructor.
UniqueIdentifier(java.lang.String ownerClassName)
          Constructor.
UniqueIdentifier(UniqueIdentifier ui)
          Copy constructor.
 
Method Summary
 boolean endElementPartXML(java.lang.StringBuffer buffer, java.lang.String qualifiedName)
          Use when defining a DefaultHandler to parse a larger XML-file where a UniqueIdentifier is a part.
 boolean equals(java.lang.Object obj)
          Compares two UniqueIdentifiers.
 java.lang.String getDTDElementName()
          Returns a String with the name of the element defining a UniqueIdentifier in a DTD.
 java.lang.String getOwnerClassName()
          Returns the full name of the class of the owning object.
 long getThreadID()
          Returns the ID of the Thread in which this UniqueIdentifier was created.
 long getTime()
          Returns the time for the creation this UniqueIdentifier.
 void printPartDTD(java.io.PrintWriter out)
          Prints the DTD for a UniqueIndentifier.
 void printPartXML(java.io.PrintWriter out)
          Prints this UniqueIdentifier to a PrintWriter as a part of a larger XML-file following the DTD in printPartDTD(java.io.PrintWriter).
 boolean startElementPartXML(java.lang.StringBuffer buffer, java.lang.String qualifiedName)
          Use when defining a DefaultHandler to parse a larger XML-file where a UniqueIdentifier is a part.
static void staticPrintPartDTD(java.io.PrintWriter out)
          Prints the DTD for a UniqueIndentifier.
 java.lang.String toString()
          Just for printing to screen.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ownerClassName

private java.lang.String ownerClassName
A String containing the full name of the class of the owner object.


time

private long time
The creation time of the UniqueIdentifier.


threadID

private long threadID
The Thread in which the UniqueIdentifier was created.

Constructor Detail

UniqueIdentifier

public UniqueIdentifier()
Constructor.


UniqueIdentifier

public UniqueIdentifier(java.lang.Object o)
Constructor.


UniqueIdentifier

public UniqueIdentifier(java.lang.String ownerClassName)
Constructor.


UniqueIdentifier

public UniqueIdentifier(UniqueIdentifier ui)
Copy constructor.


UniqueIdentifier

public UniqueIdentifier(long time,
                        long threadID,
                        java.lang.Object o)
Constructor.


UniqueIdentifier

public UniqueIdentifier(long time,
                        long threadID,
                        java.lang.String ownerClassName)
Constructor.

Method Detail

getTime

public long getTime()
Returns the time for the creation this UniqueIdentifier.


getThreadID

public long getThreadID()
Returns the ID of the Thread in which this UniqueIdentifier was created.


getOwnerClassName

public java.lang.String getOwnerClassName()
Returns the full name of the class of the owning object.


getDTDElementName

public java.lang.String getDTDElementName()
Returns a String with the name of the element defining a UniqueIdentifier in a DTD.


equals

public boolean equals(java.lang.Object obj)
Compares two UniqueIdentifiers.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Just for printing to screen. Debugging essentially.

Overrides:
toString in class java.lang.Object

staticPrintPartDTD

public static void staticPrintPartDTD(java.io.PrintWriter out)
Prints the DTD for a UniqueIndentifier. Use in the context of a larger DTD. The DTD looks like this:
 <!--A Unique Identifier-->
 <!ELEMENT UniqueIdentifier (OwnerClassName, Time, Thread)>
 <!ELEMENT OwnerClassName (#PCDATA)> <!--Class of the object it identifies-->
 <!ELEMENT Time (#PCDATA)> <!--System Time of Creation-->
 <!ELEMENT Thread (#PCDATA)> <!--ThreadID-->
 


printPartDTD

public void printPartDTD(java.io.PrintWriter out)
Description copied from interface: XMLPartIO
Prints the DTD for a UniqueIndentifier. Use in the context of a larger DTD.

Specified by:
printPartDTD in interface XMLPartIO

printPartXML

public void printPartXML(java.io.PrintWriter out)
Prints this UniqueIdentifier to a PrintWriter as a part of a larger XML-file following the DTD in printPartDTD(java.io.PrintWriter).

Specified by:
printPartXML in interface XMLPartIO

startElementPartXML

public boolean startElementPartXML(java.lang.StringBuffer buffer,
                                   java.lang.String qualifiedName)
Use when defining a DefaultHandler to parse a larger XML-file where a UniqueIdentifier is a part. This particular instance always returns false, as no information on the start of these tags are nedeed.

Specified by:
startElementPartXML in interface XMLPartIO

endElementPartXML

public boolean endElementPartXML(java.lang.StringBuffer buffer,
                                 java.lang.String qualifiedName)
Use when defining a DefaultHandler to parse a larger XML-file where a UniqueIdentifier is a part. Returns true when the elements in the DTD (see printPartDTD(java.io.PrintWriter)) are found. In these cases the content of the UniqueIdentifier are set to the the values found in the XML-file.

Specified by:
endElementPartXML in interface XMLPartIO