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.xsom;
027:
028: import java.util.List;
029: import java.util.Set;
030:
031: /**
032: * Element declaration.
033: *
034: * @author
035: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
036: */
037: public interface XSElementDecl extends XSDeclaration, XSTerm {
038: XSType getType();
039:
040: boolean isNillable();
041:
042: XSElementDecl getSubstAffiliation();
043:
044: /**
045: * Returns all the {@link XSIdentityConstraint}s in this element decl.
046: *
047: * @return
048: * never null, but can be empty.
049: */
050: List<XSIdentityConstraint> getIdentityConstraints();
051:
052: /**
053: * Checks the substitution excluded property of the schema component.
054: *
055: * IOW, this checks the value of the <code>final</code> attribute
056: * (plus <code>finalDefault</code>).
057: *
058: * @param method
059: * Possible values are {@link XSType.EXTENSION} or
060: * <code>XSType.RESTRICTION</code>.
061: */
062: boolean isSubstitutionExcluded(int method);
063:
064: /**
065: * Checks the diallowed substitution property of the schema component.
066: *
067: * IOW, this checks the value of the <code>block</code> attribute
068: * (plus <code>blockDefault</code>).
069: *
070: * @param method
071: * Possible values are {@link XSType.EXTENSION},
072: * <code>XSType.RESTRICTION</code>, or <code>XSType.SUBSTITUTION</code>
073: */
074: boolean isSubstitutionDisallowed(int method);
075:
076: boolean isAbstract();
077:
078: /**
079: * Returns the element declarations that can substitute
080: * this element.
081: *
082: * <p>
083: * IOW, this set returns all the element decls that satisfies
084: * <a href="http://www.w3.org/TR/xmlschema-1/#cos-equiv-derived-ok-rec">
085: * the "Substitution Group OK" constraint.
086: * </a>
087: *
088: * @return
089: * nun-null valid array. The return value always contains this element
090: * decl itself.
091: *
092: * @deprecated
093: * this method allocates a new array every time, so it could be
094: * inefficient when working with a large schema. Use
095: * {@link #getSubstitutables()} instead.
096: */
097: XSElementDecl[] listSubstitutables();
098:
099: /**
100: * Returns the element declarations that can substitute
101: * this element.
102: *
103: * <p>
104: * IOW, this set returns all the element decls that satisfies
105: * <a href="http://www.w3.org/TR/xmlschema-1/#cos-equiv-derived-ok-rec">
106: * the "Substitution Group OK" constraint.
107: * </a>
108: *
109: * <p>
110: * Note that the above clause does <em>NOT</em> check for
111: * abstract elements. So abstract elements may still show up
112: * in the returned set.
113: *
114: * @return
115: * nun-null unmodifiable list.
116: * The returned list always contains this element decl itself.
117: */
118: Set<? extends XSElementDecl> getSubstitutables();
119:
120: /**
121: * Returns true if this element declaration can be validly substituted
122: * by the given declaration.
123: *
124: * <p>
125: * Just a short cut of <tt>getSubstitutables().contain(e);</tt>
126: */
127: boolean canBeSubstitutedBy(XSElementDecl e);
128:
129: // TODO: identitiy constraints
130: // TODO: scope
131:
132: XmlString getDefaultValue();
133:
134: XmlString getFixedValue();
135: }
|