Package adams.core.management
Class AbstractOutputPrinter
- java.lang.Object
-
- adams.core.management.AbstractOutputPrinter
-
- Direct Known Subclasses:
DefaultOutputPrinter
public abstract class AbstractOutputPrinter extends Object
Ancestor for printer objects for processes.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
OutputProcessStream
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringm_IDthe ID of the process.protected BufferedReaderm_Readerthe reader.protected booleanm_StdOutwhether to output to stdout.
-
Constructor Summary
Constructors Constructor Description AbstractOutputPrinter(boolean stdout, Process process)Initializes the printer.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringgetID()Returns the ID in use.protected voidinitialize(boolean stdout, Process process)Initializes the printer.booleanisStdOut()Returns whether stdout or stderr is used.protected abstract voidoutput(String line)Outputs the specified line.booleanprocess()Reads and outputs (if possible) a line from the reader.protected Stringread()Reads a line from the reader and returns it.StringtoString()Returns a short description.
-
-
-
Field Detail
-
m_StdOut
protected boolean m_StdOut
whether to output to stdout.
-
m_ID
protected String m_ID
the ID of the process.
-
m_Reader
protected BufferedReader m_Reader
the reader.
-
-
Constructor Detail
-
AbstractOutputPrinter
public AbstractOutputPrinter(boolean stdout, Process process)Initializes the printer.- Parameters:
stdout- whether to use stdout or stderrprocess- the process to monitor
-
-
Method Detail
-
initialize
protected void initialize(boolean stdout, Process process)Initializes the printer.- Parameters:
stdout- whether to use stdout or stderrprocess- the process to monitor
-
getID
public String getID()
Returns the ID in use.- Returns:
- the ID
-
isStdOut
public boolean isStdOut()
Returns whether stdout or stderr is used.- Returns:
- true if stdout is used
-
read
protected String read()
Reads a line from the reader and returns it.- Returns:
- the line read, or null in case of error
-
output
protected abstract void output(String line)
Outputs the specified line.- Parameters:
line- the text to output
-
process
public boolean process()
Reads and outputs (if possible) a line from the reader.
-
-