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.List;
029:
030: import javax.xml.bind.annotation.XmlTransient;
031:
032: /**
033: * Information about JAXB-bound class.
034: *
035: * <p>
036: * All the JAXB annotations are already reflected to the model so that
037: * the caller doesn't have to worry about them. For this reason, you
038: * cannot access annotations on properties.
039: *
040: * <h2>XML representation</h2>
041: * <p>
042: * A JAXB-bound class always have at least one representation
043: * (called "type representation"),but it can optionally have another
044: * representation ("element representation").
045: *
046: * <p>
047: * In the type representaion, a class
048: * is represented as a set of attributes and (elements or values).
049: * You can inspect the details of those attributes/elements/values by {@link #getProperties()}.
050: * This representation corresponds to a complex/simple type in XML Schema.
051: * You can obtain the schema type name by {@link #getTypeName()}.
052: *
053: * <p>
054: * If a class has an element representation, {@link #isElement()} returns true.
055: * This representation is mostly similar to the type representation
056: * except that the whoe attributes/elements/values are wrapped into
057: * one element. You can obtain the name of this element through {@link #asElement()}.
058: *
059: * @author Kohsuke Kawaguchi (kk@kohsuke.org)
060: */
061: public interface ClassInfo<T, C> extends MaybeElement<T, C> {
062:
063: /**
064: * Obtains the information about the base class.
065: *
066: * @return null
067: * if this info extends from {@link Object}.
068: */
069: ClassInfo<T, C> getBaseClass();
070:
071: /**
072: * Gets the declaration this object is wrapping.
073: */
074: C getClazz();
075:
076: /**
077: * Gets the fully-qualified name of the class.
078: */
079: String getName();
080:
081: /**
082: * Returns all the properties newly declared in this class.
083: *
084: * <p>
085: * This excludes properties defined in the super class.
086: *
087: * <p>
088: * If the properties are {@link #isOrdered() ordered},
089: * it will be returned in the order that appear in XML.
090: * Otherwise it will be returned in no particular order.
091: *
092: * <p>
093: * Properties marked with {@link XmlTransient} will not show up
094: * in this list. As far as JAXB is concerned, they are considered
095: * non-existent.
096: *
097: * @return
098: * always non-null, but can be empty.
099: */
100: List<? extends PropertyInfo<T, C>> getProperties();
101:
102: /**
103: * Gets the property that has the specified name.
104: *
105: * <p>
106: * This is just a convenience method for:
107: * <pre>
108: * for( PropertyInfo p : getProperties() ) {
109: * if(p.getName().equals(name))
110: * return p;
111: * }
112: * return null;
113: * </pre>
114: *
115: * @return null
116: * if the property was not found.
117: *
118: * @see PropertyInfo#getName()
119: */
120: PropertyInfo<T, C> getProperty(String name);
121:
122: /**
123: * If the class has properties, return true. This is only
124: * true if the Collection object returned by {@link #getProperties()}
125: * is not empty.
126: */
127: boolean hasProperties();
128:
129: /**
130: * If this class is abstract and thus shall never be directly instanciated.
131: */
132: boolean isAbstract();
133:
134: /**
135: * Returns true if the properties of this class is ordered in XML.
136: * False if it't not.
137: *
138: * <p>
139: * In RELAX NG context, ordered properties mean <group> and
140: * unordered properties mean <interleave>.
141: */
142: boolean isOrdered();
143:
144: /**
145: * If this class is marked as final and no further extension/restriction is allowed.
146: */
147: boolean isFinal();
148:
149: /**
150: * True if there's a known sub-type of this class in {@link TypeInfoSet}.
151: */
152: boolean hasSubClasses();
153:
154: /**
155: * Returns true if this bean class has an attribute wildcard.
156: *
157: * <p>
158: * This is true if the class declares an attribute wildcard,
159: * or it is inherited from its super classes.
160: *
161: * @see #inheritsAttributeWildcard()
162: */
163: boolean hasAttributeWildcard();
164:
165: /**
166: * Returns true iff this class inherits a wildcard attribute
167: * from its ancestor classes.
168: */
169: boolean inheritsAttributeWildcard();
170:
171: /**
172: * Returns true iff this class declares a wildcard attribute.
173: */
174: boolean declaresAttributeWildcard();
175: }
|