Owl2Jena – Usage & Requirements

Configuration

Primitive Type Mapping

Owl datatype properties are mapped to the corresponding java class (where applicable). The mapping table can be configured via the static xsd2javaName map in the class XsdMapConfig. For each java type a getXYZ method must be supplied as shown in the static javaName2Method map.

Namespaces

Namespaces with a given prefix are transfered to java packages. For classes and interfaces of namespaces without a prefix a new namespace of the notation “p1”, “p2″… is created.

Naming Conventions

By default all properties, classes and instances are named PropertynamePrefix, ClassnamePrefix and IInterfacenamePrefix respectively. This can be configured via static variables in de.incunabulum.owl2java.model.jmodel.utils.NamingUtils.

For any property prefixed by has, is like hasName this prefix is removed if (and only if) no other property just named name exists. This can be configured via static variables in de.incunabulum.owl2java.model.jmodel.utils.NamingUtils with propertyIgnoredPrefixes, propertyStripPrefixes.

Running the API generator

The main generator class for running the generator is de.incunabulum.owl2java.JenaGenerator. To run the generator, execute one of the three generate methods. A base directory for the generated java classes as well as a java base package must be supplied.

Also, the following configuration options are avaibale via setter methods:

  • setToolsPackage: Defines the package name for the tools package. In this package vocabulary, test case class and factory class are generated
  • setFactoryName: The class name of the factory class. This class is used to register all generated classes with jena etc.
  • setVocabularyName: The class name of the vocabulary class. This classs contains jena compliant definitions of all properties and classes in the owl model.
  • setTestCaseName: The class name for the test class. Also includes a static main() function to run the tests directly.
  • setCreateTestClass: If set to true (default), the test class is generated
  • setReassignDomainlessProperties: If set to true (default) for all properties without a range the range is changed to the classes highest up in the class hierarchy with a retriction on the property.

Using the API

Basically, running the java bindings requires a OntModel pointing to a valid ontology. The generated classes are registered in jena as custom classes via:

  Factory factory = new Factory();
  factory.registerImports(ontModel, ontology);
  factory.registerCustomClasses();

Instance creation is done via the create() methods of the required class. Property access is performed via the getX, setX, listX, removeX methods.

For more details, run the generator and have a look a the generated test class.

Requirements

Currently, the Jakuzi Generator depends on the following libraries

The runtime, i. e. the generated API depends on Jena and Apache Commons Logging only. Apache Commons Codec is required for the mapping from Hex to Ascii-encoded strings etc.