Package jade.content.onto
Class BeanOntology
- java.lang.Object
-
- jade.content.onto.Ontology
-
- jade.content.onto.BeanOntology
-
- All Implemented Interfaces:
Serializable,Serializable
public class BeanOntology extends Ontology
Extension ofOntologythat allows to build the ontological elements adding directly the classes of the corresponding JavaBeans. TheBeanOntologyinternally needs to use its introspectorBeanIntrospector. A typical pattern to create an ontology extending theBeanOntologyis the following:
The ontologypublic class MyOntology extends BeanOntology {
private static Ontology theInstance = new MyOntology(ONTOLOGY_NAME); public static Ontology getInstance() { return theInstance; } private MyOntology(String name) { super(name); try { add("com.acme.rocket.ontology"); add(C1.class); add(C2.class); } catch (OntologyException e) { e.printStackTrace(); } } }MyOntologywill be built creating the hierarchy of ontological items defined by the beans in packagecom.acme.rocket.ontologyplus the two beansC1andC2. An ontological bean is a class implementing eitherConceptorPredicateExample:
A set of annotatons allow to customize the ontological properties of the slots.public class CD extends Item { private String title; protected List tracks; public String getTitle() { return title; } public void setTitle(String t) { title = t; }@AggregateSlot(cardMin = 1) public List getTracks() { return tracks; } public void setTracks(List l) { tracks = l; } }- Author:
- Paolo Cancedda
- See Also:
Concept,Predicate,Element,Slot,SuppressSlot,AggregateSlot,Result,AggregateResult,Ontology,BasicOntology, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BeanOntology(String name)Create an Ontology with the givenname.BeanOntology(String name, Ontology base)Create an Ontology with the givennamethat extends the ontologybase, which must haveBasicOntologyin its hierarchy.BeanOntology(String name, Ontology[] base)Create an Ontology with the givennamethat extends thebaseset of ontologies.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Class clazz)Adds to the ontology the schema built from the classclazz.voidadd(Class clazz, boolean buildHierarchy)Adds to the ontology the schema built from the classclazz.voidadd(String pkgname)Adds all the ontological beans (the ones which implement eitherConceptorPredicate) found in the specified package.voidadd(String pkgname, boolean buildHierarchy)Adds all the ontological beans (the ones which implement eitherConceptorPredicate) found in the specified package.-
Methods inherited from class jade.content.onto.Ontology
add, add, checkIsTerm, createConceptSlotFunction, dump, dump, externalize, externalizeSlotValue, fromObject, fromObject, getActionNames, getClassForElement, getConceptNames, getIntrospector, getName, getOwnActionNames, getOwnConceptNames, getOwnPredicateNames, getPredicateNames, getReferencedSchemas, getSchema, getSchema, getSlotValue, internalize, internalizeSlotValue, isBaseOntology, setSlotValue, toObject, toObject, toString, useConceptSlotsAsFunctions
-
-
-
-
Constructor Detail
-
BeanOntology
public BeanOntology(String name)
Create an Ontology with the givenname. TheBasicOntologyis automatically added as the base ontology.- Parameters:
name- The identifier of the ontology.
-
BeanOntology
public BeanOntology(String name, Ontology base)
Create an Ontology with the givennamethat extends the ontologybase, which must haveBasicOntologyin its hierarchy.- Parameters:
name- The identifier of the ontology.base- The base ontology.
-
-
Method Detail
-
add
public void add(Class clazz) throws BeanOntologyException
Adds to the ontology the schema built from the classclazz. The class must implement eitherConceptorPredicate.- Parameters:
clazz- class from which to build the ontological schema- Throws:
BeanOntologyException
-
add
public void add(String pkgname) throws BeanOntologyException
Adds all the ontological beans (the ones which implement eitherConceptorPredicate) found in the specified package.- Parameters:
pkgname- name of the package containing the beans- Throws:
BeanOntologyException
-
add
public void add(Class clazz, boolean buildHierarchy) throws BeanOntologyException
Adds to the ontology the schema built from the classclazz. The class must implement eitherConceptorPredicate.- Parameters:
clazz- class from which to build the ontological schemabuildHierarchy- iftrue, build the full hierarchy ontological elements. Otherwise, build a set of flat unrelated elements- Throws:
BeanOntologyException
-
add
public void add(String pkgname, boolean buildHierarchy) throws BeanOntologyException
Adds all the ontological beans (the ones which implement eitherConceptorPredicate) found in the specified package.- Parameters:
pkgname- name of the package containing the beansbuildHierarchy- iftrue, build the full hierarchy ontological elements. Otherwise, build a set of flat unrelated elements- Throws:
BeanOntologyException
-
-