creamtec.core
Class FormattedStringBuffer

java.lang.Object
  extended by creamtec.core.FormattedStringBuffer

public class FormattedStringBuffer
extends java.lang.Object

Provides implementation for a buffer of characters, that are stored in a formatted way. Formatting includes new lines, indent and some HTML specific functionality


Constructor Summary
FormattedStringBuffer()
          Initializes the buffer with the default buffer size of 4000 characters
FormattedStringBuffer(FormattedStringBuffer buffer)
          Initializes the buffer with the default buffer size and sets indent to be the same as in the given buffer
FormattedStringBuffer(int bufferSize)
          Initializes the buffer with the given buffer size
FormattedStringBuffer(java.lang.String value)
          Initializes the buffer with the given string
 
Method Summary
 void append(char ch)
          Appends the given character to the buffer
 void append(FormattedStringBuffer buf)
           
 void append(int ch)
           
 void append(java.lang.String s)
          Appends the given string to the buffer
 void append(java.lang.StringBuffer buf)
           
 void appendHTMLText(java.lang.String htmlText, boolean noBreak)
           
 void appendHTMLText(java.lang.String htmlText, boolean noBreak, boolean ignoreAllTags)
          Appends given HTML text to the buffer.
 void appendln(java.lang.String s)
          Appends the given string to the buffer and terminates the line
 void appendText(java.lang.String text)
          Appends the given text as non-breakable spaced text (for HTML inserts spaces as  ).
 void appendText(java.lang.String text, boolean noBreak)
           
 void appendText(java.lang.String text, boolean noBreak, boolean ignoreAllHTMLTags)
           
 void appendText(java.lang.String text, boolean noBreak, boolean ignoreAllHTMLTags, boolean javaScript)
          Appends the given text as HTML-ready text.
 void clear()
          Resets the buffer by deleting the entire contents and setting indent to 0
 void decreaseIndent()
          Decreases the indent in the buffer
 void delete(int start, int end)
          Deletes characters int the buffer between start and end
 java.lang.StringBuffer getBuffer()
           
 int getIndent()
          Returns the indent in the buffer
 int getNoBreakFlag()
           
 void increaseIndent()
          Increases the indent in the buffer
 void insert(int position, java.lang.String string)
          Inserts the given text at the absolute position
 void insertMarked(java.lang.String string)
          Inserts the given text into the buffer at the marked position.
 int length()
          Returns the current size of the buffer in characters
 void markPosition()
          Stores the current position to be reused later by insertMarked
 void newLine()
          Ensure that next text appended will be written on the new line Does not actually insert a new line character (use appendln("") instead
 void setIndent(int indent)
          Sets the indent in the buffer to the absolute value
 void setNoBreak(boolean noBreak)
          Marks beginning/end of unbreakable text using <nobr> tag
 void setNoBreakFlag(boolean noBreak)
          Will not append tags, just manipulate the flag
 boolean shouldIgnoreTag(java.lang.String tag)
          Returns true if the tag should be skipped
 java.lang.String toString()
          Returns the buffer as a string
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FormattedStringBuffer

public FormattedStringBuffer()
Initializes the buffer with the default buffer size of 4000 characters


FormattedStringBuffer

public FormattedStringBuffer(FormattedStringBuffer buffer)
Initializes the buffer with the default buffer size and sets indent to be the same as in the given buffer


FormattedStringBuffer

public FormattedStringBuffer(int bufferSize)
Initializes the buffer with the given buffer size


FormattedStringBuffer

public FormattedStringBuffer(java.lang.String value)
Initializes the buffer with the given string

Method Detail

appendln

public void appendln(java.lang.String s)
Appends the given string to the buffer and terminates the line


newLine

public void newLine()
Ensure that next text appended will be written on the new line Does not actually insert a new line character (use appendln("") instead


append

public void append(java.lang.String s)
Appends the given string to the buffer


append

public void append(char ch)
Appends the given character to the buffer


append

public void append(java.lang.StringBuffer buf)

append

public void append(FormattedStringBuffer buf)

append

public void append(int ch)

appendText

public void appendText(java.lang.String text)
Appends the given text as non-breakable spaced text (for HTML inserts spaces as  ). Special characters like ' and <> are converted into the appropriate HTML counterparts


appendText

public void appendText(java.lang.String text,
                       boolean noBreak)

appendText

public void appendText(java.lang.String text,
                       boolean noBreak,
                       boolean ignoreAllHTMLTags)

appendText

public void appendText(java.lang.String text,
                       boolean noBreak,
                       boolean ignoreAllHTMLTags,
                       boolean javaScript)
Appends the given text as HTML-ready text. Special characters like ' and <> are converted into the appropriate HTML counterparts.

Parameters:
noBreak - if true, <nobr></nobr> is added
ignoreAllHTMLTags - if true, all HTML tags will be clipped out from the string
javaScript - if true, the text is prepared for JavaScript body (\ are replaced with \\ etc.)

appendHTMLText

public void appendHTMLText(java.lang.String htmlText,
                           boolean noBreak)

appendHTMLText

public void appendHTMLText(java.lang.String htmlText,
                           boolean noBreak,
                           boolean ignoreAllTags)
Appends given HTML text to the buffer. Should be used to add HTML formatted blocks to the buffer to ensure the proper page formatting and structure


shouldIgnoreTag

public boolean shouldIgnoreTag(java.lang.String tag)
Returns true if the tag should be skipped


increaseIndent

public void increaseIndent()
Increases the indent in the buffer


decreaseIndent

public void decreaseIndent()
Decreases the indent in the buffer


getIndent

public int getIndent()
Returns the indent in the buffer


setIndent

public void setIndent(int indent)
Sets the indent in the buffer to the absolute value


setNoBreak

public void setNoBreak(boolean noBreak)
Marks beginning/end of unbreakable text using <nobr> tag


setNoBreakFlag

public void setNoBreakFlag(boolean noBreak)
Will not append tags, just manipulate the flag


getNoBreakFlag

public int getNoBreakFlag()

markPosition

public void markPosition()
Stores the current position to be reused later by insertMarked


insertMarked

public void insertMarked(java.lang.String string)
Inserts the given text into the buffer at the marked position. Must be preceded by a call to markPosition


insert

public void insert(int position,
                   java.lang.String string)
Inserts the given text at the absolute position


length

public int length()
Returns the current size of the buffer in characters


delete

public void delete(int start,
                   int end)
Deletes characters int the buffer between start and end


clear

public void clear()
Resets the buffer by deleting the entire contents and setting indent to 0


toString

public java.lang.String toString()
Returns the buffer as a string

Overrides:
toString in class java.lang.Object

getBuffer

public java.lang.StringBuffer getBuffer()


Copyright © 2000-2006 CreamTec LLC. All Rights Reserved.