1 /*
2 * Copyright (c) 1997, 2013, 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
25
26 package com.sun.tools.internal.xjc.model;
27
28 import java.lang.annotation.Annotation;
29 import java.util.Collection;
30 import java.util.Map;
31
32 import javax.xml.XMLConstants;
33 import javax.xml.bind.annotation.XmlTransient;
34 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
35 import javax.xml.namespace.QName;
36
37 import com.sun.codemodel.internal.JClass;
38 import com.sun.codemodel.internal.JJavaName;
39 import com.sun.codemodel.internal.JType;
40 import com.sun.tools.internal.xjc.generator.bean.field.FieldRenderer;
41 import com.sun.tools.internal.xjc.model.nav.NClass;
42 import com.sun.tools.internal.xjc.model.nav.NType;
43 import com.sun.tools.internal.xjc.reader.Ring;
44 import com.sun.xml.internal.bind.api.impl.NameConverter;
45 import com.sun.xml.internal.bind.v2.WellKnownNamespace;
46 import com.sun.xml.internal.bind.v2.model.core.PropertyInfo;
47 import com.sun.xml.internal.bind.v2.runtime.RuntimeUtil;
48 import com.sun.xml.internal.xsom.XSComponent;
49
50 import org.xml.sax.Locator;
51
52 /**
53 * Model of a property to be generated.
54 *
55 * @author Kohsuke Kawaguchi
56 */
57 public abstract class CPropertyInfo implements PropertyInfo<NType,NClass>, CCustomizable {
58
59 @XmlTransient
60 private CClassInfo parent;
61 private String privateName;
62 private String publicName;
63 private final boolean isCollection;
64
65 @XmlTransient
273 }
274
275 /**
276 * Returns true if this property needs to represent null
277 * just for the purpose of representing an absence of the property.
278 */
279 public boolean isOptionalPrimitive() {
280 return false;
281 }
282
283 public CCustomizations getCustomizations() {
284 return customizations;
285 }
286
287 public boolean inlineBinaryData() {
288 return inlineBinaryData;
289 }
290
291 public abstract <V> V accept( CPropertyVisitor<V> visitor );
292
293 /**
294 * Checks if the given {@link TypeUse} would need an explicit {@link XmlSchemaType}
295 * annotation with the given type name.
296 */
297 protected static boolean needsExplicitTypeName(TypeUse type, QName typeName) {
298 if(typeName==null)
299 // this is anonymous type. can't have @XmlSchemaType
300 return false;
301
302 if(!XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(typeName.getNamespaceURI()))
303 // if we put application-defined type name, it will be undefined
304 // by the time we generate a schema.
305 return false;
306
307 if(type.isCollection())
308 // there's no built-in binding for a list simple type,
309 // so any collection type always need @XmlSchemaType
310 return true;
311
312 QName itemType = type.getInfo().getTypeName();
|
1 /*
2 * Copyright (c) 1997, 2014, 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
25
26 package com.sun.tools.internal.xjc.model;
27
28 import java.lang.annotation.Annotation;
29 import java.util.Collection;
30 import java.util.Map;
31
32 import javax.xml.XMLConstants;
33 import javax.xml.bind.annotation.XmlTransient;
34 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
35 import javax.xml.namespace.QName;
36
37 import com.sun.codemodel.internal.JClass;
38 import com.sun.codemodel.internal.JJavaName;
39 import com.sun.codemodel.internal.JType;
40 import com.sun.tools.internal.xjc.generator.bean.field.FieldRenderer;
41 import com.sun.tools.internal.xjc.model.nav.NClass;
42 import com.sun.tools.internal.xjc.model.nav.NType;
43 import com.sun.tools.internal.xjc.reader.Ring;
44 import com.sun.xml.internal.bind.api.impl.NameConverter;
45 import com.sun.xml.internal.bind.v2.model.core.PropertyInfo;
46 import com.sun.xml.internal.bind.v2.runtime.RuntimeUtil;
47 import com.sun.xml.internal.xsom.XSComponent;
48
49 import org.xml.sax.Locator;
50
51 /**
52 * Model of a property to be generated.
53 *
54 * @author Kohsuke Kawaguchi
55 */
56 public abstract class CPropertyInfo implements PropertyInfo<NType,NClass>, CCustomizable {
57
58 @XmlTransient
59 private CClassInfo parent;
60 private String privateName;
61 private String publicName;
62 private final boolean isCollection;
63
64 @XmlTransient
272 }
273
274 /**
275 * Returns true if this property needs to represent null
276 * just for the purpose of representing an absence of the property.
277 */
278 public boolean isOptionalPrimitive() {
279 return false;
280 }
281
282 public CCustomizations getCustomizations() {
283 return customizations;
284 }
285
286 public boolean inlineBinaryData() {
287 return inlineBinaryData;
288 }
289
290 public abstract <V> V accept( CPropertyVisitor<V> visitor );
291
292 public abstract <R, P> R accept( CPropertyVisitor2<R, P> visitor, P p );
293
294 /**
295 * Checks if the given {@link TypeUse} would need an explicit {@link XmlSchemaType}
296 * annotation with the given type name.
297 */
298 protected static boolean needsExplicitTypeName(TypeUse type, QName typeName) {
299 if(typeName==null)
300 // this is anonymous type. can't have @XmlSchemaType
301 return false;
302
303 if(!XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(typeName.getNamespaceURI()))
304 // if we put application-defined type name, it will be undefined
305 // by the time we generate a schema.
306 return false;
307
308 if(type.isCollection())
309 // there's no built-in binding for a list simple type,
310 // so any collection type always need @XmlSchemaType
311 return true;
312
313 QName itemType = type.getInfo().getTypeName();
|