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.namespace.QName;
031:
032: /**
033: * Property that maps to an element.
034: *
035: * @author Kohsuke Kawaguchi
036: */
037: // TODO: there seems to be too much interactions between switches, and that's no good.
038: public interface ElementPropertyInfo<T, C> extends PropertyInfo<T, C> {
039: /**
040: * Returns the information about the types allowed in this property.
041: *
042: * <p>
043: * In a simple case like the following, an element property only has
044: * one {@link TypeRef} that points to {@link String} and tag name "foo".
045: * <pre>
046: * @XmlElement
047: * String abc;
048: * </pre>
049: *
050: * <p>
051: * However, in a general case an element property can be heterogeneous,
052: * meaning you can put different types in it, each with a different tag name
053: * (and a few other settings.)
054: * <pre>
055: * // list can contain String or Integer.
056: * @XmlElements({
057: * @XmlElement(name="a",type=String.class),
058: * @XmlElement(name="b",type=Integer.class),
059: * })
060: * List<Object> abc;
061: * </pre>
062: * <p>
063: * In this case this method returns a list of two {@link TypeRef}s.
064: *
065: *
066: * @return
067: * Always non-null. Contains at least one entry.
068: * If {@link #isValueList()}==true, there's always exactly one type.
069: */
070: List<? extends TypeRef<T, C>> getTypes();
071:
072: /**
073: * Gets the wrapper element name.
074: *
075: * @return
076: * must be null if {@link #isCollection()}==false or
077: * if {@link #isValueList()}==true.
078: *
079: * Otherwise,
080: * this can be null (in which case there'll be no wrapper),
081: * or it can be non-null (in which case there'll be a wrapper)
082: */
083: QName getXmlName();
084:
085: /**
086: * Returns true if this property is nillable
087: * (meaning the absence of the value is treated as nil='true')
088: *
089: * <p>
090: * This method is only used when this property is a collection.
091: */
092: boolean isCollectionNillable();
093:
094: /**
095: * Returns true if this property is a collection but its XML
096: * representation is a list of values, not repeated elements.
097: *
098: * <p>
099: * If {@link #isCollection()}==false, this property is always false.
100: *
101: * <p>
102: * When this flag is true, <tt>getTypes().size()==1</tt> always holds.
103: */
104: boolean isValueList();
105:
106: /**
107: * Returns true if this element is mandatory.
108: *
109: * For collections, this property isn't used.
110: * TODO: define the semantics when this is a collection
111: */
112: boolean isRequired();
113:
114: Adapter<T, C> getAdapter();
115: }
|