1 5 6 package javax.xml.bind; 7 8 import javax.xml.namespace.QName ; 9 import java.io.Serializable ; 10 11 43 44 public class JAXBElement<T> implements Serializable { 45 46 47 final protected QName name; 48 49 50 final protected Class <T> declaredType; 51 52 59 final protected Class scope; 60 61 63 protected T value; 64 65 66 protected boolean nil = false; 67 68 71 public static final class GlobalScope {} 72 73 86 public JAXBElement(QName name, 87 Class <T> declaredType, 88 Class scope, 89 T value) { 90 if(declaredType==null || name==null) 91 throw new IllegalArgumentException (); 92 this.declaredType = declaredType; 93 if(scope==null) scope = GlobalScope.class; 94 this.scope = scope; 95 this.name = name; 96 setValue(value); 97 } 98 99 104 public JAXBElement(QName name, Class <T> declaredType, T value ) { 105 this(name,declaredType,GlobalScope.class,value); 106 } 107 108 111 public Class <T> getDeclaredType() { 112 return declaredType; 113 } 114 115 118 public QName getName() { 119 return name; 120 } 121 122 130 public void setValue(T t) { 131 this.value = t; 132 } 133 134 140 public T getValue() { 141 return value; 142 } 143 144 150 public Class getScope() { 151 return scope; 152 } 153 154 163 public boolean isNil() { 164 return (value == null) || nil; 165 } 166 167 172 public void setNil(boolean value) { 173 this.nil = value; 174 } 175 176 180 181 184 public boolean isGlobalScope() { 185 return this.scope == GlobalScope.class; 186 } 187 188 192 public boolean isTypeSubstituted() { 193 if(value==null) return false; 194 return value.getClass() != declaredType; 195 } 196 197 private static final long serialVersionUID = 1L; 198 } 199 | Popular Tags |