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 java.util.Iterator;
29import java.util.Collection;
30
31import com.sun.xml.internal.xsom.visitor.XSWildcardFunction;
32import com.sun.xml.internal.xsom.visitor.XSWildcardVisitor;
33
34/**
35 * Wildcard schema component (used for both attribute wildcard
36 * and element wildcard.)
37 *
38 * XSWildcard interface can always be downcasted to either
39 * Any, Other, or Union.
40 */
41public interface XSWildcard extends XSComponent, XSTerm
42{
43    static final int LAX = 1;
44    static final int STRTICT = 2;
45    static final int SKIP = 3;
46    /**
47     * Gets the processing mode.
48     *
49     * @return
50     *      Either LAX, STRICT, or SKIP.
51     */
52    int getMode();
53
54    /**
55     * Returns true if the specified namespace URI is valid
56     * wrt this wildcard.
57     *
58     * @param namespaceURI
59     *      Use the empty string to test the default no-namespace.
60     */
61    boolean acceptsNamespace(String namespaceURI);
62
63    /** Visitor support. */
64    void visit(XSWildcardVisitor visitor);
65    <T> T apply(XSWildcardFunction<T> function);
66
67    /**
68     * <code>##any</code> wildcard.
69     */
70    interface Any extends XSWildcard {
71    }
72    /**
73     * <code>##other</code> wildcard.
74     */
75    interface Other extends XSWildcard {
76        /**
77         * Gets the namespace URI excluded from this wildcard.
78         */
79        String getOtherNamespace();
80    }
81    /**
82     * Wildcard of a set of namespace URIs.
83     */
84    interface Union extends XSWildcard {
85        /**
86         * Short for <code>getNamespaces().iterator()</code>
87         */
88        Iterator<String> iterateNamespaces();
89
90        /**
91         * Read-only list of namespace URIs.
92         */
93        Collection<String> getNamespaces();
94    }
95}
96