Package com.jk.core.util
Class JKStringBuffer
java.lang.Object
com.jk.core.util.JKStringBuffer
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
This method adds a line of text with a specified number of preceeding spaces and optional parameters.void
This method appends a formatted line to the internal buffer with optional parameters.void
This method appends the provided contents to the internal buffer.void
endBlock()
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
line()
This method adds an empty line of text.void
reset()
This method resets the internal buffer, clearing all previously added content.void
setBuffer
(StringBuffer buffer) This method sets the internal `StringBuffer` instance to a specified buffer.void
This method increases the indentation level for a new block of content.toString()
This method retrieves the string representation of the object.
-
Constructor Details
-
JKStringBuffer
public JKStringBuffer()
-
-
Method Details
-
add
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
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
This method returns the accumulated text content.- Returns:
- the accumulated text content.
-
getBuffer
This method returns the internal `StringBuffer` instance used for text accumulation.- Returns:
- the internal `StringBuffer` instance.
-
setBuffer
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
This method appends the provided contents to the internal buffer.- Parameters:
contents
- Specifies the contents to append to the buffer.
-
toString
This method retrieves 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.
-