ariba.util.core
Class FormatBuffer

java.lang.Object
  extended by ariba.util.core.FastStringBuffer
      extended by ariba.util.core.FormatBuffer

public class FormatBuffer
extends FastStringBuffer

A version of a FastStringBuffer that is able to append some basic java types directly without having to use intermediate strings. This class is used to try to improve performance by avoiding memory allocations in string formatting.


Constructor Summary
FormatBuffer()
          Make a FormatBuffer.
FormatBuffer(int size)
          Make a FormatBuffer.
 
Method Summary
 void append(char c)
          Append a character to the FormatBuffer.
 void append(double d)
          Append a double to the FormatBuffer.
 void append(FormatBuffer that)
          Append a one FormatBuffer to another FormatBuffer.
 void append(int i)
          Append an integer to the FormatBuffer.
 void append(int i, int radix)
          Append an integer in a radix format to the FormatBuffer.
 void append(long l)
          Append a long to the FormatBuffer.
 boolean isEmpty()
          Determine if the FormatBuffer is empty.
 void print(java.io.OutputStream out)
          Write the contents of this FormatBuffer to an OutputStream.
 void print(java.io.PrintWriter out)
          Write the contents of this FormatBuffer to a Writer.
 void print(java.io.Writer out)
          Write the contents of this FormatBuffer to a Writer.
 int size()
          Return the number of bytes used in buffer.
 
Methods inherited from class ariba.util.core.FastStringBuffer
append, append, append, append, appendCharRange, appendStringRange, charArray, charAt, getBuffer, getDoublesCapacityWhenGrowing, indexOf, indexOf, indexOf, indexOf, insert, insert, length, moveChars, removeCharAt, replace, replace, replace, setCharAt, setDoublesCapacityWhenGrowing, setStringValue, startsWith, startsWith, substring, tabOrSpaceAt, toString, truncateToLength
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FormatBuffer

public FormatBuffer()
Make a FormatBuffer. Allocate the underlying string buffer to a default size.


FormatBuffer

public FormatBuffer(int size)
Make a FormatBuffer. Allocate the underlying string buffer to a specified size.

Parameters:
size - the number of characters the FormatBuffer can hold without growing.
Method Detail

append

public void append(char c)
Append a character to the FormatBuffer.

Overrides:
append in class FastStringBuffer
Parameters:
c - the character to append

append

public void append(int i)
Append an integer to the FormatBuffer.

Parameters:
i - the integer to append

append

public void append(int i,
                   int radix)
Append an integer in a radix format to the FormatBuffer.

Parameters:
i - the integer to append
radix - the radix to use for encoding the integer i. The radix must be between Character.MIN_RADIX and Character.MAX_RADIX
See Also:
Character.MAX_RADIX, Character.MIN_RADIX

append

public void append(long l)
Append a long to the FormatBuffer.

Parameters:
l - the long to append

append

public void append(double d)
Append a double to the FormatBuffer.

Parameters:
d - the double to append

append

public void append(FormatBuffer that)
Append a one FormatBuffer to another FormatBuffer. This method is faster than converting the second FormatBuffer buffer to a string first.

Parameters:
that - a FormatBuffer to append to this FormatBuffer

size

public int size()
Return the number of bytes used in buffer.

Returns:
the current number of characters stored.

isEmpty

public boolean isEmpty()
Determine if the FormatBuffer is empty.

Returns:
true if the FormatBuffer is empty, false otherwise

print

public void print(java.io.PrintWriter out)
Write the contents of this FormatBuffer to a Writer.

Parameters:
out - the PrintWriter to write the output into.

print

public void print(java.io.Writer out)
           throws java.io.IOException
Write the contents of this FormatBuffer to a Writer.

Parameters:
out - the PrintWriter to write the output into.
Throws:
java.io.IOException

print

public void print(java.io.OutputStream out)
           throws java.io.IOException
Write the contents of this FormatBuffer to an OutputStream.

Parameters:
out - the OutputStream to write the output into.
Throws:
java.io.IOException - if an error occurs in writing to out


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.