41 * Designates a boolean field/property as a flag to indicate 42 * whether another property is present or not. 43 * 44 * <p> 45 * Sometimes you'd want to map a Java primitive type to an 46 * optional element/attribute. Doing this makes it impossible 47 * to represent the absence of the property, thus you always 48 * end up producing the value when you marshal to XML. 49 * 50 * For example, 51 * <pre> 52 * {@link XmlElement} 53 * class Foo { 54 * {@link XmlElement} 55 * int x; 56 * } 57 * 58 * marshaller.marshal(new Foo()); 59 * </pre> 60 * and you get: 61 * <pre><xmp> 62 * <foo><x>0</x></foo> 63 * </xmp></pre> 64 * 65 * <p> 66 * By creating a side boolean field/property that has this annotation, 67 * you can indicate the absence of the property by setting this boolean 68 * to false. 69 * <pre> 70 * {@link XmlElement} 71 * class Foo { 72 * {@link XmlElement} 73 * int x; 74 * {@link XmlIsSet}("x") 75 * boolean xIsPresent; 76 * } 77 * 78 * Foo f = new Foo(); 79 * f.x = 5; 80 * f.xIsPresent = false; 81 * 82 * marshaller.marshal(f); 83 * 84 * <xmp> 85 * <foo/> 86 * </xmp> 87 * 88 * f.xIsPresent = true; 89 * <xmp> 90 * <foo><x>5</x></foo> 91 * </xmp> 92 * </pre> 93 * 94 * <p> 95 * A property/field annotated with {@link XmlIsSet} itself will not show up in XML. 96 * It is an error to use this annotation on the same property/field 97 * as {@link XmlElement}, {@link XmlAttribute}, {@link XmlValue}, or {@link XmlElementRef}, 98 * ...<b>TBD</b>. 99 * 100 * @deprecated 101 * this hasn't been implemented in the RI, and this hasn't been speced yet. 102 * I believe Joe asked for this feature. I'd like to drop this. 103 * 104 * @author Kohsuke Kawaguchi 105 */ 106 @Retention(RUNTIME) 107 @Target({FIELD,METHOD}) 108 public @interface XmlIsSet { 109 /** 110 * Specifies the name of the property to attach to. 111 */ | 41 * Designates a boolean field/property as a flag to indicate 42 * whether another property is present or not. 43 * 44 * <p> 45 * Sometimes you'd want to map a Java primitive type to an 46 * optional element/attribute. Doing this makes it impossible 47 * to represent the absence of the property, thus you always 48 * end up producing the value when you marshal to XML. 49 * 50 * For example, 51 * <pre> 52 * {@link XmlElement} 53 * class Foo { 54 * {@link XmlElement} 55 * int x; 56 * } 57 * 58 * marshaller.marshal(new Foo()); 59 * </pre> 60 * and you get: 61 * <pre>{@code 62 * <foo><x>0</x></foo> 63 * }</pre> 64 * 65 * <p> 66 * By creating a side boolean field/property that has this annotation, 67 * you can indicate the absence of the property by setting this boolean 68 * to false. 69 * <pre> 70 * {@link XmlElement} 71 * class Foo { 72 * {@link XmlElement} 73 * int x; 74 * {@link XmlIsSet}("x") 75 * boolean xIsPresent; 76 * } 77 * 78 * Foo f = new Foo(); 79 * f.x = 5; 80 * f.xIsPresent = false; 81 * 82 * marshaller.marshal(f); 83 * 84 * {@code 85 * <foo/> 86 * } 87 * 88 * f.xIsPresent = true; 89 * {@code 90 * <foo><x>5</x></foo> 91 * } 92 * </pre> 93 * 94 * <p> 95 * A property/field annotated with {@link XmlIsSet} itself will not show up in XML. 96 * It is an error to use this annotation on the same property/field 97 * as {@link XmlElement}, {@link XmlAttribute}, {@link XmlValue}, or {@link XmlElementRef}, 98 * ...<b>TBD</b>. 99 * 100 * @deprecated 101 * this hasn't been implemented in the RI, and this hasn't been speced yet. 102 * I believe Joe asked for this feature. I'd like to drop this. 103 * 104 * @author Kohsuke Kawaguchi 105 */ 106 @Retention(RUNTIME) 107 @Target({FIELD,METHOD}) 108 public @interface XmlIsSet { 109 /** 110 * Specifies the name of the property to attach to. 111 */ |