append
public ByteBuffer append(String str)
Appends a String
to the buffer. The String
is
converted according to the encoding ISO-8859-1.
str
- the String
to be appended
- a reference to this
ByteBuffer
object
append
public ByteBuffer append(b[] )
Appends an array of bytes.
- a reference to this
ByteBuffer
object
append
public ByteBuffer append(b[] ,
int off,
int len)
Appends the subarray of the byte
array. The buffer will grow by
len
bytes.
off
- the offset to the start of the arraylen
- the length of bytes to append
- a reference to this
ByteBuffer
object
append
public ByteBuffer append(char c)
Appends a char
to the buffer. The char
is
converted according to the encoding ISO-8859-1.
c
- the char
to be appended
- a reference to this
ByteBuffer
object
append
public ByteBuffer append(ByteBuffer buf)
Appends another ByteBuffer
to this buffer.
buf
- the ByteBuffer
to be appended
- a reference to this
ByteBuffer
object
append
public ByteBuffer append(double d)
Appends a string representation of a double
according
to the Pdf conventions.
d
- the double
to be appended
- a reference to this
ByteBuffer
object
append
public ByteBuffer append(float i)
Appends a string representation of a float
according
to the Pdf conventions.
i
- the float
to be appended
- a reference to this
ByteBuffer
object
append
public ByteBuffer append(int i)
Appends the string representation of an int
.
i
- the int
to be appended
- a reference to this
ByteBuffer
object
append_i
public ByteBuffer append_i(int b)
Appends an int
. The size of the array will grow by one.
b
- the int to be appended
- a reference to this
ByteBuffer
object
convertToBytes
private static byte[] convertToBytes(int i)
Converts an double (multiplied by 100 and cast to an int) into an array of bytes.
fillCache
public static void fillCache(int decimals)
You can fill the cache in advance if you want to.
formatDouble
public static String formatDouble(double d)
Outputs a double
into a format suitable for the PDF.
- the
String
representation of the double
formatDouble
public static String formatDouble(double d,
ByteBuffer buf)
Outputs a double
into a format suitable for the PDF.
- the
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
.
getBuffer
public byte[] getBuffer()
reset
public void reset()
Sets the size to zero.
setCacheSize
public static void setCacheSize(int size)
Sets the cache 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 cache
size
public int size()
Returns the current size of the buffer.
- the value of the
count
field, which is the number of valid bytes in this byte buffer.
toByteArray
public byte[] toByteArray()
Creates a newly allocated byte array. Its size is the current
size of this output stream and the valid contents of the buffer
have been copied into it.
- the current contents of this output stream, as a byte array.
toString
public String toString()
Converts the buffer's contents into a string, translating bytes into
characters according to the platform's default character encoding.
- String translated from the buffer's contents.
toString
public String toString(String enc)
throws UnsupportedEncodingException
Converts the buffer's contents into a string, translating bytes into
characters according to the specified character encoding.
enc
- a character-encoding name.
- String translated from the buffer's contents.
write
public void write(byte[] b,
int off,
int len)
write
public void write(int b)
throws IOException
writeTo
public void writeTo(OutputStream out)
throws IOException
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)
.
out
- the output stream to which to write the data.