Modello

This is a reference for the Modello descriptor used to describe a model with Modello.

<model xmlns="http://codehaus-plexus.github.io/MODELLO/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://codehaus-plexus.github.io/MODELLO/2.0.0 http://codehaus-plexus.github.io/modello/xsd/modello-2.0.0.xsd"
  java.suppressAllWarnings=.. xml.namespace=.. xml.schemaLocation=.. xsd.namespace=.. xsd.targetNamespace=.. >
  <id/>
  <name/>
  <description/>
  <comment/>

  <defaults>
    <default>
      <key/>
      <value/>
    </default>
  </defaults>
  <versionDefinition>
    <type/>
    <value/>
  </versionDefinition>

  <interfaces>
    <interface>
      <name/>
      <version/>
      <superInterface/>
      <packageName/>
      <annotations/>
      <description/>
      <comment/>
      <codeSegments>
        <codeSegment>
          <version/>
          <comment/>
          <code/>
        </codeSegment>
      </codeSegments>
    </interface>
  </interfaces>

  <classes>
    <class rootElement=.. javag.generateToString=.. xml.standaloneRead=.. locationTracker=.. sourceTracker=.. xml.tagName=.. xdoc.anchorName=.. java.enabled=.. java.abstract=.. java.clone=.. java.clone.hook=.. xsd.compositor=.. >
      <name/>
      <version/>
      <superClass/>
      <interfaces/>
      <packageName/>
      <annotations/>
      <description/>
      <comment/>
      <fields>
        <field java.getter=.. java.setter=.. xdoc.separator=.. xml.attribute=.. xml.content=.. xml.trim=.. xml.tagName=.. xml.format=.. xml.transient=.. xml.insertParentFieldsUpTo=.. >
          <name/>
          <alias/>
          <version/>
          <type/>
          <association java.adder=.. java.bidi=.. java.useInterface=.. java.init=.. java.clone=.. xml.tagName=.. xml.itemsStyle=.. xml.mapStyle=.. xml.reference=.. >
            <type/>
            <multiplicity/>
          </association>
          <defaultValue/>
          <required/>
          <identifier/>
          <annotations/>
          <description/>
          <comment/>
        </field>
      </fields>
      <codeSegments>
        <codeSegment>
          <version/>
          <comment/>
          <code/>
        </codeSegment>
      </codeSegments>
    </class>
  </classes>
</model>

model

Root tag for the description of a model.

Attribute Type Since Description
java.suppressAllWarnings boolean 1.1.0 Add @SuppressWarnings( "all" ) to all generated sources if Java 5 is enabled.

Default value is: true

.
xml.namespace String The namespace to use when generating XML content. Since Modello 1.0, this value can contain ${version} placeholder, which will be replaced by the model version during generation. Before Modello 1.0, this attribute was in class element.
xml.schemaLocation String The schemaLocation to use when generating XML content. Since Modello 1.0-alpha-13, this value can contain ${version} placeholder, which will be replaced by the model version during generation. Before Modello 1.0, this attribute was in class element.
xsd.namespace String The namespace to use when generating XSD. Since Modello 1.0:
  • if this value is not set, xml.namespace is used instead,
  • this value can contain ${version} placeholder, which will be replaced by the model version during generation.
xsd.targetNamespace String The targetNamespace to use when generating XSD. Since Modello 1.0
  • if this value is not set, xml.namespace or xsd.namespace is used instead,
  • this value can contain ${version} placeholder, which will be replaced by the model version during generation.
Element Type Since Description
id String Unique identifier of this model.
name String The name of the element.
description String A user-level description of the element.
comment String A private comment about the element.
defaults/default* List<ModelDefault> (Many) List of defaults settings for properties of this model.
versionDefinition VersionDefinition Information on model version recognition support.
interfaces/interface* List<ModelInterface> (Many) List of interfaces provided by the model.
classes/class* List<ModelClass> (Many) List of classes provided by the model.

default

A default setting for some of the properties of this model. Available properties are:

key since default value usage
package model The package where java classes are generated by default if no packageName defined in class or interface model
java.util.List new java.util.ArrayList<?>() The default code generated for List fields initialization
java.util.Set new java.util.HashSet<?>() The default code generated for Set fields initialization
java.util.Map new java.util.HashMap() The default code generated for Map fields initialization
java.util.Properties new java.util.Properties() The default code generated for Properties fields initialization
strictXmlAttributes 1.2 true If set to true, reading an XML document with strict parsing enabled not only checks elements but attributes too (new in Modello 1.2). Setting this property to false makes strict parsing behave like previously, ie ignoring attributes.
checkDeprecation false If set to true, checks that if a class has a version range with a specified upper version, its deprecatedVersion is not null
Element Type Since Description
key String The key to this property. Can be one of: checkDeprecation, package, java.util.List, java.util.Map, java.util.Properties, java.util.Set, strictXmlAttributes.
value String The value of this property.

versionDefinition

No description.

Element Type Since Description
type String The type of model version definition recognition. Can be one of: field, namespace, field+namespace.
value String If type contains field, the name of the field containing the model version.

interface

An interface provided by the model.

Element Type Since Description
name String The name of the element.
version String The versions related to this element. Examples: 1.0.0 (a precise version), 1.0.0+ (a version or higher), 1.0.0/2.0.0 (a version range).
superInterface String The name of the super interface for this interface.
packageName String The destination package name for this interface.
annotations/annotation* List<String> 1.3.0 (Many) Java annotations for the element (inserted in generated sources for the model only if Java 5 source generation feature is enabled).
description String A user-level description of the element.
comment String A private comment about the element.
codeSegments/codeSegment* List<CodeSegment> (Many) List of code segments appended to this interface.

codeSegment

A segment of code to be appended to this element.

Element Type Since Description
version String The versions related to this element. Examples: 1.0.0 (a precise version), 1.0.0+ (a version or higher), 1.0.0/2.0.0 (a version range).
comment String A private comment about the element.
code String The code block.

class

A class for this model.

Attribute Type Since Description
rootElement boolean Indicates that this class is the root of the model (only one class in a model can have this attribute set to true).

Default value is: false

.
javag.generateToString String 1.8.0 Will generate toString method for all fields of the class (disable per default). toString method is still generated per default for identifier field.
xml.standaloneRead boolean 1.4.1 If true, the xml reader will have read methods that allow to read xml that has this class as root element.

Default value is: false

.
locationTracker String 1.4.0 Indicates that this class is used to track line/column information (at most one class in a model can have this attribute set). The value of this attribute specifies the field name (in plural form, e.g. "locations") that will be used in all other model classes to store the location tracking information and indirectly controls the names of the generated accessors.
sourceTracker String 1.4.0 Indicates that this class is used to track source file information (at most one class in a model can have this attribute set). The value of this attribute specifies the field name (e.g. "source") that will be used in the class marked by locationTracker to store the source tracking information and indirectly controls the names of the generated accessors. This attribute is only relevant in combination with locationTracker and must not be used on the same class.
xml.tagName String Define a tag name to be used in XML content, which can be different from the class name.
xdoc.anchorName String 2.0.0 Define a anchor base name to be used in XML content, which can be different from the XML tag name name.
java.enabled boolean Enable or disable generation of a java source for this class in the model.

Default value is: true

.
java.abstract boolean Mark this class as abstract.

Default value is: false

.
java.clone String 1.1.0 Controls the generation of a clone() method for this class. Allowed values are none, shallow and deep. The value is inherited from super classes and defaults to none if no super class declares otherwise.
java.clone.hook String 1.1.0 Enables the usage of a custom hook method that will be called from the generated clone() method. The value of this attribute specifies the simple name of the hook method which is assumed to be provided as part of some code segment. For convenience, the boolean literal true can also be given to use the default method name cloneHook. The hook method itself must have a single parameter whose type matches this class in order to receive the cloned object for further manipulation before completion of the clone operation. Besides, the hook method must not have a return value and must not throw a checked exception.
xsd.compositor String Can be one of : all, sequence.

Default value is: all

.
Element Type Since Description
name String The name of the element.
version String The versions related to this element. Examples: 1.0.0 (a precise version), 1.0.0+ (a version or higher), 1.0.0/2.0.0 (a version range).
superClass String The name of the super class for this class.
interfaces/interface* List<String> (Many) A set of interfaces implemented by this class.
packageName String The destination package name for this class.
annotations/annotation* List<String> 1.3.0 (Many) Java annotations for the element (inserted in generated sources for the model only if Java 5 source generation feature is enabled).
description String A user-level description of the element.
comment String A private comment about the element.
fields/field* List<ModelField> (Many) Fields available in this class.
codeSegments/codeSegment* List<CodeSegment> (Many) List of code segments appended to this class.

field

A field to be defined in a class.

Attribute Type Since Description
java.getter boolean Generate a getter method for this field.

Default value is: true

.
java.setter boolean Generate a setter method for this field.

Default value is: true

.
xdoc.separator String Can be one of : blank.
xml.attribute boolean Consider this field as an XML attribute instead of an element.

Default value is: false

.
xml.content boolean 1.4.0 Consider this field as the content of the class' element.

Default value is: false

.
xml.trim boolean Trim the content when reading.

Default value is: true

.
xml.tagName String Define a tag name to be used in XML content, which can be different from the field name. May be '*' (since version 2.1.0) to allow all names (this effectively disables XSD validation of this field).
xml.format String The date format to use when parsing/writing a date (see java SimpleDateFormat).
xml.transient boolean 1.1.0 Whether this field should be excluded from parsers and writers. Fields marked as transient carry runtime state that is not meant to be persisted into XML.

Default value is: false

.
xml.insertParentFieldsUpTo String 1.2.0 Insert fields from parent class before this one in the XML representation of the class.
Element Type Since Description
name String The name of the element.
alias String Alias name for this field (a parser should allow for this name instead of the given name).
version String The versions related to this element. Examples: 1.0.0 (a precise version), 1.0.0+ (a version or higher), 1.0.0/2.0.0 (a version range).
type String Simple type for this field (or array of such type). Can be one of : boolean, byte, char, short, int, long, float, double, String, Boolean, Date, DOM.
association ModelAssociation An association allows to map a field to a complex type and/or to map a field to a many-multiplicity element.
defaultValue String The default value for this field.
required boolean Whether this field is required in model or not.

Default value is: false

.
identifier boolean Whether this field is part of the identification of the object or not.

Default value is: false

.
annotations/annotation* List<String> 1.3.0 (Many) Java annotations for the element (inserted in generated sources for the model only if Java 5 source generation feature is enabled).
description String A user-level description of the element.
comment String A private comment about the element.

association

An association allows for mapping of a field to a complex type, or to a many-multiplicity field.

Attribute Type Since Description
java.adder boolean Generate addFieldName( Type ) and removeFieldName( Type ) methods for this field (only for many multiplicity association).

Default value is: true

.
java.bidi boolean Generate createTypeAssociation( Type ) and breakTypeAssociation( Type ) methods for this field (only for a bi-directional association: each class of the association has an association to the other, either one or many multiplicity).

Default value is: true

.
java.useInterface String Use specified interface in generated methods signatures (add, remove, createAssociation and breakAssociation).
java.init String Can be one of : lazy, constructor, field.

Default value is: lazy

.
java.clone String 1.1.0 Allows to override the clone mode for this assocation. Allowed values are shallow and deep. If the value is not specified, the clone mode of the container class will be used.
xml.tagName String Define a tag name to be used for every element inside a multiple association. By default, the name is calculated as the singular of the field tag name. May be '*' (since version 2.1.0) to allow all names (this effectively disables XSD validation of this field).
xml.itemsStyle String Can be one of : wrapped, flat. wrapped means that the content items will be wrapped into an element, where flat doesn't add this wrapping element. Example:
<wrappedElements>
  <wrappedElement>element type content</wrappedElement>
  ...
<wrappedElements>
<flatElement>element type content</flatElement>
...

Default value is: wrapped

.
xml.mapStyle String Can be one of : inline, explode. Example:
<inlineProperties>
  <the key>the value</the key>
  ...
</inlineProperties>
<explodeProperties>
  <explodeProperty>
    <key>the key</key>
    <value>the value</value>
  </explodeProperty>
  ...
</explodeProperties>

Default value is: inline

.
xml.reference boolean No description.

Default value is: false

.
Element Type Since Description
type String No description.
multiplicity String Can be 1 if only one such child is allowed, or * if any number (0 to infinity) is allowed.

Default value is: 1

.