2727 * @author Ortwin Gl�ck
2828 */
2929public class CharBuffer {
30+
3031 private char [] c ;
32+
3133 /**
3234 * Actually used number of characters in the array.
3335 * It is also the index at which
@@ -47,7 +49,9 @@ public CharBuffer() {
4749 * of <code>length</code> characters.
4850 */
4951 public CharBuffer (final int length ) {
50- if (length == 0 ) throw new IllegalArgumentException ("Can't create an empty CharBuffer" );
52+ if (length == 0 ) {
53+ throw new IllegalArgumentException ("Can't create an empty CharBuffer" );
54+ }
5155 this .c = new char [length ];
5256 }
5357
@@ -81,7 +85,9 @@ public int capacity() {
8185 * @param cb the CharBuffer to append or null
8286 */
8387 public void append (final CharBuffer cb ) {
84- if (cb == null ) return ;
88+ if (cb == null ) {
89+ return ;
90+ }
8591 provideCapacity (length + cb .length );
8692 System .arraycopy (cb .c , 0 , c , length , cb .length );
8793 length += cb .length ;
@@ -93,7 +99,9 @@ public void append(final CharBuffer cb) {
9399 * @param s the String to append or null
94100 */
95101 public void append (final String s ) {
96- if (s == null ) return ;
102+ if (s == null ) {
103+ return ;
104+ }
97105 append (s .toCharArray ());
98106 }
99107
@@ -103,7 +111,9 @@ public void append(final String s) {
103111 * @param sb the StringBuffer to append or null
104112 */
105113 public void append (final StringBuffer sb ) {
106- if (sb == null ) return ;
114+ if (sb == null ) {
115+ return ;
116+ }
107117 provideCapacity (length + sb .length ());
108118 sb .getChars (0 , sb .length (), c , length );
109119 length += sb .length ();
@@ -115,7 +125,9 @@ public void append(final StringBuffer sb) {
115125 * @param data the char[] to append or null
116126 */
117127 public void append (final char [] data ) {
118- if (data == null ) return ;
128+ if (data == null ) {
129+ return ;
130+ }
119131 provideCapacity (length + data .length );
120132 System .arraycopy (data , 0 , c , length , data .length );
121133 length += data .length ;
@@ -137,7 +149,9 @@ public void append(final char data) {
137149 * This method involves copying the data once!
138150 */
139151 public void shrink () {
140- if (c .length == length ) return ;
152+ if (c .length == length ) {
153+ return ;
154+ }
141155 char [] newc = new char [length ];
142156 System .arraycopy (c , 0 , newc , 0 , length );
143157 c = newc ;
@@ -161,7 +175,9 @@ public void trimTrailingWhitespace() {
161175 * @return
162176 */
163177 public char [] getCharacters () {
164- if (c .length == length ) return c ;
178+ if (c .length == length ) {
179+ return c ;
180+ }
165181 char [] chars = new char [length ];
166182 System .arraycopy (c , 0 , chars , 0 , length );
167183 return chars ;
@@ -199,7 +215,9 @@ public String toString() {
199215 * @param capacity
200216 */
201217 public void provideCapacity (final int capacity ) {
202- if (c .length >= capacity ) return ;
218+ if (c .length >= capacity ) {
219+ return ;
220+ }
203221 int newcapacity = ((capacity *3 )>>1 ) + 1 ;
204222 char [] newc = new char [newcapacity ];
205223 System .arraycopy (c , 0 , newc , 0 , length );
0 commit comments