Java2OWL
Class J2OIndividualManager

Object
  extended by J2OIndividualManager

public class J2OIndividualManager
extends Object

This class is for mapping Java-Objects to OWL-individuals and vice versa.

It provides the following services:

  1. One can insert new Java-objects and create corresponding OWL-individuals
  2. If an attribute of a Java-object is changed, one can change the corresponding attribute of the OWL-individual.
  3. One can map OWL-individuals to Java-objects.

Since OWL allows for multiple inheritance, and Java does not, the system may map a single OWL-individual to several Java-objects. As an example an instance of a amphibian-vehicle (a subclass of Ship and Surface-Vehicle) would be mapped to both, a ship and a surface-vehicle. The correspondences are kept in the IndividualWrapper structure.


Method Summary
 void activateSynchronisation(boolean log, Object... iwrps)
          activates synchronisation for the objects in all given individual wrappers.
 J2OIndividualManager addPropertyValue(Object object, Method getter, Object key, Object value)
          This method forwards in an adder method the information that an object is to be added.
 void clear()
          clears all internal data about individuals.
 J2OIndividualManager clearPropertyValues(Object object, Method getter, Object values)
          This method can be called when an already mapped Java-object removes all attribute values.
 void deactivateSynchronisation(boolean log, Object... iwrps)
          deactivates synchronisation for the objects in all given individual wrappers.
 J2OIndividualManager exchangePropertyValue(Object object, Method getter, Object oldValue, Object newValue)
          This method can be called when an already mapped Java-object replaces an attribute value by a new one
 ArrayList<IndividualWrapper> getInstances(OWLClassExpression cle)
          uses the reasoner to find all instances of the class expression and maps them back to the Java-objects.
 ArrayList<IndividualWrapper> getInstances(String cle)
          uses the reasoner to find all instances of the class expression and maps them back to the Java-objects.
 IndividualWrapper getIWR(Object object)
           
 IndividualWrapper getIWR(OWLNamedIndividual individual)
           
 Set<IndividualWrapper> getIWRs(Class jcl)
          return the individual wrappers stored for the given class, or null if there are none.
 J2OManager getJ2OManager()
          returns the top manager.
 String getName()
          returns the name of the individual manager.
 IndividualWrapper individual2Java(OWLNamedIndividual individual)
          maps an OWL-individual to corresponding Java-objects.
static void main(String[] args)
           
 IndividualWrapper object2OWL(Object object)
          generates for a Java-object the corresponding OWL-individual.
 void reclassify(boolean forceReclassification, Object... iwrds)
          reclassifies all objects in the given individual wrappers.
 J2OIndividualManager removePropertyValue(Object object, Method getter, Object key, Object value)
          This method can be called when an already mapped Java-object removes an attribute value.
 void synchroniseWithOWL(Object... iwrps)
          synchronises the objects in the given individual wrappers with the corresponding OWL-individual.
 String toString()
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getJ2OManager

public J2OManager getJ2OManager()
returns the top manager.


getName

public String getName()
returns the name of the individual manager.


getIWRs

public Set<IndividualWrapper> getIWRs(Class jcl)
return the individual wrappers stored for the given class, or null if there are none.

Parameters:
jcl - a Java class
Returns:
the individual wrappers stored for the given class or the lowest superclass of jcl, or null if there are none at all.

getIWR

public IndividualWrapper getIWR(Object object)
Returns:
the individual wrapper for the object, or null if there is none.

getIWR

public IndividualWrapper getIWR(OWLNamedIndividual individual)
Returns:
the individual wrapper for the individual, or null if there is none.

activateSynchronisation

public void activateSynchronisation(boolean log,
                                    Object... iwrps)
activates synchronisation for the objects in all given individual wrappers.

Parameters:
iwrps - are single individual wrappers or arrays or collections of individual wrappers.
log - if 'true' then the activation is logged.

deactivateSynchronisation

public void deactivateSynchronisation(boolean log,
                                      Object... iwrps)
deactivates synchronisation for the objects in all given individual wrappers.

Parameters:
iwrps - are single individual wrappers or arrays or collections of individual wrappers.
log - if 'true' then the deactivation is logged.

clear

public void clear()
clears all internal data about individuals.


object2OWL

public IndividualWrapper object2OWL(Object object)
generates for a Java-object the corresponding OWL-individual.

Parameters:
object - an atomic Java object (no array or collection)
Returns:
the corresponding IndividualWrapper or null if something went wrong.

All attributes of the object, which are accessible by the annotated getter methods are also mapped to OWL-individuals. The axioms specifying the new OWL-individuals are generated, but not yet made effective. Therefore you can generate mappings for several Java-objects first and then call applyChanges. If the generation of the mapping fails at some point, no axioms are inserted into the ontology manager.


addPropertyValue

public J2OIndividualManager addPropertyValue(Object object,
                                             Method getter,
                                             Object key,
                                             Object value)
This method forwards in an adder method the information that an object is to be added.

Parameters:
object - a Java-object whose attribute value is to be inserted/removed
getter - the name of the getter method
value - the atomic value to be inserted.
Returns:
the individual manager.

This method is called by the injected synchroniser code in add-methods for attribute values and updates the extension ontology.


removePropertyValue

public J2OIndividualManager removePropertyValue(Object object,
                                                Method getter,
                                                Object key,
                                                Object value)
This method can be called when an already mapped Java-object removes an attribute value.

Parameters:
object - a Java-object whose attribute value is to be inserted/removed
getter - the name of the getter method
value - either the atomic value to be removed, or the key if the property is a functional mapper.
Returns:
the individual manager.

This method is called by the injected synchroniser code in remove-methods for attribute values and updates the extension ontology.

If the property is relational and not a mapper, then the method is called within a remove method: removeItem(item).
If the property is a functional mapper then the method is called within a remove method removeItem(key), where the actual object to be removed is getter().get(key).


clearPropertyValues

public J2OIndividualManager clearPropertyValues(Object object,
                                                Method getter,
                                                Object values)
This method can be called when an already mapped Java-object removes all attribute values.

Parameters:
object - a Java-object whose attribute values are to be removed.
getter - the name of the getter method
values - the values to be removed.
Returns:
the individual manager.

This method is called by the injected synchroniser code in clearer methods for attribute values and updates the extension ontology.


exchangePropertyValue

public J2OIndividualManager exchangePropertyValue(Object object,
                                                  Method getter,
                                                  Object oldValue,
                                                  Object newValue)
This method can be called when an already mapped Java-object replaces an attribute value by a new one

Parameters:
object - a Java-object whose attribute value is to be inserted/removed
getter - a getter-method in the Java-class which is mapped to an OWL-property.
oldValue - the value to be removed.
newValue - the value to be inserted.
Returns:
the individual manager.

This method is called by the injected synchroniser code in setter methods for attribute values. The given method, however, should be the annotated getter-method.


synchroniseWithOWL

public void synchroniseWithOWL(Object... iwrps)
synchronises the objects in the given individual wrappers with the corresponding OWL-individual.

This method can be called if the object synchronisation has been turned off for a while.

Parameters:
iwrps - are single individual wrappers, arrays or collection of individual wrappers.
Throws:
ClassClastException - if the objects are not individual wrappers.

individual2Java

public IndividualWrapper individual2Java(OWLNamedIndividual individual)
maps an OWL-individual to corresponding Java-objects.

Parameters:
individual - an OWLNamedIndividual
Returns:
the corresponding IndividualWrapper or null, if, for example the OWL-classes are not mapped to Java classes. Since OWL allows for multiple inheritance, and Java does not, the system may map a single OWL-individual to several Java-objects. As an example an instance of a amphibian-vehicle (a subclass of Ship and Surface-Vehicle) would be mapped to both, a ship and a surface-vehicle. The correspondences are kept in the IndividualWrapper structure.

reclassify

public void reclassify(boolean forceReclassification,
                       Object... iwrds)
reclassifies all objects in the given individual wrappers.

Parameters:
iwrds - single individual wrappers, arrays or collections of individual wrappers.
forceReclassification - if this flag is false then reclassification is done only if some attributes have been changed since the last reclassification.
Throws:
ClassCastException - if the objects are not IndividualWrappers.

getInstances

public ArrayList<IndividualWrapper> getInstances(OWLClassExpression cle)
uses the reasoner to find all instances of the class expression and maps them back to the Java-objects.

Parameters:
cle - an OWLClassExpression.
Returns:
a list of IndividualWrapper which represent the Java-objects corresponding to the instances of class expression.

getInstances

public ArrayList<IndividualWrapper> getInstances(String cle)
                                          throws ParserException
uses the reasoner to find all instances of the class expression and maps them back to the Java-objects.

Parameters:
cle - an OWLClassExpression in Manchester Syntax
Returns:
a list of IndividualWrapper which represent the Java-objects corresponding to the instances of class expressions.
Throws:
ParserException

toString

public String toString()
Overrides:
toString in class Object
Returns:
a String-representation of the entire data.

main

public static void main(String[] args)