com.sun.xml.internal.bind.v2.model.annotation.MethodLocatable Java Examples
The following examples show how to use
com.sun.xml.internal.bind.v2.model.annotation.MethodLocatable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassInfoImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Adds properties that consists of accessors. */ private void findGetterSetterProperties(XmlAccessType at) { // in the first step we accumulate getters and setters // into this map keyed by the property name. Map<String,M> getters = new LinkedHashMap<String,M>(); Map<String,M> setters = new LinkedHashMap<String,M>(); C c = clazz; do { collectGetterSetters(clazz, getters, setters); // take super classes into account if they have @XmlTransient c = nav().getSuperClass(c); } while(shouldRecurseSuperClass(c)); // compute the intersection Set<String> complete = new TreeSet<String>(getters.keySet()); complete.retainAll(setters.keySet()); resurrect(getters, complete); resurrect(setters, complete); // then look for read/write properties. for (String name : complete) { M getter = getters.get(name); 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; boolean hasAnnotation = hasJAXBAnnotation(ga) || hasJAXBAnnotation(sa); boolean isOverriding = false; if(!hasAnnotation) { // checking if the method is overriding others isn't free, // so we don't compute it if it's not necessary. isOverriding = (getter!=null && nav().isOverriding(getter,c)) && (setter!=null && nav().isOverriding(setter,c)); } if((at==XmlAccessType.PROPERTY && !isOverriding) || (at==XmlAccessType.PUBLIC_MEMBER && isConsideredPublic(getter) && isConsideredPublic(setter) && !isOverriding) || hasAnnotation) { // make sure that the type is consistent if(getter!=null && setter!=null && !nav().isSameType(nav().getReturnType(getter), nav().getMethodParameters(setter)[0])) { // inconsistent builder.reportError(new IllegalAnnotationException( Messages.GETTER_SETTER_INCOMPATIBLE_TYPE.format( nav().getTypeName(nav().getReturnType(getter)), nav().getTypeName(nav().getMethodParameters(setter)[0]) ), new MethodLocatable<M>( this, getter, nav()), new MethodLocatable<M>( this, setter, nav()))); continue; } // merge annotations from two list Annotation[] r; if(ga.length==0) { r = sa; } else if(sa.length==0) { r = ga; } else { r = new Annotation[ga.length+sa.length]; System.arraycopy(ga,0,r,0,ga.length); System.arraycopy(sa,0,r,ga.length,sa.length); } addProperty(createAccessorSeed(getter, setter), r, false); } } // done with complete pairs getters.keySet().removeAll(complete); setters.keySet().removeAll(complete); // TODO: think about // class Foo { // int getFoo(); // } // class Bar extends Foo { // void setFoo(int x); // } // and how it will be XML-ized. }
Example #2
Source File: RegistryInfoImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Picks up references in this registry to other types. */ RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) { this.nav = builder.nav; this.registryClass = registryClass; this.upstream = upstream; builder.registries.put(getPackageName(),this); if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) { // the user is trying to use ObjectFactory that we generate for interfaces, // that means he's missing jaxb.properties builder.reportError(new IllegalAnnotationException( Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()), this )); // looking at members will only add more errors, so just abort now return; } for( M m : nav.getDeclaredMethods(registryClass) ) { XmlElementDecl em = builder.reader.getMethodAnnotation( XmlElementDecl.class, m, this ); if(em==null) { if(nav.getMethodName(m).startsWith("create")) { // this is a factory method. visit this class references.add( builder.getTypeInfo(nav.getReturnType(m), new MethodLocatable<M>(this,m,nav))); } continue; } ElementInfoImpl<T,C,F,M> ei; try { ei = builder.createElementInfo(this,m); } catch (IllegalAnnotationException e) { builder.reportError(e); continue; // recover by ignoring this element } // register this mapping // TODO: any chance this could cause a stack overflow (by recursively visiting classes)? builder.typeInfoSet.add(ei,builder); references.add(ei); } }
Example #3
Source File: ClassInfoImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Adds properties that consists of accessors. */ private void findGetterSetterProperties(XmlAccessType at) { // in the first step we accumulate getters and setters // into this map keyed by the property name. Map<String,M> getters = new LinkedHashMap<String,M>(); Map<String,M> setters = new LinkedHashMap<String,M>(); C c = clazz; do { collectGetterSetters(clazz, getters, setters); // take super classes into account if they have @XmlTransient c = nav().getSuperClass(c); } while(shouldRecurseSuperClass(c)); // compute the intersection Set<String> complete = new TreeSet<String>(getters.keySet()); complete.retainAll(setters.keySet()); resurrect(getters, complete); resurrect(setters, complete); // then look for read/write properties. for (String name : complete) { M getter = getters.get(name); 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; boolean hasAnnotation = hasJAXBAnnotation(ga) || hasJAXBAnnotation(sa); boolean isOverriding = false; if(!hasAnnotation) { // checking if the method is overriding others isn't free, // so we don't compute it if it's not necessary. isOverriding = (getter!=null && nav().isOverriding(getter,c)) && (setter!=null && nav().isOverriding(setter,c)); } if((at==XmlAccessType.PROPERTY && !isOverriding) || (at==XmlAccessType.PUBLIC_MEMBER && isConsideredPublic(getter) && isConsideredPublic(setter) && !isOverriding) || hasAnnotation) { // make sure that the type is consistent if(getter!=null && setter!=null && !nav().isSameType(nav().getReturnType(getter), nav().getMethodParameters(setter)[0])) { // inconsistent builder.reportError(new IllegalAnnotationException( Messages.GETTER_SETTER_INCOMPATIBLE_TYPE.format( nav().getTypeName(nav().getReturnType(getter)), nav().getTypeName(nav().getMethodParameters(setter)[0]) ), new MethodLocatable<M>( this, getter, nav()), new MethodLocatable<M>( this, setter, nav()))); continue; } // merge annotations from two list Annotation[] r; if(ga.length==0) { r = sa; } else if(sa.length==0) { r = ga; } else { r = new Annotation[ga.length+sa.length]; System.arraycopy(ga,0,r,0,ga.length); System.arraycopy(sa,0,r,ga.length,sa.length); } addProperty(createAccessorSeed(getter, setter), r, false); } } // done with complete pairs getters.keySet().removeAll(complete); setters.keySet().removeAll(complete); // TODO: think about // class Foo { // int getFoo(); // } // class Bar extends Foo { // void setFoo(int x); // } // and how it will be XML-ized. }
Example #4
Source File: RegistryInfoImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Picks up references in this registry to other types. */ RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) { this.nav = builder.nav; this.registryClass = registryClass; this.upstream = upstream; builder.registries.put(getPackageName(),this); if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) { // the user is trying to use ObjectFactory that we generate for interfaces, // that means he's missing jaxb.properties builder.reportError(new IllegalAnnotationException( Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()), this )); // looking at members will only add more errors, so just abort now return; } for( M m : nav.getDeclaredMethods(registryClass) ) { XmlElementDecl em = builder.reader.getMethodAnnotation( XmlElementDecl.class, m, this ); if(em==null) { if(nav.getMethodName(m).startsWith("create")) { // this is a factory method. visit this class references.add( builder.getTypeInfo(nav.getReturnType(m), new MethodLocatable<M>(this,m,nav))); } continue; } ElementInfoImpl<T,C,F,M> ei; try { ei = builder.createElementInfo(this,m); } catch (IllegalAnnotationException e) { builder.reportError(e); continue; // recover by ignoring this element } // register this mapping // TODO: any chance this could cause a stack overflow (by recursively visiting classes)? builder.typeInfoSet.add(ei,builder); references.add(ei); } }
Example #5
Source File: ClassInfoImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Adds properties that consists of accessors. */ private void findGetterSetterProperties(XmlAccessType at) { // in the first step we accumulate getters and setters // into this map keyed by the property name. Map<String,M> getters = new LinkedHashMap<String,M>(); Map<String,M> setters = new LinkedHashMap<String,M>(); C c = clazz; do { collectGetterSetters(clazz, getters, setters); // take super classes into account if they have @XmlTransient c = nav().getSuperClass(c); } while(shouldRecurseSuperClass(c)); // compute the intersection Set<String> complete = new TreeSet<String>(getters.keySet()); complete.retainAll(setters.keySet()); resurrect(getters, complete); resurrect(setters, complete); // then look for read/write properties. for (String name : complete) { M getter = getters.get(name); 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; boolean hasAnnotation = hasJAXBAnnotation(ga) || hasJAXBAnnotation(sa); boolean isOverriding = false; if(!hasAnnotation) { // checking if the method is overriding others isn't free, // so we don't compute it if it's not necessary. isOverriding = (getter!=null && nav().isOverriding(getter,c)) && (setter!=null && nav().isOverriding(setter,c)); } if((at==XmlAccessType.PROPERTY && !isOverriding) || (at==XmlAccessType.PUBLIC_MEMBER && isConsideredPublic(getter) && isConsideredPublic(setter) && !isOverriding) || hasAnnotation) { // make sure that the type is consistent if(getter!=null && setter!=null && !nav().isSameType(nav().getReturnType(getter), nav().getMethodParameters(setter)[0])) { // inconsistent builder.reportError(new IllegalAnnotationException( Messages.GETTER_SETTER_INCOMPATIBLE_TYPE.format( nav().getTypeName(nav().getReturnType(getter)), nav().getTypeName(nav().getMethodParameters(setter)[0]) ), new MethodLocatable<M>( this, getter, nav()), new MethodLocatable<M>( this, setter, nav()))); continue; } // merge annotations from two list Annotation[] r; if(ga.length==0) { r = sa; } else if(sa.length==0) { r = ga; } else { r = new Annotation[ga.length+sa.length]; System.arraycopy(ga,0,r,0,ga.length); System.arraycopy(sa,0,r,ga.length,sa.length); } addProperty(createAccessorSeed(getter, setter), r, false); } } // done with complete pairs getters.keySet().removeAll(complete); setters.keySet().removeAll(complete); // TODO: think about // class Foo { // int getFoo(); // } // class Bar extends Foo { // void setFoo(int x); // } // and how it will be XML-ized. }
Example #6
Source File: RegistryInfoImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Picks up references in this registry to other types. */ RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) { this.nav = builder.nav; this.registryClass = registryClass; this.upstream = upstream; builder.registries.put(getPackageName(),this); if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) { // the user is trying to use ObjectFactory that we generate for interfaces, // that means he's missing jaxb.properties builder.reportError(new IllegalAnnotationException( Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()), this )); // looking at members will only add more errors, so just abort now return; } for( M m : nav.getDeclaredMethods(registryClass) ) { XmlElementDecl em = builder.reader.getMethodAnnotation( XmlElementDecl.class, m, this ); if(em==null) { if(nav.getMethodName(m).startsWith("create")) { // this is a factory method. visit this class references.add( builder.getTypeInfo(nav.getReturnType(m), new MethodLocatable<M>(this,m,nav))); } continue; } ElementInfoImpl<T,C,F,M> ei; try { ei = builder.createElementInfo(this,m); } catch (IllegalAnnotationException e) { builder.reportError(e); continue; // recover by ignoring this element } // register this mapping // TODO: any chance this could cause a stack overflow (by recursively visiting classes)? builder.typeInfoSet.add(ei,builder); references.add(ei); } }
Example #7
Source File: ClassInfoImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Adds properties that consists of accessors. */ private void findGetterSetterProperties(XmlAccessType at) { // in the first step we accumulate getters and setters // into this map keyed by the property name. Map<String,M> getters = new LinkedHashMap<String,M>(); Map<String,M> setters = new LinkedHashMap<String,M>(); C c = clazz; do { collectGetterSetters(clazz, getters, setters); // take super classes into account if they have @XmlTransient c = nav().getSuperClass(c); } while(shouldRecurseSuperClass(c)); // compute the intersection Set<String> complete = new TreeSet<String>(getters.keySet()); complete.retainAll(setters.keySet()); resurrect(getters, complete); resurrect(setters, complete); // then look for read/write properties. for (String name : complete) { M getter = getters.get(name); 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; boolean hasAnnotation = hasJAXBAnnotation(ga) || hasJAXBAnnotation(sa); boolean isOverriding = false; if(!hasAnnotation) { // checking if the method is overriding others isn't free, // so we don't compute it if it's not necessary. isOverriding = (getter!=null && nav().isOverriding(getter,c)) && (setter!=null && nav().isOverriding(setter,c)); } if((at==XmlAccessType.PROPERTY && !isOverriding) || (at==XmlAccessType.PUBLIC_MEMBER && isConsideredPublic(getter) && isConsideredPublic(setter) && !isOverriding) || hasAnnotation) { // make sure that the type is consistent if(getter!=null && setter!=null && !nav().isSameType(nav().getReturnType(getter), nav().getMethodParameters(setter)[0])) { // inconsistent builder.reportError(new IllegalAnnotationException( Messages.GETTER_SETTER_INCOMPATIBLE_TYPE.format( nav().getTypeName(nav().getReturnType(getter)), nav().getTypeName(nav().getMethodParameters(setter)[0]) ), new MethodLocatable<M>( this, getter, nav()), new MethodLocatable<M>( this, setter, nav()))); continue; } // merge annotations from two list Annotation[] r; if(ga.length==0) { r = sa; } else if(sa.length==0) { r = ga; } else { r = new Annotation[ga.length+sa.length]; System.arraycopy(ga,0,r,0,ga.length); System.arraycopy(sa,0,r,ga.length,sa.length); } addProperty(createAccessorSeed(getter, setter), r, false); } } // done with complete pairs getters.keySet().removeAll(complete); setters.keySet().removeAll(complete); // TODO: think about // class Foo { // int getFoo(); // } // class Bar extends Foo { // void setFoo(int x); // } // and how it will be XML-ized. }
Example #8
Source File: RegistryInfoImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Picks up references in this registry to other types. */ RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) { this.nav = builder.nav; this.registryClass = registryClass; this.upstream = upstream; builder.registries.put(getPackageName(),this); if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) { // the user is trying to use ObjectFactory that we generate for interfaces, // that means he's missing jaxb.properties builder.reportError(new IllegalAnnotationException( Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()), this )); // looking at members will only add more errors, so just abort now return; } for( M m : nav.getDeclaredMethods(registryClass) ) { XmlElementDecl em = builder.reader.getMethodAnnotation( XmlElementDecl.class, m, this ); if(em==null) { if(nav.getMethodName(m).startsWith("create")) { // this is a factory method. visit this class references.add( builder.getTypeInfo(nav.getReturnType(m), new MethodLocatable<M>(this,m,nav))); } continue; } ElementInfoImpl<T,C,F,M> ei; try { ei = builder.createElementInfo(this,m); } catch (IllegalAnnotationException e) { builder.reportError(e); continue; // recover by ignoring this element } // register this mapping // TODO: any chance this could cause a stack overflow (by recursively visiting classes)? builder.typeInfoSet.add(ei,builder); references.add(ei); } }
Example #9
Source File: ClassInfoImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Adds properties that consists of accessors. */ private void findGetterSetterProperties(XmlAccessType at) { // in the first step we accumulate getters and setters // into this map keyed by the property name. Map<String,M> getters = new LinkedHashMap<String,M>(); Map<String,M> setters = new LinkedHashMap<String,M>(); C c = clazz; do { collectGetterSetters(clazz, getters, setters); // take super classes into account if they have @XmlTransient c = nav().getSuperClass(c); } while(shouldRecurseSuperClass(c)); // compute the intersection Set<String> complete = new TreeSet<String>(getters.keySet()); complete.retainAll(setters.keySet()); resurrect(getters, complete); resurrect(setters, complete); // then look for read/write properties. for (String name : complete) { M getter = getters.get(name); 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; boolean hasAnnotation = hasJAXBAnnotation(ga) || hasJAXBAnnotation(sa); boolean isOverriding = false; if(!hasAnnotation) { // checking if the method is overriding others isn't free, // so we don't compute it if it's not necessary. isOverriding = (getter!=null && nav().isOverriding(getter,c)) && (setter!=null && nav().isOverriding(setter,c)); } if((at==XmlAccessType.PROPERTY && !isOverriding) || (at==XmlAccessType.PUBLIC_MEMBER && isConsideredPublic(getter) && isConsideredPublic(setter) && !isOverriding) || hasAnnotation) { // make sure that the type is consistent if(getter!=null && setter!=null && !nav().isSameType(nav().getReturnType(getter), nav().getMethodParameters(setter)[0])) { // inconsistent builder.reportError(new IllegalAnnotationException( Messages.GETTER_SETTER_INCOMPATIBLE_TYPE.format( nav().getTypeName(nav().getReturnType(getter)), nav().getTypeName(nav().getMethodParameters(setter)[0]) ), new MethodLocatable<M>( this, getter, nav()), new MethodLocatable<M>( this, setter, nav()))); continue; } // merge annotations from two list Annotation[] r; if(ga.length==0) { r = sa; } else if(sa.length==0) { r = ga; } else { r = new Annotation[ga.length+sa.length]; System.arraycopy(ga,0,r,0,ga.length); System.arraycopy(sa,0,r,ga.length,sa.length); } addProperty(createAccessorSeed(getter, setter), r, false); } } // done with complete pairs getters.keySet().removeAll(complete); setters.keySet().removeAll(complete); // TODO: think about // class Foo { // int getFoo(); // } // class Bar extends Foo { // void setFoo(int x); // } // and how it will be XML-ized. }
Example #10
Source File: RegistryInfoImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Picks up references in this registry to other types. */ RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) { this.nav = builder.nav; this.registryClass = registryClass; this.upstream = upstream; builder.registries.put(getPackageName(),this); if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) { // the user is trying to use ObjectFactory that we generate for interfaces, // that means he's missing jaxb.properties builder.reportError(new IllegalAnnotationException( Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()), this )); // looking at members will only add more errors, so just abort now return; } for( M m : nav.getDeclaredMethods(registryClass) ) { XmlElementDecl em = builder.reader.getMethodAnnotation( XmlElementDecl.class, m, this ); if(em==null) { if(nav.getMethodName(m).startsWith("create")) { // this is a factory method. visit this class references.add( builder.getTypeInfo(nav.getReturnType(m), new MethodLocatable<M>(this,m,nav))); } continue; } ElementInfoImpl<T,C,F,M> ei; try { ei = builder.createElementInfo(this,m); } catch (IllegalAnnotationException e) { builder.reportError(e); continue; // recover by ignoring this element } // register this mapping // TODO: any chance this could cause a stack overflow (by recursively visiting classes)? builder.typeInfoSet.add(ei,builder); references.add(ei); } }
Example #11
Source File: ClassInfoImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Adds properties that consists of accessors. */ private void findGetterSetterProperties(XmlAccessType at) { // in the first step we accumulate getters and setters // into this map keyed by the property name. Map<String,M> getters = new LinkedHashMap<String,M>(); Map<String,M> setters = new LinkedHashMap<String,M>(); C c = clazz; do { collectGetterSetters(clazz, getters, setters); // take super classes into account if they have @XmlTransient c = nav().getSuperClass(c); } while(shouldRecurseSuperClass(c)); // compute the intersection Set<String> complete = new TreeSet<String>(getters.keySet()); complete.retainAll(setters.keySet()); resurrect(getters, complete); resurrect(setters, complete); // then look for read/write properties. for (String name : complete) { M getter = getters.get(name); 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; boolean hasAnnotation = hasJAXBAnnotation(ga) || hasJAXBAnnotation(sa); boolean isOverriding = false; if(!hasAnnotation) { // checking if the method is overriding others isn't free, // so we don't compute it if it's not necessary. isOverriding = (getter!=null && nav().isOverriding(getter,c)) && (setter!=null && nav().isOverriding(setter,c)); } if((at==XmlAccessType.PROPERTY && !isOverriding) || (at==XmlAccessType.PUBLIC_MEMBER && isConsideredPublic(getter) && isConsideredPublic(setter) && !isOverriding) || hasAnnotation) { // make sure that the type is consistent if(getter!=null && setter!=null && !nav().isSameType(nav().getReturnType(getter), nav().getMethodParameters(setter)[0])) { // inconsistent builder.reportError(new IllegalAnnotationException( Messages.GETTER_SETTER_INCOMPATIBLE_TYPE.format( nav().getTypeName(nav().getReturnType(getter)), nav().getTypeName(nav().getMethodParameters(setter)[0]) ), new MethodLocatable<M>( this, getter, nav()), new MethodLocatable<M>( this, setter, nav()))); continue; } // merge annotations from two list Annotation[] r; if(ga.length==0) { r = sa; } else if(sa.length==0) { r = ga; } else { r = new Annotation[ga.length+sa.length]; System.arraycopy(ga,0,r,0,ga.length); System.arraycopy(sa,0,r,ga.length,sa.length); } addProperty(createAccessorSeed(getter, setter), r, false); } } // done with complete pairs getters.keySet().removeAll(complete); setters.keySet().removeAll(complete); // TODO: think about // class Foo { // int getFoo(); // } // class Bar extends Foo { // void setFoo(int x); // } // and how it will be XML-ized. }
Example #12
Source File: RegistryInfoImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Picks up references in this registry to other types. */ RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) { this.nav = builder.nav; this.registryClass = registryClass; this.upstream = upstream; builder.registries.put(getPackageName(),this); if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) { // the user is trying to use ObjectFactory that we generate for interfaces, // that means he's missing jaxb.properties builder.reportError(new IllegalAnnotationException( Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()), this )); // looking at members will only add more errors, so just abort now return; } for( M m : nav.getDeclaredMethods(registryClass) ) { XmlElementDecl em = builder.reader.getMethodAnnotation( XmlElementDecl.class, m, this ); if(em==null) { if(nav.getMethodName(m).startsWith("create")) { // this is a factory method. visit this class references.add( builder.getTypeInfo(nav.getReturnType(m), new MethodLocatable<M>(this,m,nav))); } continue; } ElementInfoImpl<T,C,F,M> ei; try { ei = builder.createElementInfo(this,m); } catch (IllegalAnnotationException e) { builder.reportError(e); continue; // recover by ignoring this element } // register this mapping // TODO: any chance this could cause a stack overflow (by recursively visiting classes)? builder.typeInfoSet.add(ei,builder); references.add(ei); } }
Example #13
Source File: ClassInfoImpl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Adds properties that consists of accessors. */ private void findGetterSetterProperties(XmlAccessType at) { // in the first step we accumulate getters and setters // into this map keyed by the property name. Map<String,M> getters = new LinkedHashMap<String,M>(); Map<String,M> setters = new LinkedHashMap<String,M>(); C c = clazz; do { collectGetterSetters(clazz, getters, setters); // take super classes into account if they have @XmlTransient c = nav().getSuperClass(c); } while(shouldRecurseSuperClass(c)); // compute the intersection Set<String> complete = new TreeSet<String>(getters.keySet()); complete.retainAll(setters.keySet()); resurrect(getters, complete); resurrect(setters, complete); // then look for read/write properties. for (String name : complete) { M getter = getters.get(name); 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; boolean hasAnnotation = hasJAXBAnnotation(ga) || hasJAXBAnnotation(sa); boolean isOverriding = false; if(!hasAnnotation) { // checking if the method is overriding others isn't free, // so we don't compute it if it's not necessary. isOverriding = (getter!=null && nav().isOverriding(getter,c)) && (setter!=null && nav().isOverriding(setter,c)); } if((at==XmlAccessType.PROPERTY && !isOverriding) || (at==XmlAccessType.PUBLIC_MEMBER && isConsideredPublic(getter) && isConsideredPublic(setter) && !isOverriding) || hasAnnotation) { // make sure that the type is consistent if(getter!=null && setter!=null && !nav().isSameType(nav().getReturnType(getter), nav().getMethodParameters(setter)[0])) { // inconsistent builder.reportError(new IllegalAnnotationException( Messages.GETTER_SETTER_INCOMPATIBLE_TYPE.format( nav().getTypeName(nav().getReturnType(getter)), nav().getTypeName(nav().getMethodParameters(setter)[0]) ), new MethodLocatable<M>( this, getter, nav()), new MethodLocatable<M>( this, setter, nav()))); continue; } // merge annotations from two list Annotation[] r; if(ga.length==0) { r = sa; } else if(sa.length==0) { r = ga; } else { r = new Annotation[ga.length+sa.length]; System.arraycopy(ga,0,r,0,ga.length); System.arraycopy(sa,0,r,ga.length,sa.length); } addProperty(createAccessorSeed(getter, setter), r, false); } } // done with complete pairs getters.keySet().removeAll(complete); setters.keySet().removeAll(complete); // TODO: think about // class Foo { // int getFoo(); // } // class Bar extends Foo { // void setFoo(int x); // } // and how it will be XML-ized. }
Example #14
Source File: RegistryInfoImpl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Picks up references in this registry to other types. */ RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) { this.nav = builder.nav; this.registryClass = registryClass; this.upstream = upstream; builder.registries.put(getPackageName(),this); if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) { // the user is trying to use ObjectFactory that we generate for interfaces, // that means he's missing jaxb.properties builder.reportError(new IllegalAnnotationException( Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()), this )); // looking at members will only add more errors, so just abort now return; } for( M m : nav.getDeclaredMethods(registryClass) ) { XmlElementDecl em = builder.reader.getMethodAnnotation( XmlElementDecl.class, m, this ); if(em==null) { if(nav.getMethodName(m).startsWith("create")) { // this is a factory method. visit this class references.add( builder.getTypeInfo(nav.getReturnType(m), new MethodLocatable<M>(this,m,nav))); } continue; } ElementInfoImpl<T,C,F,M> ei; try { ei = builder.createElementInfo(this,m); } catch (IllegalAnnotationException e) { builder.reportError(e); continue; // recover by ignoring this element } // register this mapping // TODO: any chance this could cause a stack overflow (by recursively visiting classes)? builder.typeInfoSet.add(ei,builder); references.add(ei); } }
Example #15
Source File: ClassInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Adds properties that consists of accessors. */ private void findGetterSetterProperties(XmlAccessType at) { // in the first step we accumulate getters and setters // into this map keyed by the property name. Map<String,M> getters = new LinkedHashMap<String,M>(); Map<String,M> setters = new LinkedHashMap<String,M>(); C c = clazz; do { collectGetterSetters(clazz, getters, setters); // take super classes into account if they have @XmlTransient c = nav().getSuperClass(c); } while(shouldRecurseSuperClass(c)); // compute the intersection Set<String> complete = new TreeSet<String>(getters.keySet()); complete.retainAll(setters.keySet()); resurrect(getters, complete); resurrect(setters, complete); // then look for read/write properties. for (String name : complete) { M getter = getters.get(name); 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; boolean hasAnnotation = hasJAXBAnnotation(ga) || hasJAXBAnnotation(sa); boolean isOverriding = false; if(!hasAnnotation) { // checking if the method is overriding others isn't free, // so we don't compute it if it's not necessary. isOverriding = (getter!=null && nav().isOverriding(getter,c)) && (setter!=null && nav().isOverriding(setter,c)); } if((at==XmlAccessType.PROPERTY && !isOverriding) || (at==XmlAccessType.PUBLIC_MEMBER && isConsideredPublic(getter) && isConsideredPublic(setter) && !isOverriding) || hasAnnotation) { // make sure that the type is consistent if(getter!=null && setter!=null && !nav().isSameType(nav().getReturnType(getter), nav().getMethodParameters(setter)[0])) { // inconsistent builder.reportError(new IllegalAnnotationException( Messages.GETTER_SETTER_INCOMPATIBLE_TYPE.format( nav().getTypeName(nav().getReturnType(getter)), nav().getTypeName(nav().getMethodParameters(setter)[0]) ), new MethodLocatable<M>( this, getter, nav()), new MethodLocatable<M>( this, setter, nav()))); continue; } // merge annotations from two list Annotation[] r; if(ga.length==0) { r = sa; } else if(sa.length==0) { r = ga; } else { r = new Annotation[ga.length+sa.length]; System.arraycopy(ga,0,r,0,ga.length); System.arraycopy(sa,0,r,ga.length,sa.length); } addProperty(createAccessorSeed(getter, setter), r, false); } } // done with complete pairs getters.keySet().removeAll(complete); setters.keySet().removeAll(complete); // TODO: think about // class Foo { // int getFoo(); // } // class Bar extends Foo { // void setFoo(int x); // } // and how it will be XML-ized. }
Example #16
Source File: RegistryInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Picks up references in this registry to other types. */ RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) { this.nav = builder.nav; this.registryClass = registryClass; this.upstream = upstream; builder.registries.put(getPackageName(),this); if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) { // the user is trying to use ObjectFactory that we generate for interfaces, // that means he's missing jaxb.properties builder.reportError(new IllegalAnnotationException( Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()), this )); // looking at members will only add more errors, so just abort now return; } for( M m : nav.getDeclaredMethods(registryClass) ) { XmlElementDecl em = builder.reader.getMethodAnnotation( XmlElementDecl.class, m, this ); if(em==null) { if(nav.getMethodName(m).startsWith("create")) { // this is a factory method. visit this class references.add( builder.getTypeInfo(nav.getReturnType(m), new MethodLocatable<M>(this,m,nav))); } continue; } ElementInfoImpl<T,C,F,M> ei; try { ei = builder.createElementInfo(this,m); } catch (IllegalAnnotationException e) { builder.reportError(e); continue; // recover by ignoring this element } // register this mapping // TODO: any chance this could cause a stack overflow (by recursively visiting classes)? builder.typeInfoSet.add(ei,builder); references.add(ei); } }