KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > xni > NamespaceContext


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package com.sun.org.apache.xerces.internal.xni;
59
60 import java.util.Enumeration JavaDoc;
61
62 /**
63  * Represents an interface to query namespace information.
64  * <p>
65  * The prefix and namespace must be identical references for equal strings, thus
66  * each string should be internalized (@see String.intern())
67  * or added to the <code>SymbolTable</code>
68  *
69  * @see <a HREF="../../../../../xerces2/com/sun/org/apache/xerces/internal/util/SymbolTable.html">
70  * com.sun.org.apache.xerces.internal.util.SymbolTable</a>
71  *
72  * @author Andy Clark, IBM
73  *
74  * @version $Id: NamespaceContext.java,v 1.10 2003/01/23 17:27:12 sandygao Exp $
75  */

76 public interface NamespaceContext {
77
78     //
79
// Constants
80
//
81

82     /**
83      * The XML Namespace ("http://www.w3.org/XML/1998/namespace"). This is
84      * the Namespace URI that is automatically mapped to the "xml" prefix.
85      */

86     public final static String JavaDoc XML_URI = "http://www.w3.org/XML/1998/namespace".intern();
87
88     /**
89      * XML Information Set REC
90      * all namespace attributes (including those named xmlns,
91      * whose [prefix] property has no value) have a namespace URI of http://www.w3.org/2000/xmlns/
92      */

93     public final static String JavaDoc XMLNS_URI = "http://www.w3.org/2000/xmlns/".intern();
94
95     //
96
// NamespaceContext methods
97
//
98

99     /**
100      * Start a new Namespace context.
101      * <p>
102      * A new context should be pushed at the beginning
103      * of each XML element: the new context will automatically inherit
104      * the declarations of its parent context, but it will also keep
105      * track of which declarations were made within this context.
106      * <p>
107      *
108      * @see #popContext
109      */

110     public void pushContext();
111
112    /**
113      * Revert to the previous Namespace context.
114      * <p>
115      * The context should be popped at the end of each
116      * XML element. After popping the context, all Namespace prefix
117      * mappings that were previously in force are restored.
118      * <p>
119      * Users must not attempt to declare additional Namespace
120      * prefixes after popping a context, unless you push another
121      * context first.
122      *
123      * @see #pushContext
124      */

125     public void popContext();
126
127     /**
128      * Declare a Namespace prefix.
129      * <p>
130      * This method declares a prefix in the current Namespace
131      * context; the prefix will remain in force until this context
132      * is popped, unless it is shadowed in a descendant context.
133      * <p>
134      * Note that to declare a default Namespace, use the empty string.
135      * The prefixes "xml" and "xmlns" can't be rebound.
136      * <p>
137      * Note that you must <em>not</em> declare a prefix after
138      * you've pushed and popped another Namespace.
139      *
140      * @param prefix The prefix to declare, or null for the empty
141      * string.
142      * @param uri The Namespace URI to associate with the prefix.
143      *
144      * @return true if the prefix was legal, false otherwise
145      *
146      * @see #getURI
147      * @see #getDeclaredPrefixAt
148      */

149     public boolean declarePrefix(String JavaDoc prefix, String JavaDoc uri);
150     
151
152     /**
153      * Look up a prefix and get the currently-mapped Namespace URI.
154      * <p>
155      * This method looks up the prefix in the current context. If no mapping
156      * is found, this methods will continue lookup in the parent context(s).
157      * Use the empty string ("") for the default Namespace.
158      *
159      * @param prefix The prefix to look up.
160      *
161      * @return The associated Namespace URI, or null if the prefix
162      * is undeclared in this context.
163      */

164     public String JavaDoc getURI(String JavaDoc prefix);
165     
166     /**
167      * Look up a namespace URI and get one of the mapped prefix.
168      * <p>
169      * This method looks up the namespace URI in the current context.
170      * If more than one prefix is currently mapped to the same URI,
171      * this method will make an arbitrary selection
172      * If no mapping is found, this methods will continue lookup in the
173      * parent context(s).
174      *
175      * @param uri The namespace URI to look up.
176      *
177      * @return One of the associated prefixes, or null if the uri
178      * does not map to any prefix.
179      *
180      * @see #getPrefix
181      */

182     public String JavaDoc getPrefix(String JavaDoc uri);
183     
184     /**
185      * Return a count of locally declared prefixes, including
186      * the default prefix if bound.
187      */

188     public int getDeclaredPrefixCount();
189
190     /**
191      * Returns the prefix at the specified index in the current context.
192      */

193     public String JavaDoc getDeclaredPrefixAt(int index);
194
195     /**
196      * Return an enumeration of all prefixes whose declarations are active
197      * in the current context. This includes declarations from parent contexts
198      * that have not been overridden.
199      * @return Enumeration
200      */

201     public Enumeration JavaDoc getAllPrefixes();
202     
203     /**
204      * Reset this Namespace support object for reuse.
205      *
206      * <p>It is necessary to invoke this method before reusing the
207      * Namespace support object for a new session.</p>
208      *
209      * <p>Note that implementations of this method need to ensure that
210      * the declaration of the prefixes "xmlns" and "xml" are available.</p>
211      */

212     public void reset();
213     
214
215
216 } // interface NamespaceContext
217
Popular Tags