JSON
Version 1.0

org.codehaus.jackson.util
Class TextBuffer

java.lang.Object
  extended by org.codehaus.jackson.util.TextBuffer

public final class TextBuffer
extends Object

TextBuffer is a class similar to StringBuffer, with following differences:


Constructor Summary
TextBuffer(BufferRecycler allocator)
           
 
Method Summary
 void append(char[] c, int start, int len)
           
 char[] contentsAsArray()
           
 String contentsAsString()
           
 int contentsToArray(int srcStart, char[] dst, int dstStart, int len)
           
 void ensureNotShared()
          Method called to make sure that buffer is not using shared input buffer; if it is, it will copy such contents to private buffer.
 char[] finishCurrentSegment()
           
 char[] getCurrentSegment()
           
 int getCurrentSegmentSize()
           
 char[] getTextBuffer()
           
 int getTextOffset()
           
 int rawContentsTo(Writer w)
          Method that will stream contents of this buffer into specified Writer.
 void releaseBuffers()
          Method called to indicate that the underlying buffers should now be recycled if they haven't yet been recycled.
 void resetWithCopy(char[] buf, int start, int len)
           
 void resetWithEmpty()
          Method called to clear out any content text buffer may have, and initializes buffer to use non-shared data.
 void resetWithShared(char[] buf, int start, int len)
          Method called to initialize the buffer with a shared copy of data; this means that buffer will just have pointers to actual data.
 void resetWithString(String str)
           
 void setCurrentLength(int len)
           
 int size()
           
 String toString()
          Note: calling this method may not be as efficient as calling contentsAsString(), since it's not guaranteed that resulting String is cached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextBuffer

public TextBuffer(BufferRecycler allocator)
Method Detail

releaseBuffers

public void releaseBuffers()
Method called to indicate that the underlying buffers should now be recycled if they haven't yet been recycled. Although caller can still use this text buffer, it is not advisable to call this method if that is likely, since next time a buffer is needed, buffers need to reallocated. Note: calling this method automatically also clears contents of the buffer.


resetWithEmpty

public void resetWithEmpty()
Method called to clear out any content text buffer may have, and initializes buffer to use non-shared data.


resetWithShared

public void resetWithShared(char[] buf,
                            int start,
                            int len)
Method called to initialize the buffer with a shared copy of data; this means that buffer will just have pointers to actual data. It also means that if anything is to be appended to the buffer, it will first have to unshare it (make a local copy).


resetWithCopy

public void resetWithCopy(char[] buf,
                          int start,
                          int len)

resetWithString

public void resetWithString(String str)

size

public int size()
Returns:
Number of characters currently stored by this collector

getTextOffset

public int getTextOffset()

getTextBuffer

public char[] getTextBuffer()

contentsAsString

public String contentsAsString()

contentsAsArray

public char[] contentsAsArray()

contentsToArray

public int contentsToArray(int srcStart,
                           char[] dst,
                           int dstStart,
                           int len)

rawContentsTo

public int rawContentsTo(Writer w)
                  throws IOException
Method that will stream contents of this buffer into specified Writer.

Throws:
IOException

ensureNotShared

public void ensureNotShared()
Method called to make sure that buffer is not using shared input buffer; if it is, it will copy such contents to private buffer.


append

public void append(char[] c,
                   int start,
                   int len)

getCurrentSegment

public char[] getCurrentSegment()

getCurrentSegmentSize

public int getCurrentSegmentSize()

setCurrentLength

public void setCurrentLength(int len)

finishCurrentSegment

public char[] finishCurrentSegment()

toString

public String toString()
Note: calling this method may not be as efficient as calling contentsAsString(), since it's not guaranteed that resulting String is cached.

Overrides:
toString in class Object

JSON
Version 1.0

Apache License, Version 2.0