Top Description Methods
org.glassfish.jaxb.core.annotation

public @Interface XmlIsSet

extends Annotation
Annotations
@Retention:RUNTIME
@Target:FIELD, METHOD
@Deprecated
Imports
java.lang.annotation.Retention, .Target, jakarta.xml.bind.annotation.XmlAttribute, .XmlElement, .XmlElementRef, .XmlValue

Deprecated

this hasn't been implemented in the RI, and this hasn't been speced yet. I believe Joe asked for this feature. I'd like to drop this.

Designates 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,

XmlElement
class Foo {
     XmlElement
     int x;
}

marshaller.marshal(new Foo());
and you get:
<foo><x>0</x></foo>

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.

XmlElement
class Foo {
     XmlElement
     int x;
     XmlIsSet("x")
     boolean xIsPresent;
}

Foo f = new Foo();
f.x = 5;
f.xIsPresent = false;

marshaller.marshal(f);

<foo/>


f.xIsPresent = true;
<foo><x>5</x></foo>

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.

Author
Kohsuke Kawaguchi

Method Summary

Modifier and TypeMethod and Description
public String
value()

Specifies the name of the property to attach to.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public String value()

Specifies the name of the property to attach to.