01: /*
02: * The contents of this file are subject to the terms
03: * of the Common Development and Distribution License
04: * (the "License"). You may not use this file except
05: * in compliance with the License.
06: *
07: * You can obtain a copy of the license at
08: * https://jwsdp.dev.java.net/CDDLv1.0.html
09: * See the License for the specific language governing
10: * permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL
13: * HEADER in each file and include the License file at
14: * https://jwsdp.dev.java.net/CDDLv1.0.html If applicable,
15: * add the following below this CDDL HEADER, with the
16: * fields enclosed by brackets "[]" replaced with your
17: * own identifying information: Portions Copyright [yyyy]
18: * [name of copyright owner]
19: */
20: package com.sun.xml.xsom;
21:
22: /**
23: * Base interface for {@link XSComplexType} and {@link XSSimpleType}.
24: *
25: * @author
26: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
27: */
28: public interface XSType extends XSDeclaration {
29: /**
30: * Returns the base type of this type.
31: *
32: * Note that if this type represents <tt>xs:anyType</tt>, this method returns itself.
33: * This is awkward as an API, but it follows the schema specification.
34: *
35: * @return always non-null.
36: */
37: XSType getBaseType();
38:
39: final static int EXTENSION = 1;
40: final static int RESTRICTION = 2;
41: final static int SUBSTITUTION = 4;
42:
43: int getDerivationMethod();
44:
45: /** Returns true if <code>this instanceof XSSimpleType</code>. */
46: boolean isSimpleType();
47:
48: /** Returns true if <code>this instanceof XSComplexType</code>. */
49: boolean isComplexType();
50:
51: /**
52: * Lists up types that can substitute this type by using xsi:type.
53: * Includes this type itself.
54: * <p>
55: * This method honors the block flag.
56: */
57: XSType[] listSubstitutables();
58:
59: /**
60: * If this {@link XSType} is redefined by another type,
61: * return that component.
62: *
63: * @return null
64: * if this component has not been redefined.
65: */
66: XSType getRedefinedBy();
67:
68: /**
69: * Returns the number of complex types that redefine this component.
70: *
71: * <p>
72: * For example, if A is redefined by B and B is redefined by C,
73: * A.getRedefinedCount()==2, B.getRedefinedCount()==1, and
74: * C.getRedefinedCount()==0.
75: */
76: int getRedefinedCount();
77:
78: /** Casts this object to XSSimpleType if possible, otherwise returns null. */
79: XSSimpleType asSimpleType();
80:
81: /** Casts this object to XSComplexType if possible, otherwise returns null. */
82: XSComplexType asComplexType();
83:
84: /**
85: * Returns true if this type is derived from the specified type.
86: *
87: * <p>
88: * Note that <tt>t.isDerivedFrom(t)</tt> returns true.
89: */
90: boolean isDerivedFrom(XSType t);
91: }
|