| java.lang.Object java.io.OutputStream com.lowagie.text.pdf.ByteBuffer
ByteBuffer | public class ByteBuffer extends OutputStream (Code) | | Acts like a StringBuffer but works with byte arrays.
Floating point is converted to a format suitable to the PDF.
author: Paulo Soares (psoares@consiste.pt) |
Field Summary | |
public static boolean | HIGH_PRECISION If true always output floating point numbers with 6 decimal digits. | final public static byte | ZERO | protected byte | buf The buffer where the bytes are stored. | protected int | count The count of bytes in the buffer. |
Constructor Summary | |
public | ByteBuffer() | public | ByteBuffer(int size) Creates a byte buffer with a certain capacity. |
Method Summary | |
public ByteBuffer | append(byte b, int off, int len) Appends the subarray of the byte array. | public ByteBuffer | append(byte b) Appends an array of bytes. | public ByteBuffer | append(String str) Appends a String to the buffer. | public ByteBuffer | append(char c) Appends a char to the buffer. | public ByteBuffer | append(ByteBuffer buf) Appends another ByteBuffer to this buffer. | public ByteBuffer | append(int i) Appends the string representation of an int . | public ByteBuffer | append(byte b) | public ByteBuffer | append(float i) Appends a string representation of a float according
to the Pdf conventions. | public ByteBuffer | append(double d) Appends a string representation of a double according
to the Pdf conventions. | public ByteBuffer | appendHex(byte b) | public ByteBuffer | append_i(int b) Appends an int . | public static void | fillCache(int decimals) You can fill the cache in advance if you want to. | public static String | formatDouble(double d) Outputs a double into a format suitable for the PDF. | public static String | formatDouble(double d, ByteBuffer buf) Outputs a double into a format suitable for the PDF.
Parameters: d - a double Parameters: buf - a ByteBuffer the String representation of the double ifbuf is null . | public byte[] | getBuffer() | public void | reset() Sets the size to zero. | public static void | setCacheSize(int size) Sets the cache size. | public void | setSize(int size) | public int | size() Returns the current size of the buffer. | public byte[] | toByteArray() Creates a newly allocated byte array. | public String | toString() Converts the buffer's contents into a string, translating bytes into
characters according to the platform's default character encoding. | public String | toString(String enc) Converts the buffer's contents into a string, translating bytes into
characters according to the specified character encoding.
Parameters: enc - a character-encoding name. | public void | write(int b) | public void | write(byte[] b, int off, int len) | public void | writeTo(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) . |
HIGH_PRECISION | public static boolean HIGH_PRECISION(Code) | | If true always output floating point numbers with 6 decimal digits.
If false uses the faster, although less precise, representation.
|
ZERO | final public static byte ZERO(Code) | | |
buf | protected byte buf(Code) | | The buffer where the bytes are stored.
|
count | protected int count(Code) | | The count of bytes in the buffer.
|
ByteBuffer | public ByteBuffer()(Code) | | Creates new ByteBuffer with capacity 128
|
ByteBuffer | public ByteBuffer(int size)(Code) | | Creates a byte buffer with a certain capacity.
Parameters: size - the initial capacity |
append | public ByteBuffer append(byte b, int off, int len)(Code) | | Appends the subarray of the byte array. The buffer will grow by
len bytes.
Parameters: b - the array to be appended Parameters: off - the offset to the start of the array Parameters: len - the length of bytes to append a reference to this ByteBuffer object |
append | public ByteBuffer append(byte b)(Code) | | Appends an array of bytes.
Parameters: b - the array to be appended a reference to this ByteBuffer object |
append | public ByteBuffer append(String str)(Code) | | Appends a String to the buffer. The String is
converted according to the encoding ISO-8859-1.
Parameters: str - the String to be appended a reference to this ByteBuffer object |
append | public ByteBuffer append(char c)(Code) | | Appends a char to the buffer. The char is
converted according to the encoding ISO-8859-1.
Parameters: c - the char to be appended a reference to this ByteBuffer object |
append | public ByteBuffer append(ByteBuffer buf)(Code) | | Appends another ByteBuffer to this buffer.
Parameters: buf - the ByteBuffer to be appended a reference to this ByteBuffer object |
append | public ByteBuffer append(int i)(Code) | | Appends the string representation of an int .
Parameters: i - the int to be appended a reference to this ByteBuffer object |
append | public ByteBuffer append(float i)(Code) | | Appends a string representation of a float according
to the Pdf conventions.
Parameters: i - the float to be appended a reference to this ByteBuffer object |
append | public ByteBuffer append(double d)(Code) | | Appends a string representation of a double according
to the Pdf conventions.
Parameters: d - the double to be appended a reference to this ByteBuffer object |
append_i | public ByteBuffer append_i(int b)(Code) | | Appends an int . The size of the array will grow by one.
Parameters: b - the int to be appended a reference to this ByteBuffer object |
fillCache | public static void fillCache(int decimals)(Code) | | You can fill the cache in advance if you want to.
Parameters: decimals - |
formatDouble | public static String formatDouble(double d)(Code) | | Outputs a double into a format suitable for the PDF.
Parameters: d - a double the String representation of the double |
formatDouble | public static String formatDouble(double d, ByteBuffer buf)(Code) | | Outputs a double into a format suitable for the PDF.
Parameters: d - a double Parameters: buf - a ByteBuffer the String representation of the double ifbuf is null . If buf is not null ,then the double is appended directly to the buffer and this methods returns null . |
getBuffer | public byte[] getBuffer()(Code) | | |
reset | public void reset()(Code) | | Sets the size to zero.
|
setCacheSize | public static void setCacheSize(int size)(Code) | | 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.
Parameters: size - the size of the cache |
setSize | public void setSize(int size)(Code) | | |
size | public int size()(Code) | | 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()(Code) | | 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()(Code) | | 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(Code) | | Converts the buffer's contents into a string, translating bytes into
characters according to the specified character encoding.
Parameters: enc - a character-encoding name. String translated from the buffer's contents. throws: UnsupportedEncodingException - If the named encoding is not supported. |
write | public void write(byte[] b, int off, int len)(Code) | | |
writeTo | public void writeTo(OutputStream out) throws IOException(Code) | | 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) .
Parameters: out - the output stream to which to write the data. exception: IOException - if an I/O error occurs. |
|
|