|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
org.spaceroots.jarmor.Base16Encoder
This class encodes a binary stream into a text stream.
The Base16 encoding is suitable when binary data needs to be transmitted or stored as text, when case insensitivity is needed. It is defined in RFC 3548 The Base16, Base32, and Base64 Data Encodings by S. Josefsson
If strict RFC 3548 compliance is specified (by using the one
argument constructor),
the produced stream is guaranteed to use only the upper case letters
'A' to 'F' and the digits '0' to '9'.
If the encoded text must obey higher level requirement, the user can
ask for the encoded text to be split in lines by specifying a maximal
line length, an end of line marker and an optional start of line marker
(for indentation purposes for example) by using the four arguments
constructor. In
this case, the markers must not belong to the Base16 alphabet,
and the corresponding decoder must be set up to silently
ignore these characters.
Converting the Base16 encoded data stream into text should be straigthforward regardless of the character set as according to the RFC the alphabet used (perhaps with the exception of the start/end of line markers if the user is not cautious) has the same representation in all versions of ISO 646, US-ASCII, and all versions of EBCDIC.
The encoded stream is about twice as large than the corresponding binary stream (4 binary bits are converted into 8 encoded bits, and there may be start/end of line markers).
Base16Decoder| Field Summary |
| Fields inherited from class java.io.FilterOutputStream |
out |
| Constructor Summary | |
Base16Encoder(OutputStream out)
Create an encoder wrapping a sink of binary data. |
|
Base16Encoder(OutputStream out,
int lineLength,
byte[] sol,
byte[] eol)
Create an encoder wrapping a sink of binary data. |
|
| Method Summary | |
void |
close()
Closes this output stream and releases any system resources associated with the stream. |
void |
write(int b)
Writes the specified byte to this output stream. |
| Methods inherited from class java.io.FilterOutputStream |
flush, write, write |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Base16Encoder(OutputStream out)
The encoder built using this constructor will strictly obey RFC 3548.
Note that calling this constructor is equivalent to calling
Base16Encoder(.out, -1, null,
null)
out - sink of binary data to filter
public Base16Encoder(OutputStream out,
int lineLength,
byte[] sol,
byte[] eol)
The encoder built using this constructor will not strictly obey RFC 3548. The corresponding decoder must be aware of the settings used here to properly ignore the start/end of line markers.
Note that specifying a negative number for lineLength
is really equivalent to calling the one argument
constructor.
If non-null start/end of line are used, they must be free of any Base16 characters that would otherwise interfere with the decoding process on the other side of the channel. For safety, it is recommended to stick to space (' ', 0x32) and horizontal tabulation ('\t', 0x9) characters for the start of line marker, and to line feed ('\n', 0xa) and carriage return ('\r', 0xd) characters according to the platform convention for the end of line marker.
out - sink of binary data to filterlineLength - maximal length of a ligne (counting sol
but not counting eol), if negative lines will not be
splitsol - start of line marker to use (mainly for indentation
purposes), may be nulleol - end of line marker to use, may be null only if
lineLength is negative| Method Detail |
public void close()
throws IOException
IOException - if the underlying stream throws one
public void write(int b)
throws IOException
b - byte to write (only the 8 low order bits are used)
IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||