Package jade.content

Class ContentManager

  • All Implemented Interfaces:
    Serializable, Serializable

    public class ContentManager
    extends 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 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,
                                     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,
                                     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​(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​(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:
        Codec.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:
        Codec.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:
        Codec.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:
        Codec.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.
        UngroundedException
      • 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
      • getLanguageNames

        public String[] getLanguageNames()
      • getOntologyNames

        public String[] getOntologyNames()