/** * Examine the specified element ref and determine if a swaRef attribute needs to be generated */ private boolean generateSwaRefAdapter(PropertyInfo<T,C> prop) { final Adapter<T,C> adapter = prop.getAdapter(); if (adapter == null) return false; final Object o = navigator.asDecl(SwaRefAdapter.class); if (o == null) return false; return (o.equals(adapter.adapterType)); }
public Adapter( XmlJavaTypeAdapter spec, AnnotationReader<TypeT,ClassDeclT,?,?> reader, Navigator<TypeT,ClassDeclT,?,?> nav) { this( nav.asDecl(reader.getClassValue(spec,"value")), nav ); }
public Location getLocation() { return nav.getClassLocation(nav.asDecl(Object.class)); }
/** * Returns a {@link ClassInfo} for the given bean. * * <p> * This method is almost like refinement of {@link #getTypeInfo(Object)} except * our C cannot derive from T. * * @return * null if the specified type is not bound by JAXB or otherwise * unknown to this set. */ public NonElement<T,C> getClassInfo( C type ) { LeafInfo<T,C> l = builtins.get(nav.use(type)); if(l!=null) return l; l = enums.get(type); if(l!=null) return l; if(nav.asDecl(Object.class).equals(type)) return anyType; return beans.get(type); }
/** * This method is used to add a root reference to a model. */ public NonElement<T,C> getTypeInfo(Ref<T,C> ref) { // TODO: handle XmlValueList assert !ref.valueList; C c = nav.asDecl(ref.type); if(c!=null && reader.getClassAnnotation(XmlRegistry.class,c,null/*TODO: is this right?*/)!=null) { return null; // TODO: is this correct? } else return getTypeInfo(ref.type); }
/** * Returns a {@link TypeInfo} for the given type. * * @return * null if the specified type cannot be bound by JAXB, or * not known to this set. */ public NonElement<T,C> getTypeInfo( T type ) { type = nav.erasure(type); // replace type variables by their bounds LeafInfo<T,C> l = builtins.get(type); if(l!=null) return l; if( nav.isArray(type) ) { return arrays.get(type); } C d = nav.asDecl(type); if(d==null) return null; return getClassInfo(d); }
/** * This method is used to add a root reference to a model. */ public NonElement<T,C> getTypeInfo(Ref<T,C> ref) { // TODO: handle XmlValueList assert !ref.valueList; C c = nav.asDecl(ref.type); if(c!=null && reader.getClassAnnotation(XmlRegistry.class,c,null/*TODO: is this right?*/)!=null) { if(!registries.containsKey(nav.getPackageName(c))) addRegistry(c,null); return null; // TODO: is this correct? } else return getTypeInfo(ref.type,null); }
public ClassInfoImpl<T,C,F,M> getBaseClass() { if (!baseClassComputed) { // compute the base class C s = nav().getSuperClass(clazz); if(s==null || s==nav().asDecl(Object.class)) { baseClass = null; } else { NonElement<T,C> b = builder.getClassInfo(s, true, this); if(b instanceof ClassInfoImpl) { baseClass = (ClassInfoImpl<T,C,F,M>) b; baseClass.hasSubClasses = true; } else { baseClass = null; } } baseClassComputed = true; } return baseClass; }
/** * Have the builder recognize the type (if it hasn't done so yet), * and returns a {@link NonElement} that represents it. * * @return * always non-null. */ public NonElement<T,C> getTypeInfo(T t,Locatable upstream) { NonElement<T,C> r = typeInfoSet.getTypeInfo(t); if(r!=null) return r; if(nav.isArray(t)) { // no need for checking byte[], because above typeInfoset.getTypeInfo() would return non-null ArrayInfoImpl<T,C,F,M> ai = createArrayInfo(upstream, t); addTypeName(ai); typeInfoSet.add(ai); return ai; } C c = nav.asDecl(t); assert c!=null : t.toString()+" must be a leaf, but we failed to recognize it."; return getClassInfo(c,upstream); }
private boolean addAllSubtypes(T type) { Navigator<T,C,F,M> nav = nav(); // this allows the explicitly referenced type to be sucked in to the model NonElement<T,C> t = parent.builder.getClassInfo(nav.asDecl(type),this); if(!(t instanceof ClassInfo)) // this is leaf. return false; boolean result = false; ClassInfo<T,C> c = (ClassInfo<T,C>) t; if(c.isElement()) { types.add(c.asElement()); result = true; } // look for other possible types for( ClassInfo<T,C> ci : parent.owner.beans().values() ) { if(ci.isElement() && nav.isSubClassOf(ci.getType(),type)) { types.add(ci.asElement()); result = true; } } // don't allow local elements to substitute. for( ElementInfo<T,C> ei : parent.owner.getElementMappings(null).values()) { if(nav.isSubClassOf(ei.getType(),type)) { types.add(ei); result = true; } } return result; }
public ReferencePropertyInfoImpl( ClassInfoImpl<T,C,F,M> classInfo, PropertySeed<T,C,F,M> seed) { super(classInfo, seed); isMixed = seed.readAnnotation(XmlMixed.class) != null; XmlAnyElement xae = seed.readAnnotation(XmlAnyElement.class); if(xae==null) { wildcard = null; domHandler = null; } else { wildcard = xae.lax()?WildcardMode.LAX:WildcardMode.SKIP; domHandler = nav().asDecl(reader().getClassValue(xae,"value")); } }
public Adapter(ClassDeclT adapterType,Navigator<TypeT,ClassDeclT,?,?> nav) { this.adapterType = adapterType; TypeT baseClass = nav.getBaseClass(nav.use(adapterType), nav.asDecl(XmlAdapter.class)); // because the parameterization of XmlJavaTypeAdapter requires that the class derives from XmlAdapter. assert baseClass!=null; if(nav.isParameterizedType(baseClass)) defaultType = nav.getTypeArgument(baseClass,0); else defaultType = nav.ref(Object.class); if(nav.isParameterizedType(baseClass)) customType = nav.getTypeArgument(baseClass,1); else customType = nav.ref(Object.class); } }
if(clazz.getClazz()==navigator.asDecl(CompositeStructure.class)) return; // this is a special class we introduced for JAX-WS that we *don't* want in the schema
/** * Checks if the given adapter is applicable to the declared property type. */ private boolean isApplicable(XmlJavaTypeAdapter jta, T declaredType ) { if(jta==null) return false; T type = reader().getClassValue(jta,"type"); if(nav().isSameType(declaredType, type)) return true; // for types explicitly marked in XmlJavaTypeAdapter.type() T ad = reader().getClassValue(jta,"value"); T ba = nav().getBaseClass(ad, nav().asDecl(XmlAdapter.class)); if(!nav().isParameterizedType(ba)) return true; // can't check type applicability. assume Object, which means applicable to any. T inMemType = nav().getTypeArgument(ba, 1); return nav().isSubClassOf(declaredType,inMemType); }
public T getIndividualType() { if(adapter!=null) return adapter.defaultType; T raw = getRawType(); if(!isCollection()) { return raw; } else { if(nav().isArrayButNotByteArray(raw)) return nav().getComponentType(raw); T bt = nav().getBaseClass(raw, nav().asDecl(Collection.class) ); if(nav().isParameterizedType(bt)) return nav().getTypeArgument(bt,0); else return nav().ref(Object.class); } }
public MapPropertyInfoImpl(ClassInfoImpl<T,C,F,M> ci, PropertySeed<T,C,F,M> seed) { super(ci, seed); XmlElementWrapper xe = seed.readAnnotation(XmlElementWrapper.class); xmlName = calcXmlName(xe); nil = xe!=null && xe.nillable(); T raw = getRawType(); T bt = nav().getBaseClass(raw, nav().asDecl(Map.class) ); assert bt!=null; // Map property is only for Maps if(nav().isParameterizedType(bt)) { keyType = nav().getTypeArgument(bt,0); valueType = nav().getTypeArgument(bt,1); } else { keyType = valueType = nav().ref(Object.class); } }
private XmlJavaTypeAdapter getApplicableAdapter(T type) { XmlJavaTypeAdapter jta = seed.readAnnotation(XmlJavaTypeAdapter.class); if(jta!=null && isApplicable(jta,type)) return jta; // check the applicable adapters on the package XmlJavaTypeAdapters jtas = reader().getPackageAnnotation(XmlJavaTypeAdapters.class, parent.clazz, seed ); if(jtas!=null) { for (XmlJavaTypeAdapter xjta : jtas.value()) { if(isApplicable(xjta,type)) return xjta; } } jta = reader().getPackageAnnotation(XmlJavaTypeAdapter.class, parent.clazz, seed ); if(isApplicable(jta,type)) return jta; // then on the target class C refType = nav().asDecl(type); if(refType!=null) { jta = reader().getClassAnnotation(XmlJavaTypeAdapter.class, refType, seed ); if(jta!=null && isApplicable(jta,type)) // the one on the type always apply. return jta; } return null; }
T baseClass = nav().getBaseClass(elementType,nav().asDecl(JAXBElement.class)); if(baseClass==null) throw new IllegalAnnotationException( if(xsa!=null) { TODO.prototype("in Annotation Processing swaRefAdapter isn't avaialble, so this returns null"); a = new Adapter<T,C>(owner.nav.asDecl(SwaRefAdapter.class),owner.nav); T list = nav().getBaseClass(tOfJAXBElementT,nav().asDecl(List.class)); if(list==null) { isCollection = false; else { NonElement<T,C> scp = builder.getClassInfo(nav().asDecl(s),this); if(!(scp instanceof ClassInfo)) { throw new IllegalAnnotationException(
if(xsa!=null) { parent.builder.hasSwaRef = true; adapter = new Adapter<T,C>(nav().asDecl(SwaRefAdapter.class),nav()); } else { adapter = null;