Source Code Cross Referenced for AttributeList.java in  » Web-Server » Quadcap-Web-Server » com » quadcap » text » sax » 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 » Quadcap Web Server » com.quadcap.text.sax 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.quadcap.text.sax;
002:
003:        /* Copyright 2000 - 2003 Quadcap Software.  All rights reserved.
004:         *
005:         * This software is distributed under the Quadcap Free Software License.
006:         * This software may be used or modified for any purpose, personal or
007:         * commercial.  Open Source redistributions are permitted.  Commercial
008:         * redistribution of larger works derived from, or works which bundle
009:         * this software requires a "Commercial Redistribution License"; see
010:         * http://www.quadcap.com/purchase.
011:         *
012:         * Redistributions qualify as "Open Source" under  one of the following terms:
013:         *   
014:         *    Redistributions are made at no charge beyond the reasonable cost of
015:         *    materials and delivery.
016:         *
017:         *    Redistributions are accompanied by a copy of the Source Code or by an
018:         *    irrevocable offer to provide a copy of the Source Code for up to three
019:         *    years at the cost of materials and delivery.  Such redistributions
020:         *    must allow further use, modification, and redistribution of the Source
021:         *    Code under substantially the same terms as this license.
022:         *
023:         * Redistributions of source code must retain the copyright notices as they
024:         * appear in each source code file, these license terms, and the
025:         * disclaimer/limitation of liability set forth as paragraph 6 below.
026:         *
027:         * Redistributions in binary form must reproduce this Copyright Notice,
028:         * these license terms, and the disclaimer/limitation of liability set
029:         * forth as paragraph 6 below, in the documentation and/or other materials
030:         * provided with the distribution.
031:         *
032:         * The Software is provided on an "AS IS" basis.  No warranty is
033:         * provided that the Software is free of defects, or fit for a
034:         * particular purpose.  
035:         *
036:         * Limitation of Liability. Quadcap Software shall not be liable
037:         * for any damages suffered by the Licensee or any third party resulting
038:         * from use of the Software.
039:         */
040:
041:        /**
042:         * AttributeList implementation; uses arrays of Strings internally. 
043:         *
044:         * @author Stan Bailes
045:         */
046:        public class AttributeList implements  org.xml.sax.AttributeList {
047:            int length = 0;
048:            String[] name = new String[8];
049:            String[] value = new String[8];
050:            String[] type = new String[8];
051:
052:            /**
053:             * Return the number of attributes in this list.
054:             *
055:             * <p>The SAX parser may provide attributes in any
056:             * arbitrary order, regardless of the order in which they were
057:             * declared or specified.  The number of attributes may be
058:             * zero.</p>
059:             *
060:             * @return The number of attributes in the list.  
061:             */
062:            public final int getLength() {
063:                return length;
064:            }
065:
066:            /**
067:             * Return the name of an attribute in this list (by position).
068:             *
069:             * <p>The names must be unique: the SAX parser shall not include the
070:             * same attribute twice.  Attributes without values (those declared
071:             * #IMPLIED without a value specified in the start tag) will be
072:             * omitted from the list.</p>
073:             *
074:             * <p>If the attribute name has a namespace prefix, the prefix
075:             * will still be attached.</p>
076:             *
077:             * @param i The index of the attribute in the list (starting at 0).
078:             * @return The name of the indexed attribute, or null
079:             *         if the index is out of range.
080:             * @see #getLength 
081:             */
082:            public final String getName(int i) {
083:                try {
084:                    return name[i];
085:                } catch (ArrayIndexOutOfBoundsException e) {
086:                    return null;
087:                }
088:            }
089:
090:            /**
091:             * Return the type of an attribute in the list (by position).
092:             *
093:             * <p>The attribute type is one of the strings "CDATA", "ID",
094:             * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
095:             * or "NOTATION" (always in upper case).</p>
096:             *
097:             * <p>If the parser has not read a declaration for the attribute,
098:             * or if the parser does not report attribute types, then it must
099:             * return the value "CDATA" as stated in the XML 1.0 Recommentation
100:             * (clause 3.3.3, "Attribute-Value Normalization").</p>
101:             *
102:             * <p>For an enumerated attribute that is not a notation, the
103:             * parser will report the type as "NMTOKEN".</p>
104:             *
105:             * @param i The index of the attribute in the list (starting at 0).
106:             * @return The attribute type as a string, or
107:             *         null if the index is out of range.
108:             * @see #getLength 
109:             * @see #getType(java.lang.String)
110:             */
111:            public final String getType(int i) {
112:                try {
113:                    return type[i];
114:                } catch (ArrayIndexOutOfBoundsException e) {
115:                    return null;
116:                }
117:            }
118:
119:            /**
120:             * Return the value of an attribute in the list (by position).
121:             *
122:             * <p>If the attribute value is a list of tokens (IDREFS,
123:             * ENTITIES, or NMTOKENS), the tokens will be concatenated
124:             * into a single string separated by whitespace.</p>
125:             *
126:             * @param i The index of the attribute in the list (starting at 0).
127:             * @return The attribute value as a string, or
128:             *         null if the index is out of range.
129:             * @see #getLength
130:             * @see #getValue(java.lang.String)
131:             */
132:            public final String getValue(int i) {
133:                try {
134:                    return value[i];
135:                } catch (ArrayIndexOutOfBoundsException e) {
136:                    return null;
137:                }
138:            }
139:
140:            /**
141:             * Return the type of an attribute in the list (by name).
142:             *
143:             * <p>The return value is the same as the return value for
144:             * getType(int).</p>
145:             *
146:             * <p>If the attribute name has a namespace prefix in the document,
147:             * the application must include the prefix here.</p>
148:             *
149:             * @param name The name of the attribute.
150:             * @return The attribute type as a string, or null if no
151:             *         such attribute exists.
152:             * @see #getType(int)
153:             */
154:            public final String getType(String name) {
155:                return getType(getAttribute(name));
156:            }
157:
158:            /**
159:             * Return the value of an attribute in the list (by name).
160:             *
161:             * <p>The return value is the same as the return value for
162:             * getValue(int).</p>
163:             *
164:             * <p>If the attribute name has a namespace prefix in the document,
165:             * the application must include the prefix here.</p>
166:             *
167:             * @param i The index of the attribute in the list.
168:             * @return The attribute value as a string, or null if
169:             *         no such attribute exists.
170:             * @see #getValue(int)
171:             */
172:            public final String getValue(String n) {
173:                return getValue(getAttribute(n));
174:            }
175:
176:            final int getAttribute(String n) {
177:                for (int i = 0; i < length; i++) {
178:                    if (name[i].equals(n))
179:                        return i;
180:                }
181:                return -1;
182:            }
183:
184:            final String[] resize(String[] v, int len) {
185:                String[] n = new String[len];
186:                System.arraycopy(v, 0, n, 0, v.length);
187:                return n;
188:            }
189:
190:            final void addAttribute(String n, String t, String v) {
191:                if (length >= name.length) {
192:                    name = resize(name, length + (length >> 2) + 4);
193:                    type = resize(type, length + (length >> 2) + 4);
194:                    value = resize(value, length + (length >> 2) + 4);
195:                }
196:                name[length] = n;
197:                type[length] = t;
198:                value[length] = v;
199:                length++;
200:            }
201:
202:            final void clear() {
203:                length = 0;
204:            }
205:
206:            public static AttributeList copy(org.xml.sax.AttributeList a) {
207:                AttributeList c = new AttributeList();
208:                for (int i = 0; i < a.getLength(); i++) {
209:                    c.addAttribute(a.getName(i), a.getType(i), a.getValue(i));
210:                }
211:                return c;
212:            }
213:
214:            public static String toString(org.xml.sax.AttributeList attributes) {
215:                StringBuffer sb = new StringBuffer();
216:                if (attributes != null) {
217:                    for (int i = 0; i < attributes.getLength(); i++) {
218:                        sb.append(' ');
219:                        sb.append(attributes.getName(i));
220:                        sb.append("=\"");
221:                        sb.append(attributes.getValue(i));
222:                        sb.append("\"");
223:                    }
224:                }
225:                return sb.toString();
226:            }
227:
228:            public String toString() {
229:                return toString(this);
230:            }
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.