m865.datastructures
Class PrioritizedItem

java.lang.Object
  extended bym865.datastructures.PrioritizedItem
All Implemented Interfaces:
java.lang.Comparable, Prioritizeable

public class PrioritizedItem
extends java.lang.Object
implements Prioritizeable

The PrioritizedItem class contains objects which consist of a comparable object which represents the explicit priority, and a general object which is the prioritized datum.

Version:
2.1 09/26/05
Author:
Daniel D. Warner

Field Summary
protected  java.lang.Object datum
          The general object which the datum.
protected  java.lang.Comparable priority
          The Comparable object which designates the priority.
 
Constructor Summary
protected PrioritizedItem()
          Default constuctor
protected PrioritizedItem(java.lang.Comparable p, java.lang.Object obj)
          General Constructor
 
Method Summary
 boolean adjustPriority(java.lang.Comparable p)
          Adjusts the priority of this object
 java.lang.Object clone()
          Creates a clone of this object
 int compareTo(java.lang.Object pqi)
          The compareTo method required by the Comparable interface If the priorities are comparable this returns an int specifying the relation between the two priorities.
 boolean equals(java.lang.Object obj)
          Tests for the equality of this object with a specified object
 java.lang.Object getDatum()
          Get the datum of this object
 java.lang.Comparable getPriority()
          Get the priority of this object
 int hashCode()
          Calculates the hashCode
 boolean higherThan(Prioritizeable obj)
          Compares the priority of this object with a specified object.
 boolean lowerThan(Prioritizeable obj)
          Compares the priority of this object with a specified object.
 void setDatum(java.lang.Object obj)
          Set the dataum of this object
 void setPriority(java.lang.Comparable p)
          Set the priority of this object
 java.lang.String toString()
          Display this prioritized item
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

priority

protected java.lang.Comparable priority
The Comparable object which designates the priority.


datum

protected java.lang.Object datum
The general object which the datum.

Constructor Detail

PrioritizedItem

protected PrioritizedItem(java.lang.Comparable p,
                          java.lang.Object obj)
General Constructor

Parameters:
p - the priority of the Prioritized item
obj - the datum of the Prioritized item

PrioritizedItem

protected PrioritizedItem()
Default constuctor

Method Detail

setPriority

public void setPriority(java.lang.Comparable p)
Set the priority of this object

Parameters:
p - the priority

getPriority

public java.lang.Comparable getPriority()
Get the priority of this object

Returns:
the Comparable object which represents the priority

setDatum

public void setDatum(java.lang.Object obj)
Set the dataum of this object

Parameters:
obj - the datum of this object

getDatum

public java.lang.Object getDatum()
Get the datum of this object

Returns:
the Object which is the datum

adjustPriority

public boolean adjustPriority(java.lang.Comparable p)
Adjusts the priority of this object

Specified by:
adjustPriority in interface Prioritizeable
Parameters:
p - the new priority
Returns:
true in the new priority is greater than or equal to the old priority.

higherThan

public boolean higherThan(Prioritizeable obj)
Compares the priority of this object with a specified object. If the objects are not comparable, then the method may throw a ClassCastException.

Specified by:
higherThan in interface Prioritizeable
Parameters:
obj - the specified object
Returns:
true if this object has priority equal to or higher than the specified object.

lowerThan

public boolean lowerThan(Prioritizeable obj)
Compares the priority of this object with a specified object. If the objects are not comparable, then the method may throw a ClassCastException.

Specified by:
lowerThan in interface Prioritizeable
Parameters:
obj - the specified object
Returns:
true if this object has priority strictly lower than the specified object.

compareTo

public int compareTo(java.lang.Object pqi)
The compareTo method required by the Comparable interface If the priorities are comparable this returns an int specifying the relation between the two priorities.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
pqi - the specified object which should be a PrioritizedItem
Returns:
a negative integer if this object should appear before the specified object in a sorted list; zero if this object is equal to the specified object; and a positive integer if this object should appear after the specified object in a sorted list.

clone

public java.lang.Object clone()
Creates a clone of this object

Returns:
a copy of the pair of reference variables constituting this PrioritizedItem.

equals

public boolean equals(java.lang.Object obj)
Tests for the equality of this object with a specified object

Parameters:
obj - the specified object
Returns:
true if this object is equal to the specified object

hashCode

public int hashCode()
Calculates the hashCode

Returns:
the hash code for this composite object

toString

public java.lang.String toString()
Display this prioritized item

Returns:
a formatted string listing the two pieces of this composite object