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


001:        /*
002:         * Copyright 2001-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: AttributeList.java,v 1.8 2004/02/16 22:55:54 minchau Exp $
018:         */
019:
020:        package org.apache.xalan.xsltc.runtime;
021:
022:        import java.util.Vector;
023:
024:        /**
025:         * @author Morten Jorgensen
026:         */
027:        public class AttributeList implements  org.xml.sax.Attributes {
028:
029:            private final static String EMPTYSTRING = "";
030:            private final static String CDATASTRING = "CDATA";
031:
032:            private Hashtable _attributes;
033:            private Vector _names;
034:            private Vector _qnames;
035:            private Vector _values;
036:            private Vector _uris;
037:            private int _length;
038:
039:            /**
040:             * AttributeList constructor
041:             */
042:            public AttributeList() {
043:                /*
044:                _attributes = new Hashtable();
045:                _names  = new Vector();
046:                _values = new Vector();
047:                _qnames = new Vector();
048:                _uris   = new Vector();
049:                 */
050:                _length = 0;
051:            }
052:
053:            /**
054:             * Attributes clone constructor
055:             */
056:            public AttributeList(org.xml.sax.Attributes attributes) {
057:                this ();
058:                if (attributes != null) {
059:                    final int count = attributes.getLength();
060:                    for (int i = 0; i < count; i++) {
061:                        add(attributes.getQName(i), attributes.getValue(i));
062:                    }
063:                }
064:            }
065:
066:            /**
067:             * Allocate memory for the AttributeList
068:             * %OPT% Use on-demand allocation for the internal vectors. The memory
069:             * is only allocated when there is an attribute. This reduces the cost 
070:             * of creating many small RTFs.
071:             */
072:            private void alloc() {
073:                _attributes = new Hashtable();
074:                _names = new Vector();
075:                _values = new Vector();
076:                _qnames = new Vector();
077:                _uris = new Vector();
078:            }
079:
080:            /**
081:             * SAX2: Return the number of attributes in the list. 
082:             */
083:            public int getLength() {
084:                return (_length);
085:            }
086:
087:            /**
088:             * SAX2: Look up an attribute's Namespace URI by index.
089:             */
090:            public String getURI(int index) {
091:                if (index < _length)
092:                    return ((String) _uris.elementAt(index));
093:                else
094:                    return (null);
095:            }
096:
097:            /**
098:             * SAX2: Look up an attribute's local name by index.
099:             */
100:            public String getLocalName(int index) {
101:                if (index < _length)
102:                    return ((String) _names.elementAt(index));
103:                else
104:                    return (null);
105:            }
106:
107:            /**
108:             * Return the name of an attribute in this list (by position).
109:             */
110:            public String getQName(int pos) {
111:                if (pos < _length)
112:                    return ((String) _qnames.elementAt(pos));
113:                else
114:                    return (null);
115:            }
116:
117:            /**
118:             * SAX2: Look up an attribute's type by index.
119:             */
120:            public String getType(int index) {
121:                return (CDATASTRING);
122:            }
123:
124:            /**
125:             * SAX2: Look up the index of an attribute by Namespace name.
126:             */
127:            public int getIndex(String namespaceURI, String localPart) {
128:                return (-1);
129:            }
130:
131:            /**
132:             * SAX2: Look up the index of an attribute by XML 1.0 qualified name.
133:             */
134:            public int getIndex(String qname) {
135:                return (-1);
136:            }
137:
138:            /**
139:             * SAX2: Look up an attribute's type by Namespace name.
140:             */
141:            public String getType(String uri, String localName) {
142:                return (CDATASTRING);
143:            }
144:
145:            /**
146:             * SAX2: Look up an attribute's type by qname.
147:             */
148:            public String getType(String qname) {
149:                return (CDATASTRING);
150:            }
151:
152:            /**
153:             * SAX2: Look up an attribute's value by index.
154:             */
155:            public String getValue(int pos) {
156:                if (pos < _length)
157:                    return ((String) _values.elementAt(pos));
158:                else
159:                    return (null);
160:            }
161:
162:            /**
163:             * SAX2: Look up an attribute's value by qname.
164:             */
165:            public String getValue(String qname) {
166:                if (_attributes != null) {
167:                    final Integer obj = (Integer) _attributes.get(qname);
168:                    if (obj == null)
169:                        return null;
170:                    return (getValue(obj.intValue()));
171:                } else
172:                    return null;
173:            }
174:
175:            /**
176:             * SAX2: Look up an attribute's value by Namespace name - SLOW!
177:             */
178:            public String getValue(String uri, String localName) {
179:                return (getValue(uri + ':' + localName));
180:            }
181:
182:            /**
183:             * Adds an attribute to the list
184:             */
185:            public void add(String qname, String value) {
186:                // Initialize the internal vectors at the first usage.
187:                if (_attributes == null)
188:                    alloc();
189:
190:                // Stuff the QName into the names vector & hashtable
191:                Integer obj = (Integer) _attributes.get(qname);
192:                if (obj == null) {
193:                    _attributes.put(qname, obj = new Integer(_length++));
194:                    _qnames.addElement(qname);
195:                    _values.addElement(value);
196:                    int col = qname.lastIndexOf(':');
197:                    if (col > -1) {
198:                        _uris.addElement(qname.substring(0, col));
199:                        _names.addElement(qname.substring(col + 1));
200:                    } else {
201:                        _uris.addElement(EMPTYSTRING);
202:                        _names.addElement(qname);
203:                    }
204:                } else {
205:                    final int index = obj.intValue();
206:                    _values.set(index, value);
207:                }
208:            }
209:
210:            /**
211:             * Clears the attribute list
212:             */
213:            public void clear() {
214:                _length = 0;
215:                if (_attributes != null) {
216:                    _attributes.clear();
217:                    _names.removeAllElements();
218:                    _values.removeAllElements();
219:                    _qnames.removeAllElements();
220:                    _uris.removeAllElements();
221:                }
222:            }
223:
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.