jade.content.abs
Class AbsHelper

java.lang.Object
  extended by jade.content.abs.AbsHelper

public class AbsHelper
extends java.lang.Object

Author:
Federico Bergenti - Universita` di Parma, Giovanni Caire - TILAB

Constructor Summary
AbsHelper()
           
 
Method Summary
static AbsObject addPrefix(AbsObject abs, java.lang.String prefix)
          Recursively add prefix to abs-type-name, except for BasicOntology types Eg.
static AbsObject applyDefaultValues(AbsObject absTemplate, AbsObject absDefault)
          Apply default value to template Replace node with default value only if the value in template is null or AbsVariable or default value is null and template is a true template
static AbsObject createAbsTemplate(java.lang.Class clazz, Ontology onto)
          Generate an AbsObject consistently with class.
static AbsObject createAbsTemplate(ObjectSchema schema)
          Generate an AbsObject consistently with schema.
static AbsObject createAbsTemplate(ObjectSchema schema, java.lang.String prefix)
          Generate an AbsObject consistently with schema.
static AbsAgentAction externaliseACLMessage(ACLMessage obj, Ontology onto)
          Converts an ACLMessage into an AbsAgentAction using the specified ontology.
static AbsConcept externaliseAID(AID obj)
          Converts an AID into an AbsConcept representing an AID
static AbsContentElementList externaliseContentElementList(ContentElementList obj, Ontology onto)
          Converts a ContentElementList into an AbsContentElementList using the specified ontology.
static AbsAggregate externaliseIterator(java.util.Iterator obj, Ontology onto, java.lang.String AggregateType)
          Converts an Iterator into a AbsAggregate using the specified ontology.
static AbsAggregate externaliseList(List obj, Ontology onto, java.lang.String AggregateType)
          Converts a List into a AbsAggregate using the specified ontology.
static AbsAggregate externaliseSet(Set obj, Ontology onto, java.lang.String AggregateType)
          Converts a Set into a AbsAggregate using the specified ontology.
static OntoACLMessage internaliseACLMessage(AbsAgentAction absMsg, Ontology onto)
          Converts to an AbsAgentAction representing an ACLMessage into an OntoACLMessage using the specified ontology.
static OntoAID internaliseAID(AbsConcept aid)
          Converts an AbsConcept representing an AID into an OntoAID
static ContentElementList internaliseContentElementList(AbsContentElementList l, Ontology onto)
          Converts to an AbsContentElementList into a ContentElementList using the specified ontology.
static java.util.Collection internaliseJavaCollection(AbsAggregate aggregate, Ontology onto)
          Converts an AbsAggregate into a List using the specified ontology.
static List internaliseList(AbsAggregate aggregate, Ontology onto)
          Converts an AbsAggregate into a List using the specified ontology.
static Set internaliseSet(AbsAggregate aggregate, Ontology onto)
          Converts an AbsAggregate into a Set using the specified ontology.
static boolean isAbsTemplate(AbsObject abs)
          Return true if the abs-object is a template.
static AbsObject nullifyVariables(AbsObject abs, boolean removeEmptyAggregate)
          Remove all variables and empty aggregates (only if specified)
static AbsObject removePrefix(AbsObject abs, java.lang.String separator)
          Recursively removes prefix (if present) from abs-type-name, except for BasicOntology types Prefix is identified from last separator string Eg.
static void setAttribute(AbsObject abs, java.lang.String attrName, AbsObject attrValue)
          Set an attribute in an abstract descriptor performing all necessary type checks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbsHelper

public AbsHelper()
Method Detail

externaliseList

public static AbsAggregate externaliseList(List obj,
                                           Ontology onto,
                                           java.lang.String AggregateType)
                                    throws OntologyException
Converts a List into a AbsAggregate using the specified ontology.

Parameters:
obj - the List
onto - the ontology.
Returns:
the abstract descriptor.
Throws:
OntologyException

externaliseSet

public static AbsAggregate externaliseSet(Set obj,
                                          Ontology onto,
                                          java.lang.String AggregateType)
                                   throws OntologyException
Converts a Set into a AbsAggregate using the specified ontology.

Parameters:
obj - the Set
onto - the ontology.
Returns:
the abstract descriptor.
Throws:
OntologyException

externaliseIterator

public static AbsAggregate externaliseIterator(java.util.Iterator obj,
                                               Ontology onto,
                                               java.lang.String AggregateType)
                                        throws OntologyException
Converts an Iterator into a AbsAggregate using the specified ontology.

Parameters:
obj - the Iterator
onto - the ontology.
Returns:
the abstract descriptor.
Throws:
OntologyException

externaliseAID

public static AbsConcept externaliseAID(AID obj)
Converts an AID into an AbsConcept representing an AID

Parameters:
obj - the AID
Returns:
the abstract descriptor.

externaliseContentElementList

public static AbsContentElementList externaliseContentElementList(ContentElementList obj,
                                                                  Ontology onto)
                                                           throws OntologyException
Converts a ContentElementList into an AbsContentElementList using the specified ontology.

Parameters:
obj - the ContentElementList
onto - the ontology.
Returns:
the abstract descriptor.
Throws:
OntologyException

externaliseACLMessage

public static AbsAgentAction externaliseACLMessage(ACLMessage obj,
                                                   Ontology onto)
                                            throws OntologyException
Converts an ACLMessage into an AbsAgentAction using the specified ontology.

Parameters:
obj - the ACLMessage
onto - the ontology.
Returns:
the abstract descriptor.
Throws:
OntologyException

internaliseList

public static List internaliseList(AbsAggregate aggregate,
                                   Ontology onto)
                            throws OntologyException
Converts an AbsAggregate into a List using the specified ontology.

Parameters:
onto - the ontology
Returns:
the List
Throws:
OntologyException

internaliseSet

public static Set internaliseSet(AbsAggregate aggregate,
                                 Ontology onto)
                          throws OntologyException
Converts an AbsAggregate into a Set using the specified ontology.

Parameters:
onto - the ontology
Returns:
the Set
Throws:
OntologyException

internaliseJavaCollection

public static java.util.Collection internaliseJavaCollection(AbsAggregate aggregate,
                                                             Ontology onto)
                                                      throws OntologyException
Converts an AbsAggregate into a List using the specified ontology.

Parameters:
onto - the ontology
Returns:
the List
Throws:
OntologyException

internaliseAID

public static OntoAID internaliseAID(AbsConcept aid)
                              throws OntologyException
Converts an AbsConcept representing an AID into an OntoAID

Returns:
the OntoAID
Throws:
OntologyException - if aid does not represent a valid AID

internaliseContentElementList

public static ContentElementList internaliseContentElementList(AbsContentElementList l,
                                                               Ontology onto)
                                                        throws OntologyException
Converts to an AbsContentElementList into a ContentElementList using the specified ontology.

Parameters:
onto - the ontology
Returns:
the ContentElementList
Throws:
OntologyException

internaliseACLMessage

public static OntoACLMessage internaliseACLMessage(AbsAgentAction absMsg,
                                                   Ontology onto)
                                            throws OntologyException
Converts to an AbsAgentAction representing an ACLMessage into an OntoACLMessage using the specified ontology.

Parameters:
onto - the ontology
Returns:
the OntoACLMessage
Throws:
OntologyException

setAttribute

public static void setAttribute(AbsObject abs,
                                java.lang.String attrName,
                                AbsObject attrValue)
                         throws OntologyException
Set an attribute in an abstract descriptor performing all necessary type checks.

Throws:
OntologyException - if a type mismatch is detected

nullifyVariables

public static AbsObject nullifyVariables(AbsObject abs,
                                         boolean removeEmptyAggregate)
Remove all variables and empty aggregates (only if specified)

Parameters:
abs - to nullify
removeEmptyAggregate - if true remove all empty aggregates
Returns:
abs without variables and empty aggregates

removePrefix

public static AbsObject removePrefix(AbsObject abs,
                                     java.lang.String separator)
                              throws OntologyException
Recursively removes prefix (if present) from abs-type-name, except for BasicOntology types Prefix is identified from last separator string Eg. A.B.C -> C (if separator is .)

Parameters:
abs - abs to un-prefix
separator - separator string
Returns:
un-prefixde abs
Throws:
OntologyException

addPrefix

public static AbsObject addPrefix(AbsObject abs,
                                  java.lang.String prefix)
                           throws OntologyException
Recursively add prefix to abs-type-name, except for BasicOntology types Eg. C -> A.B.C (if prefix is A.B.)

Parameters:
abs - abs to prefix
prefix - prefix to add
Returns:
prefix abs
Throws:
OntologyException

isAbsTemplate

public static boolean isAbsTemplate(AbsObject abs)
Return true if the abs-object is a template. A template is an abs with all slots AbsVariable or AbsAggregate empty

Parameters:
abs - abs-object to check
Returns:
true if is a template

applyDefaultValues

public static AbsObject applyDefaultValues(AbsObject absTemplate,
                                           AbsObject absDefault)
                                    throws OntologyException
Apply default value to template Replace node with default value only if the value in template is null or AbsVariable or default value is null and template is a true template

Parameters:
absTemplate - abs template value
absDefault - abs value with default value
Returns:
Throws:
OntologyException

createAbsTemplate

public static AbsObject createAbsTemplate(java.lang.Class clazz,
                                          Ontology onto)
                                   throws OntologyException
Generate an AbsObject consistently with class.

Parameters:
clazz - class to convert
onto - reference ontology
Returns:
abs-object
Throws:
OntologyException

createAbsTemplate

public static AbsObject createAbsTemplate(ObjectSchema schema)
                                   throws OntologyException
Generate an AbsObject consistently with schema.

Parameters:
schema - to convert
Returns:
abs-object
Throws:
java.lang.Exception
OntologyException

createAbsTemplate

public static AbsObject createAbsTemplate(ObjectSchema schema,
                                          java.lang.String prefix)
                                   throws OntologyException
Generate an AbsObject consistently with schema. All variables are prefixed

Parameters:
schema - to convert
prefix - for variable
Returns:
abs-object
Throws:
java.lang.Exception
OntologyException