Class JKStringBuffer

java.lang.Object
com.jk.core.util.JKStringBuffer

public class JKStringBuffer extends Object
This class is a utility class used for building and formatting text content with indentation.

It provides methods for adding lines of text, managing indentation levels, and other text-related operations.

Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int preSpaces, String line, Object... params)
    This method adds a line of text with a specified number of preceeding spaces and optional parameters.
    void
    add(String line, Object... params)
    This method appends a formatted line to the internal buffer with optional parameters.
    void
    append(String contents)
    This method appends the provided contents to the internal buffer.
    void
    This method decreases the indentation level after a block of content.
    This method returns the internal `StringBuffer` instance used for text accumulation.
    This method returns the accumulated text content.
    void
    This method adds an empty line of text.
    void
    This method resets the internal buffer, clearing all previously added content.
    void
    This method sets the internal `StringBuffer` instance to a specified buffer.
    void
    This method increases the indentation level for a new block of content.
    This method retrieves the string representation of the object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • JKStringBuffer

      public JKStringBuffer()
  • Method Details

    • add

      public void add(int preSpaces, String line, Object... params)
      This method adds a line of text with a specified number of preceeding spaces and optional parameters.
      Parameters:
      preSpaces - Specifies the number of spaces to prepend before the line.
      line - Specifies the line of text to add, with optional format parameters.
      params - Specifies the optional parameters to format the line.
    • add

      public void add(String line, Object... params)
      This method appends a formatted line to the internal buffer with optional parameters.
      Parameters:
      line - Specifies the format string for the line to be added.
      params - Specifies the optional parameters to be inserted into the format string.
    • reset

      public void reset()
      This method resets the internal buffer, clearing all previously added content.
    • getResults

      public String getResults()
      This method returns the accumulated text content.
      Returns:
      the accumulated text content.
    • getBuffer

      public StringBuffer getBuffer()
      This method returns the internal `StringBuffer` instance used for text accumulation.
      Returns:
      the internal `StringBuffer` instance.
    • setBuffer

      public void setBuffer(StringBuffer buffer)
      This method sets the internal `StringBuffer` instance to a specified buffer.
      Parameters:
      buffer - Specifies the `StringBuffer` instance to set.
    • line

      public void line()
      This method adds an empty line of text.
    • append

      public void append(String contents)
      This method appends the provided contents to the internal buffer.
      Parameters:
      contents - Specifies the contents to append to the buffer.
    • toString

      public String toString()
      This method retrieves the string representation of the object.
      Overrides:
      toString in class Object
      Returns:
      the string representation of the object.
    • startBlock

      public void startBlock()
      This method increases the indentation level for a new block of content.
    • endBlock

      public void endBlock()
      This method decreases the indentation level after a block of content.