Package org.apache.commons.io.input
Class Tailer.Builder
java.lang.Object
org.apache.commons.io.build.AbstractSupplier<Tailer,Tailer.Builder>
org.apache.commons.io.build.AbstractOriginSupplier<Tailer,Tailer.Builder>
org.apache.commons.io.build.AbstractStreamBuilder<Tailer,Tailer.Builder>
org.apache.commons.io.input.Tailer.Builder
- All Implemented Interfaces:
IOSupplier<Tailer>
- Enclosing class:
Tailer
Builds a
Tailer
with default values.
For example:
Tailer t = Tailer.builder()
.setPath(path)
.setCharset(StandardCharsets.UTF_8)
.setDelayDuration(Duration.ofSeconds(1))
.setExecutorService(Executors.newSingleThreadExecutor(Builder::newDaemonThread))
.setReOpen(false)
.setStartThread(true)
.setTailable(tailable)
.setTailerListener(tailerListener)
.setTailFromEnd(false)
.get();
- Since:
- 2.12.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Duration
private Duration
private boolean
private ExecutorService
private boolean
private boolean
private Tailer.Tailable
private TailerListener
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget()
Constructs a new instance.private static Thread
newDaemonThread
(Runnable runnable) Creates a new daemon thread.setDelayDuration
(Duration delayDuration) Sets the delay duration.setExecutorService
(ExecutorService executorService) Sets the executor service to use when startThread is true.protected Tailer.Builder
setOrigin
(AbstractOrigin<?, ?> origin) Sets the origin.setReOpen
(boolean reOpen) Sets the re-open behavior.setStartThread
(boolean startThread) Sets the daemon thread startup behavior.setTailable
(Tailer.Tailable tailable) Sets the tailable.setTailerListener
(TailerListener tailerListener) Sets the listener.setTailFromEnd
(boolean end) Sets the tail start behavior.Methods inherited from class org.apache.commons.io.build.AbstractStreamBuilder
getBufferSize, getBufferSizeDefault, getCharSequence, getCharset, getCharsetDefault, getInputStream, getOpenOptions, getOutputStream, getPath, getWriter, setBufferSize, setBufferSize, setBufferSizeDefault, setCharset, setCharset, setCharsetDefault, setOpenOptions
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, 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
-
Field Details
-
DEFAULT_DELAY_DURATION
-
tailable
-
tailerListener
-
delayDuration
-
end
private boolean end -
reOpen
private boolean reOpen -
startThread
private boolean startThread -
executorService
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
newDaemonThread
Creates a new daemon thread.- Parameters:
runnable
- the thread's runnable.- Returns:
- a new daemon thread.
-
get
Constructs a new instance.This builder use the aspects tailable, Charset, TailerListener, delayDuration, end, reOpen, buffer size.
- Returns:
- a new instance.
-
setDelayDuration
Sets the delay duration. null resets to the default delay of one second.- Parameters:
delayDuration
- the delay between checks of the file for new content.- Returns:
- this
-
setExecutorService
Sets the executor service to use when startThread is true.- Parameters:
executorService
- the executor service to use when startThread is true.- Returns:
- this
-
setOrigin
Sets the origin.- Overrides:
setOrigin
in classAbstractOriginSupplier<Tailer,
Tailer.Builder> - Parameters:
origin
- the new origin.- Returns:
- this
- Throws:
UnsupportedOperationException
- if the origin cannot be converted to a Path.
-
setReOpen
Sets the re-open behavior.- Parameters:
reOpen
- whether to close/reopen the file between chunks- Returns:
- this
-
setStartThread
Sets the daemon thread startup behavior.- Parameters:
startThread
- whether to create a daemon thread automatically.- Returns:
- this
-
setTailable
Sets the tailable.- Parameters:
tailable
- the tailable.- Returns:
- this.
-
setTailerListener
Sets the listener.- Parameters:
tailerListener
- the listener.- Returns:
- this
-
setTailFromEnd
Sets the tail start behavior.- Parameters:
end
- Set to true to tail from the end of the file, false to tail from the beginning of the file.- Returns:
- this
-