JaxMe Types

The following types are available in JaxMe schemata:

XML Schema Standard Types

See the
JavaDocs.

ResourceBundle Formatted Types

Types formatted by a ResourceBundle are actually wrappers for other types. The backing type might be a dateTime, a number or a String. The wrapper adds the ability of converting an element or attribute value to XML using an instance of java.text.Format. In other words: You choose how the value is formatted in the generated or parsed XML document.

The instance can be specified explicitly, in which case it is generated at compile time. It can also be specified implicitly using a ResourceBundle key. The actual instance is then at run time by looking up the (possibly localized) pattern in the ResourceBundle and instantiating the Formatter.

Configuration examples:

  <!-- Explicit format specificaton of a SimpleDateFormat

     instance -->

  <element name="staticDate" type="jm:rbFormatted">

    <xs:annotation>

      <xs:appinfo>

        <jm:resourceBundeFormatted base="xs:dateTime"

          type="date" pattern="yyyy-MM-dd HH:mm:ss"/>

      </xs:appinfo>

    </xs:annotation>

  </element>

  <!-- Implicit format specification of a DecimalFormat

    instance -->

  <element name="localizedDecimalNumber" type="jm:rbFormatted>

    <xs:annotation>

      <xs:appinfo>

        <jm:rbFormatted base="xs:double"

          type="decimal" key="localized.decimal.number.pattern"/>

      </xs:appinfo>

    </xs:annotation>

  </element>

The jm:rbFormatted child of xs:appinfo supports the following attributes: 
Name Description
base Specifies the base type. Defaults to xs:string.
defaultPattern Used in conjunction with the key attribute: If no Pattern is found in the ResourceBundle, then the specified pattern is used to create a Formatter.
formatClass Specificies the subclass of java.text.Format being used. This class must support a static method getInstance(String pattern). An alternative is using the type attribute, which provides shortcuts. The formatClass and type attributes are mutually exclusive.
key Specifying this attribute implies the generation of the Formatter at run time. It is mutually exclusive with the attributes pattern and newFormatter. To create a Formatter, the Marshallers or Unmarshallers method getResourceBundle() will be invoked. If no ResourceBundle is returned or if the key is not defined in the ResourceBundle, then a SAXException is thrown. You may use the attribute defaultPattern to prevent the exception..
newFormatter If you want to specify a different way how a Formatter should be obtained, then you may use this method. This attribute is mutually exclusive with the attributes pattern and key.
pattern Specifying this attribute implies the generation of the Formatter at compile time, hence it is mutually exclusive with the attributes key and newFormatter. The Formatter will typically be generated by invoking formatClass.getInstance(pattern).
type Specificies the subclass of java.text.Format being used. Valid values are: 
date java.text.SimpleDateFormat
decimal java.text.DecimalFormat
message java.text.MessageFormat

All attributes may also be as atomic child elements. This is particularly useful in the case of the newFormatter attribute.

For further details see 

Types generated from SQL statements

See the JavaDocs.

The AutoUpdateDateTime type

See the JavaDocs

BLOB and CLOB types

The types jm:blob and jm:clob are quite similar to xs:base64Binary and xs:string, respectively. The only difference is that they are handled differently when being written to an SQL database:
Schema typeJava typeWritingReading
xs:base64Binarybyte[] PreparedStatement.setBytes(int,byte[]) ResultSet.getBytes(int)
jm:blobbyte[] PreparedStatement.setBinaryStream(int,InputStream,int) ResultSet.getBinaryStream(int)
xs:stringString PreparedStatement.setString(int,String) ResultSet.getString(int)
jm:blobString PreparedStatement.setCharacterStream(int,Reader,int) ResultSet.getCharacterStream(int)

For more details, see the JavaDocs of BlobType and ClobType.

The "any" type

The type xs:any is treated as an element with arbitrary content. No classes are generated for such elements, but the default types JMAnyElement and JMContentHandler are used as elements and SAX content handlers, respectively.

User defined types

JaxMe includes a number of builtin types. However, it is possible to extend the list with your own, predefined types. For example:

      <xs:schema
          xmlns:jm="http://ispsoft.de/namespaces/jaxme/schema"
          xmlns:my="http://company.com/namespaces/my">
        <xs:annotation>
          <xs:appinfo>
            <jm:declare type="my:clobType" class="de.ispsoft.jaxme.generator.types.OraClobType$URLEncoded"/>
            <jm:declare type="my:blobType" class="de.ispsoft.jaxme.generator.types.OraBlobType"/>
          </xs:appinfo>
        </xs:annotation>
      </xs:schema>
    

The example would declare that the type named clobType in the namespace http://company.com/namespaces/my is assigned to the class de.ispsoft.jaxme.generator.types.OraClobType$URLEncoded. Likewise, the type blobType in the same namespace is assigned to de.ispsoft.jaxme.generator.types.OraClobType.