org.jmlspecs.jml4.rac
Class CodeBuffer

java.lang.Object
  extended by org.jmlspecs.jml4.rac.CodeBuffer

public class CodeBuffer
extends java.lang.Object

Improved version of the StringBuffer class. This class provides a similar feature as the StringBuffer class. In addition, it allows a formated strings to be appended, as implemented by the method append(String, Object...).

Author:
Yoonsik Cheon
See Also:
append(String, Object...)

Constructor Summary
CodeBuffer()
          Creates a new code buffer.
 
Method Summary
 CodeBuffer append(boolean b)
          Appends the string representation of the boolean argument.
 CodeBuffer append(char c)
          Appends the string representation of the character argument.
 CodeBuffer append(char[] str)
          Appends the string representation of the char[] argument.
 CodeBuffer append(CodeBuffer cb)
          Appends the given string buffer.
 CodeBuffer append(int i)
          Appends the string representation of the int argument.
 CodeBuffer append(java.lang.Object o)
          Appends the string representation of the object argument.
 CodeBuffer append(java.lang.String str)
          Appends the given string.
 CodeBuffer append(java.lang.StringBuffer sb)
          Appends the given string buffer.
 CodeBuffer append(java.lang.String str, java.lang.Object... args)
          Appends the given string to this buffer with format strings appearing in the string replaced with the corresponding arguments.
static void main(java.lang.String[] args)
           
 CodeBuffer tab()
          Appends one tab of spaces.
 CodeBuffer tab(int n)
          Appends given number of tab spaces.
 java.lang.String toString()
          Returns a string contained in this code buffer.
 java.lang.StringBuffer toStringBuffer()
          Returns a string buffer representation of this code buffer The returned string buffer is aliased o the internal one, thus changes are visible to each other.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CodeBuffer

public CodeBuffer()
Creates a new code buffer.

Method Detail

tab

public CodeBuffer tab()
Appends one tab of spaces.


tab

public CodeBuffer tab(int n)
Appends given number of tab spaces. Each tab consists of two chars.


append

public CodeBuffer append(java.lang.String str,
                         java.lang.Object... args)
Appends the given string to this buffer with format strings appearing in the string replaced with the corresponding arguments. The format string is of the form: %n, where the number n denotes the position of the argument to replace the format string. For example, the following two statements have the same effect:
        append("Beauti%1 %2de, %2de!", "ful", "co")
  append("Beautiful code, code!")
 
If an argument is of type char[], it is first converted to a string; otherwise, a toString method is used to convert it to a string.

A format string with no corresponding argument remains the same. If an argument itself contains a format string, its effect is not specified; it may be or may not be replaced depending on the order of the arguments.


append

public CodeBuffer append(boolean b)
Appends the string representation of the boolean argument.


append

public CodeBuffer append(char c)
Appends the string representation of the character argument.


append

public CodeBuffer append(char[] str)
Appends the string representation of the char[] argument.


append

public CodeBuffer append(int i)
Appends the string representation of the int argument.


append

public CodeBuffer append(java.lang.Object o)
Appends the string representation of the object argument.


append

public CodeBuffer append(java.lang.String str)
Appends the given string.


append

public CodeBuffer append(java.lang.StringBuffer sb)
Appends the given string buffer.


append

public CodeBuffer append(CodeBuffer cb)
Appends the given string buffer.


toString

public java.lang.String toString()
Returns a string contained in this code buffer.

Overrides:
toString in class java.lang.Object

toStringBuffer

public java.lang.StringBuffer toStringBuffer()
Returns a string buffer representation of this code buffer The returned string buffer is aliased o the internal one, thus changes are visible to each other.


main

public static void main(java.lang.String[] args)