agentland.resource
Class ResourceBunch

java.lang.Object
  |
  +--agentland.resource.ResourceBunch

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  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 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)
           
 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()
           
 String getTiedTo()
          Just a shortcut -- returns the first tied to in the tied to list
 Vector getTiedTos()
           
 void merge(ResourceBunch rb)
           
 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
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()

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)

merge

public void merge(ResourceBunch rb)

setTiedTos

public void setTiedTos(Vector v)

getTiedTos

public Vector getTiedTos()

getTiedTo

public String getTiedTo()
Just a shortcut -- returns the first tied to in the tied to list

get

public Object get(Object o)

getAgent

public Agent getAgent(Resource res)

getAgent

public Agent getAgent(String res)

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.