FileDocCategorySizeDatePackage
ANTLRStringBuffer.javaAPI DocGlassfish v2 API2054Wed Aug 30 15:34:02 BST 2006persistence.antlr

ANTLRStringBuffer

public class ANTLRStringBuffer extends Object

Fields Summary
protected char[]
buffer
protected int
length
Constructors Summary
public ANTLRStringBuffer()

		// length and also where to store next char


      
        buffer = new char[50];
    
public ANTLRStringBuffer(int n)

        buffer = new char[n];
    
Methods Summary
public final voidappend(char c)

        // This would normally be  an "ensureCapacity" method, but inlined
        // here for speed.
        if (length >= buffer.length) {
            // Compute a new length that is at least double old length
            int newSize = buffer.length;
            while (length >= newSize) {
                newSize *= 2;
            }
            // Allocate new array and copy buffer
            char[] newBuffer = new char[newSize];
            for (int i = 0; i < length; i++) {
                newBuffer[i] = buffer[i];
            }
            buffer = newBuffer;
        }
        buffer[length] = c;
        length++;
    
public final voidappend(java.lang.String s)

        for (int i = 0; i < s.length(); i++) {
            append(s.charAt(i));
        }
    
public final charcharAt(int index)

        return buffer[index];
    
public final char[]getBuffer()

        return buffer;
    
public final intlength()

        return length;
    
public final voidsetCharAt(int index, char ch)

        buffer[index] = ch;
    
public final voidsetLength(int newLength)

        if (newLength < length) {
            length = newLength;
        }
        else {
            while (newLength > length) {
                append('\0");
            }
        }
    
public final java.lang.StringtoString()

        return new String(buffer, 0, length);