Java Doc for SStringBuilder.java in  » Swing-Library » wings3 » org » wings » util » 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 » Swing Library » wings3 » org.wings.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.wings.util.SStringBuilder

SStringBuilder
final public class SStringBuilder implements java.io.Serializable,CharSequence(Code)
A mutable sequence of characters. This class provides an API compatible with StringBuffer, but with no guarantee of synchronization. This class is designed for use as a drop-in replacement for StringBuffer in places where the string buffer was being used by a single thread (as is generally the case). Where possible, it is recommended that this class be used in preference to StringBuffer as it will be faster under most implementations.

The principal operations on a StringBuilder are the append and insert methods, which are overloaded so as to accept data of any type. Each effectively converts a given datum to a string and then appends or inserts the characters of that string to the string builder. The append method always adds these characters at the end of the builder; the insert method adds the characters at a specified point.

For example, if z refers to a string builder object whose current contents are "start", then the method call z.append("le") would cause the string builder to contain "startle", whereas z.insert(4, "le") would alter the string builder to contain "starlet".

In general, if sb refers to an instance of a StringBuilder, then sb.append(x) has the same effect as sb.insert(sb.length(), x). Every string builder has a capacity. As long as the length of the character sequence contained in the string builder does not exceed the capacity, it is not necessary to allocate a new internal buffer. If the internal buffer overflows, it is automatically made larger.

Instances of StringBuilder are not safe for use by multiple threads. If such synchronization is required then it is recommended that java.lang.StringBuffer be used.
author:
   Michael McCloskey
version:
   1.9, 07/16/04
See Also:   java.lang.StringBuffer
See Also:   java.lang.String
since:
   1.5



Field Summary
 intcount
     The count is the number of characters used.
final static  longserialVersionUID
    
final static  int[]sizeTable
    
 charvalue
     The value is used for character storage.

Constructor Summary
public  SStringBuilder()
     Constructs a string builder with no characters in it and an initial capacity of 16 characters.
public  SStringBuilder(int capacity)
     Constructs a string builder with no characters in it and an initial capacity specified by the capacity argument.
public  SStringBuilder(String str)
     Constructs a string builder initialized to the contents of the specified string.
public  SStringBuilder(CharSequence seq)
     Constructs a string builder that contains the same characters as the specified CharSequence.

Method Summary
public  SStringBuilderappend(Object obj)
     Appends the string representation of the Object argument.

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence.
Parameters:
  obj - an Object.

public  SStringBuilderappend(String str)
     Appends the specified string to this character sequence.

The characters of the String argument are appended, in order, increasing the length of this sequence by the length of the argument.

public  SStringBuilderappend(StringBuffer sb)
    
public  SStringBuilderappend(CharSequence s, int start, int end)
     Appends a subsequence of the specified CharSequence to this sequence.

Characters of the argument s, starting at index start, are appended, in order, to the contents of this sequence up to the (exclusive) index end.

public  SStringBuilderappend(char str)
     Appends the string representation of the char array argument to this sequence.
public  SStringBuilderappend(char str, int offset, int len)
     Appends the string representation of a subarray of the char array argument to this sequence.

Characters of the char array str, starting at index offset, are appended, in order, to the contents of this sequence.

public  SStringBuilderappend(boolean b)
     Appends the string representation of the boolean argument to the sequence.

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence.

public  SStringBuilderappend(char c)
     Appends the string representation of the char argument to this sequence.
public  SStringBuilderappend(int i)
     Appends the string representation of the int argument to this sequence.
public  SStringBuilderappend(long l)
     Appends the string representation of the long argument to this sequence.

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence.
Parameters:
  l - a long.

public  SStringBuilderappend(float f)
     Appends the string representation of the float argument to this sequence.

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this string sequence.
Parameters:
  f - a float.

public  SStringBuilderappend(double d)
     Appends the string representation of the double argument to this sequence.

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence.
Parameters:
  d - a double.

public  SStringBuilderappend(CharSequence s)
    
public  intcapacity()
     Returns the current capacity.
public  charcharAt(int index)
     Returns the char value in this sequence at the specified index. The first char value is at index 0, the next at index 1, and so on, as in array indexing.

The index argument must be greater than or equal to 0, and less than the length of this sequence.

If the char value specified by the index is a surrogate, the surrogate value is returned.
Parameters:
  index - the index of the desired char value.

public  SStringBuilderdelete(int start, int end)
     Removes the characters in a substring of this sequence. The substring begins at the specified start and extends to the character at index end - 1 or to the end of the sequence if no such character exists.
public  SStringBuilderdeleteCharAt(int index)
     Removes the char at the specified position in this sequence.
public  voidensureCapacity(int minimumCapacity)
     Ensures that the capacity is at least equal to the specified minimum. If the current capacity is less than the argument, then a new internal array is allocated with greater capacity.
 voidexpandCapacity(int minimumCapacity)
     This implements the expansion semantics of ensureCapacity with no size check or synchronization.
public  voidgetChars(int srcBegin, int srcEnd, char dst, int dstBegin)
     Characters are copied from this sequence into the destination character array dst.
final  char[]getValue()
     Needed by String for the contentEquals method.
public  SStringBuilderinsert(int offset, String str)
     Inserts the string into this character sequence.

The characters of the String argument are inserted, in order, into this sequence at the indicated offset, moving up any characters originally above that position and increasing the length of this sequence by the length of the argument.

public  intlength()
     Returns the length (character count).
public  voidsetCharAt(int index, char ch)
     The character at the specified index is set to ch.
public  voidsetLength(int newLength)
     Sets the length of the character sequence. The sequence is changed to a new character sequence whose length is specified by the argument.
static  intstringSizeOfInt(int x)
    
static  intstringSizeOfLong(long x)
    
public  CharSequencesubSequence(int start, int end)
     Returns a new character sequence that is a subsequence of this sequence.

An invocation of this method of the form

 sb.subSequence(begin, end)
behaves in exactly the same way as the invocation
 sb.substring(begin, end)
This method is provided so that this class can implement the CharSequence interface.
public  Stringsubstring(int start)
     Returns a new String that contains a subsequence of characters currently contained in this character sequence.
public  Stringsubstring(int start, int end)
     Returns a new String that contains a subsequence of characters currently contained in this sequence.
public  StringtoString()
    
public  voidtrimToSize()
     Attempts to reduce storage used for the character sequence. If the buffer is larger than necessary to hold its current sequence of characters, then it may be resized to become more space efficient.

Field Detail
count
int count(Code)
The count is the number of characters used.



serialVersionUID
final static long serialVersionUID(Code)
use serialVersionUID for interoperability



sizeTable
final static int[] sizeTable(Code)



value
char value(Code)
The value is used for character storage.




Constructor Detail
SStringBuilder
public SStringBuilder()(Code)
Constructs a string builder with no characters in it and an initial capacity of 16 characters.



SStringBuilder
public SStringBuilder(int capacity)(Code)
Constructs a string builder with no characters in it and an initial capacity specified by the capacity argument.
Parameters:
  capacity - the initial capacity.
throws:
  NegativeArraySizeException - if the capacityargument is less than 0.



SStringBuilder
public SStringBuilder(String str)(Code)
Constructs a string builder initialized to the contents of the specified string. The initial capacity of the string builder is 16 plus the length of the string argument.
Parameters:
  str - the initial contents of the buffer.
throws:
  NullPointerException - if str is null



SStringBuilder
public SStringBuilder(CharSequence seq)(Code)
Constructs a string builder that contains the same characters as the specified CharSequence. The initial capacity of the string builder is 16 plus the length of the CharSequence argument.
Parameters:
  seq - the sequence to copy.
throws:
  NullPointerException - if seq is null




Method Detail
append
public SStringBuilder append(Object obj)(Code)
Appends the string representation of the Object argument.

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence.
Parameters:
  obj - an Object. a reference to this object.




append
public SStringBuilder append(String str)(Code)
Appends the specified string to this character sequence.

The characters of the String argument are appended, in order, increasing the length of this sequence by the length of the argument. If str is null, then the four characters "null" are appended.

Let n be the length of this character sequence just prior to execution of the append method. Then the character at index k in the new character sequence is equal to the character at index k in the old character sequence, if k is less than n; otherwise, it is equal to the character at index k-n in the argument str.
Parameters:
  str - a string. a reference to this object.




append
public SStringBuilder append(StringBuffer sb)(Code)



append
public SStringBuilder append(CharSequence s, int start, int end)(Code)
Appends a subsequence of the specified CharSequence to this sequence.

Characters of the argument s, starting at index start, are appended, in order, to the contents of this sequence up to the (exclusive) index end. The length of this sequence is increased by the value of end - start.

Let n be the length of this character sequence just prior to execution of the append method. Then the character at index k in this character sequence becomes equal to the character at index k in this sequence, if k is less than n; otherwise, it is equal to the character at index k+start-n in the argument s.

If s is null, then this method appends characters as if the s parameter was a sequence containing the four characters "null".
Parameters:
  s - the sequence to append.
Parameters:
  start - the starting index of the subsequence to be appended.
Parameters:
  end - the end index of the subsequence to be appended. a reference to this object.
throws:
  IndexOutOfBoundsException - ifstart or end are negative, orstart is greater than end orend is greater than s.length()




append
public SStringBuilder append(char str)(Code)
Appends the string representation of the char array argument to this sequence.

The characters of the array argument are appended, in order, to the contents of this sequence. The length of this sequence increases by the length of the argument.

The overall effect is exactly as if the argument were converted to a string by the method String.valueOf(char[]) and the characters of that string were then SStringBuilder.append(String) appended to this character sequence.
Parameters:
  str - the characters to be appended. a reference to this object.




append
public SStringBuilder append(char str, int offset, int len)(Code)
Appends the string representation of a subarray of the char array argument to this sequence.

Characters of the char array str, starting at index offset, are appended, in order, to the contents of this sequence. The length of this sequence increases by the value of len.

The overall effect is exactly as if the arguments were converted to a string by the method String.valueOf(char[]intint) and the characters of that string were then SStringBuilder.append(String) appended to this character sequence.
Parameters:
  str - the characters to be appended.
Parameters:
  offset - the index of the first char to append.
Parameters:
  len - the number of chars to append. a reference to this object.




append
public SStringBuilder append(boolean b)(Code)
Appends the string representation of the boolean argument to the sequence.

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence.
Parameters:
  b - a boolean. a reference to this object.




append
public SStringBuilder append(char c)(Code)
Appends the string representation of the char argument to this sequence.

The argument is appended to the contents of this sequence. The length of this sequence increases by 1.

The overall effect is exactly as if the argument were converted to a string by the method String.valueOf(char) and the character in that string were then SStringBuilder.append(String) appended to this character sequence.
Parameters:
  c - a char. a reference to this object.




append
public SStringBuilder append(int i)(Code)
Appends the string representation of the int argument to this sequence.

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence.
Parameters:
  i - an int. a reference to this object.




append
public SStringBuilder append(long l)(Code)
Appends the string representation of the long argument to this sequence.

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence.
Parameters:
  l - a long. a reference to this object.




append
public SStringBuilder append(float f)(Code)
Appends the string representation of the float argument to this sequence.

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this string sequence.
Parameters:
  f - a float. a reference to this object.




append
public SStringBuilder append(double d)(Code)
Appends the string representation of the double argument to this sequence.

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence.
Parameters:
  d - a double. a reference to this object.




append
public SStringBuilder append(CharSequence s)(Code)

throws:
  IndexOutOfBoundsException -



capacity
public int capacity()(Code)
Returns the current capacity. The capacity is the amount of storage available for newly inserted characters, beyond which an allocation will occur. the current capacity



charAt
public char charAt(int index)(Code)
Returns the char value in this sequence at the specified index. The first char value is at index 0, the next at index 1, and so on, as in array indexing.

The index argument must be greater than or equal to 0, and less than the length of this sequence.

If the char value specified by the index is a surrogate, the surrogate value is returned.
Parameters:
  index - the index of the desired char value. the char value at the specified index.
throws:
  IndexOutOfBoundsException - if index is negative or greater than or equal to length().




delete
public SStringBuilder delete(int start, int end)(Code)
Removes the characters in a substring of this sequence. The substring begins at the specified start and extends to the character at index end - 1 or to the end of the sequence if no such character exists. If start is equal to end, no changes are made.
Parameters:
  start - The beginning index, inclusive.
Parameters:
  end - The ending index, exclusive. This object.
throws:
  StringIndexOutOfBoundsException - if startis negative, greater than length(), orgreater than end.



deleteCharAt
public SStringBuilder deleteCharAt(int index)(Code)
Removes the char at the specified position in this sequence. This sequence is shortened by one char.

Note: If the character at the given index is a supplementary character, this method does not remove the entire character. If correct handling of supplementary characters is required, determine the number of chars to remove by calling Character.charCount(thisSequence.codePointAt(index)), where thisSequence is this sequence.
Parameters:
  index - Index of char to remove This object.
throws:
  StringIndexOutOfBoundsException - if the indexis negative or greater than or equal tolength().




ensureCapacity
public void ensureCapacity(int minimumCapacity)(Code)
Ensures that the capacity is at least equal to the specified minimum. If the current capacity is less than the argument, then a new internal array is allocated with greater capacity. The new capacity is the larger of:
  • The minimumCapacity argument.
  • Twice the old capacity, plus 2.
If the minimumCapacity argument is nonpositive, this method takes no action and simply returns.
Parameters:
  minimumCapacity - the minimum desired capacity.



expandCapacity
void expandCapacity(int minimumCapacity)(Code)
This implements the expansion semantics of ensureCapacity with no size check or synchronization.



getChars
public void getChars(int srcBegin, int srcEnd, char dst, int dstBegin)(Code)
Characters are copied from this sequence into the destination character array dst. The first character to be copied is at index srcBegin; the last character to be copied is at index srcEnd-1. The total number of characters to be copied is srcEnd-srcBegin. The characters are copied into the subarray of dst starting at index dstBegin and ending at index:

 dstbegin + (srcEnd-srcBegin) - 1
 

Parameters:
  srcBegin - start copying at this offset.
Parameters:
  srcEnd - stop copying at this offset.
Parameters:
  dst - the array to copy the data into.
Parameters:
  dstBegin - offset into dst.
throws:
  NullPointerException - if dst is null.
throws:
  IndexOutOfBoundsException - if any of the following is true:
  • srcBegin is negative
  • dstBegin is negative
  • the srcBegin argument is greater than the srcEnd argument.
  • srcEnd is greater than this.length().
  • dstBegin+srcEnd-srcBegin is greater than dst.length



getValue
final char[] getValue()(Code)
Needed by String for the contentEquals method.



insert
public SStringBuilder insert(int offset, String str)(Code)
Inserts the string into this character sequence.

The characters of the String argument are inserted, in order, into this sequence at the indicated offset, moving up any characters originally above that position and increasing the length of this sequence by the length of the argument. If str is null, then the four characters "null" are inserted into this sequence.

The character at index k in the new character sequence is equal to:

  • the character at index k in the old character sequence, if k is less than offset
  • the character at index k-offset in the argument str, if k is not less than offset but is less than offset+str.length()
  • the character at index k-str.length() in the old character sequence, if k is not less than offset+str.length()

The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.
Parameters:
  offset - the offset.
Parameters:
  str - a string. a reference to this object.
throws:
  StringIndexOutOfBoundsException - if the offset is invalid.




length
public int length()(Code)
Returns the length (character count). the length of the sequence of characters currently represented by this object



setCharAt
public void setCharAt(int index, char ch)(Code)
The character at the specified index is set to ch. This sequence is altered to represent a new character sequence that is identical to the old character sequence, except that it contains the character ch at position index.

The index argument must be greater than or equal to 0, and less than the length of this sequence.
Parameters:
  index - the index of the character to modify.
Parameters:
  ch - the new character.
throws:
  IndexOutOfBoundsException - if index is negative or greater than or equal to length().




setLength
public void setLength(int newLength)(Code)
Sets the length of the character sequence. The sequence is changed to a new character sequence whose length is specified by the argument. For every nonnegative index k less than newLength, the character at index k in the new character sequence is the same as the character at index k in the old sequence if k is less than the length of the old character sequence; otherwise, it is the null character '\u0000'. In other words, if the newLength argument is less than the current length, the length is changed to the specified length.

If the newLength argument is greater than or equal to the current length, sufficient null characters ('\u0000') are appended so that length becomes the newLength argument.

The newLength argument must be greater than or equal to 0.
Parameters:
  newLength - the new length
throws:
  IndexOutOfBoundsException - if thenewLength argument is negative.




stringSizeOfInt
static int stringSizeOfInt(int x)(Code)



stringSizeOfLong
static int stringSizeOfLong(long x)(Code)



subSequence
public CharSequence subSequence(int start, int end)(Code)
Returns a new character sequence that is a subsequence of this sequence.

An invocation of this method of the form

 sb.subSequence(begin, end)
behaves in exactly the same way as the invocation
 sb.substring(begin, end)
This method is provided so that this class can implement the CharSequence interface.


Parameters:
  start - the start index, inclusive.
Parameters:
  end - the end index, exclusive. the specified subsequence.
throws:
  IndexOutOfBoundsException - if start or end are negative,if end is greater than length(),or if start is greater than end



substring
public String substring(int start)(Code)
Returns a new String that contains a subsequence of characters currently contained in this character sequence. The substring begins at the specified index and extends to the end of this sequence.
Parameters:
  start - The beginning index, inclusive. The new string.
throws:
  StringIndexOutOfBoundsException - if start isless than zero, or greater than the length of this object.



substring
public String substring(int start, int end)(Code)
Returns a new String that contains a subsequence of characters currently contained in this sequence. The substring begins at the specified start and extends to the character at index end - 1.
Parameters:
  start - The beginning index, inclusive.
Parameters:
  end - The ending index, exclusive. The new string.
throws:
  StringIndexOutOfBoundsException - if startor end are negative or greater thanlength(), or start isgreater than end.



toString
public String toString()(Code)



trimToSize
public void trimToSize()(Code)
Attempts to reduce storage used for the character sequence. If the buffer is larger than necessary to hold its current sequence of characters, then it may be resized to become more space efficient. Calling this method may, but is not required to, affect the value returned by a subsequent call to the SStringBuilder.capacity() method.



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.