1/*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.xml.internal.xsom;
27
28import javax.xml.namespace.NamespaceContext;
29import java.util.Iterator;
30import java.util.Collection;
31
32/**
33 * Set of {@link XSSchema} objects.
34 *
35 * @author
36 *  Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
37 */
38public interface XSSchemaSet
39{
40    XSSchema getSchema(String targetNamespace);
41    XSSchema getSchema(int idx);
42    int getSchemaSize();
43    Iterator<XSSchema> iterateSchema();
44
45    /**
46     * Gets all {@link XSSchema}s in a single collection.
47     */
48    Collection<XSSchema> getSchemas();
49
50    XSType getType(String namespaceURI, String localName);
51    XSSimpleType getSimpleType(String namespaceURI, String localName);
52    XSAttributeDecl getAttributeDecl(String namespaceURI, String localName);
53    XSElementDecl getElementDecl(String namespaceURI, String localName);
54    XSModelGroupDecl getModelGroupDecl(String namespaceURI, String localName);
55    XSAttGroupDecl getAttGroupDecl(String namespaceURI, String localName);
56    XSComplexType getComplexType(String namespaceURI, String localName);
57    XSIdentityConstraint getIdentityConstraint(String namespaceURI, String localName);
58
59    /** Iterates all element declarations in all the schemas. */
60    Iterator<XSElementDecl> iterateElementDecls();
61    /** Iterates all type definitions in all the schemas. */
62    Iterator<XSType> iterateTypes();
63    /** Iterates all atribute declarations in all the schemas. */
64    Iterator<XSAttributeDecl> iterateAttributeDecls();
65    /** Iterates all attribute group declarations in all the schemas. */
66    Iterator<XSAttGroupDecl> iterateAttGroupDecls();
67    /** Iterates all model group declarations in all the schemas. */
68    Iterator<XSModelGroupDecl> iterateModelGroupDecls();
69    /** Iterates all simple type definitions in all the schemas. */
70    Iterator<XSSimpleType> iterateSimpleTypes();
71    /** Iterates all complex type definitions in all the schemas. */
72    Iterator<XSComplexType> iterateComplexTypes();
73    /** Iterates all notation declarations in all the schemas. */
74    Iterator<XSNotation> iterateNotations();
75    /**
76     * Iterates all identity constraints in all the schemas.
77     */
78    Iterator<XSIdentityConstraint> iterateIdentityConstraints();
79
80    // conceptually static methods
81    XSComplexType getAnyType();
82    XSSimpleType getAnySimpleType();
83    XSContentType getEmpty();
84
85    /**
86     * Evaluates a schema component designator against this schema component
87     * and returns the resulting schema components.
88     *
89     * @throws IllegalArgumentException
90     *      if SCD is syntactically incorrect.
91     * @param scd
92     *      Schema component designator. See {@link SCD} for more details.
93     * @param nsContext
94     *      The namespace context in which SCD is evaluated. Cannot be null.
95     * @return
96     *      Can be empty but never null.
97     */
98    Collection<XSComponent> select(String scd, NamespaceContext nsContext);
99
100    /**
101     * Evaluates a schema component designator against this schema component
102     * and returns the first resulting schema component.
103     *
104     * @throws IllegalArgumentException
105     *      if SCD is syntactically incorrect.
106     * @param scd
107     *      Schema component designator. See {@link SCD} for more details.
108     * @param nsContext
109     *      The namespace context in which SCD is evaluated. Cannot be null.
110     * @return
111     *      null if the SCD didn't match anything. If the SCD matched more than one node,
112     *      the first one will be returned.
113     */
114    XSComponent selectSingle(String scd, NamespaceContext nsContext);
115}
116