Package org.wildfly.plugin.common
Class StandardOutput
- java.lang.Object
-
- org.wildfly.plugin.common.StandardOutput
-
public class StandardOutput extends Object
Information on how thestdout
should be consumed.- Author:
- James R. Perkins
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StandardOutput.Target
The target for the the output stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<ProcessBuilder.Redirect>
getRedirect()
An option redirect for thestdout
.Path
getStdoutPath()
The path to the file where the data was written.StandardOutput.Target
getTarget()
The target the data was written to.static boolean
isFile(String output)
static StandardOutput
parse(String stdout, boolean discardNone)
Parses the string and attempts to determine where the data for the stream should be written.static StandardOutput
parse(String stdout, boolean discardNone, boolean append)
Parses the string and attempts to determine where the data for the stream should be written.The following are the options for the value:none
indicates the data for this stream will be consumed andtoString()
will return the data of thediscardNone
parameter isfalse
, otherwise the data will be discardedSystem.out
orSystem.err
to write to the respective stream Any other value is assumed to be the path to a file and the data will written to the fileOptional<Thread>
startConsumer(Process process)
If the processesstdout
should be consumed a thread which consumes it will be started.String
toString()
-
-
-
Method Detail
-
parse
public static StandardOutput parse(String stdout, boolean discardNone) throws IOException
Parses the string and attempts to determine where the data for the stream should be written. The following are the options for the value:none
indicates the data for this stream will be consumed andtoString()
will return the data of thediscardNone
parameter isfalse
, otherwise the data will be discardedSystem.out
orSystem.err
to write to the respective stream- Any other value is assumed to be the path to a file and the data will written to the file
- Parameters:
stdout
- the value to be parseddiscardNone
-true
if thestdout
value isnone
and the data should be discarded, otherwise the data will be consumed if thestdout
value isnone
and will be available viatoString()
- Returns:
- a new output stream
- Throws:
IOException
- if there is an error creating the stream
-
parse
public static StandardOutput parse(String stdout, boolean discardNone, boolean append) throws IOException
Parses the string and attempts to determine where the data for the stream should be written.The following are the options for the value:none
indicates the data for this stream will be consumed andtoString()
will return the data of thediscardNone
parameter isfalse
, otherwise the data will be discardedSystem.out
orSystem.err
to write to the respective stream- Any other value is assumed to be the path to a file and the data will written to the file
- Parameters:
stdout
- the value to be parseddiscardNone
-true
if thestdout
value isnone
and the data should be discarded, otherwise the data will be consumed if thestdout
value isnone
and will be available viatoString()
append
- If stdout is a file, append output to existing file if true, otherwise a new file is created.- Returns:
- a new output stream
- Throws:
IOException
- if there is an error creating the stream
-
isFile
public static boolean isFile(String output)
-
getRedirect
public Optional<ProcessBuilder.Redirect> getRedirect()
An option redirect for thestdout
.- Returns:
- the optional redirect
-
startConsumer
public Optional<Thread> startConsumer(Process process)
If the processesstdout
should be consumed a thread which consumes it will be started.- Parameters:
process
- the process to possibly start the thread for- Returns:
- the optional thread
-
getStdoutPath
public Path getStdoutPath()
The path to the file where the data was written.- Returns:
- the path to where the data was written, otherwise {@link null} if the data was not written to a file.
-
getTarget
public StandardOutput.Target getTarget()
The target the data was written to.- Returns:
- the target
-
-