~vcs-imports/xena/trunk

« back to all changes in this revision

Viewing changes to ext/src/xerces-2_9_1/src/org/apache/xerces/xni/NamespaceContext.java

  • Committer: matthewoliver
  • Date: 2009-12-10 03:18:07 UTC
  • Revision ID: vcs-imports@canonical.com-20091210031807-l086qguzdlljtkl9
Merged Xena Testing into Xena Stable for the Xena 5 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
 
8
 * 
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 * 
 
11
 * Unless required by applicable law or agreed to in writing, software
 
12
 * distributed under the License is distributed on an "AS IS" BASIS,
 
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
 * See the License for the specific language governing permissions and
 
15
 * limitations under the License.
 
16
 */
 
17
 
 
18
package org.apache.xerces.xni;
 
19
 
 
20
import java.util.Enumeration;
 
21
 
 
22
/**
 
23
 * Represents an interface to query namespace information.
 
24
 * <p>
 
25
 * The prefix and namespace must be identical references for equal strings, thus
 
26
 * each string should be internalized (@see String.intern()) 
 
27
 * or added to the <code>SymbolTable</code>
 
28
 *
 
29
 * @see <a href="../../../../../xerces2/org/apache/xerces/util/SymbolTable.html">
 
30
 * org.apache.xerces.util.SymbolTable</a>
 
31
 *
 
32
 * @author Andy Clark, IBM
 
33
 *
 
34
 * @version $Id: NamespaceContext.java,v 1.2 2009/12/10 03:18:46 matthewoliver Exp $
 
35
 */
 
36
public interface NamespaceContext {
 
37
 
 
38
    //
 
39
    // Constants
 
40
    //
 
41
 
 
42
    /**
 
43
     * The XML Namespace ("http://www.w3.org/XML/1998/namespace"). This is
 
44
     * the Namespace URI that is automatically mapped to the "xml" prefix.
 
45
     */
 
46
    public final static String XML_URI = "http://www.w3.org/XML/1998/namespace".intern();
 
47
 
 
48
    /**
 
49
     * XML Information Set REC
 
50
     * all namespace attributes (including those named xmlns, 
 
51
     * whose [prefix] property has no value) have a namespace URI of http://www.w3.org/2000/xmlns/
 
52
     */
 
53
    public final static String XMLNS_URI = "http://www.w3.org/2000/xmlns/".intern();
 
54
 
 
55
    //
 
56
    // NamespaceContext methods
 
57
    //
 
58
        
 
59
    /**
 
60
     * Start a new Namespace context.
 
61
     * <p>
 
62
     * A new context should be pushed at the beginning
 
63
     * of each XML element: the new context will automatically inherit
 
64
     * the declarations of its parent context, but it will also keep
 
65
     * track of which declarations were made within this context.
 
66
     * <p>
 
67
     *
 
68
     * @see #popContext
 
69
     */
 
70
    public void pushContext();
 
71
 
 
72
   /**
 
73
     * Revert to the previous Namespace context.
 
74
     * <p>
 
75
     * The context should be popped at the end of each
 
76
     * XML element.  After popping the context, all Namespace prefix
 
77
     * mappings that were previously in force are restored.
 
78
     * <p>
 
79
     * Users must not attempt to declare additional Namespace
 
80
     * prefixes after popping a context, unless you push another
 
81
     * context first.
 
82
     *
 
83
     * @see #pushContext
 
84
     */
 
85
    public void popContext();
 
86
 
 
87
    /**
 
88
     * Declare a Namespace prefix.
 
89
     * <p>
 
90
     * This method declares a prefix in the current Namespace
 
91
     * context; the prefix will remain in force until this context
 
92
     * is popped, unless it is shadowed in a descendant context.
 
93
     * <p>
 
94
     * Note that to declare a default Namespace, use the empty string.  
 
95
     * The prefixes "xml" and "xmlns" can't be rebound.
 
96
     * <p>
 
97
     * Note that you must <em>not</em> declare a prefix after
 
98
     * you've pushed and popped another Namespace.
 
99
     *
 
100
     * @param prefix The prefix to declare, or null for the empty
 
101
     *        string. 
 
102
     * @param uri The Namespace URI to associate with the prefix.
 
103
     *
 
104
     * @return true if the prefix was legal, false otherwise
 
105
     *
 
106
     * @see #getURI
 
107
     * @see #getDeclaredPrefixAt
 
108
     */
 
109
    public boolean declarePrefix(String prefix, String uri);
 
110
    
 
111
 
 
112
    /**
 
113
     * Look up a prefix and get the currently-mapped Namespace URI.
 
114
     * <p>
 
115
     * This method looks up the prefix in the current context. If no mapping 
 
116
     * is found, this methods will continue lookup in the parent context(s).
 
117
     * Use the empty string ("") for the default Namespace.
 
118
     *
 
119
     * @param prefix The prefix to look up. 
 
120
     *
 
121
     * @return The associated Namespace URI, or null if the prefix
 
122
     *         is undeclared in this context.
 
123
     */
 
124
    public String getURI(String prefix);
 
125
    
 
126
    /**
 
127
     * Look up a namespace URI and get one of the mapped prefix.
 
128
     * <p>
 
129
     * This method looks up the namespace URI in the current context.
 
130
     * If more than one prefix is currently mapped to the same URI, 
 
131
     * this method will make an arbitrary selection
 
132
     * If no mapping is found, this methods will continue lookup in the 
 
133
     * parent context(s).
 
134
     *
 
135
     * @param uri The namespace URI to look up.
 
136
     *
 
137
     * @return One of the associated prefixes, or null if the uri
 
138
     *         does not map to any prefix.
 
139
     *
 
140
     * @see #getPrefix
 
141
     */
 
142
    public String getPrefix(String uri);
 
143
    
 
144
    /**
 
145
     * Return a count of locally declared prefixes, including
 
146
     * the default prefix if bound.
 
147
     */
 
148
    public int getDeclaredPrefixCount();
 
149
 
 
150
    /** 
 
151
     * Returns the prefix at the specified index in the current context.
 
152
     */
 
153
    public String getDeclaredPrefixAt(int index);
 
154
 
 
155
        /**
 
156
         * Return an enumeration of all prefixes whose declarations are active 
 
157
     * in the current context. This includes declarations from parent contexts 
 
158
     * that have not been overridden.
 
159
         * @return Enumeration
 
160
         */
 
161
    public Enumeration getAllPrefixes();
 
162
    
 
163
    /**
 
164
     * Reset this Namespace support object for reuse.
 
165
     *
 
166
     * <p>It is necessary to invoke this method before reusing the
 
167
     * Namespace support object for a new session.</p>
 
168
     * 
 
169
     * <p>Note that implementations of this method need to ensure that
 
170
     * the declaration of the prefixes "xmlns" and "xml" are available.</p>
 
171
     */
 
172
    public void reset();
 
173
    
 
174
 
 
175
 
 
176
} // interface NamespaceContext