Java Doc for TextBuilder.java in  » Development » Javolution » javolution » text » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » Javolution » javolution.text 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javolution.text.TextBuilder

TextBuilder
public class TextBuilder implements Appendable,CharSequence,Reusable,Realtime,Serializable(Code)

This class represents an Appendable text whose capacity expands gently without incurring expensive resize/copy operations ever.

This class is not intended for large documents manipulations which should be performed with the Text class directly (O(Log(n)) Text.insert insertion and Text.delete deletion capabilities).

This implementation is not synchronized.


author:
   Jean-Marie Dautelle
version:
   3.7, January 1, 2006



Constructor Summary
public  TextBuilder()
     Creates a text builder of small initial capacity.
public  TextBuilder(CharSequence csq)
     Creates a text builder holding the specified character sequence.
public  TextBuilder(String str)
     Creates a text builder holding the specified String.
public  TextBuilder(int capacity)
     Creates a text builder of specified initial capacity.

Method Summary
final public  Appendableappend(char c)
     Appends the specified character.
Parameters:
  c - the character to append.
final public  TextBuilderappend(Object obj)
     Appends the textual representation of the specified object.
final public  Appendableappend(CharSequence csq)
     Appends the specified character sequence.
final public  Appendableappend(CharSequence csq, int start, int end)
     Appends a subsequence of the specified character sequence. If the specified character sequence is null this method is equivalent to append("null").
final public  TextBuilderappend(String str)
     Appends the specified string to this text builder.
final public  TextBuilderappend(String str, int start, int end)
     Appends a subsequence of the specified string. If the specified character sequence is null this method is equivalent to append("null").
final public  TextBuilderappend(Text txt)
     Appends the specified text to this text builder.
final public  TextBuilderappend(Text txt, int start, int end)
     Appends a subsequence of the specified text. If the specified character sequence is null this method is equivalent to append("null").
final public  TextBuilderappend(char chars)
     Appends the characters from the char array argument.
Parameters:
  chars - the character array source.
final public  TextBuilderappend(char chars, int offset, int length)
     Appends the characters from a subarray of the char array argument.
Parameters:
  chars - the character array source.
Parameters:
  offset - the index of the first character to append.
Parameters:
  length - the number of character to append.
final public  TextBuilderappend(boolean b)
     Appends the textual representation of the specified boolean argument.
Parameters:
  b - the boolean to format.
final public  TextBuilderappend(int i)
     Appends the decimal representation of the specified int argument.
Parameters:
  i - the int to format.
final public  TextBuilderappend(int i, int radix)
     Appends the radix representation of the specified int argument.
Parameters:
  i - the int to format.
Parameters:
  radix - the radix (e.g.
final public  TextBuilderappend(long l)
     Appends the decimal representation of the specified long argument.
Parameters:
  l - the long to format.
final public  TextBuilderappend(long l, int radix)
     Appends the radix representation of the specified long argument.
Parameters:
  l - the long to format.
Parameters:
  radix - the radix (e.g.
final  voidappendFraction(long l, int digits, boolean showZero)
     Appends the textual representation of the specified double according to the specified formatting arguments.
Parameters:
  d - the double value.
Parameters:
  digits - the number of significative digits (excludes exponent) or-1 to mimic the standard library (16 or 17 digits).
Parameters:
  scientific - true to forces the use of the scientific notation (e.g.
final  voidappendTo(StringBuffer sb)
     Appends the content of this text builder to the specified string buffer (only for text builder with length less than 32).
final public  charcharAt(int i)
     Returns the character at the specified index.
Parameters:
  i - the index of the character.
final  char[]charsAt(int i)
    
final public  TextBuilderclear()
     Removes all the characters of this text builder (equivalent to this.delete(start, this.length())).
final public  booleancontentEquals(CharSequence csq)
     Indicates if this text builder has the same character content as the specified character sequence.
Parameters:
  csq - the character sequence to compare with.
final public  booleancontentEquals(String csq)
     Equivalent to TextBuilder.contentEquals(CharSequence) (for J2ME compability).
Parameters:
  csq - the string character sequence to compare with.
final public  TextBuilderdelete(int start, int end)
     Removes the characters between the specified indices.
Parameters:
  start - the beginning index, inclusive.
Parameters:
  end - the ending index, exclusive.
final public  booleanequals(Object obj)
     Compares this text builder against the specified object for equality. Returns true if the specified object is a text builder having the same character content.
Parameters:
  obj - the object to compare with or null.
final public  voidgetChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
     Copies the character from this text builder into the destination character array.
final public  inthashCode()
     Returns the hash code for this text builder.
final public  TextBuilderinsert(int index, CharSequence csq)
     Inserts the specified character sequence at the specified location.
Parameters:
  index - the insertion position.
Parameters:
  csq - the character sequence being inserted.
final public  intlength()
     Returns the length (character count) of this text builder.
public static  TextBuildernewInstance()
     Returns a new, preallocated or TextBuilder.recycle recycled text builder (on the stack when executing in a javolution.context.StackContextStackContext ).
public  voidprint()
     Prints out this text builder to System.out (UTF-8 encoding).
public  voidprint(Writer writer)
     Prints out this text builder to the specified writer.
public  voidprintln()
     Prints out this text builder to System.out and then terminates the line.
public  voidprintln(Writer writer)
     Prints out this text builder to the specified writer and then terminates the line.
public static  voidrecycle(TextBuilder instance)
     Recycles a text builder TextBuilder.newInstance() instance immediately (on the stack when executing in a javolution.context.StackContextStackContext ).
final public  voidreset()
     Resets this text builder for reuse (equivalent to TextBuilder.clear ).
final public  TextBuilderreverse()
     Reverses this character sequence.
final public  voidsetCharAt(int index, char c)
     Sets the character at the specified position.
Parameters:
  index - the index of the character to modify.
Parameters:
  c - the new character.
final public  voidsetLength(int newLength)
     Sets the length of this character builder. If the length is greater than the current length; the null character '\u0000' is inserted.
final public  CharSequencesubSequence(int start, int end)
     Returns an instance of Text (immutable) corresponding to the character sequence between the specified indexes.
Parameters:
  start - the index of the first character inclusive.
Parameters:
  end - the index of the last character exclusive.
final public  StringtoString()
     Returns the String representation of this TextBuilder .
final public  TexttoText()
     Returns the Text corresponding to this TextBuilder (allocated on the "stack" when executing in a javolution.context.StackContext StackContext ).


Constructor Detail
TextBuilder
public TextBuilder()(Code)
Creates a text builder of small initial capacity.



TextBuilder
public TextBuilder(CharSequence csq)(Code)
Creates a text builder holding the specified character sequence.
Parameters:
  csq - the initial character sequence of this text builder.



TextBuilder
public TextBuilder(String str)(Code)
Creates a text builder holding the specified String.
Parameters:
  str - the initial string content of this text builder.



TextBuilder
public TextBuilder(int capacity)(Code)
Creates a text builder of specified initial capacity. Unless the text length exceeds the specified capacity, operations on this text builder will not allocate memory.
Parameters:
  capacity - the initial capacity.




Method Detail
append
final public Appendable append(char c)(Code)
Appends the specified character.
Parameters:
  c - the character to append. this



append
final public TextBuilder append(Object obj)(Code)
Appends the textual representation of the specified object. If the specified object is null this method is equivalent to append("null").
Parameters:
  obj - the object to represent or null. this



append
final public Appendable append(CharSequence csq)(Code)
Appends the specified character sequence. If the specified character sequence is null this method is equivalent to append("null").
Parameters:
  csq - the character sequence to append or null. this



append
final public Appendable append(CharSequence csq, int start, int end)(Code)
Appends a subsequence of the specified character sequence. If the specified character sequence is null this method is equivalent to append("null").
Parameters:
  csq - the character sequence to append or null.
Parameters:
  start - the index of the first character to append.
Parameters:
  end - the index after the last character to append. this
throws:
  IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > csq.length())



append
final public TextBuilder append(String str)(Code)
Appends the specified string to this text builder. If the specified string is null this method is equivalent to append("null").
Parameters:
  str - the string to append or null. this



append
final public TextBuilder append(String str, int start, int end)(Code)
Appends a subsequence of the specified string. If the specified character sequence is null this method is equivalent to append("null").
Parameters:
  str - the string to append or null.
Parameters:
  start - the index of the first character to append.
Parameters:
  end - the index after the last character to append. this
throws:
  IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > str.length())



append
final public TextBuilder append(Text txt)(Code)
Appends the specified text to this text builder. If the specified text is null this method is equivalent to append("null").
Parameters:
  txt - the text to append or null. this



append
final public TextBuilder append(Text txt, int start, int end)(Code)
Appends a subsequence of the specified text. If the specified character sequence is null this method is equivalent to append("null").
Parameters:
  txt - the text to append or null.
Parameters:
  start - the index of the first character to append.
Parameters:
  end - the index after the last character to append. this
throws:
  IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > txt.length())



append
final public TextBuilder append(char chars)(Code)
Appends the characters from the char array argument.
Parameters:
  chars - the character array source. this



append
final public TextBuilder append(char chars, int offset, int length)(Code)
Appends the characters from a subarray of the char array argument.
Parameters:
  chars - the character array source.
Parameters:
  offset - the index of the first character to append.
Parameters:
  length - the number of character to append. this
throws:
  IndexOutOfBoundsException - if (offset < 0) || (length < 0) || ((offset + length) > chars.length)



append
final public TextBuilder append(boolean b)(Code)
Appends the textual representation of the specified boolean argument.
Parameters:
  b - the boolean to format. this
See Also:   TypeFormat



append
final public TextBuilder append(int i)(Code)
Appends the decimal representation of the specified int argument.
Parameters:
  i - the int to format. this



append
final public TextBuilder append(int i, int radix)(Code)
Appends the radix representation of the specified int argument.
Parameters:
  i - the int to format.
Parameters:
  radix - the radix (e.g. 16 for hexadecimal). this



append
final public TextBuilder append(long l)(Code)
Appends the decimal representation of the specified long argument.
Parameters:
  l - the long to format. this



append
final public TextBuilder append(long l, int radix)(Code)
Appends the radix representation of the specified long argument.
Parameters:
  l - the long to format.
Parameters:
  radix - the radix (e.g. 16 for hexadecimal). this



appendFraction
final void appendFraction(long l, int digits, boolean showZero)(Code)
Appends the textual representation of the specified double according to the specified formatting arguments.
Parameters:
  d - the double value.
Parameters:
  digits - the number of significative digits (excludes exponent) or-1 to mimic the standard library (16 or 17 digits).
Parameters:
  scientific - true to forces the use of the scientific notation (e.g. 1.23E3); false otherwise.
Parameters:
  showZero - true if trailing fractional zeros are represented; false otherwise. this
throws:
  IllegalArgumentException - if (digits > 19))public final TextBuilder append(double d, int digits,boolean scientific, boolean showZero) {if (digits > 19)throw new IllegalArgumentException("digits: " + digits);if (d != d) // NaNreturn append("NaN");if (d < 0) { // Work with positive number.d = -d;append('-');}if (d == Double.POSITIVE_INFINITY) // Infinity.return append("Infinity");if (d == 0.0) { // Zero.if (digits == 1)return append("0.");if (!showZero)return append("0.0");append("0.0");for (int i = 2; i < digits; i++) {append('0');}return this;}// Find the exponent e such as: value == x.xxx * 10^eint e = MathLib.floorLog10(d);long m;if (digits < 0) { // Use 16 or 17 digits.// Try 17 digits.long m17 = MathLib.toLongPow10(d, (17 - 1) - e);// Check if we can use 16 digits.long m16 = m17 / 10;double dd = MathLib.toDoublePow10(m16, e - 16 + 1);if (dd == d) { // 16 digits is enough.digits = 16;m = m16;} else { // We cannot remove the last digit.digits = 17;m = m17;}} else { // Use the specified number of digits.m = MathLib.toLongPow10(d, (digits - 1) - e);}// Formats.if (scientific || (e >= digits)) {// Scientific notation has to be used ("x.xxxEyy").long pow10 = POW10_LONG[digits - 1];int i = (int) (m / pow10); // Single digit.append(DIGIT_TO_CHAR[i]);m = m - pow10 * i;appendFraction(m, digits - 1, showZero);append('E');append(e);} else { // Dot within the string ("xxxx.xxxxx").if (e < 0) {append('0');} else {long pow10 = POW10_LONG[digits - e - 1];long l = m / pow10;append(l);m = m - pow10 * l;}appendFraction(m, digits - e - 1, showZero);}return this;}private static final long[] POW10_LONG = new long[] { 1L, 10L, 100L, 1000L,10000L, 100000L, 1000000L, 10000000L, 100000000L, 1000000000L,10000000000L, 100000000000L, 1000000000000L, 10000000000000L,100000000000000L, 1000000000000000L, 10000000000000000L,100000000000000000L, 1000000000000000000L };/*



appendTo
final void appendTo(StringBuffer sb)(Code)
Appends the content of this text builder to the specified string buffer (only for text builder with length less than 32).
Parameters:
  sb - the string buffer.



charAt
final public char charAt(int i)(Code)
Returns the character at the specified index.
Parameters:
  i - the index of the character. the character at the specified index.
throws:
  IndexOutOfBoundsException - if (i < 0) || (i >= this.length()).



charsAt
final char[] charsAt(int i)(Code)



clear
final public TextBuilder clear()(Code)
Removes all the characters of this text builder (equivalent to this.delete(start, this.length())). this.delete(0, this.length())



contentEquals
final public boolean contentEquals(CharSequence csq)(Code)
Indicates if this text builder has the same character content as the specified character sequence.
Parameters:
  csq - the character sequence to compare with. true if the specified character sequence has the same character content as this text; false otherwise.



contentEquals
final public boolean contentEquals(String csq)(Code)
Equivalent to TextBuilder.contentEquals(CharSequence) (for J2ME compability).
Parameters:
  csq - the string character sequence to compare with. true if the specified string has the same character content as this text; false otherwise.



delete
final public TextBuilder delete(int start, int end)(Code)
Removes the characters between the specified indices.
Parameters:
  start - the beginning index, inclusive.
Parameters:
  end - the ending index, exclusive. this
throws:
  IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > this.length())



equals
final public boolean equals(Object obj)(Code)
Compares this text builder against the specified object for equality. Returns true if the specified object is a text builder having the same character content.
Parameters:
  obj - the object to compare with or null. true if that is a text builder with the same character content as this text; false otherwise.



getChars
final public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)(Code)
Copies the character from this text builder into the destination character array.
Parameters:
  srcBegin - this text start index.
Parameters:
  srcEnd - this text end index (not included).
Parameters:
  dst - the destination array to copy the data into.
Parameters:
  dstBegin - the offset into the destination array.
throws:
  IndexOutOfBoundsException - if (srcBegin < 0) ||(dstBegin < 0) || (srcBegin > srcEnd) || (srcEnd > this.length())|| ((dstBegin + srcEnd - srcBegin) > dst.length)



hashCode
final public int hashCode()(Code)
Returns the hash code for this text builder. the hash code value.



insert
final public TextBuilder insert(int index, CharSequence csq)(Code)
Inserts the specified character sequence at the specified location.
Parameters:
  index - the insertion position.
Parameters:
  csq - the character sequence being inserted. this
throws:
  IndexOutOfBoundsException - if (index < 0) || (index > this.length())



length
final public int length()(Code)
Returns the length (character count) of this text builder. the number of characters (16-bits Unicode).



newInstance
public static TextBuilder newInstance()(Code)
Returns a new, preallocated or TextBuilder.recycle recycled text builder (on the stack when executing in a javolution.context.StackContextStackContext ). a new, preallocated or recycled text builder instance.



print
public void print()(Code)
Prints out this text builder to System.out (UTF-8 encoding). This method is equivalent to:[code] synchronized(OUT) { print(OUT); OUT.flush(); } ... static final OUT = new UTF8StreamWriter().setOutput(System.out); [/code]



print
public void print(Writer writer) throws IOException(Code)
Prints out this text builder to the specified writer.
Parameters:
  writer - the destination writer.



println
public void println()(Code)
Prints out this text builder to System.out and then terminates the line. This method is equivalent to:[code] synchronized(OUT) { println(OUT); OUT.flush(); } ... static final OUT = new UTF8StreamWriter().setOutput(System.out); [/code]



println
public void println(Writer writer) throws IOException(Code)
Prints out this text builder to the specified writer and then terminates the line.
Parameters:
  writer - the destination writer.



recycle
public static void recycle(TextBuilder instance)(Code)
Recycles a text builder TextBuilder.newInstance() instance immediately (on the stack when executing in a javolution.context.StackContextStackContext ).



reset
final public void reset()(Code)
Resets this text builder for reuse (equivalent to TextBuilder.clear ).



reverse
final public TextBuilder reverse()(Code)
Reverses this character sequence. this



setCharAt
final public void setCharAt(int index, char c)(Code)
Sets the character at the specified position.
Parameters:
  index - the index of the character to modify.
Parameters:
  c - the new character.
throws:
  IndexOutOfBoundsException - if (index < 0) || (index >= this.length())



setLength
final public void setLength(int newLength)(Code)
Sets the length of this character builder. If the length is greater than the current length; the null character '\u0000' is inserted.
Parameters:
  newLength - the new length of this builder.
throws:
  IndexOutOfBoundsException - if (newLength < 0)



subSequence
final public CharSequence subSequence(int start, int end)(Code)
Returns an instance of Text (immutable) corresponding to the character sequence between the specified indexes.
Parameters:
  start - the index of the first character inclusive.
Parameters:
  end - the index of the last character exclusive. an immutable character sequence.
throws:
  IndexOutOfBoundsException - if (start < 0) || (end < 0) ||(start > end) || (end > this.length())



toString
final public String toString()(Code)
Returns the String representation of this TextBuilder . the java.lang.String for this text builder.



toText
final public Text toText()(Code)
Returns the Text corresponding to this TextBuilder (allocated on the "stack" when executing in a javolution.context.StackContext StackContext ). the corresponding Text instance.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.