|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectunsw.cse.mica.data.Mob
public class Mob
The basic unit of storage and communication in MICA.
Generally, MICA objects (Mobs) are considered to be immutable. Each Mob has several characteristics: firstly, a name that identifies the Mob, secondly, the mob's type, thirdaly, a persistence specifying the lifespan of the mob on the blackboard, and finally a list of slots. Each slot in turn has a list of values.
The current implementation of mobs supports slot lists that consist solely of Strings. Future versions are likely to include some kind of type checking measure, and allow more arbitrary elements in the slots.
Field Summary |
---|
Constructor Summary | |
---|---|
Mob(Mob mob)
Make a mob that is an exact deep copy of an existing mob. |
|
Mob(java.lang.String type)
Create a new Mob with the specified type, and with an empty name. |
Method Summary | |
---|---|
void |
addEmptySlot(java.lang.String slotName)
Add a slot with no values. |
void |
addSlot(java.lang.String slotName,
java.util.List values)
Create a new slot with the given values, or if the slot already exists, add the new values |
void |
addSlot(java.lang.String slotName,
java.lang.String value)
Create a new slot with a given value, or if the slot already exists, add a new value |
long |
getCreationTime()
Get the mob's create time (as a long value in milliseconds) |
java.lang.String |
getCreator()
Get the name of the agent that created this mob (that is, the agent that wrote it to the blackboard) |
java.lang.String |
getDeleter()
Get the name of the agent that deleted this mob from the blackboard. |
long |
getDeletionTime()
Get the mob's deletion time (as a long value in milliseconds) If a mob is transient it's deletion time may not be specified. |
java.lang.String |
getName()
Get the name of this mob. |
java.lang.String |
getPersistence()
Get the mob's persistence setting (either null or one of the strings defined in MicaConstants.PERSISTENCES ) |
java.util.List |
getSlot(java.lang.String slotName)
Gets the values for a particular slot. |
java.lang.String |
getSlot1(java.lang.String slotName)
Get the first element of a given slot. |
double |
getSlot1AsDouble(java.lang.String slotName)
Return the first element of the given slot as a double. |
int |
getSlot1AsInt(java.lang.String slotName)
Return the first element of the given slot as an integer. |
java.lang.String |
getSlotN(java.lang.String slotName,
int n)
Get the nth element of a given slot, using a 0-based index. |
java.util.Set |
getSlots()
Get the names of all slots that this Mob has. |
java.lang.String |
getType()
Get the type of this Mob. |
boolean |
hasSlot(java.lang.String slotName)
Tests to see if this particular Mob has a slot of the mentioned name. |
void |
removeSlot(java.lang.String slotName)
Removes a particular slot from a mob |
void |
setName(java.lang.String name)
Set the name of this mob. |
void |
setPersistence(java.lang.String persistence)
Set the mob's persistence. |
void |
setSlot(java.lang.String slotName,
java.util.List slotValues)
Set a slot with a list of values. |
void |
setSlot(java.lang.String slotName,
java.lang.String slotValue)
Set a slot with a single values. |
void |
setType(java.lang.String type)
Set the type of this mob. |
java.lang.String |
toString()
Represent the Mob as a string. |
java.lang.String |
toXML()
Convert the Mob to XML. |
java.lang.String |
toXML(java.lang.String initIndent,
java.lang.String otherIndent)
Convert the Mob to XML. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Mob(java.lang.String type)
type
- The type of the Mob to be created, which must be non-null and non-empty
java.lang.IllegalArgumentException
- if type is either null or an empty string.public Mob(Mob mob)
mob
- Method Detail |
---|
public void setType(java.lang.String type)
type
- the new type for the mob, which must not be null or have length zero
java.lang.IllegalArgumentException
- if type is null.public java.lang.String getType()
public void setName(java.lang.String name)
WARNING: Generally, only the blackboard should set the name of a Mob. Changing the name will generally break references between Mobs.
name
- the new name for the mob, whichmust not be null
java.lang.IllegalArgumentException
- if name is null.public java.lang.String getName()
public void setPersistence(java.lang.String persistence)
persistence
- the new persistence value for this mob. Must be equal to one of
the persistence constants defined in MicaConstants
java.lang.IllegalArgumentException
- if the persistence is not a known valueMicaConstants
public java.lang.String getPersistence()
MicaConstants.PERSISTENCES
)
MicaConstants
public long getCreationTime()
public java.lang.String getCreator()
public long getDeletionTime()
public java.lang.String getDeleter()
public boolean hasSlot(java.lang.String slotName)
slotName
- Name of the slot
public java.util.List getSlot(java.lang.String slotName)
This returns a list of values associated with the slot.
slotName
- Name of the slot you want to get the vector for.
public int getSlot1AsInt(java.lang.String slotName)
slotName
- the name of the slot for which the first element is required
public double getSlot1AsDouble(java.lang.String slotName)
Double.NaN
slotName
- the name of the slot for which the first element is required
public java.lang.String getSlot1(java.lang.String slotName)
This version only gets the first element of the slot. It is often useful if you know that the slot only has one value.
slotName
- The name of the slot to retrieve the values for.
public java.lang.String getSlotN(java.lang.String slotName, int n)
slotName
- The name of the slot from which to retrieve the value.
public void setSlot(java.lang.String slotName, java.util.List slotValues)
This sets the slot to have a list of values.
To add a value to an existing slot, used addSlot instead.
slotName
- The slot to setslotValues
- The list of values for the slot.public void setSlot(java.lang.String slotName, java.lang.String slotValue)
This sets the slot to have a a single value.
To add a value to an existing slot, used addSlot instead.
slotName
- The slot to setslotValue
- The new value for the slot.public void removeSlot(java.lang.String slotName)
slotName
- the name of the slot to removepublic java.util.Set getSlots()
public void addSlot(java.lang.String slotName, java.lang.String value)
slotName
- the name of the slotvalue
- the value to add to the slot, which must be non-null
java.lang.IllegalArgumentException
- if value is null.public void addSlot(java.lang.String slotName, java.util.List values)
slotName
- the name of the slotvalues
- the values to add to the slot, which must be non-null
java.lang.IllegalArgumentException
- if values is null or any element or values is nullpublic void addEmptySlot(java.lang.String slotName)
This function is convenient for sometimes creating a slot, so that the Mob has a slot, but has no values stored in it.
slotName
- the new slot namepublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toXML(java.lang.String initIndent, java.lang.String otherIndent)
This is sometimes convenient, when you want to output a string in XML.
initIndent
- The initial indentation of the first line of the XML. Every
line will begin with this initial indentation.otherIndent
- The indent for subsequent lines. Each line will be indented by
this string for each level of nesting of the XML structure.
public java.lang.String toXML()
This method simply calls toXML("","\t")
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |