Java Objects

This section briefly describes the mapping of struct instances to java classes.

The underlying philosophy is to provide an intuitive, typed mechanism to manipulate the data structures, and provide automated validation features.

For each struct, 3 java files are generated:

  • {class}.java is the main class. {class} implements the IXMLStruct interface.

  • {class}ArrayList.java is a collection of {class} that is used as the data type for glfields. {class}ArrayList implements the XMLStruct interface.

  • {class}Meta.java contains the metadata, used to validate and automate the conversion from/to XML.

All files must be included in a project that uses {class}, except for {class}ArrayList that must be included only when collections are used. The project must have the org.xooof.xmlstruct package which provide helper functions to the generated code.

To each field of the struct corresponds a property of {class}.

For vfields, the variant datatype is exposed, so null values can be manipulated. Howver, the underlying datatype is fixed and an automatic coercion is done whenever a property is set (see the table below).

For gfields, the generate class is used as the datatype.

For vlfields, typed collections are used (see the table below).

For glfields, the generated collection class is used as the datatype.

struct datatype

Java datatype

Java collection datatype

string

java.lang.String

org.xooof.xmlstruct.StringArrayList (behaves as an array list of String)

int

java.lang.Integer

org.xooof.xmlstruct.IntergerArrayList (behaves as an array list of Integer)

decimal

java.math.BigDecimal

org.xooof.xmlstruct.BigDecimalArrayList (behaves as a collection of BigDecimal)

boolean

java.lang.Boolean

org.xooof.xmlstruct.BooleanArrayList (behaves as a collection of Boolean)

code

String

org.xooof.xmlstruct.StringArrayList (behaves as a collection of String)

datetime

org.xooof.xmlstruct.XSDateTime

org.xooof.xmlstruct.XSDateTimeArrayList (behaves as a collection of XSDateTime)

time

org.xooof.xmlstruct.XSTime

org.xooof.xmlstruct.XSTimeArrayList (behaves as a collection of XSTime)

date

org.xooof.xmlstruct.XSDate

org.xooof.xmlstruct.XSDateArrayList (behaves as a collection of XSDate)

binary

org.xooof.xmlstruct.XSBinary

org.xooof.xmlstruct.XSBinaryArrayList (behaves as a collection of XSBinary)

Note

The python script struct2java.py is used to produce java files from struct instances.