001: /*
002: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.xml.internal.bind.v2.model.core;
027:
028: import java.util.Collection;
029:
030: import javax.activation.MimeType;
031: import javax.xml.bind.annotation.XmlID;
032: import javax.xml.bind.annotation.XmlIDREF;
033: import javax.xml.bind.annotation.XmlType;
034: import javax.xml.bind.annotation.XmlSchemaType;
035: import javax.xml.namespace.QName;
036:
037: import com.sun.istack.internal.Nullable;
038:
039: /**
040: * Information about a JAXB-bound property.
041: *
042: * <p>
043: * All the JAXB annotations are already incorporated into the model so that
044: * the caller doesn't have to worry about reading them. For this reason, you
045: * cannot access annotations on properties directly.
046: *
047: * TODO: don't we need a visitor?
048: *
049: * @author Kohsuke Kawaguchi
050: */
051: public interface PropertyInfo<T, C> {
052:
053: /**
054: * Gets the {@link ClassInfo} or {@link ElementInfo} to which this property belongs.
055: */
056: TypeInfo<T, C> parent();
057:
058: /**
059: * Gets the name of the property.
060: *
061: * <p>
062: * For example, "foo" or "bar".
063: * Generally, a property name is different from XML,
064: * (although they are often related, as a property name is often
065: * computed from tag names / attribute names.)
066: * In fact, <b>property names do not directly affect XML</b>.
067: * The property name uniquely identifies a property within a class.
068: *
069: * @see XmlType#propOrder()
070: */
071: String getName();
072:
073: /**
074: * Gets the display name of the property.
075: *
076: * <p>
077: * This is a convenience method for
078: * {@code parent().getName()+'#'+getName()}.
079: */
080: String displayName();
081:
082: /**
083: * Returns true if this is a multi-valued collection property.
084: * Otherwise false, in which case the property is a single value.
085: */
086: boolean isCollection();
087:
088: /**
089: * List of {@link TypeInfo}s that this property references.
090: *
091: * This allows the caller to traverse the reference graph without
092: * getting into the details of each different property type.
093: *
094: * @return
095: * non-null read-only collection.
096: */
097: Collection<? extends TypeInfo<T, C>> ref();
098:
099: /**
100: * Gets the kind of this proeprty.
101: *
102: * @return
103: * always non-null.
104: */
105: PropertyKind kind();
106:
107: /**
108: * @return
109: * null if the property is not adapted.
110: */
111: Adapter<T, C> getAdapter();
112:
113: /**
114: * Returns the IDness of the value of this element.
115: *
116: * @see XmlID
117: * @see XmlIDREF
118: *
119: * @return
120: * always non-null
121: */
122: ID id();
123:
124: /**
125: * Expected MIME type, if any.
126: */
127: MimeType getExpectedMimeType();
128:
129: /**
130: * If this is true and this property indeed represents a binary data,
131: * it should be always inlined.
132: */
133: boolean inlineBinaryData();
134:
135: /**
136: * The effective value of {@link XmlSchemaType} annotation, if any.
137: *
138: * <p>
139: * If the property doesn't have {@link XmlSchemaType} annotation,
140: * this method returns null.
141: *
142: * <p>
143: * Since a type name is a property of a Java type, not a Java property,
144: * A schema type name of a Java type should be primarily obtained
145: * by using {@link NonElement#getTypeName()}. This method is to correctly
146: * implement the ugly semantics of {@link XmlSchemaType} (namely
147: * when this returns non-null, it overrides the type names of all types
148: * that are in this property.)
149: */
150: @Nullable
151: QName getSchemaType();
152: }
|