public <A extends Annotation> A readAnnotation(Class<A> a) { return reader().getClassAnnotation(a,clazz,this); }
/** * 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); }
protected final QName parseTypeName(ClassDeclT clazz) { return parseTypeName( clazz, reader().getClassAnnotation(XmlType.class,clazz,this) ); }
protected XmlAccessorFactory findXmlAccessorFactoryAnnotation(Class clazz) { XmlAccessorFactory factoryAnn = reader().getClassAnnotation(XmlAccessorFactory.class,clazz,this); if (factoryAnn == null) { factoryAnn = reader().getPackageAnnotation(XmlAccessorFactory.class,clazz,this); } return factoryAnn; }
/** * Gets an annotation that are allowed on both class and type. */ private <T extends Annotation> T getClassOrPackageAnnotation(Class<T> type) { T t = reader().getClassAnnotation(type,clazz,this); if(t!=null) return t; // defaults to the package level return reader().getPackageAnnotation(type,clazz,this); }
/** * 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); }
/** * Parses an {@link XmlRootElement} annotation on a class * and determine the element name. * * @return null * if none was found. */ protected final QName parseElementName(ClassDeclT clazz) { XmlRootElement e = reader().getClassAnnotation(XmlRootElement.class,clazz,this); if(e==null) return null; String local = e.name(); if(local.equals("##default")) { // if defaulted... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); } String nsUri = e.namespace(); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
/** * @param clazz * @param type * clazz and type should both point to the enum class * that this {@link EnumLeafInfo} represents. * Because of the type parameterization we have to take them separately. */ public EnumLeafInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C clazz, T type ) { super(builder,upstream); this.clazz = clazz; this.type = type; elementName = parseElementName(clazz); // compute the type name // TODO: I guess it must be allowed for enums to have @XmlElement typeName = parseTypeName(clazz); // locate the base type. // this can be done eagerly because there shouldn't be no cycle. XmlEnum xe = builder.reader.getClassAnnotation(XmlEnum.class, clazz, this); if(xe!=null) { T base = builder.reader.getClassValue(xe, "value"); baseType = builder.getTypeInfo(base,this); } else { baseType = builder.getTypeInfo(builder.nav.ref(String.class),this); } }
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; }
XmlSeeAlso sa = reader.getClassAnnotation(XmlSeeAlso.class, clazz, upstream); if(sa!=null) { for( T t : reader.getClassArrayValue(sa,"value") ) {
XmlType t = reader().getClassAnnotation(XmlType.class,clazz,this); typeName = parseTypeName(clazz,t); xao = reader().getClassAnnotation(XmlAccessorOrder.class, clazz, this); if((xao != null) && (xao.value() == XmlAccessOrder.UNDEFINED)) { propOrder = null;
public <A extends Annotation> A readAnnotation(Class<A> a) { return reader().getClassAnnotation(a,clazz,this); }
/** * 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); }
protected final QName parseTypeName(ClassDeclT clazz) { return parseTypeName( clazz, reader().getClassAnnotation(XmlType.class,clazz,this) ); }
protected XmlAccessorFactory findXmlAccessorFactoryAnnotation(Class clazz) { XmlAccessorFactory factoryAnn = reader().getClassAnnotation(XmlAccessorFactory.class,clazz,this); if (factoryAnn == null) { factoryAnn = reader().getPackageAnnotation(XmlAccessorFactory.class,clazz,this); } return factoryAnn; }
/** * Gets an annotation that are allowed on both class and type. */ private <T extends Annotation> T getClassOrPackageAnnotation(Class<T> type) { T t = reader().getClassAnnotation(type,clazz,this); if(t!=null) return t; // defaults to the package level return reader().getPackageAnnotation(type,clazz,this); }
/** * 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); }
/** * Parses an {@link XmlRootElement} annotation on a class * and determine the element name. * * @return null * if none was found. */ protected final QName parseElementName(ClassDeclT clazz) { XmlRootElement e = reader().getClassAnnotation(XmlRootElement.class,clazz,this); if(e==null) return null; String local = e.name(); if(local.equals("##default")) { // if defaulted... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); } String nsUri = e.namespace(); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
/** * @param clazz * @param type * clazz and type should both point to the enum class * that this {@link EnumLeafInfo} represents. * Because of the type parameterization we have to take them separately. */ public EnumLeafInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C clazz, T type ) { super(builder,upstream); this.clazz = clazz; this.type = type; elementName = parseElementName(clazz); // compute the type name // TODO: I guess it must be allowed for enums to have @XmlElement typeName = parseTypeName(clazz); // locate the base type. // this can be done eagerly because there shouldn't be no cycle. XmlEnum xe = builder.reader.getClassAnnotation(XmlEnum.class, clazz, this); if(xe!=null) { T base = builder.reader.getClassValue(xe, "value"); baseType = builder.getTypeInfo(base,this); } else { baseType = builder.getTypeInfo(builder.nav.ref(String.class),this); } }
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; }