Class Resource

java.lang.Object
  |
  +--Resource

public class Resource
extends java.lang.Object


Field Summary
private  java.util.Hashtable Data
           
 
Constructor Summary
Resource()
          Class constructor.
Resource(java.lang.String name, java.lang.String size, java.lang.String sharable, java.lang.String type, java.lang.String locktype, java.lang.String time, java.lang.String sr, java.lang.String sa)
          Class constructor that sets all fields.
 
Method Summary
 java.lang.String getLockType()
          Gets the LockType.
 java.lang.String getName()
          Returns the name of the resource
 int getSharable()
          Returns the amount of sharable resources.
 int getSingleAgent()
          Gets the amount of resource that an Agent may use at once.
 int getSingleRequest()
          Returns an int that is the amount of resource that may be requested at one time.
 int getSize()
          Returns the size of the resource.
 int getTime()
          Returns an Integer value of the length of time an Agent may use the Resource.
 java.lang.String getType()
          Gets the type of the resource.
 void setLockType(java.lang.String locktype)
          Sets the LockType.
 void setName(java.lang.String name)
          Sets the Name of the Resource.
 void setSharable(int sharable)
          Sets the Amount of the resource that is sharable.
 void setSharable(java.lang.String sharable)
          Sets the Amount of the resource that is sharable.
 void setSingleAgent(int sa)
          Sets the amount of resource that may be used by one Agent.
 void setSingleAgent(java.lang.String sa)
          Sets the amount of resource that may be requested by one Agent.
 void setSingleRequest(int sr)
          Set the amount of resource that may be requested by an Agent at one time.
 void setSingleRequest(java.lang.String sr)
          Set the amount of resource that may be requested by an Agent at one time.
 void setSize(int size)
          Sets the number of resources.
 void setSize(java.lang.String size)
          Sets the number of resources.
 void setTime(int time)
          Sets the amount of time an Agent may use a resource.
 void setTime(java.lang.String time)
          Sets the amount of time an Agent may use a resource.
 void setType(java.lang.String type)
          Set's the Type of the Resource.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

Data

private java.util.Hashtable Data
Constructor Detail

Resource

public Resource()
Class constructor. Creates an empty hashtable.

Resource

public Resource(java.lang.String name,
                java.lang.String size,
                java.lang.String sharable,
                java.lang.String type,
                java.lang.String locktype,
                java.lang.String time,
                java.lang.String sr,
                java.lang.String sa)
Class constructor that sets all fields.
Parameters:
name - The name of the Resource.
size - How much of the Resource.
sharable - How much of the Resource is sharable. May not be greater than size.
type - The type of the Resource.
locktype - LockType of the Resoruce. see setLockType.
time - Sets the amount of time an Agent may use the resoruce.
sr - see setSingleRequest.
sa - see setSingleAgent.
Method Detail

setName

public void setName(java.lang.String name)
Sets the Name of the Resource.
Parameters:
name - The name of the Resource.

getName

public java.lang.String getName()
Returns the name of the resource
Returns:
name String value of the name. Returns null if this was not set.

setSize

public void setSize(int size)
             throws java.lang.Exception
Sets the number of resources.
Parameters:
size - The amount of the resource. Throws Exception if size < 0.

setSize

public void setSize(java.lang.String size)
             throws java.lang.Exception
Sets the number of resources.
Parameters:
size - The amount of the resource. Throws Exception if size < 0.

getSize

public int getSize()
Returns the size of the resource.
Returns:
size The amount of the resource. Returns null if this was not set.

setSharable

public void setSharable(java.lang.String sharable)
                 throws java.lang.Exception
Sets the Amount of the resource that is sharable. The amount that is not sharable is (size - sharable).
Parameters:
sharable - the amount that is sharable. Must be less than or equal to the total amount of resource.

setSharable

public void setSharable(int sharable)
                 throws java.lang.Exception
Sets the Amount of the resource that is sharable. The amount that is not sharable is (size - sharable).
Parameters:
sharable - the amount that is sharable. Must be less than or equal to the total amount of resource.

getSharable

public int getSharable()
Returns the amount of sharable resources.
Returns:
sharable Integer value of the sharable resources.

setType

public void setType(java.lang.String type)
             throws java.lang.Exception
Set's the Type of the Resource. Possible types are "reusable", "replenishable", and "consumable"
Parameters:
type - Must be "reusable" or "replenishable" or "consumable".

getType

public java.lang.String getType()
Gets the type of the resource. Possible types are "reusable", "replenishable", and "consumable"
Returns:
type The type of the resource.

setLockType

public void setLockType(java.lang.String locktype)
                 throws java.lang.Exception
Sets the LockType. Possible LockTypes are "mutex" and "rwlock".
Parameters:
locktype - The LockType to set the Resource to.

getLockType

public java.lang.String getLockType()
Gets the LockType.
Returns:
locktype Returns the LockType.

setTime

public void setTime(java.lang.String time)
             throws java.lang.Exception
Sets the amount of time an Agent may use a resource. An exception is thrown if a negative value is given.
Parameters:
time - A number.

setTime

public void setTime(int time)
             throws java.lang.Exception
Sets the amount of time an Agent may use a resource. An exception is thrown if a negative value is given.
Parameters:
time - A number.

getTime

public int getTime()
Returns an Integer value of the length of time an Agent may use the Resource.
Returns:
time Length of time an Agent may use the Resource.

setSingleRequest

public void setSingleRequest(java.lang.String sr)
                      throws java.lang.Exception
Set the amount of resource that may be requested by an Agent at one time. Must be less than or equal to the total amount of resource
Parameters:
sr - String representation of a number to set Single Request to.

setSingleRequest

public void setSingleRequest(int sr)
                      throws java.lang.Exception
Set the amount of resource that may be requested by an Agent at one time. Must be less than or equal to the total amount of resource
Parameters:
sr - int representation of a number to set Single Request to.

getSingleRequest

public int getSingleRequest()
Returns an int that is the amount of resource that may be requested at one time.
Returns:
sr a number that represents the amount of resource that may be requested at one time.

setSingleAgent

public void setSingleAgent(java.lang.String sa)
                    throws java.lang.Exception
Sets the amount of resource that may be requested by one Agent. This amount is a total amount.
Parameters:
sa - String representaion of amount of resource that may be requested by one Agent.

setSingleAgent

public void setSingleAgent(int sa)
                    throws java.lang.Exception
Sets the amount of resource that may be used by one Agent. This amount is a total amount.
Parameters:
sa - int representaion of amount of resource that may used by one Agent.

getSingleAgent

public int getSingleAgent()
Gets the amount of resource that an Agent may use at once.
Returns:
sa an int value of the amount of resource an Agent may use at once.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object