src/share/jaxws_classes/com/sun/tools/internal/xjc/model/TypeUse.java

changeset 0
373ffda63c9a
equal deleted inserted replaced
-1:000000000000 0:373ffda63c9a
1 /*
2 * Copyright (c) 1997, 2011, 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
23 * questions.
24 */
25
26 package com.sun.tools.internal.xjc.model;
27
28 import javax.activation.MimeType;
29
30 import com.sun.codemodel.internal.JExpression;
31 import com.sun.tools.internal.xjc.model.nav.NType;
32 import com.sun.tools.internal.xjc.outline.Outline;
33 import com.sun.xml.internal.bind.v2.model.core.ID;
34 import com.sun.xml.internal.xsom.XmlString;
35
36 /**
37 * Information about how another type is referenced.
38 *
39 * <p>
40 * In practice it is often easier to use {@link CTypeInfo}
41 * instead of {@link NType}, so this interface defines {@link #getInfo()}.
42 *
43 * @author Kohsuke Kawaguchi
44 * @see TypeUseImpl
45 */
46 public interface TypeUse {
47 /**
48 * If the use can hold multiple values of the specified type.
49 */
50 boolean isCollection();
51
52 /**
53 * If this type use is adapting the type, returns the adapter.
54 * Otherwise return null.
55 */
56 CAdapter getAdapterUse();
57
58 /**
59 * Individual item type.
60 */
61 CNonElement getInfo();
62
63 /**
64 * Whether the referenced type (individual item type in case of collection)
65 * is ID/IDREF.
66 *
67 * <p>
68 * ID is a property of a relationship. When a bean Foo has an ID property
69 * called 'bar' whose type is String, Foo isn't an ID, String isn't an ID,
70 * but this relationship is an ID (in the sense that Foo uses this String
71 * as an ID.)
72 *
73 * <p>
74 * The same thing can be said with IDREF. When Foo refers to Bar by means of
75 * IDREF, neither Foo nor Bar is IDREF.
76 *
77 * <p>
78 * That's why we have this method in {@link TypeUse}.
79 */
80 ID idUse();
81
82 /**
83 * A {@link TypeUse} can have an associated MIME type.
84 */
85 MimeType getExpectedMimeType();
86
87 /**
88 * Creates a constant for the given lexical value.
89 *
90 * <p>
91 * For example, to create a constant 1 for <tt>xs:int</tt>, you'd do:
92 * <pre>
93 * CBuiltinLeafInfo.INT.createConstant( codeModel, "1", null );
94 * </pre>
95 *
96 * <p>
97 * This method is invoked at the backend as a part of the code generation process.
98 *
99 * @throws IllegalStateException
100 * if the type isn't bound to a text in XML.
101 *
102 * @return null
103 * if the constant cannot be created for this {@link TypeUse}
104 * (such as when it's a collection)
105 */
106 JExpression createConstant(Outline outline, XmlString lexical);
107 }

mercurial