Source Code Cross Referenced for XMLStringBuffer.java in  » Sevlet-Container » apache-tomcat-6.0.14 » org » apache » jasper » xmlparser » 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 » Sevlet Container » apache tomcat 6.0.14 » org.apache.jasper.xmlparser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         * ====================================================================
017:         *
018:         * This software consists of voluntary contributions made by many
019:         * individuals on behalf of the Apache Software Foundation and was
020:         * originally based on software copyright (c) 1999, International
021:         * Business Machines, Inc., http://www.apache.org.  For more
022:         * information on the Apache Software Foundation, please see
023:         * <http://www.apache.org/>.
024:         */
025:
026:        package org.apache.jasper.xmlparser;
027:
028:        /**
029:         * XMLString is a structure used to pass character arrays. However,
030:         * XMLStringBuffer is a buffer in which characters can be appended
031:         * and extends XMLString so that it can be passed to methods
032:         * expecting an XMLString object. This is a safe operation because
033:         * it is assumed that any callee will <strong>not</strong> modify
034:         * the contents of the XMLString structure.
035:         * <p> 
036:         * The contents of the string are managed by the string buffer. As
037:         * characters are appended, the string buffer will grow as needed.
038:         * <p>
039:         * <strong>Note:</strong> Never set the <code>ch</code>, 
040:         * <code>offset</code>, and <code>length</code> fields directly.
041:         * These fields are managed by the string buffer. In order to reset
042:         * the buffer, call <code>clear()</code>.
043:         * 
044:         * @author Andy Clark, IBM
045:         * @author Eric Ye, IBM
046:         *
047:         * @version $Id: XMLStringBuffer.java 467222 2006-10-24 03:17:11Z markt $
048:         */
049:        public class XMLStringBuffer extends XMLString {
050:
051:            //
052:            // Constants
053:            //
054:
055:            /** Default buffer size (32). */
056:            public static final int DEFAULT_SIZE = 32;
057:
058:            //
059:            // Constructors
060:            //
061:
062:            /**
063:             * 
064:             */
065:            public XMLStringBuffer() {
066:                this (DEFAULT_SIZE);
067:            } // <init>()
068:
069:            /**
070:             * 
071:             * 
072:             * @param size 
073:             */
074:            public XMLStringBuffer(int size) {
075:                ch = new char[size];
076:            } // <init>(int)
077:
078:            /** Constructs a string buffer from a char. */
079:            public XMLStringBuffer(char c) {
080:                this (1);
081:                append(c);
082:            } // <init>(char)
083:
084:            /** Constructs a string buffer from a String. */
085:            public XMLStringBuffer(String s) {
086:                this (s.length());
087:                append(s);
088:            } // <init>(String)
089:
090:            /** Constructs a string buffer from the specified character array. */
091:            public XMLStringBuffer(char[] ch, int offset, int length) {
092:                this (length);
093:                append(ch, offset, length);
094:            } // <init>(char[],int,int)
095:
096:            /** Constructs a string buffer from the specified XMLString. */
097:            public XMLStringBuffer(XMLString s) {
098:                this (s.length);
099:                append(s);
100:            } // <init>(XMLString)
101:
102:            //
103:            // Public methods
104:            //
105:
106:            /** Clears the string buffer. */
107:            public void clear() {
108:                offset = 0;
109:                length = 0;
110:            }
111:
112:            /**
113:             * append
114:             * 
115:             * @param c 
116:             */
117:            public void append(char c) {
118:                if (this .length + 1 > this .ch.length) {
119:                    int newLength = this .ch.length * 2;
120:                    if (newLength < this .ch.length + DEFAULT_SIZE)
121:                        newLength = this .ch.length + DEFAULT_SIZE;
122:                    char[] newch = new char[newLength];
123:                    System.arraycopy(this .ch, 0, newch, 0, this .length);
124:                    this .ch = newch;
125:                }
126:                this .ch[this .length] = c;
127:                this .length++;
128:            } // append(char)
129:
130:            /**
131:             * append
132:             * 
133:             * @param s 
134:             */
135:            public void append(String s) {
136:                int length = s.length();
137:                if (this .length + length > this .ch.length) {
138:                    int newLength = this .ch.length * 2;
139:                    if (newLength < this .length + length + DEFAULT_SIZE)
140:                        newLength = this .ch.length + length + DEFAULT_SIZE;
141:                    char[] newch = new char[newLength];
142:                    System.arraycopy(this .ch, 0, newch, 0, this .length);
143:                    this .ch = newch;
144:                }
145:                s.getChars(0, length, this .ch, this .length);
146:                this .length += length;
147:            } // append(String)
148:
149:            /**
150:             * append
151:             * 
152:             * @param ch 
153:             * @param offset 
154:             * @param length 
155:             */
156:            public void append(char[] ch, int offset, int length) {
157:                if (this .length + length > this .ch.length) {
158:                    char[] newch = new char[this .ch.length + length
159:                            + DEFAULT_SIZE];
160:                    System.arraycopy(this .ch, 0, newch, 0, this .length);
161:                    this .ch = newch;
162:                }
163:                System.arraycopy(ch, offset, this .ch, this .length, length);
164:                this .length += length;
165:            } // append(char[],int,int)
166:
167:            /**
168:             * append
169:             * 
170:             * @param s 
171:             */
172:            public void append(XMLString s) {
173:                append(s.ch, s.offset, s.length);
174:            } // append(XMLString)
175:
176:        } // class XMLStringBuffer
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.