ocean.doc
Class Resource

java.lang.Object
  |
  +--ocean.doc.OCEANDocNode
        |
        +--ocean.doc.Resource
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
CPU, DataObject, GraphicsHW, Library, Memory, NetworkConnection, StableStorage

public abstract class Resource
extends OCEANDocNode
implements java.lang.Comparable

The abstract Resource class is the parent of all classes that represent resource constructs in the trade proposal schemas.


Field Summary
protected  boolean requested
          Indicates whether this resource is requested or provided.
protected  org.w3c.dom.Element resElem
          The Element named "Resource" in the construct's node tree.
protected  boolean reserved
           
protected  java.lang.String resourceID
          The resource identifier.
protected  java.lang.String resourceType
          The resource type.
protected  Schedule schedule
          Schedule for this construct.
 
Fields inherited from class ocean.doc.OCEANDocNode
doc, rootNode
 
Constructor Summary
protected Resource(boolean req, org.w3c.dom.Document d)
           
protected Resource(org.w3c.dom.Node resNode, boolean req, org.w3c.dom.Document d)
           
protected Resource(java.lang.String id, java.lang.String resType, boolean req, org.w3c.dom.Document d)
           
 
Method Summary
protected abstract  void buildNode()
          This method builds the node tree of this construct, based on member data of of the implementing subclass.
abstract  int compareTo(java.lang.Object o)
          Compare this resource to another object.
protected  void createRoot(java.lang.String rootName)
          Create the root node as a named element.
 java.lang.String getID()
          Return the resource identifier.
protected  org.w3c.dom.Node getResIDNode()
          Create and return the Node named "ResourceID".
abstract  java.lang.String getResourceInfo()
          Get a String which describes the state of the Resource.
protected  org.w3c.dom.Node getSchedNode()
          Get the root Node of the availability/reservation schedule of this construct.
 Schedule getSchedule()
          Get the availability/reservation schedule for this construct
 java.lang.String getType()
          Get the resource type string.
abstract  boolean isCompatible(Resource r)
          Check if this resource is compatible with another.
 boolean isRequested()
          Check whether this resource is requested or provided.
 boolean isReserved()
           
protected  void setDocument(org.w3c.dom.Document d)
          Set the DOM Document that is used to create and modify this construct.
 void setID(java.lang.String resID)
          Set the identifier for this resource construct.
 void setReserved(boolean b)
           
 void setSchedule(Schedule s)
          Set the availability/reservation schedule for this construct.
 void setType(java.lang.String s)
          Set the resource type String
 
Methods inherited from class ocean.doc.OCEANDocNode
genID, getDocument, getRootNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resourceID

protected java.lang.String resourceID
The resource identifier. Cannot be null.

resourceType

protected java.lang.String resourceType
The resource type.

resElem

protected org.w3c.dom.Element resElem
The Element named "Resource" in the construct's node tree.

schedule

protected Schedule schedule
Schedule for this construct. Indicates an Availability or Reservation schedule, depending on whether requested is false or true.

requested

protected boolean requested
Indicates whether this resource is requested or provided.

reserved

protected boolean reserved
Constructor Detail

Resource

protected Resource(boolean req,
                   org.w3c.dom.Document d)

Resource

protected Resource(org.w3c.dom.Node resNode,
                   boolean req,
                   org.w3c.dom.Document d)

Resource

protected Resource(java.lang.String id,
                   java.lang.String resType,
                   boolean req,
                   org.w3c.dom.Document d)
Method Detail

setSchedule

public void setSchedule(Schedule s)
Set the availability/reservation schedule for this construct.
Parameters:
s - the new schedule.

getSchedule

public Schedule getSchedule()
Get the availability/reservation schedule for this construct
Returns:
the schedule associated with this construct. null if unspecified.

setID

public void setID(java.lang.String resID)
Set the identifier for this resource construct.
Parameters:
resID - the new identifier.

getID

public java.lang.String getID()
Return the resource identifier.
Returns:
the resource identifier.

isRequested

public boolean isRequested()
Check whether this resource is requested or provided.
Returns:
true if the requested (buyer). false if provided (seller).

getType

public java.lang.String getType()
Get the resource type string.
Returns:
tje resource type.

setType

public void setType(java.lang.String s)
Set the resource type String
Parameters:
s - the new resource type

isReserved

public boolean isReserved()

setReserved

public void setReserved(boolean b)

getResIDNode

protected org.w3c.dom.Node getResIDNode()
                                 throws OCEANDocException
Create and return the Node named "ResourceID".
Returns:
node named "ResourceID" based on the value of resourceID.
Throws:
OCEANDocException - if the trade proposal schema is violated

getSchedNode

protected org.w3c.dom.Node getSchedNode()
                                 throws OCEANDocException
Get the root Node of the availability/reservation schedule of this construct.
Returns:
the root Node of this constrct's Schedule. null if the schedule is null.

buildNode

protected abstract void buildNode()
                           throws OCEANDocException
Description copied from class: OCEANDocNode
This method builds the node tree of this construct, based on member data of of the implementing subclass. This method is never called directly. Instead, the
Overrides:
buildNode in class OCEANDocNode
Following copied from class: ocean.doc.OCEANDocNode
Throws:
OCEANDocException - if an attempt is made to construct a node tree that is invalid with respect to the OCEAN trade proposal schemas.

isCompatible

public abstract boolean isCompatible(Resource r)
Check if this resource is compatible with another. By convention, this resource should be requested (i.e. from a buyer) and the checked resource should be provided (i.e. from a seller). Compatibility between two resources is resource dependent. In general, two resources are compatible if the provided resource meets or exceeds the specifications of the requested resource.
Returns:
true if the resources are compatible, false otherwise.

compareTo

public abstract int compareTo(java.lang.Object o)
Compare this resource to another object. Implementing this method fulfills the contract of the Comparable interface. Implementing this interface allows resources to be sorted in a list.
Specified by:
compareTo in interface java.lang.Comparable

createRoot

protected void createRoot(java.lang.String rootName)
Create the root node as a named element.
Overrides:
createRoot in class OCEANDocNode
Parameters:
rootName - the new name of the root node.

setDocument

protected void setDocument(org.w3c.dom.Document d)
Description copied from class: OCEANDocNode
Set the DOM Document that is used to create and modify this construct.
Overrides:
setDocument in class OCEANDocNode
Following copied from class: ocean.doc.OCEANDocNode
Parameters:
d - the new Docuemnt

getResourceInfo

public abstract java.lang.String getResourceInfo()
Get a String which describes the state of the Resource.
Returns:
a description of this resource.