XMLStringBufferpublic class XMLStringBuffer extends org.apache.xerces.xni.XMLString 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() . |
Fields Summary |
---|
public static final int | DEFAULT_SIZEDefault buffer size (32). |
Constructors Summary |
---|
public XMLStringBuffer()
//
// Constructors
//
this(DEFAULT_SIZE);
| public XMLStringBuffer(int size)
ch = new char[size];
| public XMLStringBuffer(char c)Constructs a string buffer from a char.
this(1);
append(c);
| public XMLStringBuffer(String s)Constructs a string buffer from a String.
this(s.length());
append(s);
| public XMLStringBuffer(char[] ch, int offset, int length)Constructs a string buffer from the specified character array.
this(length);
append(ch, offset, length);
| public XMLStringBuffer(org.apache.xerces.xni.XMLString s)Constructs a string buffer from the specified XMLString.
this(s.length);
append(s);
|
Methods Summary |
---|
public void | append(char[] ch, int offset, int length)append
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 | append(org.apache.xerces.xni.XMLString s)append
append(s.ch, s.offset, s.length);
| public void | append(char c)append
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(java.lang.String s)append
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 | clear()Clears the string buffer.
offset = 0;
length = 0;
|
|