fipaos.agent.conversation.content
Class Content


public class Content

This class encapsulates content information in the form:

this has an attribute with a value of value

In general, the information contained within a Content object is either: a) Other Content objects (forming a tree like structure); b) Double objects; c) Long objects; or d) String objects (anything which doesn't fit catergories a-c).


Constructor Summary
Content()
          Creates a completely blank Content object with no attributes and no name
Content(String name)
          Creates a completely blank Content object with the given name
Content(Map content)
          Constructs a Content object using the given Map as a basis for the internal data structure.
Content(Content c)
          This Constructor will clone the structure of the Content object given in a manner which completely decouples this from the given Content object (i.e.

Method Summary
 synchronized voidaddAttribute(String name, Object value)
          This method associates the specified value with the specified attribute.
 synchronized voidaddAttribute(String name, List value)
          This method associates the specified values with the specified attribute.
 ObjectgetAttribute(String name)
          This method returns the value to which the given attribute maps to.
 SetgetAttributeNames()
          This method returns a Set of the attribute names contained in this Content object.
 StringgetName()
          Method to get the name of this Content object
 booleanisEmpty()
          This method indicates if this Content object has no attributes associated with it.
 synchronized voidremoveAttribute(String name)
          This method removes the mapping for this attribute from this if it is present.
 synchronized voidsetAttribute(String name, Object value)
          This method associates the specified value with the specified attribute.
 synchronized voidsetAttribute(String name, List values)
          This method associates the specified values with the specified attribute.
 StringtoString(String pre)
          This is a toString method which returns a String representation of this, each line pre-fixed with the given String.
 StringtoString()
          This is the public toString method which returns a String.

Constructor Detail

Content

public Content()
Creates a completely blank Content object with no attributes and no name

Content

public Content(String name)
Creates a completely blank Content object with the given name
Parameters:
name - The name of this particular Content object

Content

public Content(Map content)
Constructs a Content object using the given Map as a basis for the internal data structure. DO NOT USE THIS CONSTRUCTOR - The internal representation of the Content object may change at a later date
Parameters:
content - The Map upon which the internal data structure should be based

Content

public Content(Content c)
This Constructor will clone the structure of the Content object given in a manner which completely decouples this from the given Content object (i.e. it is recursively cloned - modifiying one object referenced directly or indirectly by this will have no effect on the objects directly or indirectly referenced by the given Content object).
Parameters:
content - The Content object to "clone"
Method Detail

addAttribute

public synchronized void addAttribute(String name, Object value)
This method associates the specified value with the specified attribute. If the attribute already exists, a List will be created to hold both values, else if a List has already been created, the value will be appended to the list.

addAttribute() does not overwrite attributes. It is suggested that if this is the desired operation, setAttribute() is used instead.

Parameters:
name - The attribute name to add the value to
value - The value to associate with the attribute

addAttribute

public synchronized void addAttribute(String name, List value)
This method associates the specified values with the specified attribute. If the attribute already exists, a List will be created to hold the current values and the new values

addAttribute() does not overwrite attributes. It is suggested that if this is the desired operation, setAttribute() is used instead.

Parameters:
name - The attribute name to add the value to
values - The values to associate with the attribute

getAttribute

public Object getAttribute(String name)
This method returns the value to which the given attribute maps to. In the case that this is a 1..N mapping, the object will be a List instance
Parameters:
name - The name of the attribute for which to retreive the associated value
Returns: Either the object associated with the attribute, or a List containing multiple objects, or null if there is no such attribute.

getAttributeNames

public Set getAttributeNames()
This method returns a Set of the attribute names contained in this Content object.
Returns: A Set containing all attributes of this Content object

getName

public String getName()
Method to get the name of this Content object
Returns: The name associated with this

isEmpty

public boolean isEmpty()
This method indicates if this Content object has no attributes associated with it.
Returns: True if this has no attributes

removeAttribute

public synchronized void removeAttribute(String name)
This method removes the mapping for this attribute from this if it is present.
Parameters:
name - The name of the attribute to remove

setAttribute

public synchronized void setAttribute(String name, Object value)
This method associates the specified value with the specified attribute. If the attribute already exists it will be over-written

Parameters:
name - The attribute name to add the value to
value - The value to associate with the attribute

setAttribute

public synchronized void setAttribute(String name, List values)
This method associates the specified values with the specified attribute. If the attribute already exists it will be over-written

Parameters:
name - The attribute name to add the value to
values - The values to associate with the attribute

toString

public String toString(String pre)
This is a toString method which returns a String representation of this, each line pre-fixed with the given String.
Parameters:
pre - The String to prefix to each line of the created String
Returns: A String representation of this

toString

public String toString()
This is the public toString method which returns a String.

Association Links

to Class java.util.Map

to Class java.lang.String