ocean.doc
Class StableStorage

java.lang.Object
  |
  +--ocean.doc.OCEANDocNode
        |
        +--ocean.doc.Resource
              |
              +--ocean.doc.StableStorage
All Implemented Interfaces:
java.lang.Comparable

public class StableStorage
extends Resource

The StableStorage class is a wrapper for the Stable Storage trade proposal schema construct. No distinction is made between types (i.e. hard drive, magnetic tape, etc.), so this can be considered a generic description of storage.


Field Summary
protected  Memory availableSpace
          Available space on this unit.
protected  Memory reqAmt
          Amount requested.
protected  Memory totalSpace
          Total space of this storage unit.
 
Fields inherited from class ocean.doc.Resource
requested, resElem, reserved, resourceID, resourceType, schedule
 
Fields inherited from class ocean.doc.OCEANDocNode
doc, rootNode
 
Constructor Summary
protected StableStorage(boolean r, org.w3c.dom.Document d)
           
protected StableStorage(Memory m, boolean r, org.w3c.dom.Document d)
           
protected StableStorage(Memory avail, Memory total, boolean r, org.w3c.dom.Document d)
           
protected StableStorage(org.w3c.dom.Node resNode, org.w3c.dom.Node ssNode, boolean r, org.w3c.dom.Document d)
           
 
Method Summary
protected  void buildNode()
          Build this Stable Storage construct's node tree, based on the attribute values of this StableStorage object.
 int compareTo(java.lang.Object o)
          Compare this StableStorage to the given object.
protected  void extractMemFromNode(org.w3c.dom.Node ssNode)
          Extract Memory information from a DOM Node, and set the class attributes accordingly.
 Memory getAvailableSpace()
          Get the available space.
 Memory getRequestAmount()
          Get the requested amount.
 java.lang.String getResourceInfo()
          Get a String which describes the state of this StableStorage.
 Memory getTotalSpace()
          Get the total space.
 boolean isCompatible(Resource r)
          Check if this StableStorage is compatible with the given resource.
 void setAvailableSpace(Memory mem)
          Set the available space memory measurement.
protected  void setDocument(org.w3c.dom.Document d)
          Set the DOM Document that is used to create and modify this construct.
 void setRequestAmount(Memory mem)
          Set the requested amount.
 void setTotalSpace(Memory mem)
          Set the total space memory measurement.
 
Methods inherited from class ocean.doc.Resource
createRoot, getID, getResIDNode, getSchedNode, getSchedule, getType, isRequested, isReserved, setID, setReserved, setSchedule, setType
 
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

totalSpace

protected Memory totalSpace
Total space of this storage unit.

availableSpace

protected Memory availableSpace
Available space on this unit. null if reqAmt is not null.

reqAmt

protected Memory reqAmt
Amount requested. null if availableSpace is not null.
Constructor Detail

StableStorage

protected StableStorage(boolean r,
                        org.w3c.dom.Document d)

StableStorage

protected StableStorage(org.w3c.dom.Node resNode,
                        org.w3c.dom.Node ssNode,
                        boolean r,
                        org.w3c.dom.Document d)

StableStorage

protected StableStorage(Memory m,
                        boolean r,
                        org.w3c.dom.Document d)

StableStorage

protected StableStorage(Memory avail,
                        Memory total,
                        boolean r,
                        org.w3c.dom.Document d)
Method Detail

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 Resource
Following copied from class: ocean.doc.OCEANDocNode
Parameters:
d - the new Docuemnt

setAvailableSpace

public void setAvailableSpace(Memory mem)
Set the available space memory measurement.
Parameters:
mem - the new available space.

setTotalSpace

public void setTotalSpace(Memory mem)
Set the total space memory measurement.
Parameters:
mem - the new total space.

getAvailableSpace

public Memory getAvailableSpace()
Get the available space.
Returns:
available space memory measurement.

getTotalSpace

public Memory getTotalSpace()
Get the total space.
Returns:
the total space memory measurement.

getRequestAmount

public Memory getRequestAmount()
Get the requested amount.
Returns:
requested amount as a memory measurement.

setRequestAmount

public void setRequestAmount(Memory mem)
Set the requested amount.

extractMemFromNode

protected void extractMemFromNode(org.w3c.dom.Node ssNode)
Extract Memory information from a DOM Node, and set the class attributes accordingly.

buildNode

protected void buildNode()
                  throws OCEANDocException
Build this Stable Storage construct's node tree, based on the attribute values of this StableStorage object.
Overrides:
buildNode in class Resource
Throws:
OCEANDocException - if the OCEAN Trade Proposal schemas are violated.

isCompatible

public boolean isCompatible(Resource r)
Check if this StableStorage is compatible with the given resource. For stable storage, at least this StableStorage request amount must be available to the resource being compared.
Overrides:
isCompatible in class Resource
Returns:
false if r is not of type StableStorage, or if this StableStorage is not a request, or if r is a request. true if this StableStorage request amount is exceeded by the compared resource's available amount.

compareTo

public int compareTo(java.lang.Object o)
Compare this StableStorage to the given object. Sorting is determined by the following criteria in the given order.
  • resource type string
  • available space
  • requested space
  • Overrides:
    compareTo in class Resource

    getResourceInfo

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