Application Design

A short overview over the interanls of owl2java. The intermediary meta model and the generation process are described.

Similar to rdfreactor owl2java uses an intermediary meta model. With such an approach additional transformation steps can be applied to the meta model without changing the underlying ontology.

Meta Model

The objective of the meta model is to capture all relevant information of the ontology as native java objects. For this purpose the meta model (JModel) offers classes to handle packages (JPackage), classes (JClass), properties (JProperty) and property restrictions (JOnPropertyRestriction) as well as property representations (JPropertyRepresentation). All instance of the model classes are linked together via appropriate references.

As owl2java generates an individual java package for each namespace in an ontology a JPackage contains all classes, properties and restrictions for a certain namespace. A JClass instance holds information about an OWL class like name, uri, it’s properties, any restrictions etc. JProperty instances are used to define the characteristics of a property like domain, range, uri etc. Restrictions for a property are captured with a JOnPropertyRestriction and link the restricted property with the corresponding class. A JPropertyRepresentation is the representation of a property in a certain class with all valid restrictions taken into account.

Using the enhanced graph features offered by Jena generated classes are subclassed from IndividualImpl and are registered as BuiltinPersonality. This allows easy conversion from of instance from one class type to another.

Generation Process

The genneration process can be summarized as follows:

  • Read the model: The model is read from an URI and a Jena OntModel is created. All imports are processed
  • Analyze the model: As an intermediary step the model is analyzed. Namespaces are determined and additional prefixes for unprefixed namespaces are generated.
  • Create the JModel: For each class and property in the ontology the corresponding JModel representation is created as JClass or JProperty and assigned to the relevant package. If needed, anonymous classes (union classes etc.) are converted to named classes. Restrictions are analyzed, the relevant JOnPropertyRestrictions are created. The hierarchy of properties and classes is stored in graphs.
  • Prepare the JModel: An additional step is performed to prepare the JModel for writing it to disk. Here, consistency checks are performed. Also, for each class all relevant properties and restrictions are aggregated, i. e. properties of parent classes are copied to the class etc.
  • Write to Disk: The final JModel is written to disk. The package structure is created. For each class the corresponding Java class and interface files are generated. Vocabulary and factory classes are written in the helper (tools) package.