Package org.wildfly.plugin.common
Class StandardOutput
- java.lang.Object
-
- org.wildfly.plugin.common.StandardOutput
-
public class StandardOutput extends Object
Information on how thestdoutshould be consumed.- Author:
- James R. Perkins
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStandardOutput.TargetThe 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.PathgetStdoutPath()The path to the file where the data was written.StandardOutput.TargetgetTarget()The target the data was written to.static booleanisFile(String output)static StandardOutputparse(String stdout, boolean discardNone)Parses the string and attempts to determine where the data for the stream should be written.static StandardOutputparse(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:noneindicates the data for this stream will be consumed andtoString()will return the data of thediscardNoneparameter isfalse, otherwise the data will be discardedSystem.outorSystem.errto 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 processesstdoutshould be consumed a thread which consumes it will be started.StringtoString()
-
-
-
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:noneindicates the data for this stream will be consumed andtoString()will return the data of thediscardNoneparameter isfalse, otherwise the data will be discardedSystem.outorSystem.errto 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-trueif thestdoutvalue isnoneand the data should be discarded, otherwise the data will be consumed if thestdoutvalue isnoneand 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:noneindicates the data for this stream will be consumed andtoString()will return the data of thediscardNoneparameter isfalse, otherwise the data will be discardedSystem.outorSystem.errto 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-trueif thestdoutvalue isnoneand the data should be discarded, otherwise the data will be consumed if thestdoutvalue isnoneand 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 processesstdoutshould 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
-
-