T
- the type of instances to build.B
- the type of builder subclass.public abstract class AbstractOrigin<T,B extends AbstractOrigin<T,B>> extends AbstractSupplier<T,B>
File
, Path
, Reader
, Writer
, InputStream
, OutputStream
, and
URI
.
Some methods may throw UnsupportedOperationException
if that method is not implemented in a concrete subclass, see getFile()
and
getPath()
.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractOrigin.ByteArrayOrigin
A
byte[] origin. |
static class |
AbstractOrigin.CharSequenceOrigin
A
CharSequence origin. |
static class |
AbstractOrigin.FileOrigin
A
File origin. |
static class |
AbstractOrigin.InputStreamOrigin
An
InputStream origin. |
static class |
AbstractOrigin.OutputStreamOrigin
An
OutputStream origin. |
static class |
AbstractOrigin.PathOrigin
A
Path origin. |
static class |
AbstractOrigin.ReaderOrigin
An
Reader origin. |
static class |
AbstractOrigin.URIOrigin
A
URI origin. |
static class |
AbstractOrigin.WriterOrigin
An
Writer origin. |
Modifier | Constructor and Description |
---|---|
protected |
AbstractOrigin(T origin)
Constructs a new instance for a subclass.
|
Modifier and Type | Method and Description |
---|---|
T |
get()
Gets the origin.
|
byte[] |
getByteArray()
Gets this origin as a byte array, if possible.
|
byte[] |
getByteArray(long position,
int length)
Gets this origin as a byte array, if possible.
|
CharSequence |
getCharSequence(Charset charset)
Gets this origin as a byte array, if possible.
|
File |
getFile()
Gets this origin as a Path, if possible.
|
InputStream |
getInputStream(OpenOption... options)
Gets this origin as an InputStream, if possible.
|
OutputStream |
getOutputStream(OpenOption... options)
Gets this origin as an OutputStream, if possible.
|
Path |
getPath()
Gets this origin as a Path, if possible.
|
Reader |
getReader(Charset charset)
Gets a new Reader on the origin, buffered by default.
|
Writer |
getWriter(Charset charset,
OpenOption... options)
Gets a new Writer on the origin, buffered by default.
|
long |
size()
Gets the size of the origin, if possible.
|
String |
toString() |
asThis
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
asSupplier
protected AbstractOrigin(T origin)
origin
- The origin.public byte[] getByteArray() throws IOException
IOException
- if an I/O error occurs.UnsupportedOperationException
- if the origin cannot be converted to a Path.public byte[] getByteArray(long position, int length) throws IOException
position
- the initial index of the range to be copied, inclusive.length
- How many bytes to copy.UnsupportedOperationException
- if the origin cannot be converted to a Path.ArithmeticException
- if the position
overflows an intIOException
- if an I/O error occurs.public CharSequence getCharSequence(Charset charset) throws IOException
charset
- The charset to use if conversion from bytes is needed.IOException
- if an I/O error occurs.UnsupportedOperationException
- if the origin cannot be converted to a Path.public File getFile()
UnsupportedOperationException
- if this method is not implemented in a concrete subclass.public InputStream getInputStream(OpenOption... options) throws IOException
options
- options specifying how the file is openedIOException
- if an I/O error occurs.UnsupportedOperationException
- if the origin cannot be converted to a Path.public OutputStream getOutputStream(OpenOption... options) throws IOException
options
- options specifying how the file is openedIOException
- if an I/O error occurs.UnsupportedOperationException
- if the origin cannot be converted to a Path.public Path getPath()
UnsupportedOperationException
- if this method is not implemented in a concrete subclass.public Reader getReader(Charset charset) throws IOException
charset
- the charset to use for decodingIOException
- if an I/O error occurs opening the file.public Writer getWriter(Charset charset, OpenOption... options) throws IOException
charset
- the charset to use for encodingoptions
- options specifying how the file is openedIOException
- if an I/O error occurs opening or creating the file.UnsupportedOperationException
- if the origin cannot be converted to a Path.public long size() throws IOException
IOException
- if an I/O error occurs.Copyright © 2002–2023 The Apache Software Foundation. All rights reserved.