Package org.apache.commons.io.build
Class AbstractOrigin<T,B extends AbstractOrigin<T,B>>  
java.lang.Object
org.apache.commons.io.build.AbstractSupplier<T,B>
 
org.apache.commons.io.build.AbstractOrigin<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:
- AbstractOrigin.AbstractRandomAccessFileOrigin,- AbstractOrigin.ByteArrayOrigin,- AbstractOrigin.CharSequenceOrigin,- AbstractOrigin.FileOrigin,- AbstractOrigin.InputStreamOrigin,- AbstractOrigin.OutputStreamOrigin,- AbstractOrigin.PathOrigin,- AbstractOrigin.ReaderOrigin,- AbstractOrigin.URIOrigin,- AbstractOrigin.WriterOrigin
Abstracts the origin of data for builders like a 
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().
 
- Since:
- 2.12.0
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classAbstractOrigin.AbstractRandomAccessFileOrigin<T extends RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T, B>> ARandomAccessFileorigin.static classAbyte[]origin.static classACharSequenceorigin.static classAFileorigin.static classAnInputStreamorigin.static classAIORandomAccessFileorigin.static classAnOutputStreamorigin.static classAPathorigin.static classARandomAccessFileorigin.static classAReaderorigin.static classAURIorigin.static classAWriterorigin.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractOrigin(T origin) Constructs a new instance for subclasses.
- 
Method SummaryModifier and TypeMethodDescriptionget()Gets the origin.byte[]Gets this origin as a byte array, if possible.byte[]getByteArray(long position, int length) Gets a portion of this origin as a byte array, if possible.getCharSequence(Charset charset) Gets this origin as a byte array, if possible.getFile()Gets this origin as a Path, if possible.getInputStream(OpenOption... options) Gets this origin as an InputStream, if possible.getOutputStream(OpenOption... options) Gets this origin as an OutputStream, if possible.getPath()Gets this origin as a Path, if possible.getRandomAccessFile(OpenOption... openOption) Gets this origin as a RandomAccessFile, if possible.Gets a new Reader on the origin, buffered by default.getWriter(Charset charset, OpenOption... options) Gets a new Writer on the origin, buffered by default.longsize()Gets the size of the origin, if possible.toString()Methods inherited from class org.apache.commons.io.build.AbstractSupplierasThisMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.io.function.IOSupplierasSupplier, getUnchecked
- 
Constructor Details- 
AbstractOriginConstructs a new instance for subclasses.- Parameters:
- origin- The origin, not null.
 
 
- 
- 
Method Details- 
getGets the origin.- Returns:
- the origin.
- See Also:
 
- 
getByteArrayGets this origin as a byte array, if possible.- Returns:
- this origin as a byte array, if possible.
- Throws:
- IOException- if an I/O error occurs.
- UnsupportedOperationException- if the origin cannot be converted to a Path.
 
- 
getByteArrayGets a portion of this origin as a byte array, if possible.- Parameters:
- position- the initial index of the range to be copied, inclusive.
- length- How many bytes to copy.
- Returns:
- this origin as a byte array, if possible.
- Throws:
- UnsupportedOperationException- if the origin cannot be converted to a Path.
- ArithmeticException- if the- positionoverflows an int
- IOException- if an I/O error occurs.
- Since:
- 2.13.0
 
- 
getCharSequenceGets this origin as a byte array, if possible.- Parameters:
- charset- The charset to use if conversion from bytes is needed.
- Returns:
- this origin as a byte array, if possible.
- Throws:
- IOException- if an I/O error occurs.
- UnsupportedOperationException- if the origin cannot be converted to a Path.
 
- 
getFileGets this origin as a Path, if possible.- Returns:
- this origin as a Path, if possible.
- Throws:
- UnsupportedOperationException- if this method is not implemented in a concrete subclass.
 
- 
getInputStreamGets this origin as an InputStream, if possible.- Parameters:
- options- options specifying how the file is opened
- Returns:
- this origin as an InputStream, if possible.
- Throws:
- IOException- if an I/O error occurs.
- UnsupportedOperationException- if the origin cannot be converted to a Path.
 
- 
getOutputStreamGets this origin as an OutputStream, if possible.- Parameters:
- options- options specifying how the file is opened
- Returns:
- this origin as an OutputStream, if possible.
- Throws:
- IOException- if an I/O error occurs.
- UnsupportedOperationException- if the origin cannot be converted to a Path.
 
- 
getPathGets this origin as a Path, if possible.- Returns:
- this origin as a Path, if possible.
- Throws:
- UnsupportedOperationException- if this method is not implemented in a concrete subclass.
 
- 
getRandomAccessFileGets this origin as a RandomAccessFile, if possible.- Parameters:
- openOption- options like- StandardOpenOption.
- Returns:
- this origin as a RandomAccessFile, if possible.
- Throws:
- FileNotFoundException- See- RandomAccessFile(File, String).
- UnsupportedOperationException- if this method is not implemented in a concrete subclass.
- Since:
- 2.18.0
 
- 
getReaderGets a new Reader on the origin, buffered by default.- Parameters:
- charset- the charset to use for decoding, null maps to the default Charset.
- Returns:
- a new Reader on the origin.
- Throws:
- IOException- if an I/O error occurs opening the file.
 
- 
getWriterGets a new Writer on the origin, buffered by default.- Parameters:
- charset- the charset to use for encoding
- options- options specifying how the file is opened
- Returns:
- a new Writer on the origin.
- Throws:
- IOException- if an I/O error occurs opening or creating the file.
- UnsupportedOperationException- if the origin cannot be converted to a Path.
 
- 
sizeGets the size of the origin, if possible.- Returns:
- the size of the origin in bytes or characters.
- Throws:
- IOException- if an I/O error occurs.
- Since:
- 2.13.0
 
- 
toString
 
-