60
60
* @author Paulo Soares
61
61
*/
62
62
63
- public class ByteBuffer extends OutputStream {
63
+ public class ByteBufferOutputStream extends OutputStream {
64
64
/** The count of bytes in the buffer. */
65
65
protected int count ;
66
66
@@ -80,16 +80,16 @@ public class ByteBuffer extends OutputStream {
80
80
public static boolean HIGH_PRECISION = false ;
81
81
private static final DecimalFormatSymbols dfs = new DecimalFormatSymbols (Locale .US );
82
82
83
- /** Creates new ByteBuffer with capacity 128 */
84
- public ByteBuffer () {
83
+ /** Creates new ByteBufferOutputStream with capacity 128 */
84
+ public ByteBufferOutputStream () {
85
85
this (128 );
86
86
}
87
87
88
88
/**
89
89
* Creates a byte buffer with a certain capacity.
90
90
* @param size the initial capacity
91
91
*/
92
- public ByteBuffer (int size ) {
92
+ public ByteBufferOutputStream (int size ) {
93
93
if (size < 1 )
94
94
size = 128 ;
95
95
buf = new byte [size ];
@@ -181,9 +181,9 @@ private static byte[] convertToBytes(int i) {
181
181
/**
182
182
* Appends an <CODE>int</CODE>. The size of the array will grow by one.
183
183
* @param b the int to be appended
184
- * @return a reference to this <CODE>ByteBuffer </CODE> object
184
+ * @return a reference to this <CODE>ByteBufferOutputStream </CODE> object
185
185
*/
186
- public ByteBuffer append_i (int b ) {
186
+ public ByteBufferOutputStream append_i (int b ) {
187
187
int newcount = count + 1 ;
188
188
if (newcount > buf .length ) {
189
189
byte [] newbuf = new byte [Math .max (buf .length << 1 , newcount )];
@@ -201,9 +201,9 @@ public ByteBuffer append_i(int b) {
201
201
* @param b the array to be appended
202
202
* @param off the offset to the start of the array
203
203
* @param len the length of bytes to append
204
- * @return a reference to this <CODE>ByteBuffer </CODE> object
204
+ * @return a reference to this <CODE>ByteBufferOutputStream </CODE> object
205
205
*/
206
- public ByteBuffer append (byte [] b , int off , int len ) {
206
+ public ByteBufferOutputStream append (byte [] b , int off , int len ) {
207
207
if ((off < 0 ) || (off > b .length ) || (len < 0 ) ||
208
208
((off + len ) > b .length ) || ((off + len ) < 0 ) || len == 0 )
209
209
return this ;
@@ -221,19 +221,19 @@ public ByteBuffer append(byte[] b, int off, int len) {
221
221
/**
222
222
* Appends an array of bytes.
223
223
* @param b the array to be appended
224
- * @return a reference to this <CODE>ByteBuffer </CODE> object
224
+ * @return a reference to this <CODE>ByteBufferOutputStream </CODE> object
225
225
*/
226
- public ByteBuffer append (byte [] b ) {
226
+ public ByteBufferOutputStream append (byte [] b ) {
227
227
return append (b , 0 , b .length );
228
228
}
229
229
230
230
/**
231
231
* Appends a <CODE>String</CODE> to the buffer. The <CODE>String</CODE> is
232
232
* converted according to the encoding ISO-8859-1.
233
233
* @param str the <CODE>String</CODE> to be appended
234
- * @return a reference to this <CODE>ByteBuffer </CODE> object
234
+ * @return a reference to this <CODE>ByteBufferOutputStream </CODE> object
235
235
*/
236
- public ByteBuffer append (String str ) {
236
+ public ByteBufferOutputStream append (String str ) {
237
237
if (str != null )
238
238
return append (str .getBytes ());
239
239
return this ;
@@ -243,44 +243,44 @@ public ByteBuffer append(String str) {
243
243
* Appends a <CODE>char</CODE> to the buffer. The <CODE>char</CODE> is
244
244
* converted according to the encoding ISO-8859-1.
245
245
* @param c the <CODE>char</CODE> to be appended
246
- * @return a reference to this <CODE>ByteBuffer </CODE> object
246
+ * @return a reference to this <CODE>ByteBufferOutputStream </CODE> object
247
247
*/
248
- public ByteBuffer append (char c ) {
248
+ public ByteBufferOutputStream append (char c ) {
249
249
return append_i (c );
250
250
}
251
251
252
252
/**
253
- * Appends another <CODE>ByteBuffer </CODE> to this buffer.
254
- * @param buf the <CODE>ByteBuffer </CODE> to be appended
255
- * @return a reference to this <CODE>ByteBuffer </CODE> object
253
+ * Appends another <CODE>ByteBufferOutputStream </CODE> to this buffer.
254
+ * @param buf the <CODE>ByteBufferOutputStream </CODE> to be appended
255
+ * @return a reference to this <CODE>ByteBufferOutputStream </CODE> object
256
256
*/
257
- public ByteBuffer append (ByteBuffer buf ) {
257
+ public ByteBufferOutputStream append (ByteBufferOutputStream buf ) {
258
258
return append (buf .buf , 0 , buf .count );
259
259
}
260
260
261
261
/**
262
262
* Appends the string representation of an <CODE>int</CODE>.
263
263
* @param i the <CODE>int</CODE> to be appended
264
- * @return a reference to this <CODE>ByteBuffer </CODE> object
264
+ * @return a reference to this <CODE>ByteBufferOutputStream </CODE> object
265
265
*/
266
- public ByteBuffer append (int i ) {
266
+ public ByteBufferOutputStream append (int i ) {
267
267
return append ((double )i );
268
268
}
269
269
270
270
/**
271
271
* Appends the string representation of a <CODE>long</CODE>.
272
272
* @param i the <CODE>long</CODE> to be appended
273
- * @return a reference to this <CODE>ByteBuffer </CODE> object
273
+ * @return a reference to this <CODE>ByteBufferOutputStream </CODE> object
274
274
*/
275
- public ByteBuffer append (long i ) {
275
+ public ByteBufferOutputStream append (long i ) {
276
276
return append (Long .toString (i ));
277
277
}
278
278
279
- public ByteBuffer append (byte b ) {
279
+ public ByteBufferOutputStream append (byte b ) {
280
280
return append_i (b );
281
281
}
282
282
283
- public ByteBuffer appendHex (byte b ) {
283
+ public ByteBufferOutputStream appendHex (byte b ) {
284
284
append (bytes [(b >> 4 ) & 0x0f ]);
285
285
return append (bytes [b & 0x0f ]);
286
286
}
@@ -289,19 +289,19 @@ public ByteBuffer appendHex(byte b) {
289
289
* Appends a string representation of a <CODE>float</CODE> according
290
290
* to the Pdf conventions.
291
291
* @param i the <CODE>float</CODE> to be appended
292
- * @return a reference to this <CODE>ByteBuffer </CODE> object
292
+ * @return a reference to this <CODE>ByteBufferOutputStream </CODE> object
293
293
*/
294
- public ByteBuffer append (float i ) {
294
+ public ByteBufferOutputStream append (float i ) {
295
295
return append ((double )i );
296
296
}
297
297
298
298
/**
299
299
* Appends a string representation of a <CODE>double</CODE> according
300
300
* to the Pdf conventions.
301
301
* @param d the <CODE>double</CODE> to be appended
302
- * @return a reference to this <CODE>ByteBuffer </CODE> object
302
+ * @return a reference to this <CODE>ByteBufferOutputStream </CODE> object
303
303
*/
304
- public ByteBuffer append (double d ) {
304
+ public ByteBufferOutputStream append (double d ) {
305
305
append (formatDouble (d , this ));
306
306
return this ;
307
307
}
@@ -318,12 +318,12 @@ public static String formatDouble(double d) {
318
318
/**
319
319
* Outputs a <CODE>double</CODE> into a format suitable for the PDF.
320
320
* @param d a double
321
- * @param buf a ByteBuffer
321
+ * @param buf a ByteBufferOutputStream
322
322
* @return the <CODE>String</CODE> representation of the <CODE>double</CODE> if
323
323
* <CODE>buf</CODE> is <CODE>null</CODE>. If <CODE>buf</CODE> is <B>not</B> <CODE>null</CODE>,
324
324
* then the double is appended directly to the buffer and this methods returns <CODE>null</CODE>.
325
325
*/
326
- public static String formatDouble (double d , ByteBuffer buf ) {
326
+ public static String formatDouble (double d , ByteBufferOutputStream buf ) {
327
327
if (HIGH_PRECISION ) {
328
328
DecimalFormat dn = new DecimalFormat ("0.######" , dfs );
329
329
String sform = dn .format (d );
0 commit comments