Package com.tangosol.io
Class Base64InputStream
java.lang.Object
java.io.InputStream
com.tangosol.io.Base64InputStream
- All Implemented Interfaces:
com.oracle.coherence.common.io.InputStreaming
,InputStreaming
,Closeable
,AutoCloseable
Reads binary data from a Reader using IETF RFC 2045 Base64 Content
Transfer Encoding.
Static helpers are available for decoding directly from a char array
to a byte array.
- Author:
- cp 2000.09.07
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final byte[]
Empty binary data.protected int[]
Group of bytes (stored as ints 0..255).protected boolean
True after close is invoked.protected boolean
True after eof is determined.protected int
The offset in the group of bytes.protected Reader
The Reader object from which the Base64 encoded data is read. -
Constructor Summary
ConstructorDescriptionBase64InputStream
(Reader reader) Construct a Base64InputStream on a Reader object. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.void
close()
Close the stream, flushing any accumulated bytes.static int
decode
(char ch) Decode one base64 alphabet character.static byte[]
decode
(char[] ach) Decode the passed character data that was encoded using Base64 encoding.static byte[]
decode
(char[] ach, boolean fJunk) Decode the passed character data that was encoded using Base64 encoding.static byte[]
decode
(char[] ach, int of, int cch) Decode the passed character data that was encoded using Base64 encoding.static byte[]
decode
(char[] ach, int of, int cch, boolean fJunk) Decode the passed character data that was encoded using Base64 encoding.int
read()
Reads the next byte of data from the input stream.Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.oracle.coherence.common.io.InputStreaming
mark, markSupported, read, read, reset, skip
-
Field Details
-
EMPTY
protected static final byte[] EMPTYEmpty binary data. -
m_fClosed
protected boolean m_fClosedTrue after close is invoked. -
m_fEOF
protected boolean m_fEOFTrue after eof is determined. -
m_reader
The Reader object from which the Base64 encoded data is read. -
m_abGroup
protected int[] m_abGroupGroup of bytes (stored as ints 0..255). -
m_ofbGroup
protected int m_ofbGroupThe offset in the group of bytes.
-
-
Constructor Details
-
Base64InputStream
Construct a Base64InputStream on a Reader object.- Parameters:
reader
- the Reader to read the Base64 encoded data from
-
-
Method Details
-
read
Reads the next byte of data from the input stream. The value byte is returned as anint
in the range0
to255
. If no byte is available because the end of the stream has been reached, the value-1
is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.- Specified by:
read
in interfacecom.oracle.coherence.common.io.InputStreaming
- Specified by:
read
in classInputStream
- Returns:
- the next byte of data, or
-1
if the end of the stream is reached. - Throws:
IOException
- if an I/O error occurs.
-
available
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or or another thread.- Specified by:
available
in interfacecom.oracle.coherence.common.io.InputStreaming
- Overrides:
available
in classInputStream
- Returns:
- the number of bytes that can be read from this input stream without blocking.
- Throws:
IOException
- if an I/O error occurs.
-
close
Close the stream, flushing any accumulated bytes. The underlying reader is not closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacecom.oracle.coherence.common.io.InputStreaming
- Overrides:
close
in classInputStream
- Throws:
IOException
- if an I/O error occurs.
-
decode
public static byte[] decode(char[] ach) Decode the passed character data that was encoded using Base64 encoding.- Parameters:
ach
- the array containing the characters to decode- Returns:
- the decoded binary data as a byte array
-
decode
public static byte[] decode(char[] ach, boolean fJunk) Decode the passed character data that was encoded using Base64 encoding.- Parameters:
ach
- the array containing the characters to decodefJunk
- true if the char array may contain whitespace or linefeeds- Returns:
- the decoded binary data as a byte array
-
decode
public static byte[] decode(char[] ach, int of, int cch) Decode the passed character data that was encoded using Base64 encoding.- Parameters:
ach
- the array containing the characters to decodeof
- the start offset in the char arraycch
- the number of characters to decode- Returns:
- the decoded binary data as a byte array
-
decode
public static byte[] decode(char[] ach, int of, int cch, boolean fJunk) Decode the passed character data that was encoded using Base64 encoding.- Parameters:
ach
- the array containing the characters to decodeof
- the start offset in the char arraycch
- the number of characters to decodefJunk
- true if the char array may contain whitespace or linefeeds- Returns:
- the decoded binary data as a byte array
-
decode
public static int decode(char ch) Decode one base64 alphabet character.- Parameters:
ch
- the character- Returns:
- the ordinal value of the character
-