JiBX: <format> Element

# JiBX: <format> Element |

JiBX Basics Overview Getting Started Binding Compiler Binding on Load Runtime Extras Building JiBX Maven Contributing License News and Status Support FAQ Mailing Lists Bugs User Comments Sponsors Start from Code Start from Code BindGen Example Code Example 1 Example 2 Example 3 Example 4 Customizations Reference SchemaGen Jibx2Wsdl Examples Customizations Start from Schema Start from Schema CodeGen Schema Datatype Handling Example Code Default Generation Simple Customizations More Customizations Modular Generation Customizations Reference Extensions Reference Binding Definition Binding Tutorial A basic binding Binding extras Structure mapping Collections and arrays Using mappings Advanced binding Method hooks Custom code Precompiled Bindings Definition details Definition contexts Conversions Date/time conversions XML summary <binding> element <include> element <format> element <namespace> element <mapping> element <value> element <structure> element <collection> element Attribute groups Usage API Runtime JavaDocs Subprojects Eclipse Plug-in Introduction Install Usage JiBX/WS Axis2 Usage JiBX/OTA Schema Library | ### <format> Element Definition The format element defines a conversion between some primitive or object type and the text representation used for that type. Any type with a format defined can be used with simple element (one with no child elements), text, or attribute values. During unmarshalling, the text content of the element or attribute is passed to the deserializer defined for that format, which returns a value of the appropriate type. During marshalling, the typed value is passed to the serializer for that format, which returns a text string used as the element content or attribute value. This flexibility for conversion handling is also available without using a format element definition, by directly specifying the serializer and/or deserializer in a value definition. The advantage to using a format definition is that it can be easily reused. There are two ways of doing this. When a format element does not have a label attribute, it automatically becomes the default for values of the associated type. When a format element is defined with a label, that label can be used to reference it as needed. The format element supports a pair of unique attributes along with one common attribute group, listed below. #### Attributes
label | The label for this format. If supplied, the format can only be used when referenced by label. If not supplied, this format automatically becomes the default for handling the specified type within the context. As of JiBX 1.1, the value of this attribute is interpreted as namespace qualified.
type | This required attribute gives the fully qualified class name or the primitive type for the values handled by this format. For instance, for a format handling instances of the `java.util.Date` class this would be 'java.util.Date', and for one handling `int` primitive values it would be 'int'.
string | Attributes from the string group set the default conversion of a value type for all contained elements. See the string attribute group description for usage details.
format elements are subject to the restriction that labels must be unique, and unlabeled formats with the same type cannot be defined in the same context.