1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
402 ClassInfoImpl<T, C, F, M> bc = getBaseClass();
403 if(bc!=null && bc.hasValueProperty())
404 return true;
405
406 for (PropertyInfo p : getProperties()) {
407 if (p instanceof ValuePropertyInfo) return true;
408 }
409
410 return false;
411 }
412
413 public PropertyInfo<T,C> getProperty(String name) {
414 for( PropertyInfo<T,C> p: getProperties() ) {
415 if(p.getName().equals(name))
416 return p;
417 }
418 return null;
419 }
420
421 /**
422 * This hook is used by {@link RuntimeClassInfoImpl} to look for {@link XmlLocation}.
423 */
424 protected void checkFieldXmlLocation(F f) {
425 }
426
427 /**
428 * Gets an annotation that are allowed on both class and type.
429 */
430 private <T extends Annotation> T getClassOrPackageAnnotation(Class<T> type) {
431 T t = reader().getClassAnnotation(type,clazz,this);
432 if(t!=null)
433 return t;
434 // defaults to the package level
435 return reader().getPackageAnnotation(type,clazz,this);
436 }
437
438 /**
439 * Computes the {@link XmlAccessType} on this class by looking at {@link XmlAccessorType}
440 * annotations.
441 */
442 private XmlAccessType getAccessType() {
1228 if(c.attributeWildcard!=null)
1229 return c.attributeWildcard;
1230 return null;
1231 }
1232
1233 public final QName getElementName() {
1234 return elementName;
1235 }
1236
1237 public final QName getTypeName() {
1238 return typeName;
1239 }
1240
1241 public final boolean isSimpleType() {
1242 List<? extends PropertyInfo> props = getProperties();
1243 if(props.size()!=1) return false;
1244 return props.get(0).kind()==PropertyKind.VALUE;
1245 }
1246
1247 /**
1248 * Called after all the {@link TypeInfo}s are collected into the {@link #owner}.
1249 */
1250 @Override
1251 /*package*/ void link() {
1252 getProperties(); // make sure properties!=null
1253
1254 // property name collision cehck
1255 Map<String,PropertyInfoImpl> names = new HashMap<String,PropertyInfoImpl>();
1256 for( PropertyInfoImpl<T,C,F,M> p : properties ) {
1257 p.link();
1258 PropertyInfoImpl old = names.put(p.getName(),p);
1259 if(old!=null) {
1260 builder.reportError(new IllegalAnnotationException(
1261 Messages.PROPERTY_COLLISION.format(p.getName()),
1262 p, old ));
1263 }
1264 }
1265 super.link();
1266 }
1267
1268 public Location getLocation() {
|
1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
402 ClassInfoImpl<T, C, F, M> bc = getBaseClass();
403 if(bc!=null && bc.hasValueProperty())
404 return true;
405
406 for (PropertyInfo p : getProperties()) {
407 if (p instanceof ValuePropertyInfo) return true;
408 }
409
410 return false;
411 }
412
413 public PropertyInfo<T,C> getProperty(String name) {
414 for( PropertyInfo<T,C> p: getProperties() ) {
415 if(p.getName().equals(name))
416 return p;
417 }
418 return null;
419 }
420
421 /**
422 * This hook is used by {@link RuntimeClassInfoImpl} to look for {@link com.sun.xml.internal.bind.annotation.XmlLocation}.
423 */
424 protected void checkFieldXmlLocation(F f) {
425 }
426
427 /**
428 * Gets an annotation that are allowed on both class and type.
429 */
430 private <T extends Annotation> T getClassOrPackageAnnotation(Class<T> type) {
431 T t = reader().getClassAnnotation(type,clazz,this);
432 if(t!=null)
433 return t;
434 // defaults to the package level
435 return reader().getPackageAnnotation(type,clazz,this);
436 }
437
438 /**
439 * Computes the {@link XmlAccessType} on this class by looking at {@link XmlAccessorType}
440 * annotations.
441 */
442 private XmlAccessType getAccessType() {
1228 if(c.attributeWildcard!=null)
1229 return c.attributeWildcard;
1230 return null;
1231 }
1232
1233 public final QName getElementName() {
1234 return elementName;
1235 }
1236
1237 public final QName getTypeName() {
1238 return typeName;
1239 }
1240
1241 public final boolean isSimpleType() {
1242 List<? extends PropertyInfo> props = getProperties();
1243 if(props.size()!=1) return false;
1244 return props.get(0).kind()==PropertyKind.VALUE;
1245 }
1246
1247 /**
1248 * Called after all the {@link com.sun.xml.internal.bind.v2.model.core.TypeInfo}s are collected into the {@link #owner}.
1249 */
1250 @Override
1251 /*package*/ void link() {
1252 getProperties(); // make sure properties!=null
1253
1254 // property name collision cehck
1255 Map<String,PropertyInfoImpl> names = new HashMap<String,PropertyInfoImpl>();
1256 for( PropertyInfoImpl<T,C,F,M> p : properties ) {
1257 p.link();
1258 PropertyInfoImpl old = names.put(p.getName(),p);
1259 if(old!=null) {
1260 builder.reportError(new IllegalAnnotationException(
1261 Messages.PROPERTY_COLLISION.format(p.getName()),
1262 p, old ));
1263 }
1264 }
1265 super.link();
1266 }
1267
1268 public Location getLocation() {
|