org.apache.jasper.xmlparser
public class: XMLStringBuffer [javadoc |
source]
java.lang.Object
org.apache.jasper.xmlparser.XMLString
org.apache.jasper.xmlparser.XMLStringBuffer
XMLString is a structure used to pass character arrays. However,
XMLStringBuffer is a buffer in which characters can be appended
and extends XMLString so that it can be passed to methods
expecting an XMLString object. This is a safe operation because
it is assumed that any callee will
not modify
the contents of the XMLString structure.
The contents of the string are managed by the string buffer. As
characters are appended, the string buffer will grow as needed.
Note: Never set the ch,
offset, and length fields directly.
These fields are managed by the string buffer. In order to reset
the buffer, call clear().
- author:
Andy - Clark, IBM
- author:
Eric - Ye, IBM
- version:
$ - Id: XMLStringBuffer.java 467222 2006-10-24 03:17:11Z markt $
| Field Summary |
|---|
| public static final int | DEFAULT_SIZE | Default buffer size (32). |
| Method from org.apache.jasper.xmlparser.XMLStringBuffer Detail: |
public void append(char c) {
if (this.length + 1 > this.ch.length) {
int newLength = this.ch.length*2;
if (newLength < this.ch.length + DEFAULT_SIZE)
newLength = this.ch.length + DEFAULT_SIZE;
char[] newch = new char[newLength];
System.arraycopy(this.ch, 0, newch, 0, this.length);
this.ch = newch;
}
this.ch[this.length] = c;
this.length++;
}
|
public void append(String s) {
int length = s.length();
if (this.length + length > this.ch.length) {
int newLength = this.ch.length*2;
if (newLength < this.length + length + DEFAULT_SIZE)
newLength = this.ch.length + length + DEFAULT_SIZE;
char[] newch = new char[newLength];
System.arraycopy(this.ch, 0, newch, 0, this.length);
this.ch = newch;
}
s.getChars(0, length, this.ch, this.length);
this.length += length;
}
|
public void append(XMLString s) {
append(s.ch, s.offset, s.length);
}
|
public void append(char[] ch,
int offset,
int length) {
if (this.length + length > this.ch.length) {
char[] newch = new char[this.ch.length + length + DEFAULT_SIZE];
System.arraycopy(this.ch, 0, newch, 0, this.length);
this.ch = newch;
}
System.arraycopy(ch, offset, this.ch, this.length, length);
this.length += length;
}
|
public void clear() {
offset = 0;
length = 0;
}
Clears the string buffer. |