Source Code Cross Referenced for AttList.java in  » XML » xalan » org » apache » xml » serializer » utils » 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 » xalan » org.apache.xml.serializer.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2004 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        /*
017:         * $Id: AttList.java,v 1.2 2005/01/24 04:04:40 mcnamara Exp $
018:         */
019:        package org.apache.xml.serializer.utils;
020:
021:        import org.w3c.dom.Attr;
022:        import org.w3c.dom.NamedNodeMap;
023:        import org.w3c.dom.Node;
024:
025:        import org.xml.sax.Attributes;
026:
027:        /**
028:         * Wraps a DOM attribute list in a SAX Attributes.
029:         * 
030:         * This class is a copy of the one in org.apache.xml.utils. 
031:         * It exists to cut the serializers dependancy on that package.
032:         * A minor changes from that package are:
033:         * DOMHelper reference changed to DOM2Helper, class is not "public"
034:         *  
035:         * This class is not a public API, it is only public because it is 
036:         * used in org.apache.xml.serializer.
037:         * 
038:         * @xsl.usage internal
039:         */
040:        public final class AttList implements  Attributes {
041:
042:            /** List of attribute nodes          */
043:            NamedNodeMap m_attrs;
044:
045:            /** Index of last attribute node          */
046:            int m_lastIndex;
047:
048:            // ARGHH!!  JAXP Uses Xerces without setting the namespace processing to ON!
049:            // DOM2Helper m_dh = new DOM2Helper();
050:
051:            /** Local reference to DOMHelper          */
052:            DOM2Helper m_dh;
053:
054:            //  /**
055:            //   * Constructor AttList
056:            //   *
057:            //   *
058:            //   * @param attrs List of attributes this will contain
059:            //   */
060:            //  public AttList(NamedNodeMap attrs)
061:            //  {
062:            //
063:            //    m_attrs = attrs;
064:            //    m_lastIndex = m_attrs.getLength() - 1;
065:            //    m_dh = new DOM2Helper();
066:            //  }
067:
068:            /**
069:             * Constructor AttList
070:             *
071:             *
072:             * @param attrs List of attributes this will contain
073:             * @param dh DOMHelper 
074:             */
075:            public AttList(NamedNodeMap attrs, DOM2Helper dh) {
076:
077:                m_attrs = attrs;
078:                m_lastIndex = m_attrs.getLength() - 1;
079:                m_dh = dh;
080:            }
081:
082:            /**
083:             * Get the number of attribute nodes in the list 
084:             *
085:             *
086:             * @return number of attribute nodes
087:             */
088:            public int getLength() {
089:                return m_attrs.getLength();
090:            }
091:
092:            /**
093:             * Look up an attribute's Namespace URI by index.
094:             *
095:             * @param index The attribute index (zero-based).
096:             * @return The Namespace URI, or the empty string if none
097:             *         is available, or null if the index is out of
098:             *         range.
099:             */
100:            public String getURI(int index) {
101:                String ns = m_dh
102:                        .getNamespaceOfNode(((Attr) m_attrs.item(index)));
103:                if (null == ns)
104:                    ns = "";
105:                return ns;
106:            }
107:
108:            /**
109:             * Look up an attribute's local name by index.
110:             *
111:             * @param index The attribute index (zero-based).
112:             * @return The local name, or the empty string if Namespace
113:             *         processing is not being performed, or null
114:             *         if the index is out of range.
115:             */
116:            public String getLocalName(int index) {
117:                return m_dh.getLocalNameOfNode(((Attr) m_attrs.item(index)));
118:            }
119:
120:            /**
121:             * Look up an attribute's qualified name by index.
122:             *
123:             *
124:             * @param i The attribute index (zero-based).
125:             *
126:             * @return The attribute's qualified name
127:             */
128:            public String getQName(int i) {
129:                return ((Attr) m_attrs.item(i)).getName();
130:            }
131:
132:            /**
133:             * Get the attribute's node type by index
134:             *
135:             *
136:             * @param i The attribute index (zero-based)
137:             *
138:             * @return the attribute's node type
139:             */
140:            public String getType(int i) {
141:                return "CDATA"; // for the moment
142:            }
143:
144:            /**
145:             * Get the attribute's node value by index
146:             *
147:             *
148:             * @param i The attribute index (zero-based)
149:             *
150:             * @return the attribute's node value
151:             */
152:            public String getValue(int i) {
153:                return ((Attr) m_attrs.item(i)).getValue();
154:            }
155:
156:            /**
157:             * Get the attribute's node type by name
158:             *
159:             *
160:             * @param name Attribute name
161:             *
162:             * @return the attribute's node type
163:             */
164:            public String getType(String name) {
165:                return "CDATA"; // for the moment
166:            }
167:
168:            /**
169:             * Look up an attribute's type by Namespace name.
170:             *
171:             * @param uri The Namespace URI, or the empty String if the
172:             *        name has no Namespace URI.
173:             * @param localName The local name of the attribute.
174:             * @return The attribute type as a string, or null if the
175:             *         attribute is not in the list or if Namespace
176:             *         processing is not being performed.
177:             */
178:            public String getType(String uri, String localName) {
179:                return "CDATA"; // for the moment
180:            }
181:
182:            /**
183:             * Look up an attribute's value by name.
184:             *
185:             *
186:             * @param name The attribute node's name
187:             *
188:             * @return The attribute node's value
189:             */
190:            public String getValue(String name) {
191:                Attr attr = ((Attr) m_attrs.getNamedItem(name));
192:                return (null != attr) ? attr.getValue() : null;
193:            }
194:
195:            /**
196:             * Look up an attribute's value by Namespace name.
197:             *
198:             * @param uri The Namespace URI, or the empty String if the
199:             *        name has no Namespace URI.
200:             * @param localName The local name of the attribute.
201:             * @return The attribute value as a string, or null if the
202:             *         attribute is not in the list.
203:             */
204:            public String getValue(String uri, String localName) {
205:                Node a = m_attrs.getNamedItemNS(uri, localName);
206:                return (a == null) ? null : a.getNodeValue();
207:            }
208:
209:            /**
210:             * Look up the index of an attribute by Namespace name.
211:             *
212:             * @param uri The Namespace URI, or the empty string if
213:             *        the name has no Namespace URI.
214:             * @param localPart The attribute's local name.
215:             * @return The index of the attribute, or -1 if it does not
216:             *         appear in the list.
217:             */
218:            public int getIndex(String uri, String localPart) {
219:                for (int i = m_attrs.getLength() - 1; i >= 0; --i) {
220:                    Node a = m_attrs.item(i);
221:                    String u = a.getNamespaceURI();
222:                    if ((u == null ? uri == null : u.equals(uri))
223:                            && a.getLocalName().equals(localPart))
224:                        return i;
225:                }
226:                return -1;
227:            }
228:
229:            /**
230:             * Look up the index of an attribute by raw XML 1.0 name.
231:             *
232:             * @param qName The qualified (prefixed) name.
233:             * @return The index of the attribute, or -1 if it does not
234:             *         appear in the list.
235:             */
236:            public int getIndex(String qName) {
237:                for (int i = m_attrs.getLength() - 1; i >= 0; --i) {
238:                    Node a = m_attrs.item(i);
239:                    if (a.getNodeName().equals(qName))
240:                        return i;
241:                }
242:                return -1;
243:            }
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.