com.ccg.macros
Class OutputStringBuffer

java.lang.Object
  extended by com.ccg.macros.OutputStringBuffer
All Implemented Interfaces:
Output

public class OutputStringBuffer
extends Object
implements Output

A Output implementation which uses a string buffer.

This implementation is fairly efficient and useful if you want to be able to get a String after interpreting macros.

Since:
1.0
Version:
$Revision: 1.1.1.1 $
Author:
$Author: pkb $
See Also:
Output

Constructor Summary
OutputStringBuffer()
          Construct a output string buffer with the default initial capacity.
OutputStringBuffer(int size)
          Construct a output string buffer with a initial capacity.
OutputStringBuffer(String init)
          Construct a output buffer with some initial content.
OutputStringBuffer(StringBuffer sb)
          Construct a output buffer with a existing buffer.
 
Method Summary
 void clear()
          One line summary...
 StringBuffer getBuffer()
          One line summary...
 void setBuffer(int size)
          One line summary...
 void setBuffer(String with)
          One line summary...
 void setBuffer(StringBuffer sb)
          One line summary...
 String toString()
          One line summary...
 void write(char[] buf, int ofs, int len)
          Writes a set of characters from a buffer to the output.
 void write(Object o)
          Appends the string representation of a Object to the output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OutputStringBuffer

public OutputStringBuffer()
Construct a output string buffer with the default initial capacity.

Since:
1.0

OutputStringBuffer

public OutputStringBuffer(int size)
Construct a output string buffer with a initial capacity.

Parameters:
cap - Initial capacity to allocate.
Since:
1.0

OutputStringBuffer

public OutputStringBuffer(StringBuffer sb)
Construct a output buffer with a existing buffer. This method allows one to contstruct a output buffer with an existing StringBuffer object. This will initialize the resulting output with the contents of the object passed. All data which is written to the output buffer will be appended.

It should be noted, that in this case a new StringBuffer object is not allocated - the object will directly append output to the object you supply.

Parameters:
init - Initial contents to load the output buffer with (any new output will be appeneded). You can pass null (buffer won't have any initial contents)
Since:
1.0
See Also:
setBuffer(StringBuffer)

OutputStringBuffer

public OutputStringBuffer(String init)
Construct a output buffer with some initial content. This method allows one to contstruct a output buffer with an existing String object. This will initialize the resulting output with the contents of the object passed. All data which is written to the output buffer will be appended.

Parameters:
init - Initial contents to load the output buffer with (any new output will be appended). You can pass null (buffer won't have any initial contents)
Since:
1.0
See Also:
setBuffer(String)
Method Detail

setBuffer

public void setBuffer(StringBuffer sb)
One line summary... Describe...

Parameters:
arg1 - arg1-describe
arg2 - arg2-describe
Throws:
exc - Why thrown
Since:
1.0

setBuffer

public void setBuffer(int size)
One line summary... Describe...

Parameters:
arg1 - arg1-describe
arg2 - arg2-describe
Throws:
exc - Why thrown
Since:
1.0

setBuffer

public void setBuffer(String with)
One line summary... Describe...

Parameters:
arg1 - arg1-describe
arg2 - arg2-describe
Throws:
exc - Why thrown
Since:
1.0

getBuffer

public StringBuffer getBuffer()
One line summary... Describe...

Parameters:
arg1 - arg1-describe
arg2 - arg2-describe
Returns:
ret-description
Throws:
exc - Why thrown
Since:
1.0

clear

public void clear()
One line summary... Describe...

Parameters:
arg1 - arg1-describe
arg2 - arg2-describe
Throws:
exc - Why thrown
Since:
1.0

toString

public String toString()
One line summary... Describe...

Overrides:
toString in class Object
Parameters:
arg1 - arg1-describe
arg2 - arg2-describe
Returns:
ret-description
Throws:
exc - Why thrown
Since:
1.0

write

public void write(char[] buf,
                  int ofs,
                  int len)
           throws IOException
Writes a set of characters from a buffer to the output. This method is used by macro processors (such as the AtMacros class) to send a set of characters to the output device (string, file, etc).

Specified by:
write in interface Output
Parameters:
buf - A character array to take the data from (must not be null)
ofs - Offset into the buffer to the first character to start the copy from. Should be in the range of [0,buf.length-1].
len - How many characters to copy. When added to the offset, the resulting value should not exceed the length of the array.
Throws:
IOException - If a I/O error is encountered (which this implementation of a Output device will probably never throw).
Since:
1.0

write

public void write(Object o)
           throws IOException
Appends the string representation of a Object to the output. This method is used by macro processors (such as the AtMacros class) to cause the string representation of a Object to be added to the output produced.

Specified by:
write in interface Output
Parameters:
object - The object to write out (the toString() method is used to write out the string representation of the object). You may pass null (in which case nothing will be done).
Throws:
IOException - If a I/O error is encountered (which this implementation of a Output device will probably never throw).
Since:
1.0


Copyright 1998-1998-2006 null. All Rights Reserved.