|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
com.lowagie.text.pdf.ByteBuffer
public class ByteBuffer
Acts like a StringBuffer but works with byte arrays.
Floating point is converted to a format suitable to the PDF.
| Field Summary | |
|---|---|
protected byte[] |
buf
The buffer where the bytes are stored. |
private static byte[][] |
byteCache
|
private static int |
byteCacheSize
|
private static byte[] |
bytes
|
private static char[] |
chars
|
protected int |
count
The count of bytes in the buffer. |
static byte |
ZERO
|
| Constructor Summary | |
|---|---|
ByteBuffer()
Creates new ByteBuffer with capacity 128 |
|
ByteBuffer(int size)
Creates a byte buffer with a certain capacity. |
|
| Method Summary | |
|---|---|
ByteBuffer |
append_i(int b)
Appends an int. |
ByteBuffer |
append(byte b)
|
ByteBuffer |
append(byte[] b)
Appends an array of bytes. |
ByteBuffer |
append(byte[] b,
int off,
int len)
Appends the subarray of the byte array. |
ByteBuffer |
append(ByteBuffer buf)
Appends another ByteBuffer to this buffer. |
ByteBuffer |
append(char c)
Appends a char to the buffer. |
ByteBuffer |
append(double d)
Appends a string representation of a double according
to the Pdf conventions. |
ByteBuffer |
append(float i)
Appends a string representation of a float according
to the Pdf conventions. |
ByteBuffer |
append(int i)
Appends the string representation of an int. |
ByteBuffer |
append(java.lang.String str)
Appends a String to the buffer. |
ByteBuffer |
appendHex(byte b)
|
private static byte[] |
convertToBytes(int i)
Converts an double (multiplied by 100 and cast to an int) into an array of bytes. |
static void |
fillCache(int decimals)
You can fill the cache in advance if you want to. |
static java.lang.String |
formatDouble(double d)
Outputs a double into a format suitable for the PDF. |
static java.lang.String |
formatDouble(double d,
ByteBuffer buf)
Outputs a double into a format suitable for the PDF. |
byte[] |
getBuffer()
|
void |
reset()
Sets the size to zero. |
static void |
setCacheSize(int size)
Sets the cache size. |
int |
size()
Returns the current size of the buffer. |
byte[] |
toByteArray()
Creates a newly allocated byte array. |
java.lang.String |
toString()
Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding. |
java.lang.String |
toString(java.lang.String enc)
Converts the buffer's contents into a string, translating bytes into characters according to the specified character encoding. |
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
void |
writeTo(java.io.OutputStream out)
Writes the complete contents of this byte buffer output to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count). |
| Methods inherited from class java.io.OutputStream |
|---|
close, flush, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int count
protected byte[] buf
private static int byteCacheSize
private static byte[][] byteCache
public static byte ZERO
private static final char[] chars
private static final byte[] bytes
| Constructor Detail |
|---|
public ByteBuffer()
public ByteBuffer(int size)
size - the initial capacity| Method Detail |
|---|
public static void setCacheSize(int size)
This can only be used to increment the size. If the size that is passed through is smaller than the current size, nothing happens.
size - the size of the cachepublic static void fillCache(int decimals)
decimals - private static byte[] convertToBytes(int i)
i - the int
public ByteBuffer append_i(int b)
int. The size of the array will grow by one.
b - the int to be appended
ByteBuffer object
public ByteBuffer append(byte[] b,
int off,
int len)
byte array. The buffer will grow by
len bytes.
b - the array to be appendedoff - the offset to the start of the arraylen - the length of bytes to append
ByteBuffer objectpublic ByteBuffer append(byte[] b)
b - the array to be appended
ByteBuffer objectpublic ByteBuffer append(java.lang.String str)
String to the buffer. The String is
converted according to the encoding ISO-8859-1.
str - the String to be appended
ByteBuffer objectpublic ByteBuffer append(char c)
char to the buffer. The char is
converted according to the encoding ISO-8859-1.
c - the char to be appended
ByteBuffer objectpublic ByteBuffer append(ByteBuffer buf)
ByteBuffer to this buffer.
buf - the ByteBuffer to be appended
ByteBuffer objectpublic ByteBuffer append(int i)
int.
i - the int to be appended
ByteBuffer objectpublic ByteBuffer append(byte b)
public ByteBuffer appendHex(byte b)
public ByteBuffer append(float i)
float according
to the Pdf conventions.
i - the float to be appended
ByteBuffer objectpublic ByteBuffer append(double d)
double according
to the Pdf conventions.
d - the double to be appended
ByteBuffer objectpublic static java.lang.String formatDouble(double d)
double into a format suitable for the PDF.
d - a double
String representation of the double
public static java.lang.String formatDouble(double d,
ByteBuffer buf)
double into a format suitable for the PDF.
d - a double
String representation of the double if
d is null. If d is not null,
then the double is appended directly to the buffer and this methods returns null.public void reset()
public byte[] toByteArray()
public int size()
count field, which is the number of valid bytes in this byte buffer.public java.lang.String toString()
toString in class java.lang.Object
public java.lang.String toString(java.lang.String enc)
throws java.io.UnsupportedEncodingException
enc - a character-encoding name.
java.io.UnsupportedEncodingException - If the named encoding is not supported.
public void writeTo(java.io.OutputStream out)
throws java.io.IOException
out.write(buf, 0, count).
out - the output stream to which to write the data.
java.io.IOException - if an I/O error occurs.
public void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOException
public void write(byte[] b,
int off,
int len)
write in class java.io.OutputStreampublic byte[] getBuffer()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||