Refine search
public String toString() { StringBuilder sb = new StringBuilder(super.toString()); sb.append('\n'); for( IllegalAnnotationException error : errors ) sb.append(error.toString()).append('\n'); return sb.toString(); }
public IllegalAnnotationException(String message, Throwable cause, Locatable src) { super(message, cause); pos = build(src); }
/** * @param builder * used for reporting errors. */ public final void add( ElementInfoImpl<T,C,F,M> ei, ModelBuilder<T,C,F,M> builder ) { C scope = null; if(ei.getScope()!=null) scope = ei.getScope().getClazz(); Map<QName,ElementInfoImpl<T,C,F,M>> m = elementMappings.get(scope); if(m==null) elementMappings.put(scope,m=new LinkedHashMap<QName,ElementInfoImpl<T,C,F,M>>()); ElementInfoImpl<T,C,F,M> existing = m.put(ei.getElementName(),ei); if(existing!=null) { QName en = ei.getElementName(); builder.reportError( new IllegalAnnotationException( Messages.CONFLICTING_XML_ELEMENT_MAPPING.format(en.getNamespaceURI(),en.getLocalPart()), ei, existing )); } }
public ArrayInfoImpl(ModelBuilder<TypeT,ClassDeclT,FieldT,MethodT> builder, Locatable upstream, TypeT arrayType) { super(builder, upstream); this.arrayType = arrayType; TypeT componentType = nav().getComponentType(arrayType); this.itemType = builder.getTypeInfo(componentType, this); QName n = itemType.getTypeName(); if(n==null) { builder.reportError(new IllegalAnnotationException(Messages.ANONYMOUS_ARRAY_ITEM.format( nav().getTypeName(componentType)),this)); n = new QName("#dummy"); // for error recovery } this.typeName = ArrayInfoUtil.calcArrayTypeName(n); }
public void link() { super.link(); if (!(NonElement.ANYTYPE_NAME.equals(type.getTypeName()) || type.isSimpleType() || id()==ID.IDREF)) { parent.builder.reportError(new IllegalAnnotationException( Messages.SIMPLE_TYPE_IS_REQUIRED.format(), seed )); } if(!isCollection() && seed.hasAnnotation(XmlList.class)) { parent.builder.reportError(new IllegalAnnotationException( Messages.XMLLIST_ON_SINGLE_PROPERTY.format(), this )); } }
anno = reader().getMethodAnnotation( XmlElementDecl.class, m, this ); assert anno!=null; // the caller should check this assert anno instanceof Locatable; elementType = nav().getReturnType(m); T baseClass = nav().getBaseClass(elementType,nav().asDecl(JAXBElement.class)); if(baseClass==null) throw new IllegalAnnotationException( Messages.XML_ELEMENT_MAPPING_ON_NON_IXMLELEMENT_METHOD.format(nav().getMethodName(m)), anno ); if(list==null) { isCollection = false; contentType = builder.getTypeInfo(tOfJAXBElementT,this); // suck this type into the current set. } else { isCollection = true; contentType = builder.getTypeInfo(nav().getTypeArgument(list,0),this); contentType = builder.getTypeInfo(this.adapter.defaultType,this); isCollection = false; NonElement<T,C> scp = builder.getClassInfo(nav().asDecl(s),this); if(!(scp instanceof ClassInfo)) { throw new IllegalAnnotationException( Messages.SCOPE_IS_NOT_COMPLEXTYPE.format(nav().getTypeName(s)), anno );
T fClass = reader().getClassValue(t, "factoryClass"); if (method.length() > 0){ if(nav().isSameType(fClass, nav().ref(XmlType.DEFAULT.class))){ fClass = nav().use(clazz); for(M m: nav().getDeclaredMethods(nav().asDecl(fClass))){ builder.reportError(new IllegalAnnotationException( Messages.NO_FACTORY_METHOD.format(nav().getClassName(nav().asDecl(fClass)), method), this )); } else if(!nav().isSameType(fClass, nav().ref(XmlType.DEFAULT.class))){ builder.reportError(new IllegalAnnotationException( Messages.FACTORY_CLASS_NEEDS_FACTORY_METHOD.format(nav().getClassName(nav().asDecl(fClass))), this ));
parent.builder.reportError(new IllegalAnnotationException( Messages.MUTUALLY_EXCLUSIVE_ANNOTATIONS.format( nav().getClassName(parent.getClazz())+'#'+seed.getName(), ref.annotationType().getName(), refs.annotationType().getName()), ref, refs )); AnnotationReader<T,C,F,M> reader = reader(); parent.builder.reportError(new IllegalAnnotationException( Messages.NO_XML_ELEMENT_DECL.format( getEffectiveNamespaceFor(r), r.name()), )); } else { parent.builder.reportError(new IllegalAnnotationException( Messages.INVALID_XML_ELEMENT_REF.format(type),this)); parent.builder.reportError(new IllegalAnnotationException( parent.builder.reportError(new IllegalAnnotationException( Messages.NO_XML_ELEMENT_DECL.format( getEffectiveNamespaceFor(r), r.name()), )); } else { parent.builder.reportError(new IllegalAnnotationException( Messages.INVALID_XML_ELEMENT_REF.format(),this));
parent.builder.reportError(new IllegalAnnotationException( Messages.ILLEGAL_ANNOTATION.format(XmlMimeType.class.getName()), seed.readAnnotation(XmlMimeType.class) this.isCollection = nav().isSubClassOf(t, nav().ref(Collection.class)) || nav().isArrayButNotByteArray(t); T ad = reader().getClassValue(xjta,"value"); parent.builder.reportError(new IllegalAnnotationException( Messages.UNMATCHABLE_ADAPTER.format( nav().getTypeName(ad), nav().getTypeName(t)),
builder.registries.put(getPackageName(),this); if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) { builder.reportError(new IllegalAnnotationException( Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()), this for( M m : nav.getDeclaredMethods(registryClass) ) { XmlElementDecl em = builder.reader.getMethodAnnotation( XmlElementDecl.class, m, this ); if(nav.getMethodName(m).startsWith("create")) { builder.getTypeInfo(nav.getReturnType(m), new MethodLocatable<M>(this,m,nav))); ei = builder.createElementInfo(this,m); } catch (IllegalAnnotationException e) { builder.reportError(e);
private void findFieldProperties(C c, XmlAccessType at) { C sc = nav().getSuperClass(c); if (shouldRecurseSuperClass(sc)) { findFieldProperties(sc,at); for( F f : nav().getDeclaredFields(c) ) { Annotation[] annotations = reader().getAllFieldAnnotations(f,this); boolean isDummy = reader().hasFieldAnnotation(OverrideAnnotationOf.class, f); if( nav().isTransient(f) ) { builder.reportError(new IllegalAnnotationException( Messages.TRANSIENT_FIELD_NOT_BINDABLE.format(nav().getFieldName(f)), getSomeJAXBAnnotation(annotations)));
c = nav().getSuperClass(c); } while(shouldRecurseSuperClass(c)); M setter = setters.get(name); Annotation[] ga = getter!=null ? reader().getAllMethodAnnotations(getter,new MethodLocatable<M>(this,getter,nav())) : EMPTY_ANNOTATIONS; Annotation[] sa = setter!=null ? reader().getAllMethodAnnotations(setter,new MethodLocatable<M>(this,setter,nav())) : EMPTY_ANNOTATIONS; isOverriding = (getter!=null && nav().isOverriding(getter,c)) && (setter!=null && nav().isOverriding(setter,c)); && !nav().isSameType(nav().getReturnType(getter), nav().getMethodParameters(setter)[0])) { builder.reportError(new IllegalAnnotationException( Messages.GETTER_SETTER_INCOMPATIBLE_TYPE.format( nav().getTypeName(nav().getReturnType(getter)),
parent.builder.reportError(new IllegalAnnotationException( Messages.MUTUALLY_EXCLUSIVE_ANNOTATIONS.format( nav().getClassName(parent.getClazz())+'#'+seed.getName(), xe.annotationType().getName(), xes.annotationType().getName()), xe, xes )); if(!nav().isPrimitive(t) || isCollection()) isRequired = false; TypeT type = reader().getClassValue(item, "type"); if (nav().isSameType(type, nav().ref(XmlElement.DEFAULT.class))) type = getIndividualType(); if((!nav().isPrimitive(type) || isCollection()) && !item.required())
XmlType t = reader().getClassAnnotation(XmlType.class,clazz,this); typeName = parseTypeName(clazz,t); XmlAccessorOrder xao = reader().getPackageAnnotation(XmlAccessorOrder.class, clazz, this); if((xao != null) && (xao.value() == XmlAccessOrder.UNDEFINED)) { propOrder = null; xao = reader().getClassAnnotation(XmlAccessorOrder.class, clazz, this); if((xao != null) && (xao.value() == XmlAccessOrder.UNDEFINED)) { propOrder = null; if(nav().isInterface(clazz)) { builder.reportError(new IllegalAnnotationException( Messages.CANT_HANDLE_INTERFACE.format(nav().getClassName(clazz)), this )); if(!nav().hasDefaultConstructor(clazz)){ if(nav().isInnerClass(clazz)) { builder.reportError(new IllegalAnnotationException( Messages.CANT_HANDLE_INNER_CLASS.format(nav().getClassName(clazz)), this )); } else if (elementName != null) { builder.reportError(new IllegalAnnotationException( Messages.NO_DEFAULT_CONSTRUCTOR.format(nav().getClassName(clazz)), this ));
protected void link() { super.link(); for (TypeRefImpl<TypeT, ClassDeclT> ref : getTypes() ) { ref.link(); } if(isValueList()) { // ugly test, because IDREF's are represented as text on the wire, // it's OK to be a value list in that case. if(id()!= ID.IDREF) { // check if all the item types are simple types // this can't be done when we compute types because // not all TypeInfos are available yet for (TypeRefImpl<TypeT,ClassDeclT> ref : types) { if(!ref.getTarget().isSimpleType()) { parent.builder.reportError(new IllegalAnnotationException( Messages.XMLLIST_NEEDS_SIMPLETYPE.format( nav().getTypeName(ref.getTarget().getType())), this )); break; } } } if(!isCollection()) parent.builder.reportError(new IllegalAnnotationException( Messages.XMLLIST_ON_SINGLE_PROPERTY.format(), this )); } } }
/** * Checks the uniqueness of the type name. */ private void addTypeName(NonElement<T, C> r) { QName t = r.getTypeName(); if(t==null) return; TypeInfo old = typeNames.put(t,r); if(old!=null) { // collision reportError(new IllegalAnnotationException( Messages.CONFLICTING_XML_TYPE_MAPPING.format(r.getTypeName()), old, r )); } }
private ID calcId() { if(seed.hasAnnotation(XmlID.class)) { // check the type if(!nav().isSameType(getIndividualType(), nav().ref(String.class))) parent.builder.reportError(new IllegalAnnotationException( Messages.ID_MUST_BE_STRING.format(getName()), seed ) ); return ID.ID; } else if(seed.hasAnnotation(XmlIDREF.class)) { return ID.IDREF; } else { return ID.NONE; } }
accFactory = factoryAnn.value().newInstance(); } catch (InstantiationException e) { builder.reportError(new IllegalAnnotationException( Messages.ACCESSORFACTORY_INSTANTIATION_EXCEPTION.format( factoryAnn.getClass().getName(), nav().getClassName(clazz)), this)); } catch (IllegalAccessException e) { builder.reportError(new IllegalAnnotationException( Messages.ACCESSORFACTORY_ACCESS_EXCEPTION.format( factoryAnn.getClass().getName(), nav().getClassName(clazz)),this));
/** * Called after all the {@link TypeInfo}s are collected into the governing {@link TypeInfoSet}. * * Derived class can do additional actions to complete the model. */ protected void link() { if(id==ID.IDREF) { // make sure that the refereced type has ID for (TypeInfo<T,C> ti : ref()) { if(!ti.canBeReferencedByIDREF()) parent.builder.reportError(new IllegalAnnotationException( Messages.INVALID_IDREF.format( parent.builder.nav.getTypeName(ti.getType())), this )); } } }