jade.content
Class ContentManager

java.lang.Object
  |
  +--jade.content.ContentManager

public class ContentManager
extends java.lang.Object
implements Serializable

This class provides all methods to manage the content languages and ontologies "known" by a given agent and to fill and extract the content of an ACL message according to a given content language and ontology. Each agent has a ContentManager object accessible through the getContentManager() method of the Agent class.

Author:
Federico Bergenti, Govanni Caire - TILAB
See Also:
Serialized Form

Constructor Summary
ContentManager()
           
 
Method Summary
 AbsContentElement extractAbsContent(ACLMessage msg)
          Translates the :content slot of an ACLMessage msg into an AbsContentElement using the content language and ontology indicated in the :language and :ontology fields of msg.
 ContentElement extractContent(ACLMessage msg)
          Translates the :content slot of an ACLMessage msg into a ContentElement using the content language and ontology indicated in the :language and :ontology fields of msg.
 void fillContent(ACLMessage msg, AbsContentElement content)
          Fills the :content slot of an ACLMessage msg using the content language and ontology indicated in the :language and :ontology fields of msg.
 void fillContent(ACLMessage msg, ContentElement content)
          Fills the :content slot of an ACLMessage msg using the content language and ontology indicated in the :language and :ontology fields of msg.
 Ontology getOntology(ACLMessage msg)
           
 boolean getValidationMode()
          Return the currently set validation mode i.e. whether contents that are managed by this content manager should be validated during message content filling/extraction.
 Codec lookupLanguage(java.lang.String name)
          Retrieves a previously registered Codec giving its name.
 Ontology lookupOntology(java.lang.String name)
          Retrieves a previously registered Ontology giving its name.
 void registerLanguage(Codec c)
          Registers a Codec for a given content language with its default name (i.e. the name returned by its getName() method.
 void registerLanguage(Codec c, java.lang.String name)
          Registers a Codec for a given content language with a given name.
 void registerOntology(Ontology o)
          Registers an Ontology with its default name (i.e. the name returned by its getName() method.
 void registerOntology(Ontology o, java.lang.String name)
          Registers an Ontology with a given name.
 void setValidationMode(boolean mode)
          Set the validation mode i.e. whether contents that are managed by this content manager should be validated during message content filling/extraction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentManager

public ContentManager()
Method Detail

registerLanguage

public void registerLanguage(Codec c)
Registers a Codec for a given content language with its default name (i.e. the name returned by its getName() method. Since this operation is performed the agent that owns this ContentManager is able to "speak" the language corresponding to the registered Codec.
Parameters:
c - the Codec to be registered.

registerLanguage

public void registerLanguage(Codec c,
                             java.lang.String name)
Registers a Codec for a given content language with a given name.
Parameters:
c - the Codec to be registered.
name - the name associated to the registered codec.

registerOntology

public void registerOntology(Ontology o)
Registers an Ontology with its default name (i.e. the name returned by its getName() method. Since this operation is performed the agent that owns this ContentManager "knows" the registered Ontology.
Parameters:
o - the Ontology to be registered.

registerOntology

public void registerOntology(Ontology o,
                             java.lang.String name)
Registers an Ontology with a given name.
Parameters:
o - the Ontology to be registered.
name - the name associated to the registered Ontology.

lookupLanguage

public Codec lookupLanguage(java.lang.String name)
Retrieves a previously registered Codec giving its name.
Parameters:
name - the name associated to the Codec to be retrieved.
Returns:
the Codec associated to name or null if no Codec was registered with the given name.

lookupOntology

public Ontology lookupOntology(java.lang.String name)
Retrieves a previously registered Ontology giving its name.
Parameters:
name - the name associated to the Ontology to be retrieved.
Returns:
the Ontology associated to name or null if no Ontology was registered with the given name.

fillContent

public void fillContent(ACLMessage msg,
                        AbsContentElement content)
                 throws Codec.CodecException,
                        OntologyException
Fills the :content slot of an ACLMessage msg using the content language and ontology indicated in the :language and :ontology fields of msg.
Parameters:
msg - the message whose content has to be filled.
content - the content of the message represented as an AbsContentElement.
Throws:
CodecException - if content is not compliant to the content language used for this operation.
OntologyException - if content is not compliant to the ontology used for this operation.

fillContent

public void fillContent(ACLMessage msg,
                        ContentElement content)
                 throws Codec.CodecException,
                        OntologyException
Fills the :content slot of an ACLMessage msg using the content language and ontology indicated in the :language and :ontology fields of msg.
Parameters:
msg - the message whose content has to be filled.
content - the content of the message represented as a ContentElement.
Throws:
CodecException - if content is not compliant to the content language used for this operation.
OntologyException - if content is not compliant to the ontology used for this operation.

extractAbsContent

public AbsContentElement extractAbsContent(ACLMessage msg)
                                    throws Codec.CodecException,
                                           OntologyException
Translates the :content slot of an ACLMessage msg into an AbsContentElement using the content language and ontology indicated in the :language and :ontology fields of msg.
Parameters:
msg - the message whose content has to be extracted.
Returns:
the content of the message represented as an AbsContentElement.
Throws:
CodecException - if the content of the message is not compliant to the content language used for this operation.
OntologyException - if the content of the message is not compliant to the ontology used for this operation.

extractContent

public ContentElement extractContent(ACLMessage msg)
                              throws Codec.CodecException,
                                     UngroundedException,
                                     OntologyException
Translates the :content slot of an ACLMessage msg into a ContentElement using the content language and ontology indicated in the :language and :ontology fields of msg.
Parameters:
msg - the message whose content has to be extracted.
Returns:
the content of the message represented as a ContentElement.
Throws:
CodecException - if the content of the message is not compliant to the content language used for this operation.
OntologyException - if the content of the message is not compliant to the ontology used for this operation.

setValidationMode

public void setValidationMode(boolean mode)
Set the validation mode i.e. whether contents that are managed by this content manager should be validated during message content filling/extraction. Default value is true
Parameters:
mode - the new validation mode

getValidationMode

public boolean getValidationMode()
Return the currently set validation mode i.e. whether contents that are managed by this content manager should be validated during message content filling/extraction. Default value is true
Returns:
the currently set validation mode

getOntology

public Ontology getOntology(ACLMessage msg)