/ LJCJSCodeDoc / LJCTextBuilderLib / LJCTextBuilder


Syntax

JavaScript
class TextBuilder

Represents a built string value.

Remarks

The LJCTextBuilder class is designed for creating text. It can also be used to create HTML and XML text.

The LJCTextBuilder class stores the built text internally. The text is retrieved with the ToString() method.

"Append" Methods
"Append Text" methods add the potentially indented and wrapped text to the builder.
These methods append the supplied text without an ending newline. This behavior is done for consistency and it allows for appending to the existing text if desired.
The "Append" methods start the appended text with a newline if the builder already has text, param allowNewLine = true (default) and the builder text does not already end with a newline.

"Get" Methods
"Get" methods create and return the potentialy indented and wrapped text but do not add it to the builder.
This allows for using the text outside of the builder.
Use the "addIndent" parameter set to "false" when appending text to the builder that was retrieved using a "Get" method. This is because the indent may already have been added to the text by the "Get" method.

"Add Text" Methods
AddLine(), AddText()
The "Add Text" methods add text to the builder unmodified except for AddLine() which appends a newline.

"Append Text" Methods
Line(), Text()
The "Append Text" methods add the potentially indented and wrapped text to the builder. The Line() method appends a newline.

The AddIndent() method manually controls the current indent count. The indent string length is calculated with the properties (IndentCount * IndentCharCount) and can be retrieved with the IndentLength property.

"Get Text" Methods
GetLine(), GetText()
The "Get Text" methods create and return the potentialy indented and wrapped text but do not add it to the builder.
The GetLine() and GetText() methods modify the returned text the same as the Line() and Text() methods.

"Append Element" Methods
Begin(), Create(), End()
These methods append element tags and content. Begin() automatically increments the IndentCount by 1. Create() also increments the IndentCount by 1 if the isEmpty parameter is false and the close parameter is false. End() automatically decrements the IndentCount by 1 if the IndentCount is currently greater than zero.

"Get Element" Methods
GetBegin(), GetCreate(), GetEnd()
The "Get Element" methods create and return the potentialy indented and wrapped text but do not add it to the builder.

Public Methods

Constructor Methods
construct Initializes a class instance.
Data Class Methods
ToString Gets the built string.
Add Text
AddLine Appends a text line without modification.
AddText Appends text without modification.
Append Text
Line Appends a potentially indented text line to the builder.
Text Appends the potentially indented text.
Get Text
GetLine Gets the potentially indented and wrapped text line.
GetText Gets the potentially indented and wrapped text.
Other Get Text
GetIndented Gets a new potentially indented line.
GetIndentString Returns the current indent string.
GetWrapped Appends added text and new wrapped line.
Get Attribs
Attribs Gets common element attributes.
GetAttribs Gets the attributes text.
StartAttribs Creates the HTML element attributes.
StartXMLAttribs Creates the XML element attributes.
TableAttribs Gets common table attributes.
Append Element
Begin Appends the element begin tag.
Create Appends an element.
End Appends the element end tag.
Get Element
GetBegin Gets the element begin tag.
GetCreate Gets an element.
GetEnd Gets the element end tag.
Other Methods
AddChildIndent Adds the new (child) indents.
AddIndent Changes the IndentCount by the provided value.
EndsWithNewLine Indicates if the builder text ends with a newline.
GetTextState Gets a current LJCTextState object.
HasText Indicates if the builder has text.
IndentLength Gets the current indent length.
StartWithNewLine Checks if the text can start with a newline.
getIndentCount _FunctionSummary_
30 Methods

Public Properties
IndentCharCount _PropertySummary_
LineLength Gets the current length.
LineLimit Gets or sets the character limit.
WrapEnabled Indicates if the wrap functionality is enabled.
4 Properties

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.