T
- the type of instances to build.B
- the type of builder subclass.public abstract class AbstractStreamBuilder<T,B extends AbstractStreamBuilder<T,B>> extends AbstractOriginSupplier<T,B>
T
.Modifier and Type | Field and Description |
---|---|
private int |
bufferSize
The buffer size, defaults to
IOUtils.DEFAULT_BUFFER_SIZE (). |
private java.util.function.IntUnaryOperator |
bufferSizeChecker
The checking behavior for a buffer size request.
|
private int |
bufferSizeDefault
The buffer size, defaults to
IOUtils.DEFAULT_BUFFER_SIZE (). |
private int |
bufferSizeMax
The maximum buffer size.
|
private java.nio.charset.Charset |
charset
The Charset, defaults to
Charset.defaultCharset() . |
private java.nio.charset.Charset |
charsetDefault
The Charset, defaults to
Charset.defaultCharset() . |
private static int |
DEFAULT_MAX_VALUE |
private static java.nio.file.OpenOption[] |
DEFAULT_OPEN_OPTIONS |
private java.util.function.IntUnaryOperator |
defaultSizeChecker
The default checking behavior for a buffer size request.
|
private java.nio.file.OpenOption[] |
openOptions |
Constructor and Description |
---|
AbstractStreamBuilder() |
Modifier and Type | Method and Description |
---|---|
private int |
checkBufferSize(int size)
Applies the buffer size request.
|
protected int |
getBufferSize()
Gets the buffer size, defaults to
IOUtils.DEFAULT_BUFFER_SIZE (). |
protected int |
getBufferSizeDefault()
Gets the buffer size default, defaults to
IOUtils.DEFAULT_BUFFER_SIZE (). |
protected java.lang.CharSequence |
getCharSequence()
Gets a CharSequence from the origin with a Charset.
|
java.nio.charset.Charset |
getCharset()
Gets the Charset, defaults to
Charset.defaultCharset() . |
protected java.nio.charset.Charset |
getCharsetDefault()
Gets the Charset default, defaults to
Charset.defaultCharset() . |
protected java.io.InputStream |
getInputStream()
Gets an input stream from the origin with open options.
|
protected java.nio.file.OpenOption[] |
getOpenOptions()
Gets the OpenOption.
|
protected java.io.OutputStream |
getOutputStream()
Gets an OutputStream from the origin with open options.
|
protected java.nio.file.Path |
getPath()
Gets a Path from the origin.
|
protected java.io.Writer |
getWriter()
Gets an writer from the origin with open options.
|
B |
setBufferSize(int bufferSize)
Sets the buffer size.
|
B |
setBufferSize(java.lang.Integer bufferSize)
Sets the buffer size.
|
B |
setBufferSizeChecker(java.util.function.IntUnaryOperator bufferSizeChecker)
Sets the buffer size checker function.
|
protected B |
setBufferSizeDefault(int bufferSizeDefault)
Sets the buffer size for subclasses to initialize.
|
B |
setBufferSizeMax(int bufferSizeMax)
The maximum buffer size checked by the buffer size checker.
|
B |
setCharset(java.nio.charset.Charset charset)
Sets the Charset.
|
B |
setCharset(java.lang.String charset)
Sets the Charset.
|
protected B |
setCharsetDefault(java.nio.charset.Charset defaultCharset)
Sets the Charset default for subclasses to initialize.
|
B |
setOpenOptions(java.nio.file.OpenOption... openOptions)
Sets the OpenOption[].
|
private int |
throwIae(int size,
int max) |
checkOrigin, getOrigin, hasOrigin, newByteArrayOrigin, newCharSequenceOrigin, newFileOrigin, newFileOrigin, newInputStreamOrigin, newOutputStreamOrigin, newPathOrigin, newPathOrigin, newReaderOrigin, newURIOrigin, newWriterOrigin, setByteArray, setCharSequence, setFile, setFile, setInputStream, setOrigin, setOutputStream, setPath, setPath, setReader, setURI, setWriter
asThis
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
asSupplier, get
private static final int DEFAULT_MAX_VALUE
private static final java.nio.file.OpenOption[] DEFAULT_OPEN_OPTIONS
private int bufferSize
IOUtils.DEFAULT_BUFFER_SIZE
().private int bufferSizeDefault
IOUtils.DEFAULT_BUFFER_SIZE
().private int bufferSizeMax
private java.nio.charset.Charset charset
Charset.defaultCharset()
.private java.nio.charset.Charset charsetDefault
Charset.defaultCharset()
.private java.nio.file.OpenOption[] openOptions
private final java.util.function.IntUnaryOperator defaultSizeChecker
IllegalArgumentException
by default.private java.util.function.IntUnaryOperator bufferSizeChecker
private int checkBufferSize(int size)
size
- the size request.IllegalArgumentException
.protected int getBufferSize()
IOUtils.DEFAULT_BUFFER_SIZE
().IOUtils.DEFAULT_BUFFER_SIZE
().protected int getBufferSizeDefault()
IOUtils.DEFAULT_BUFFER_SIZE
().IOUtils.DEFAULT_BUFFER_SIZE
().protected java.lang.CharSequence getCharSequence() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.java.lang.UnsupportedOperationException
- if the origin cannot be converted to a CharSequence.java.lang.IllegalStateException
- if the origin
is null
.AbstractOrigin.getCharSequence(Charset)
public java.nio.charset.Charset getCharset()
Charset.defaultCharset()
.Charset.defaultCharset()
.protected java.nio.charset.Charset getCharsetDefault()
Charset.defaultCharset()
.Charset.defaultCharset()
.protected java.io.InputStream getInputStream() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.java.lang.UnsupportedOperationException
- if the origin cannot be converted to an InputStream.java.lang.IllegalStateException
- if the origin
is null
.AbstractOrigin.getInputStream(OpenOption...)
protected java.nio.file.OpenOption[] getOpenOptions()
protected java.io.OutputStream getOutputStream() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.java.lang.UnsupportedOperationException
- if the origin cannot be converted to an OutputStream.java.lang.IllegalStateException
- if the origin
is null
.AbstractOrigin.getOutputStream(OpenOption...)
protected java.nio.file.Path getPath()
java.lang.UnsupportedOperationException
- if the origin cannot be converted to a Path.java.lang.IllegalStateException
- if the origin
is null
.AbstractOrigin.getPath()
protected java.io.Writer getWriter() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.java.lang.UnsupportedOperationException
- if the origin cannot be converted to a Writer.java.lang.IllegalStateException
- if the origin
is null
.AbstractOrigin.getOutputStream(OpenOption...)
public B setBufferSize(int bufferSize)
Subclasses may ignore this setting.
bufferSize
- the buffer size.public B setBufferSize(java.lang.Integer bufferSize)
Subclasses may ignore this setting.
bufferSize
- the buffer size, null resets to the default.public B setBufferSizeChecker(java.util.function.IntUnaryOperator bufferSizeChecker)
IllegalArgumentException
by default.bufferSizeChecker
- the buffer size checker function. null resets to the default behavior.protected B setBufferSizeDefault(int bufferSizeDefault)
Subclasses may ignore this setting.
bufferSizeDefault
- the buffer size, null resets to the default.public B setBufferSizeMax(int bufferSizeMax)
IllegalArgumentException
.bufferSizeMax
- maximum buffer size checked by the buffer size checker.public B setCharset(java.nio.charset.Charset charset)
Subclasses may ignore this setting.
charset
- the Charset, null resets to the default.public B setCharset(java.lang.String charset)
Subclasses may ignore this setting.
charset
- the Charset name, null resets to the default.protected B setCharsetDefault(java.nio.charset.Charset defaultCharset)
Subclasses may ignore this setting.
defaultCharset
- the Charset name, null resets to the default.public B setOpenOptions(java.nio.file.OpenOption... openOptions)
Normally used with InputStream, OutputStream, and Writer.
Subclasses may ignore this setting.
openOptions
- the OpenOption[] name, null resets to the default.AbstractOriginSupplier.setInputStream(InputStream)
,
AbstractOriginSupplier.setOutputStream(OutputStream)
,
AbstractOriginSupplier.setWriter(Writer)
private int throwIae(int size, int max)