Source Code Cross Referenced for Attributes2Impl.java in  » Web-Server » Rimfaxe-Web-Server » org » xml » sax » ext » 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 » org.xml.sax.ext 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Attributes2Impl.java - extended AttributesImpl
002:        // http://www.saxproject.org
003:        // Public Domain: no warranty.
004:        // $Id: Attributes2Impl.java,v 1.3 2002/02/01 20:06:20 db Exp $
005:
006:        package org.xml.sax.ext;
007:
008:        import org.xml.sax.Attributes;
009:        import org.xml.sax.helpers.AttributesImpl;
010:
011:        /**
012:         * SAX2 extension helper for additional Attributes information,
013:         * implementing the {@link Attributes2} interface.
014:         *
015:         * <blockquote>
016:         * <em>This module, both source code and documentation, is in the
017:         * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
018:         * </blockquote>
019:         *
020:         * <p>This is not part of core-only SAX2 distributions.</p>
021:         *
022:         * <p>The <em>specified</em> flag for each attribute will always
023:         * be true, unless it has been set to false in the copy constructor
024:         * or using {@link #setSpecified}.  </p>
025:         *
026:         * @since SAX 2.0 (extensions 1.1 alpha)
027:         * @author David Brownell
028:         * @version TBS
029:         */
030:        public class Attributes2Impl extends AttributesImpl implements 
031:                Attributes2 {
032:            private boolean flags[];
033:
034:            /**
035:             * Construct a new, empty Attributes2Impl object.
036:             */
037:            public Attributes2Impl() {
038:            }
039:
040:            /**
041:             * Copy an existing Attributes or Attributes2 object.
042:             * If the object implements Attributes2, values of the
043:             * <em>specified</em> flag for each attribute are copied,
044:             * otherwise the flag values are set to <em>true</em>. 
045:             *
046:             * <p>This constructor is especially useful inside a
047:             * {@link org.xml.sax.ContentHandler#startElement startElement} event.</p>
048:             *
049:             * @param atts The existing Attributes object.
050:             */
051:            public Attributes2Impl(Attributes atts) {
052:                super (atts);
053:            }
054:
055:            ////////////////////////////////////////////////////////////////////
056:            // Implementation of Attributes2
057:            ////////////////////////////////////////////////////////////////////
058:
059:            /**
060:             * Returns the current value of an attribute's "specified" flag.
061:             *
062:             * @param index The attribute index (zero-based).
063:             * @return current flag value
064:             * @exception java.lang.ArrayIndexOutOfBoundsException When the
065:             *            supplied index does not identify an attribute.
066:             */
067:            public boolean isSpecified(int index) {
068:                if (index < 0 || index >= getLength())
069:                    throw new ArrayIndexOutOfBoundsException(
070:                            "No attribute at index: " + index);
071:                return flags[index];
072:            }
073:
074:            /**
075:             * Returns the current value of an attribute's "specified" flag.
076:             *
077:             * @param uri The Namespace URI, or the empty string if
078:             *        the name has no Namespace URI.
079:             * @param localName The attribute's local name.
080:             * @return current flag value
081:             * @exception java.lang.IllegalArgumentException When the
082:             *            supplied names do not identify an attribute.
083:             */
084:            public boolean isSpecified(String uri, String localName) {
085:                int index = getIndex(uri, localName);
086:
087:                if (index < 0)
088:                    throw new IllegalArgumentException(
089:                            "No such attribute: local=" + localName
090:                                    + ", namespace=" + uri);
091:                return flags[index];
092:            }
093:
094:            /**
095:             * Returns the current value of an attribute's "specified" flag.
096:             *
097:             * @param qName The XML 1.0 qualified name.
098:             * @return current flag value
099:             * @exception java.lang.IllegalArgumentException When the
100:             *            supplied name does not identify an attribute.
101:             */
102:            public boolean isSpecified(String qName) {
103:                int index = getIndex(qName);
104:
105:                if (index < 0)
106:                    throw new IllegalArgumentException("No such attribute: "
107:                            + qName);
108:                return flags[index];
109:            }
110:
111:            ////////////////////////////////////////////////////////////////////
112:            // Manipulators
113:            ////////////////////////////////////////////////////////////////////
114:
115:            /**
116:             * Copy an entire Attributes object.  The "specified" flags are
117:             * assigned as true, unless the object is an Attributes2 object
118:             * in which case those values are copied.
119:             *
120:             * @see AttributesImpl#setAttributes
121:             */
122:            public void setAttributes(Attributes atts) {
123:                int length = atts.getLength();
124:
125:                super .setAttributes(atts);
126:                flags = new boolean[length];
127:
128:                if (atts instanceof  Attributes2) {
129:                    Attributes2 a2 = (Attributes2) atts;
130:                    for (int i = 0; i < length; i++)
131:                        flags[i] = a2.isSpecified(i);
132:                } else {
133:                    for (int i = 0; i < length; i++)
134:                        flags[i] = true;
135:                }
136:
137:            }
138:
139:            /**
140:             * Add an attribute to the end of the list, setting its
141:             * "specified" flag to true.  To set that flag's value
142:             * to false, use {@link #setSpecified}.
143:             *
144:             * @see AttributesImpl#addAttribute
145:             */
146:            public void addAttribute(String uri, String localName,
147:                    String qName, String type, String value) {
148:                super .addAttribute(uri, localName, qName, type, value);
149:
150:                int length = getLength();
151:
152:                if (length < flags.length) {
153:                    boolean newFlags[] = new boolean[length];
154:                    System.arraycopy(flags, 0, newFlags, 0, flags.length);
155:                    flags = newFlags;
156:                }
157:
158:                flags[length - 1] = true;
159:            }
160:
161:            // javadoc entirely from superclass
162:            public void removeAttribute(int index) {
163:                int origMax = getLength() - 1;
164:
165:                super .removeAttribute(index);
166:                if (index != origMax)
167:                    System.arraycopy(flags, index + 1, flags, index, origMax
168:                            - index);
169:            }
170:
171:            /**
172:             * Assign a value to the "specified" flag of a specific attribute.
173:             * This is the only way this flag can be cleared, except clearing
174:             * by initialization with the copy constructor.
175:             *
176:             * @param index The index of the attribute (zero-based).
177:             * @param value The desired flag value.
178:             * @exception java.lang.ArrayIndexOutOfBoundsException When the
179:             *            supplied index does not identify an attribute.
180:             */
181:            public void setSpecified(int index, boolean value) {
182:                if (index < 0 || index >= getLength())
183:                    throw new ArrayIndexOutOfBoundsException(
184:                            "No attribute at index: " + index);
185:                flags[index] = value;
186:            }
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.