|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.stimulsoft.lib.base64.StiBase64EncoderUtil
public class StiBase64EncoderUtil
Class encodes the bytes read from the InputStream to a Base64 encoded string and writes to output stream.
| Field Summary | |
|---|---|
protected int |
buffer
24-bit buffer to translate 3 octets into 4 sextets. |
protected int |
count
The number of valid bytes in the data buffer. |
protected static int |
FOUR_SEXTETS
Number of sextets encoded from buffer. |
protected static int |
INPUT_BUFFER_SIZE
Input buffer size. |
protected static byte[] |
MAP
Array to convert sextet byte values into base64 characters. |
protected static int |
OCTET_1_MASK
Mask buffer to or with first octet. |
protected static int |
OCTET_2_MASK
Mask buffer to or with second octet. |
protected static int |
OCTET_3
Third octet in buffer. |
protected static int |
OCTET_3_MASK
Mask buffer to or with third octet. |
protected static int |
OCTET_MASK
Mask an octet. |
protected int |
octets
Number of octets in buffer. |
protected byte[] |
outputBuffer
The buffer where data is stored between writes to output stream. |
protected static byte |
PAD
Byte used to pad output. |
protected static int |
SEXTET_MASK
Mask a sextet. |
protected static int |
SHIFT_1_OCTET
Number of bits to shift for one octet. |
protected static int |
SHIFT_1_SEXTET
Number of bits to shift for one sextet. |
protected static int |
SHIFT_2_OCTET
Number of bits to shift for two octets. |
protected static int |
SHIFT_2_SEXTET
Number of bits to shift for two sextets. |
protected static int |
SHIFT_3_SEXTET
Number of bits to shift for three sextets. |
protected java.io.OutputStream |
stream
Stream for encoded characters. |
| Constructor Summary | |
|---|---|
StiBase64EncoderUtil(java.io.OutputStream stream)
Construct a Base64Encoder waiting on calls to its translate() method. |
|
| Method Summary | |
|---|---|
static byte[] |
encode(byte[] data)
Encode given byte array into an encoded byte array. |
static byte[] |
encode(byte[] data,
int begin,
int end)
Encode given byte array into an encoded byte array. |
static void |
encode(java.io.InputStream input,
java.io.OutputStream out)
Encode bytes from input stream and write encoded bytes to output stream. |
static java.lang.String |
encode(java.lang.String data)
|
protected void |
encodeBuffer()
Encode 4 sextets from buffer. |
protected void |
encodeBufferWithPadding()
Encode the remaining sextets from buffer. |
void |
flush()
Writes all encoded characters. |
protected StiBase64EncoderUtil |
translate(byte[] bytes)
Translate all bytes of given array by appending each to octet buffer. |
protected StiBase64EncoderUtil |
translate(byte[] bytes,
int begin,
int end)
Translate bytes of given array by appending each to octet buffer. |
protected void |
writeBuffer()
Write buffer to output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int FOUR_SEXTETS
protected static final int INPUT_BUFFER_SIZE
protected static final int SEXTET_MASK
protected static final int SHIFT_1_SEXTET
protected static final int SHIFT_2_SEXTET
protected static final int SHIFT_3_SEXTET
protected static final byte PAD
protected static final byte[] MAP
protected static final int OCTET_3
protected static final int OCTET_1_MASK
protected static final int OCTET_2_MASK
protected static final int OCTET_3_MASK
protected static final int OCTET_MASK
protected static final int SHIFT_1_OCTET
protected static final int SHIFT_2_OCTET
protected int buffer
protected int octets
protected final java.io.OutputStream stream
protected byte[] outputBuffer
protected int count
| Constructor Detail |
|---|
public StiBase64EncoderUtil(java.io.OutputStream stream)
stream - stream to write encoded bytes to| Method Detail |
|---|
public static void encode(java.io.InputStream input,
java.io.OutputStream out)
throws java.io.IOException
input - input streamout - output stream
java.io.IOException - if an I/O error occurspublic static byte[] encode(byte[] data)
data - the byte array to be encoded
public static java.lang.String encode(java.lang.String data)
public static byte[] encode(byte[] data,
int begin,
int end)
data - the byte array to be encodedbegin - index of the first byte to start fromend - index after the last byte
protected StiBase64EncoderUtil translate(byte[] bytes)
throws java.io.IOException
bytes - the byte array to be encoded
java.io.IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output
stream has been closed.
protected StiBase64EncoderUtil translate(byte[] bytes,
int begin,
int end)
throws java.io.IOException
bytes - the byte array to be encodedbegin - index of the first byte to start fromend - index after the last byte
java.io.IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output
stream has been closed.
protected void encodeBuffer()
throws java.io.IOException
java.io.IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output
stream has been closed.
protected void encodeBufferWithPadding()
throws java.io.IOException
java.io.IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output
stream has been closed.
protected void writeBuffer()
throws java.io.IOException
java.io.IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output
stream has been closed.
public void flush()
throws java.io.IOException
java.io.IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output
stream has been closed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||