|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||
@Retention(value=RUNTIME)
@Target(value={FIELD,METHOD})
public @interface XmlIsSetDesignates a boolean field/property as a flag to indicate whether another property is present or not.
Sometimes you'd want to map a Java primitive type to an optional element/attribute. Doing this makes it impossible to represent the absence of the property, thus you always end up producing the value when you marshal to XML. For example,
and you get:XmlElementclass Foo {XmlElementint x; } marshaller.marshal(new Foo());
0
By creating a side boolean field/property that has this annotation, you can indicate the absence of the property by setting this boolean to false.
XmlElementclass Foo {XmlElementint x;XmlIsSet("x") boolean xIsPresent; } Foo f = new Foo(); f.x = 5; f.xIsPresent = false; marshaller.marshal(f);f.xIsPresent = true; 5
A property/field annotated with XmlIsSet itself will not show up in XML.
It is an error to use this annotation on the same property/field
as XmlElement, XmlAttribute, XmlValue, or XmlElementRef,
...TBD.
| Required Element Summary | |
|---|---|
java.lang.String |
value
Deprecated. Specifies the name of the property to attach to. |
| Element Detail |
|---|
public abstract java.lang.String value
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||