Package org.apache.commons.io.build
Class AbstractStreamBuilder<T,B extends AbstractStreamBuilder<T,B>>
- java.lang.Object
-
- org.apache.commons.io.build.AbstractSupplier<T,B>
-
- org.apache.commons.io.build.AbstractOriginSupplier<T,B>
-
- org.apache.commons.io.build.AbstractStreamBuilder<T,B>
-
- Type Parameters:
T
- the type of instances to build.B
- the type of builder subclass.
- All Implemented Interfaces:
IOSupplier<T>
- Direct Known Subclasses:
AutoCloseInputStream.Builder
,BOMInputStream.Builder
,BufferedFileChannelInputStream.Builder
,CharSequenceInputStream.Builder
,ChunkedOutputStream.Builder
,DeferredFileOutputStream.Builder
,FileWriterWithEncoding.Builder
,LockableFileWriter.Builder
,MemoryMappedFileInputStream.Builder
,MessageDigestCalculatingInputStream.Builder
,QueueInputStream.Builder
,RandomAccessFileInputStream.Builder
,ReadAheadInputStream.Builder
,ReaderInputStream.Builder
,ReversedLinesFileReader.Builder
,Tailer.Builder
,UncheckedBufferedReader.Builder
,UncheckedFilterInputStream.Builder
,UncheckedFilterOutputStream.Builder
,UncheckedFilterReader.Builder
,UncheckedFilterWriter.Builder
,UnsynchronizedBufferedInputStream.Builder
,UnsynchronizedByteArrayInputStream.Builder
,UnsynchronizedByteArrayOutputStream.Builder
,UnsynchronizedFilterInputStream.Builder
,WriterOutputStream.Builder
,XmlStreamReader.Builder
,XmlStreamWriter.Builder
public abstract class AbstractStreamBuilder<T,B extends AbstractStreamBuilder<T,B>> extends AbstractOriginSupplier<T,B>
Abstracts building a typed instance ofT
.- Since:
- 2.12.0
-
-
Field Summary
Fields Modifier and Type Field Description private int
bufferSize
The buffer size, defaults toIOUtils.DEFAULT_BUFFER_SIZE
(8192).private int
bufferSizeDefault
The buffer size, defaults toIOUtils.DEFAULT_BUFFER_SIZE
(8192).private java.nio.charset.Charset
charset
The Charset, defaults toCharset.defaultCharset()
.private java.nio.charset.Charset
charsetDefault
The Charset, defaults toCharset.defaultCharset()
.private static java.nio.file.OpenOption[]
DEFAULT_OPEN_OPTIONS
private java.nio.file.OpenOption[]
openOptions
-
Constructor Summary
Constructors Constructor Description AbstractStreamBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
getBufferSize()
Gets the buffer size, defaults toIOUtils.DEFAULT_BUFFER_SIZE
(8192).protected int
getBufferSizeDefault()
Gets the buffer size default, defaults toIOUtils.DEFAULT_BUFFER_SIZE
(8192).protected java.lang.CharSequence
getCharSequence()
Gets a CharSequence from the origin with a Charset.java.nio.charset.Charset
getCharset()
Gets the Charset, defaults toCharset.defaultCharset()
.protected java.nio.charset.Charset
getCharsetDefault()
Gets the Charset default, defaults toCharset.defaultCharset()
.protected java.io.InputStream
getInputStream()
Gets an input stream from the origin with open options.protected java.nio.file.OpenOption[]
getOpenOptions()
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.protected B
setBufferSizeDefault(int bufferSizeDefault)
Sets the buffer size for subclasses to initialize.B
setCharset(java.lang.String charset)
Sets the Charset.B
setCharset(java.nio.charset.Charset 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[].-
Methods inherited from class org.apache.commons.io.build.AbstractOriginSupplier
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
-
Methods inherited from class org.apache.commons.io.build.AbstractSupplier
asThis
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.io.function.IOSupplier
asSupplier, get
-
-
-
-
Field Detail
-
DEFAULT_OPEN_OPTIONS
private static final java.nio.file.OpenOption[] DEFAULT_OPEN_OPTIONS
-
bufferSize
private int bufferSize
The buffer size, defaults toIOUtils.DEFAULT_BUFFER_SIZE
(8192).
-
bufferSizeDefault
private int bufferSizeDefault
The buffer size, defaults toIOUtils.DEFAULT_BUFFER_SIZE
(8192).
-
charset
private java.nio.charset.Charset charset
The Charset, defaults toCharset.defaultCharset()
.
-
charsetDefault
private java.nio.charset.Charset charsetDefault
The Charset, defaults toCharset.defaultCharset()
.
-
openOptions
private java.nio.file.OpenOption[] openOptions
-
-
Method Detail
-
getBufferSize
protected int getBufferSize()
Gets the buffer size, defaults toIOUtils.DEFAULT_BUFFER_SIZE
(8192).- Returns:
- the buffer size, defaults to
IOUtils.DEFAULT_BUFFER_SIZE
(8192).
-
getBufferSizeDefault
protected int getBufferSizeDefault()
Gets the buffer size default, defaults toIOUtils.DEFAULT_BUFFER_SIZE
(8192).- Returns:
- the buffer size default, defaults to
IOUtils.DEFAULT_BUFFER_SIZE
(8192).
-
getCharSequence
protected java.lang.CharSequence getCharSequence() throws java.io.IOException
Gets a CharSequence from the origin with a Charset.- Returns:
- An input stream
- Throws:
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 theorigin
isnull
.- Since:
- 2.13.0
- See Also:
AbstractOrigin.getCharSequence(Charset)
-
getCharset
public java.nio.charset.Charset getCharset()
Gets the Charset, defaults toCharset.defaultCharset()
.- Returns:
- the Charset, defaults to
Charset.defaultCharset()
.
-
getCharsetDefault
protected java.nio.charset.Charset getCharsetDefault()
Gets the Charset default, defaults toCharset.defaultCharset()
.- Returns:
- the Charset default, defaults to
Charset.defaultCharset()
.
-
getInputStream
protected java.io.InputStream getInputStream() throws java.io.IOException
Gets an input stream from the origin with open options.- Returns:
- An input stream
- Throws:
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 theorigin
isnull
.- Since:
- 2.13.0
- See Also:
AbstractOrigin.getInputStream(OpenOption...)
-
getOpenOptions
protected java.nio.file.OpenOption[] getOpenOptions()
-
getOutputStream
protected java.io.OutputStream getOutputStream() throws java.io.IOException
Gets an OutputStream from the origin with open options.- Returns:
- An OutputStream
- Throws:
java.io.IOException
- if an I/O error occurs.java.lang.UnsupportedOperationException
- if the origin cannot be converted to an OututStream.java.lang.IllegalStateException
- if theorigin
isnull
.- Since:
- 2.13.0
- See Also:
AbstractOrigin.getOutputStream(OpenOption...)
-
getPath
protected java.nio.file.Path getPath()
Gets a Path from the origin.- Returns:
- A Path
- Throws:
java.lang.UnsupportedOperationException
- if the origin cannot be converted to a Path.java.lang.IllegalStateException
- if theorigin
isnull
.- Since:
- 2.13.0
- See Also:
AbstractOrigin.getPath()
-
getWriter
protected java.io.Writer getWriter() throws java.io.IOException
Gets an writer from the origin with open options.- Returns:
- An writer.
- Throws:
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 theorigin
isnull
.- Since:
- 2.13.0
- See Also:
AbstractOrigin.getOutputStream(OpenOption...)
-
setBufferSize
public B setBufferSize(int bufferSize)
Sets the buffer size. Invalid input (bufferSize <= 0) resets the value to its default.Subclasses may ignore this setting.
- Parameters:
bufferSize
- the buffer size.- Returns:
- this.
-
setBufferSize
public B setBufferSize(java.lang.Integer bufferSize)
Sets the buffer size.Subclasses may ignore this setting.
- Parameters:
bufferSize
- the buffer size, null resets to the default.- Returns:
- this.
-
setBufferSizeDefault
protected B setBufferSizeDefault(int bufferSizeDefault)
Sets the buffer size for subclasses to initialize.Subclasses may ignore this setting.
- Parameters:
bufferSizeDefault
- the buffer size, null resets to the default.- Returns:
- this.
-
setCharset
public B setCharset(java.nio.charset.Charset charset)
Sets the Charset.Subclasses may ignore this setting.
- Parameters:
charset
- the Charset, null resets to the default.- Returns:
- this.
-
setCharset
public B setCharset(java.lang.String charset)
Sets the Charset.Subclasses may ignore this setting.
- Parameters:
charset
- the Charset name, null resets to the default.- Returns:
- this.
-
setCharsetDefault
protected B setCharsetDefault(java.nio.charset.Charset defaultCharset)
Sets the Charset default for subclasses to initialize.Subclasses may ignore this setting.
- Parameters:
defaultCharset
- the Charset name, null resets to the default.- Returns:
- this.
-
setOpenOptions
public B setOpenOptions(java.nio.file.OpenOption... openOptions)
Sets the OpenOption[].Normally used with InputStream, OutputStream, and Writer.
Subclasses may ignore this setting.
- Parameters:
openOptions
- the OpenOption[] name, null resets to the default.- Returns:
- this.
- Since:
- 2.13.0
- See Also:
AbstractOriginSupplier.setInputStream(InputStream)
,AbstractOriginSupplier.setOutputStream(OutputStream)
,AbstractOriginSupplier.setWriter(Writer)
-
-