The code generator generates fields and getter / setter methods for each slot, thereby respecting settings such as name, type, default value, and cardinality (see Figure 10.4, “Protégé Slot Options”). For slots that allow multiple values, also add / remove methods are generated. Supported slot types and their default Java mappings are:
Table 10.1. Slot to Java type mappings
Slot Type | Java Type |
---|---|
Any | n/a |
Boolean |
boolean
|
Class | n/a |
Float |
double
|
Instance | a java class |
Integer |
int
|
String |
java.lang.String
|
Symbol |
java.lang.String
|
The name to use for the generated field can be specified using the attribute name
option. The Beanynizer has its own idea of Java coding conventions and tries to create a
suitable Java name from the slot name, when no specific attribute name is given. The
attribute type allows to change the generated Java type, by specifying a fully qualified
class name, or one of the basic types (e.g. long). The names of getter and setter
methods are derived from the attribute name (which may also be derived from the slot
name). Use the get method and set method options to change the names of the methods to
generate. This is especially helpful, when including already existing classes in the
ontology.
The pure Java ontology supports two other settings for slots: "transient" and "external".
For transient slots, the field is generated with the transient
keyword.
External slots are ignored during code generation (this is useful, if the ontology class extends an
existing Java class, which already provides the get/set methods for a given slot).