Class DefaultCommandProcess
java.lang.Object
com.thebuzzmedia.exiftool.process.executor.DefaultCommandProcess
- All Implemented Interfaces:
CommandProcess
,AutoCloseable
Default implementation for
This implementation used instance of
Note: This implementation is not thread safe.
CommandProcess
interface.
This implementation used instance of
InputStream
to handle
read operation and instance of OutputStream
to handle write
operation. These streams may come from instance of Process
for instance.
Note: This implementation is not thread safe.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCommandProcess
(InputStream is, OutputStream os, InputStream err) Create process. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
flush()
Flush pending write operations.boolean
isClosed()
Check if current process has been closed.boolean
Check if current process is still opened.read()
Read output until a null line is read.read
(OutputHandler handler) Read output until: A null line is read. Handler returns false when line is read. Since command process will not be closed, a simple string is returned (an exit status cannot be computed).void
Write set of inputs to the current process.void
Write input string to the current process.
-
Constructor Details
-
DefaultCommandProcess
Create process.- Parameters:
is
- Input stream.os
- Output stream.err
- Error stream.
-
-
Method Details
-
read
Description copied from interface:CommandProcess
Read output until a null line is read.
Since command process will not be closed, a simple string is returned (an exit status cannot be computed).- Specified by:
read
in interfaceCommandProcess
- Returns:
- Command result.
- Throws:
IOException
- If an error occurred during operation.
-
read
Description copied from interface:CommandProcess
Read output until:- A null line is read.
- Handler returns false when line is read.
- Specified by:
read
in interfaceCommandProcess
- Parameters:
handler
- Output handler.- Returns:
- Full output.
- Throws:
IOException
- If an error occurred during operation.
-
write
Description copied from interface:CommandProcess
Write input string to the current process.- Specified by:
write
in interfaceCommandProcess
- Parameters:
input
- Input.others
- Other inputs.- Throws:
IOException
- If an error occurred during operation.
-
write
Description copied from interface:CommandProcess
Write set of inputs to the current process.- Specified by:
write
in interfaceCommandProcess
- Parameters:
inputs
- Collection of inputs.- Throws:
IOException
- If an error occurred during operation.
-
flush
Description copied from interface:CommandProcess
Flush pending write operations.- Specified by:
flush
in interfaceCommandProcess
- Throws:
IOException
- If an error occurred during operation.
-
isRunning
public boolean isRunning()Description copied from interface:CommandProcess
Check if current process is still opened. If this method returnstrue
, thenCommandProcess.isClosed()
should returnfalse
.- Specified by:
isRunning
in interfaceCommandProcess
- Returns:
true
if process is open,false
otherwise.
-
isClosed
public boolean isClosed()Description copied from interface:CommandProcess
Check if current process has been closed. If this method returnstrue
, thenCommandProcess.isRunning()
should returnfalse
.- Specified by:
isClosed
in interfaceCommandProcess
- Returns:
true
if process is closed,false
otherwise.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-