The Redirector class manages the setup and connection of
input and output redirection for an Ant task.
complete
public void complete()
throws IOException
Complete redirection.
This operation will close any streams and create any specified
property values.
createHandler
public ExecuteStreamHandler createHandler()
throws BuildException
Create the StreamHandler to use with our Execute instance.
- the execute stream handler to manage the input, output and
error streams.
BuildException
- if the execute stream handler cannot be created.
createStreams
public void createStreams()
Create the input, error and output streams based on the
configuration options.
getErrorStream
public OutputStream getErrorStream()
Get the error stream for the redirector
- the redirector's error stream or null if no output
has been configured
getInputStream
public InputStream getInputStream()
Get the input stream for the redirector
- the redirector's input stream or null if no output
has been configured
getOutputStream
public OutputStream getOutputStream()
Get the output stream for the redirector
- the redirector's output stream or null if no output
has been configured
handleErrorFlush
protected void handleErrorFlush(String output)
Handle a flush operation on the error stream
output
- the error information being flushed.
handleErrorOutput
protected void handleErrorOutput(String output)
Process error output
output
- the error output data.
handleFlush
protected void handleFlush(String output)
Process data due to a flush operation.
output
- the data being flushed.
handleInput
protected int handleInput(byte[] buffer,
int offset,
int length)
throws IOException
Handle an input request
buffer
- the buffer into which data is to be read.offset
- the offset into the buffer at which data is stored.length
- the amount of data to read
- the number of bytes read
handleOutput
protected void handleOutput(String output)
Pass output sent to System.out to specified output.
output
- the data to be output
setAppend
public void setAppend(boolean append)
Whether output should be appended to or overwrite an existing file.
Defaults to false.
append
- if true output and error streams are appended to their
respective files, if specified.
setAppendProperties
public void setAppendProperties(boolean appendProperties)
This Redirector
's subordinate
PropertyOutputStream
s will not set their respective
properties while (appendProperties && append)
.
appendProperties
- whether to append properties.
setCreateEmptyFiles
public void setCreateEmptyFiles(boolean createEmptyFiles)
Whether output and error files should be created even when empty.
Defaults to true.
createEmptyFiles
- boolean
.
setError
public void setError(File error)
Set the file to which standard error is to be redirected.
error
- the file to which error is to be written
setError
public void setError(File[] error)
Set the files to which standard error is to be redirected.
error
- the file to which error is to be written
setErrorEncoding
public void setErrorEncoding(String errorEncoding)
Set the error encoding.
errorEncoding
- String
.
setErrorFilterChains
public void setErrorFilterChains(Vector errorFilterChains)
Set the error FilterChain
s.
errorFilterChains
- Vector
containing FilterChain
.
setErrorProperty
public void setErrorProperty(String errorProperty)
Property name whose value should be set to the error of
the process.
errorProperty
- the name of the property to be set
with the error output.
setInput
public void setInput(File input)
Set the input to use for the task
input
- the file from which input is read.
setInput
public void setInput(File[] input)
Set the input to use for the task
input
- the files from which input is read.
setInputEncoding
public void setInputEncoding(String inputEncoding)
Set the input encoding.
inputEncoding
- String
.
setInputFilterChains
public void setInputFilterChains(Vector inputFilterChains)
Set the input FilterChain
s.
inputFilterChains
- Vector
containing FilterChain
.
setInputString
public void setInputString(String inputString)
Set the string to use as input
inputString
- the string which is used as the input source
setLogError
public void setLogError(boolean logError)
Controls whether error output of exec is logged. This is only useful
when output is being redirected and error output is desired in the
Ant log
logError
- if true the standard error is sent to the Ant log system
and not sent to output.
setOutput
public void setOutput(File out)
File the output of the process is redirected to. If error is not
redirected, it too will appear in the output
out
- the file to which output stream is written
setOutput
public void setOutput(File[] out)
Files the output of the process is redirected to. If error is not
redirected, it too will appear in the output
out
- the files to which output stream is written
setOutputEncoding
public void setOutputEncoding(String outputEncoding)
Set the output encoding.
outputEncoding
- String
.
setOutputFilterChains
public void setOutputFilterChains(Vector outputFilterChains)
Set the output FilterChain
s.
outputFilterChains
- Vector
containing FilterChain
.
setOutputProperty
public void setOutputProperty(String outputProperty)
Property name whose value should be set to the output of
the process.
outputProperty
- the name of the property to be set with the
task's output.
setProperties
public void setProperties()
Notify the Redirector
that it is now okay
to set any output and/or error properties.