Package jade.content
Class ContentManager
- java.lang.Object
-
- jade.content.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 aContentManagerobject accessible through thegetContentManager()method of theAgentclass.- Author:
- Federico Bergenti, Govanni Caire - TILAB
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ContentManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AbsContentElementextractAbsContent(ACLMessage msg)Translates the:contentslot of anACLMessage msginto anAbsContentElementusing the content language and ontology indicated in the:languageand:ontologyfields ofmsg.ContentElementextractContent(ACLMessage msg)Translates the:contentslot of anACLMessage msginto aContentElementusing the content language and ontology indicated in the:languageand:ontologyfields ofmsg.voidfillContent(ACLMessage msg, AbsContentElement content)Fills the:contentslot of anACLMessage msgusing the content language and ontology indicated in the:languageand:ontologyfields ofmsg.voidfillContent(ACLMessage msg, ContentElement content)Fills the:contentslot of anACLMessage msgusing the content language and ontology indicated in the:languageand:ontologyfields ofmsg.String[]getLanguageNames()OntologygetOntology(ACLMessage msg)String[]getOntologyNames()booleangetValidationMode()Return the currently set validation mode i.e.CodeclookupLanguage(String name)Retrieves a previously registeredCodecgiving itsname.OntologylookupOntology(String name)Retrieves a previously registeredOntologygiving itsname.voidregisterLanguage(Codec c)Registers aCodecfor a given content language with its default name (i.e.voidregisterLanguage(Codec c, String name)Registers aCodecfor a given content language with a given name.voidregisterOntology(Ontology o)Registers anOntologywith its default name (i.e.voidregisterOntology(Ontology o, String name)Registers anOntologywith a given name.voidsetValidationMode(boolean mode)Set the validation mode i.e.StringtoString()
-
-
-
Method Detail
-
registerLanguage
public void registerLanguage(Codec c)
Registers aCodecfor a given content language with its default name (i.e. the name returned by itsgetName()method. Since this operation is performed the agent that owns thisContentManageris able to "speak" the language corresponding to the registeredCodec.- Parameters:
c- theCodecto be registered.
-
registerLanguage
public void registerLanguage(Codec c, String name)
Registers aCodecfor a given content language with a given name.- Parameters:
c- theCodecto be registered.name- the name associated to the registered codec.
-
registerOntology
public void registerOntology(Ontology o)
Registers anOntologywith its default name (i.e. the name returned by itsgetName()method. Since this operation is performed the agent that owns thisContentManager"knows" the registeredOntology.- Parameters:
o- theOntologyto be registered.
-
registerOntology
public void registerOntology(Ontology o, String name)
Registers anOntologywith a given name.- Parameters:
o- theOntologyto be registered.name- the name associated to the registered Ontology.
-
lookupLanguage
public Codec lookupLanguage(String name)
Retrieves a previously registeredCodecgiving itsname.- Parameters:
name- the name associated to theCodecto be retrieved.- Returns:
- the
Codecassociated tonameornullif no Codec was registered with the given name.
-
lookupOntology
public Ontology lookupOntology(String name)
Retrieves a previously registeredOntologygiving itsname.- Parameters:
name- the name associated to theOntologyto be retrieved.- Returns:
- the
Ontologyassociated tonameornullif no Ontology was registered with the given name.
-
fillContent
public void fillContent(ACLMessage msg, AbsContentElement content) throws Codec.CodecException, OntologyException
Fills the:contentslot of anACLMessage msgusing the content language and ontology indicated in the:languageand:ontologyfields ofmsg.- Parameters:
msg- the message whose content has to be filled.content- the content of the message represented as anAbsContentElement.- Throws:
Codec.CodecException- ifcontentis not compliant to the content language used for this operation.OntologyException- ifcontentis not compliant to the ontology used for this operation.
-
fillContent
public void fillContent(ACLMessage msg, ContentElement content) throws Codec.CodecException, OntologyException
Fills the:contentslot of anACLMessage msgusing the content language and ontology indicated in the:languageand:ontologyfields ofmsg.- Parameters:
msg- the message whose content has to be filled.content- the content of the message represented as aContentElement.- Throws:
Codec.CodecException- ifcontentis not compliant to the content language used for this operation.OntologyException- ifcontentis not compliant to the ontology used for this operation.
-
extractAbsContent
public AbsContentElement extractAbsContent(ACLMessage msg) throws Codec.CodecException, OntologyException
Translates the:contentslot of anACLMessage msginto anAbsContentElementusing the content language and ontology indicated in the:languageand:ontologyfields ofmsg.- 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:contentslot of anACLMessage msginto aContentElementusing the content language and ontology indicated in the:languageand:ontologyfields ofmsg.- 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 istrue- 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 istrue- Returns:
- the currently set validation mode
-
getOntology
public Ontology getOntology(ACLMessage msg)
-
getLanguageNames
public String[] getLanguageNames()
-
getOntologyNames
public String[] getOntologyNames()
-
-