Thu, 31 Aug 2017 15:18:52 +0800
merge
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 */
26 package com.sun.xml.internal.bind.v2.model.core;
28 import java.util.Collection;
30 import javax.activation.MimeType;
31 import javax.xml.bind.annotation.XmlID;
32 import javax.xml.bind.annotation.XmlIDREF;
33 import javax.xml.bind.annotation.XmlType;
34 import javax.xml.bind.annotation.XmlSchemaType;
35 import javax.xml.namespace.QName;
37 import com.sun.istack.internal.Nullable;
38 import com.sun.xml.internal.bind.v2.model.annotation.AnnotationSource;
40 /**
41 * Information about a JAXB-bound property.
42 *
43 * <p>
44 * All the JAXB annotations are already incorporated into the model so that
45 * the caller doesn't have to worry about reading them. For this reason, you
46 * cannot access annotations on properties directly.
47 *
48 * TODO: don't we need a visitor?
49 *
50 * @author Kohsuke Kawaguchi
51 */
52 public interface PropertyInfo<T,C> extends AnnotationSource {
54 /**
55 * Gets the {@link ClassInfo} or {@link ElementInfo} to which this property belongs.
56 */
57 TypeInfo<T,C> parent();
59 /**
60 * Gets the name of the property.
61 *
62 * <p>
63 * For example, "foo" or "bar".
64 * Generally, a property name is different from XML,
65 * (although they are often related, as a property name is often
66 * computed from tag names / attribute names.)
67 * In fact, <b>property names do not directly affect XML</b>.
68 * The property name uniquely identifies a property within a class.
69 *
70 * @see XmlType#propOrder()
71 */
72 String getName();
74 /**
75 * Gets the display name of the property.
76 *
77 * <p>
78 * This is a convenience method for
79 * {@code parent().getName()+'#'+getName()}.
80 */
81 String displayName();
83 /**
84 * Returns true if this is a multi-valued collection property.
85 * Otherwise false, in which case the property is a single value.
86 */
87 boolean isCollection();
89 /**
90 * List of {@link TypeInfo}s that this property references.
91 *
92 * This allows the caller to traverse the reference graph without
93 * getting into the details of each different property type.
94 *
95 * @return
96 * non-null read-only collection.
97 */
98 Collection<? extends TypeInfo<T,C>> ref();
100 /**
101 * Gets the kind of this property.
102 *
103 * @return
104 * always non-null.
105 */
106 PropertyKind kind();
108 /**
109 * @return
110 * null if the property is not adapted.
111 */
112 Adapter<T,C> getAdapter();
114 /**
115 * Returns the IDness of the value of this element.
116 *
117 * @see XmlID
118 * @see XmlIDREF
119 *
120 * @return
121 * always non-null
122 */
123 ID id();
125 /**
126 * Expected MIME type, if any.
127 */
128 MimeType getExpectedMimeType();
130 /**
131 * If this is true and this property indeed represents a binary data,
132 * it should be always inlined.
133 */
134 boolean inlineBinaryData();
136 /**
137 * The effective value of {@link XmlSchemaType} annotation, if any.
138 *
139 * <p>
140 * If the property doesn't have {@link XmlSchemaType} annotation,
141 * this method returns null.
142 *
143 * <p>
144 * Since a type name is a property of a Java type, not a Java property,
145 * A schema type name of a Java type should be primarily obtained
146 * by using {@link NonElement#getTypeName()}. This method is to correctly
147 * implement the ugly semantics of {@link XmlSchemaType} (namely
148 * when this returns non-null, it overrides the type names of all types
149 * that are in this property.)
150 */
151 @Nullable QName getSchemaType();
152 }