agentland.resource
Class ResourceBunch

java.lang.Object
  |
  +--agentland.resource.ResourceBunch
All Implemented Interfaces:
Serializable

public class ResourceBunch
extends Object
implements Serializable

A collection of resources put in a hashtable format. This is what is returned by a resource call--it is all the various things (agents mainly) nabbed on behalf of the call, and any extra info needed.

See Also:
Serialized Form

Field Summary
protected  boolean available
          indicates if the resource in the bunch are usable right now or not (e.g.
protected  Need need
           
 
Constructor Summary
ResourceBunch()
          An empty bundle.
ResourceBunch(Resource res)
          This is the most basic form of bundle, it holds a single resource.
 
Method Summary
 void addResource(Resource res)
           
 void addResource(String name, Resource res)
          We need to key resources not by resource name but by REQUEST name; i.e.
 void dump(PrintStream ps)
           
 void fixUp(AgentAgent pop)
          This goes through and changes any AgentIDs to Agents, so things like getOnlyAgent and whatnot don't cause class cast exceptions by finding AgentIDs When a managed agent, you should not need to make this call.
 Object get(Object o)
           
 Agent getAgent(Resource res)
           
 Agent getAgent(String res)
           
 AgentID getAgentID(String res)
          Returns AgentID of the resource stored under given name (this name is usually the name of the request that got us the resource)
 Need getNeed()
          Get the value of need.
 Agent getOnlyAgent()
           
 Resource getOnlyResource()
           
 Resource getResource(String name)
          Gives you the resource of a given name
 Collection getResources()
           
 Object getTiedTo()
          Just a shortcut -- returns the first tied to in the tied to list -- it's an object because it may be either a String or an AgentID
 List getTiedTos()
           
 boolean isAvailable()
           
 void merge(ResourceBunch rb)
           
 void setAvailable(boolean v)
           
 void setNeed(Need v)
          Set the value of need.
 void setTiedTos(Vector v)
           
 int size()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

need

protected Need need

available

protected boolean available
indicates if the resource in the bunch are usable right now or not (e.g. if they have been yanked); the ManagedAgent sets and reads this variable
Constructor Detail

ResourceBunch

public ResourceBunch()
An empty bundle.

ResourceBunch

public ResourceBunch(Resource res)
This is the most basic form of bundle, it holds a single resource.
Method Detail

getResources

public Collection getResources()
Returns:
all resources in bundle.

size

public int size()

isAvailable

public boolean isAvailable()
Returns:
true if the resources in this bunch are available (i.e. have been requested and have not been withdrawn); false otherwise.

setAvailable

public void setAvailable(boolean v)

getOnlyResource

public Resource getOnlyResource()
Returns:
the resources in bundle. If more than one, throw runtime exception.

getResource

public Resource getResource(String name)
Gives you the resource of a given name
Parameters:
name - name of the resource

addResource

public void addResource(Resource res)

addResource

public void addResource(String name,
                        Resource res)
We need to key resources not by resource name but by REQUEST name; i.e. the requesting agent when it requests "some display device" will want to do get("some display device") rather than get("super duper projector");

merge

public void merge(ResourceBunch rb)

setTiedTos

public void setTiedTos(Vector v)

getTiedTos

public List getTiedTos()

getTiedTo

public Object getTiedTo()
Just a shortcut -- returns the first tied to in the tied to list -- it's an object because it may be either a String or an AgentID

get

public Object get(Object o)

getAgent

public Agent getAgent(Resource res)

getAgent

public Agent getAgent(String res)

getAgentID

public AgentID getAgentID(String res)
                   throws RemoteException
Returns AgentID of the resource stored under given name (this name is usually the name of the request that got us the resource)

getOnlyAgent

public Agent getOnlyAgent()

getNeed

public Need getNeed()
Get the value of need.
Returns:
Value of need.

setNeed

public void setNeed(Need v)
Set the value of need.
Parameters:
v - Value to assign to need.

toString

public String toString()
Overrides:
toString in class Object

dump

public void dump(PrintStream ps)

fixUp

public void fixUp(AgentAgent pop)
This goes through and changes any AgentIDs to Agents, so things like getOnlyAgent and whatnot don't cause class cast exceptions by finding AgentIDs When a managed agent, you should not need to make this call. Managed Agent does it for you. Resources marked as abstract do not get fixed up.