Parsing Engine

danbikel.switchboard
Class NumberedObject

java.lang.Object
  extended by danbikel.switchboard.NumberedObject
All Implemented Interfaces:
Serializable, Comparable

public class NumberedObject
extends Object
implements Comparable, Serializable

A class to bundle an object with an integer that represents the order in which the object was discovered in its input file or stream (the object's number), as well as a flag to indicate whether the object has been processed. Objects of this type are used by the switchboard.

See Also:
Switchboard, Serialized Form

Constructor Summary
NumberedObject(int number, boolean processed, Object obj)
          Constructs a new NumberedObject object with the specified object, processed flag and object number.
 
Method Summary
 int compareTo(Object obj)
          This allows ordering of objects by their number.
 boolean equals(Object obj)
           
 Object get()
          Returns the underlying object.
 int number()
          Returns the number of the underlying object.
 boolean processed()
          Returns whether the underlying object has been processed.
 void set(Object obj)
          Sets the underlying object to be the specified object.
 void setProcessed()
          Sets the processed flag to true.
 void setProcessed(boolean processed)
          Sets the processed flag, indicating whether this object was successfully processed.
 String toString()
          Returns a string of the form (number processed objectStr), where processed is the output of String.valueOf(boolean) when passed the processed flag of this object objectStr is the result of calling the underlying object's toString method This is the format that is written by the TextObjectWriter objects created by the TextObjectWriterFactory.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumberedObject

public NumberedObject(int number,
                      boolean processed,
                      Object obj)
Constructs a new NumberedObject object with the specified object, processed flag and object number.

Method Detail

number

public int number()
Returns the number of the underlying object.


get

public Object get()
Returns the underlying object.


processed

public boolean processed()
Returns whether the underlying object has been processed.


set

public void set(Object obj)
Sets the underlying object to be the specified object.


setProcessed

public void setProcessed(boolean processed)
Sets the processed flag, indicating whether this object was successfully processed.


setProcessed

public void setProcessed()
Sets the processed flag to true.


compareTo

public int compareTo(Object obj)
This allows ordering of objects by their number.

Specified by:
compareTo in interface Comparable
Returns:
a negative integer if the underlying object's number is less than that of the specified NumberedObject, 0 if they have the same number (should not typically happen) or a positive integer if the underlying object's number is greater than that of the specified NumberedObject
Throws:
ClassCastException - if the specified object is not an instace of NumberedObject

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Returns a string of the form (number processed objectStr), where This is the format that is written by the TextObjectWriter objects created by the TextObjectWriterFactory.

Overrides:
toString in class Object
See Also:
TextObjectWriter, Switchboard, Switchboard.Switchboard(...)

Parsing Engine

Author: Dan Bikel.