Source Code Cross Referenced for NamespaceSupport.java in  » Web-Server » Rimfaxe-Web-Server » com » rimfaxe » xml » xmlreader » 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 » Web Server » Rimfaxe Web Server » com.rimfaxe.xml.xmlreader 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.rimfaxe.xml.xmlreader;
002:
003:        import java.util.*;
004:
005:        /** Streamlined thermopylae specific implementation of 
006:         *  the org.xml.sax.helpers.NamespaceSupport class.
007:
008:         <blockquote><small> Copyright (C) 2002 Hewlett-Packard Company.
009:         This file is part of Sparta, an XML Parser, DOM, and XPath library.
010:         This library is free software; you can redistribute it and/or
011:         modify it under the terms of the <a href="doc-files/LGPL.txt">GNU
012:         Lesser General Public License</a> as published by the Free Software
013:         Foundation; either version 2.1 of the License, or (at your option)
014:         any later version.  This library is distributed in the hope that it
015:         will be useful, but WITHOUT ANY WARRANTY; without even the implied
016:         warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
017:         PURPOSE. </small></blockquote>
018:         @version  $Date: 2003/01/27 23:30:59 $  $Revision: 1.2 $
019:         @author Sergio Marti
020:         **/
021:
022:        public class NamespaceSupport {
023:
024:            static final String XMLNS = "http://www.w3.org/XML/1998/namespace";
025:            static final String XMLPREF = "xml";
026:
027:            private final Stack context_ = new Stack();
028:            private Map currContext_ = null;
029:            private final Stack oldContext_ = new Stack();
030:
031:            private String defaultNS_ = "";
032:
033:            /* Cache last prefix for speed */
034:            private String currPrefix_ = null;
035:            private String currFullPrefix_ = null;
036:            private String currNS_ = null;
037:            private int depth_ = 0;
038:
039:            public NamespaceSupport() {
040:            }
041:
042:            public void pushContext() {
043:                if (currContext_ != null)
044:                    context_.push(currContext_);
045:                if (!oldContext_.isEmpty()) {
046:                    currContext_ = (Map) oldContext_.pop();
047:                    currContext_.clear();
048:                } else
049:                    currContext_ = new HashMap();
050:
051:                depth_++;
052:            }
053:
054:            Iterator popContext() {
055:                depth_--;
056:                if (depth_ < 0)
057:                    currPrefix_ = null;
058:
059:                oldContext_.push(currContext_);
060:                Iterator keySetIterator = currContext_.keySet().iterator();
061:                if (!context_.isEmpty())
062:                    currContext_ = (Map) context_.pop();
063:                else
064:                    currContext_ = null;
065:                return keySetIterator;
066:            }
067:
068:            void declarePrefix(String prefix, String uri) {
069:                if (prefix.equals("xml") || prefix.equals("xmlns"))
070:                    return;
071:                if (prefix.equals("")) {
072:                    defaultNS_ = uri;
073:                    return;
074:                }
075:                currContext_.put(prefix, uri);
076:            }
077:
078:            String[] processName(String fullName, String[] result,
079:                    boolean attribute) throws ParseException {
080:
081:                if (currPrefix_ != null && fullName.startsWith(currFullPrefix_)) {
082:                    result[0] = currNS_;
083:                    result[1] = fullName.substring(currFullPrefix_.length());
084:                    result[2] = fullName;
085:                    return result;
086:                }
087:
088:                int a = fullName.indexOf(':');
089:                if (a > 0) {
090:                    String prefix = fullName.substring(0, a);
091:
092:                    System.out.println("NameSpace " + prefix);
093:
094:                    if (prefix.equals("xml") || prefix.equals("xmlns")) {
095:                        return null;
096:                    }
097:
098:                    result[1] = fullName.substring(a + 1);
099:                    result[2] = fullName;
100:
101:                    result[0] = (String) currContext_.get(prefix);
102:
103:                    if (result[0] == null) {
104:                        for (int i = context_.size() - 1; i >= 0; i--) {
105:                            Map ht = (Map) (context_.elementAt(i));
106:                            result[0] = (String) (ht.get(prefix));
107:                            if (result[0] != null)
108:                                break;
109:                        }
110:                    }
111:
112:                    if (result[0] == null)
113:                        throw new ParseException("Error processing tag "
114:                                + fullName + ". No namespace mapping found.");
115:
116:                    depth_ = 0;
117:                    currNS_ = result[0];
118:                    currPrefix_ = prefix;
119:                    currFullPrefix_ = prefix + ":";
120:                } else {
121:                    if (attribute)
122:                        result[0] = "";
123:                    else
124:                        result[0] = defaultNS_;
125:                    result[1] = result[2] = fullName;
126:                }
127:
128:                return result;
129:            }
130:        }
131:
132:        // $Log: NamespaceSupport.java,v $
133:        // Revision 1.2  2003/01/27 23:30:59  yuhongx
134:        // Replaced Hashtable with HashMap.
135:        //
136:        // Revision 1.1.1.1  2002/08/19 05:04:16  eobrain
137:        // import from HP Labs internal CVS
138:        //
139:        // Revision 1.5  2002/08/19 00:39:45  eob
140:        // Tweak javadoc comment.
141:        //
142:        // Revision 1.4  2002/08/18 05:45:59  eob
143:        // Add copyright and other formatting and commenting in preparation for
144:        // release to SourceForge.
145:        //
146:        // Revision 1.3  2002/08/17 00:54:14  sermarti
147:        //
148:        // Revision 1.2  2002/08/15 23:40:23  sermarti
149:        //
150:        // Revision 1.1  2002/08/09 22:36:49  sermarti
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.