public class BeanOntology extends Ontology
Ontology
that allows to build the
ontological elements adding directly the classes of the
corresponding JavaBeans.
The BeanOntology
internally needs to use its introspector
BeanIntrospector
. A typical pattern to create an ontology
extending the BeanOntology
is 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(); } } }
MyOntology
will be built creating the hierarchy
of ontological items defined by the beans in package com.acme.rocket.ontology
plus the two beans C1
and C2
.
An ontological bean is a class implementing either Concept
or Predicate
Example:
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; } }
Concept
,
Predicate
,
Element
,
Slot
,
SuppressSlot
,
AggregateSlot
,
Result
,
AggregateResult
,
Ontology
,
BasicOntology
,
Serialized FormConstructor and Description |
---|
BeanOntology(java.lang.String name)
Create an Ontology with the given
name . |
BeanOntology(java.lang.String name,
Ontology base)
Create an Ontology with the given
name that
extends the ontology base , which must have
BasicOntology in its hierarchy. |
BeanOntology(java.lang.String name,
Ontology[] base)
Create an Ontology with the given
name that
extends the base set of ontologies. |
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.Class clazz)
Adds to the ontology the schema built from the class
clazz . |
void |
add(java.lang.Class clazz,
boolean buildHierarchy)
Adds to the ontology the schema built from the class
clazz . |
void |
add(java.lang.String pkgname)
Adds all the ontological beans (the ones which implement either
Concept or Predicate ) found in the
specified package. |
void |
add(java.lang.String pkgname,
boolean buildHierarchy)
Adds all the ontological beans (the ones which implement either
Concept or Predicate ) found in the
specified package. |
add, add, checkIsTerm, createConceptSlotFunction, dump, dump, externalizeSlotValue, fromObject, getActionNames, getClassForElement, getConceptNames, getIntrospector, getName, getOwnActionNames, getOwnConceptNames, getOwnPredicateNames, getPredicateNames, getReferencedSchemas, getSchema, getSchema, internalizeSlotValue, isBaseOntology, toObject, toString, useConceptSlotsAsFunctions
public BeanOntology(java.lang.String name)
name
.
The BasicOntology
is automatically added
as the base ontology.name
- The identifier of the ontology.public BeanOntology(java.lang.String name, Ontology base)
name
that
extends the ontology base
, which must have
BasicOntology
in its hierarchy.name
- The identifier of the ontology.base
- The base ontology.public BeanOntology(java.lang.String name, Ontology[] base)
name
that
extends the base
set of ontologies. At least
one of the base
ontologies must extend the
ontology BasicOntology
.name
- The identifier of the ontology.base
- The base ontologiespublic void add(java.lang.Class clazz) throws BeanOntologyException
clazz
.
The class must implement either Concept
or Predicate
.clazz
- class from which to build the ontological schemaBeanOntologyException
public void add(java.lang.String pkgname) throws BeanOntologyException
Concept
or Predicate
) found in the
specified package.pkgname
- name of the package containing the beansBeanOntologyException
public void add(java.lang.Class clazz, boolean buildHierarchy) throws BeanOntologyException
clazz
.
The class must implement either Concept
or Predicate
.clazz
- class from which to build the ontological schemabuildHierarchy
- if true
, build the full hierarchy
ontological elements. Otherwise, build a set of
flat unrelated elementsBeanOntologyException
public void add(java.lang.String pkgname, boolean buildHierarchy) throws BeanOntologyException
Concept
or Predicate
) found in the
specified package.pkgname
- name of the package containing the beansbuildHierarchy
- if true
, build the full hierarchy
ontological elements. Otherwise, build a set of
flat unrelated elementsBeanOntologyException