|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
org.spaceroots.jarmor.AbstractDecoder
org.spaceroots.jarmor.Base64Decoder
This class decodes a text stream containing into a binary stream.
The Base64 encoding is suitable when binary data needs to be transmitted or stored as text. It is defined in RFC 3548 The Base16, Base32, and Base64 Data Encodings by S. Josefsson
Base64Encoder| Field Summary | |
protected byte[] |
encoded
Encoded bytes buffer. |
protected boolean |
endReached
End indicator. |
protected int |
nEncoded
Number of bytes already in the encoded array. |
| Fields inherited from class java.io.FilterInputStream |
in |
| Constructor Summary | |
Base64Decoder(InputStream in)
Create a decoder wrapping a source of encoded data. |
|
Base64Decoder(InputStream in,
boolean strictRFCCompliance)
Create a decoder wrapping a source of encoded data. |
|
| Method Summary | |
int |
available()
Get the number of bytes that can be read from this input stream without blocking. |
void |
close()
Close the stream. |
protected int |
filterBytes()
Get some bytes from the underlying stream and filter them. |
boolean |
markSupported()
Check if the FilterInputStream.mark(int) and
FilterInputStream.reset() methods are supported. |
protected void |
putFilteredByte(int b)
Put a filtered byte in the buffer. |
int |
read()
Reads the next byte of data from this input stream. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from this input stream into an array of bytes. |
protected int |
readEncodedBytes()
Read new encoded bytes. |
long |
skip(long n)
Skips over and discards n bytes of data from the input stream. |
| Methods inherited from class java.io.FilterInputStream |
mark, read, reset |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected byte[] encoded
protected int nEncoded
protected boolean endReached
| Constructor Detail |
public Base64Decoder(InputStream in)
The decoder built using this constructor will strictly
obey RFC 3548.
This means that if some encoded bytes do not belong to the Base64
alphabet, an IOException will be thrown at read time.
Note that calling this constructor is equivalent to calling
Base64Decoder(.in, -true)
in - source of encoded data to decode
public Base64Decoder(InputStream in,
boolean strictRFCCompliance)
If the decoder built using this constructor strictly
obeys RFC 3548
and some encoded bytes do not belong to the Base64 alphabet, then
an IOException will be thrown at read time.
Note that calling this constructor with
strictRFCComplianceset to true is equivalent to calling
the one argument constructor.
in - source of encoded data to decodestrictRFCCompliance - if true, characters outside of the Base64
alphabet will trigger an IOException at read time,
otherwise they will be silently ignored| Method Detail |
protected int filterBytes()
throws IOException
IOException - if the underlying stream throws oneAbstractDecoder.putFilteredByte(int)
public int available()
throws IOException
IOException - if the underlying stream throws one
public int read()
throws IOException
IOException - if the underlying stream throws one
public int read(byte[] b,
int off,
int len)
throws IOException
b - the buffer into which the data is read.off - the start offset of the data.len - the maximum number of bytes read.
IOException - if the underlying stream throws one
public long skip(long n)
throws IOException
n - the number of bytes to be skipped
IOException - if the underlying stream throws one
public void close()
throws IOException
IOException - if the underlying stream throws onepublic boolean markSupported()
FilterInputStream.mark(int) and
FilterInputStream.reset() methods are supported.
protected int readEncodedBytes()
throws IOException
IOException - if the underlying stream throws oneprotected void putFilteredByte(int b)
The filtered bytes buffer will be expanded if it already contains too many pending bytes.
b - byte to put in the filtered buffer
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||