001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.xml.bind.v2.model.core;
038:
039: import java.util.Collection;
040: import java.util.Set;
041:
042: import javax.xml.namespace.QName;
043:
044: /**
045: * {@link PropertyInfo} that holds references to other {@link Element}s.
046: *
047: * @author Kohsuke Kawaguchi
048: */
049: public interface ReferencePropertyInfo<T, C> extends PropertyInfo<T, C> {
050: /**
051: * Returns the information about the possible elements in this property.
052: *
053: * <p>
054: * As of 2004/08/17, the spec only allows you to use different element names
055: * when a property is a collection, but I think there's really no reason
056: * to limit it there --- if the user wants to use a different tag name
057: * for different objects, I don't see why this can be limited to collections.
058: *
059: * <p>
060: * So this is a generalization of the spec. We always allow a property to have
061: * multiple types and use different tag names for it, depending on the actual type.
062: *
063: * <p>
064: * In most of the cases, this collection only contains 1 item. So the runtime system
065: * is encouraged to provide a faster code-path that is optimized toward such cases.
066: *
067: * @return
068: * Always non-null. Contains at least one entry.
069: */
070: Set<? extends Element<T, C>> getElements();
071:
072: /**
073: * {@inheritDoc}.
074: *
075: * If this {@link ReferencePropertyInfo} has a wildcard in it,
076: * then the returned list will contain {@link WildcardTypeInfo}.
077: */
078: Collection<? extends TypeInfo<T, C>> ref();
079:
080: /**
081: * Gets the wrapper element name.
082: *
083: * @return
084: * must be null if not collection. If the property is a collection,
085: * this can be null (in which case there'll be no wrapper),
086: * or it can be non-null (in which case there'll be a wrapper)
087: */
088: QName getXmlName();
089:
090: /**
091: * Returns true if this property is nillable
092: * (meaning the absence of the value is treated as nil='true')
093: *
094: * <p>
095: * This method is only used when this property is a collection.
096: */
097: boolean isCollectionNillable();
098:
099: /**
100: * Checks if the wrapper element is required.
101: *
102: * @return
103: * Always false if {@link #getXmlName()}==null.
104: */
105: boolean isCollectionRequired();
106:
107: /**
108: * Returns true if this property can hold {@link String}s to represent
109: * mixed content model.
110: */
111: boolean isMixed();
112:
113: /**
114: * If this property supports the wildcard, returns its mode.
115: *
116: * @return null
117: * if the wildcard is not allowed on this element.
118: */
119: WildcardMode getWildcard();
120:
121: /**
122: * If this property supports the wildcard, returns its DOM handler.
123: *
124: * @return null
125: * if the wildcard is not allowed on this element.
126: */
127: C getDOMHandler();
128:
129: Adapter<T, C> getAdapter();
130: }
|