Package org.apache.axiom.util.base64
Class AbstractBase64EncodingOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.axiom.util.base64.AbstractBase64EncodingOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Direct Known Subclasses:
Base64EncodingOutputStream,Base64EncodingStringBufferOutputStream,Base64EncodingWriterOutputStream
public abstract class AbstractBase64EncodingOutputStream extends OutputStream
Base class forOutputStreamimplementations that encode data in base64.
-
-
Constructor Summary
Constructors Constructor Description AbstractBase64EncodingOutputStream()Default constructor.AbstractBase64EncodingOutputStream(boolean ignoreFlush)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()voidcomplete()Write out any pending data, including padding if necessary.protected abstract voiddoClose()Close the underlying stream, if applicable.protected abstract voiddoFlush()Flush the underlying stream, if applicable.protected abstract voiddoWrite(byte[] b)Write base64 encoded data.voidflush()protected abstract voidflushBuffer()Write any pending data to the underlying stream, if applicable.voidwrite(byte[] b, int off, int len)voidwrite(int b)-
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
-
-
-
Constructor Detail
-
AbstractBase64EncodingOutputStream
public AbstractBase64EncodingOutputStream(boolean ignoreFlush)
Constructor.- Parameters:
ignoreFlush- Specifies if calls toflush()should be ignored. Setting this totrueis particular useful in conjunction withDataHandler.writeTo(OutputStream): that method may callflush()after writing the data, but the call toDataHandler.writeTo(OutputStream)must be followed by a call toclose()orcomplete()which would then output a single chunk with a few bytes. In some cases this may be inconvenient.
-
AbstractBase64EncodingOutputStream
public AbstractBase64EncodingOutputStream()
Default constructor. This constructor does the same asAbstractBase64EncodingOutputStream(boolean)withignoreFlushset tofalse.
-
-
Method Detail
-
write
public final void write(byte[] b, int off, int len) throws IOException- Overrides:
writein classOutputStream- Throws:
IOException
-
write
public final void write(int b) throws IOException- Specified by:
writein classOutputStream- Throws:
IOException
-
complete
public final void complete() throws IOExceptionWrite out any pending data, including padding if necessary.- Throws:
IOException- if an I/O error occurs
-
flush
public final void flush() throws IOException- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
public final void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
doWrite
protected abstract void doWrite(byte[] b) throws IOExceptionWrite base64 encoded data. If necessary, the implementation should accumulate the data in a buffer before writing it to the underlying stream.- Parameters:
b- a byte array of length 4- Throws:
IOException- if an I/O error occurs
-
flushBuffer
protected abstract void flushBuffer() throws IOExceptionWrite any pending data to the underlying stream, if applicable. Note that implementations should not flush the underlying stream.- Throws:
IOException- if an I/O error occurs
-
doFlush
protected abstract void doFlush() throws IOExceptionFlush the underlying stream, if applicable.- Throws:
IOException- if an I/O error occurs
-
doClose
protected abstract void doClose() throws IOExceptionClose the underlying stream, if applicable.- Throws:
IOException- if an I/O error occurs
-
-