com.abra.j2xb.annotations
Annotation Type MOProperty


@Target(value=METHOD)
@Retention(value=RUNTIME)
public @interface MOProperty

Defines a mapping of a Java Property to XML.

The Java property may be of the following types:

Many annotations are allowed with conjunction with this annotation

Example 1:

simple Java property

 @MOProperty()
 public String getName() {...}
 

corresponds to the following XML schema:

 <xs:element name="name">
   <xs:simpleType>
     <xs:restriction base="xs:string">
     </xs:restriction>
   </xs:simpleType>
 </xs:element>
 

Example 2:

Java Property with xmlName, xmlOptional and defaultValue

 @MOProperty(xmlOrder = 2, xmlName = "employeeName", xmlOptional = true,
   defaultValue = "Mike")
 public String getName() {...}
 

corresponds to the following XML schema:

 <xs:element name="employeeName" minOccurs="0" default="mike">
   <xs:simpleType>
     <xs:restriction base="xs:string">
     </xs:restriction>
   </xs:simpleType>
 </xs:element>
 

Example 3:

Java Property with xmlName, xmlOptional and defaultValue, mapped as an XML attribute

 @MOProperty(xmlOrder = 2, xmlName = "employeeName", xmlOptional = true,
   defaultValue = "Mike", isXmlAttribute = true)
 public String getName() {...}
 

corresponds to the following XML schema:

 <xs:attribute name="employeeName" default="mike">
   <xs:simpleType>
     <xs:restriction base="xs:string">
     </xs:restriction>
   </xs:simpleType>
 </xs:attribute>
 

Since:
JDK1.5
Version:
1.0, May 1, 2008
Author:
Yoav Abrahami
See Also:
MOPropertyEditor, MOPropertyEditorRegistry, MOPolymorphicAtomProperty, MOPersistentDependentBean, MOPersistentBean

Optional Element Summary
 java.lang.String defaultValue
          defines the default value of the XML element.
 boolean isXmlAttribute
          defines if the value is written as an XML attribute or an XML element
 java.lang.String xmlName
          the xmlName() value defines the xml element or attribute name of the property.
 boolean xmlOptional
          defines if the value is optional in the XML representation.
 int xmlOrder
          defines the order at which the property appears in the XML representation.
 

xmlName

public abstract java.lang.String xmlName
the xmlName() value defines the xml element or attribute name of the property. If not specified, the Java property name is used

Default:
""

xmlOrder

public abstract int xmlOrder
defines the order at which the property appears in the XML representation. If not specified, the ordering of the properties will be based on property names.

Default:
-1

xmlOptional

public abstract boolean xmlOptional
defines if the value is optional in the XML representation.

Default:
false

isXmlAttribute

public abstract boolean isXmlAttribute
defines if the value is written as an XML attribute or an XML element

Default:
false

defaultValue

public abstract java.lang.String defaultValue
defines the default value of the XML element.

The default value is written in terms of the string representation of the property type, as defined by the matching MOPropertyEditor class.

See Also:
MOPropertyEditor.toString(Class, java.lang.Object), MOPropertyEditor.fromString(Class, String)
Default:
""


Copyright © 2008. All Rights Reserved.