Source Code Cross Referenced for SavedNamespaceContext.java in  » XML » XPath-Saxon » net » sf » saxon » instruct » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » XPath Saxon » net.sf.saxon.instruct 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.saxon.instruct;
002:
003:        import net.sf.saxon.om.NamePool;
004:        import net.sf.saxon.om.NamespaceConstant;
005:        import net.sf.saxon.om.NamespaceResolver;
006:
007:        import java.io.Serializable;
008:        import java.util.ArrayList;
009:        import java.util.Iterator;
010:
011:        /**
012:         * An object representing a list of Namespaces. Used when the namespace
013:         * controller in the stylesheet needs to be kept for use at run-time. The list of namespaces
014:         * is maintained in the form of numeric prefix/uri codes, which are only meaningful
015:         * in the controller of a name pool; however, in order to save space, the NamespaceContext
016:         * object does not keep a reference to the namepool, it requires this to be supplied
017:         * by the caller.
018:         */
019:
020:        public final class SavedNamespaceContext implements  Serializable,
021:                NamespaceResolver {
022:
023:            // TODO: static context can't vary within an XPath expression. Therefore, save the
024:            // NamespaceContext at the outermost expression level if any subexpression needs it.
025:            // (Or put a namespace context expression on the expression tree, which has no effect
026:            // at run-time, but is available to descendant expressions).
027:
028:            private int[] namespaceCodes;
029:            private NamePool namePool;
030:
031:            /**
032:             * Create a NamespaceContext object
033:             * @param nscodes an array of namespace codes. Each namespace code is an integer
034:             * in which the first 16 bits represent the prefix (zero if it's the default namespace)
035:             * and the next 16 bits represent the uri. These are codes held in the NamePool. The
036:             * list will be searched from the "high" end.
037:             */
038:
039:            public SavedNamespaceContext(int[] nscodes, NamePool pool) {
040:                namespaceCodes = nscodes;
041:                namePool = pool;
042:            }
043:
044:            /**
045:             * Get the list of in-scope namespaces held in this NamespaceContext
046:             * @return the list of namespaces
047:             */
048:
049:            public int[] getNamespaceCodes() {
050:                return namespaceCodes;
051:            }
052:
053:            /**
054:             * Get the namespace URI corresponding to a given prefix. Return null
055:             * if the prefix is not in scope.
056:             * @param prefix the namespace prefix
057:             * @param useDefault true if the default namespace is to be used when the
058:             * prefix is ""
059:             * @return the uri for the namespace, or null if the prefix is not in scope
060:             */
061:
062:            public String getURIForPrefix(String prefix, boolean useDefault) {
063:
064:                if (prefix.equals("") && !useDefault) {
065:                    return "";
066:                }
067:
068:                if (prefix.equals("xml")) {
069:                    return NamespaceConstant.XML;
070:                }
071:
072:                for (int i = namespaceCodes.length - 1; i >= 0; i--) {
073:                    if (namePool.getPrefixFromNamespaceCode(namespaceCodes[i])
074:                            .equals(prefix)) {
075:                        return namePool
076:                                .getURIFromNamespaceCode(namespaceCodes[i]);
077:                    }
078:                }
079:
080:                if (prefix.equals("") && useDefault) {
081:                    // use the "default default namespace" - namely ""
082:                    return "";
083:                } else {
084:                    return null;
085:                }
086:            }
087:
088:            /**
089:             * Get an iterator over all the prefixes declared in this namespace context. This will include
090:             * the default namespace (prefix="") and the XML namespace where appropriate
091:             */
092:
093:            public Iterator iteratePrefixes() {
094:                ArrayList prefixes = new ArrayList(namespaceCodes.length);
095:                for (int i = 0; i < namespaceCodes.length; i++) {
096:                    prefixes.add(namePool
097:                            .getPrefixFromNamespaceCode(namespaceCodes[i]));
098:                }
099:                return prefixes.iterator();
100:            }
101:
102:        }
103:
104:        //
105:        // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
106:        // you may not use this file except in compliance with the License. You may obtain a copy of the
107:        // License at http://www.mozilla.org/MPL/
108:        //
109:        // Software distributed under the License is distributed on an "AS IS" basis,
110:        // WITHOUT WARRANTY OF ANY KIND, either express or implied.
111:        // See the License for the specific language governing rights and limitations under the License.
112:        //
113:        // The Original Code is: all this file.
114:        //
115:        // The Initial Developer of the Original Code is Michael H. Kay
116:        //
117:        // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
118:        //
119:        // Contributor(s): none.
120:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.