Package org.apache.tools.ant.taskdefs
Class Redirector
java.lang.Object
org.apache.tools.ant.taskdefs.Redirector
The Redirector class manages the setup and connection of input and output
 redirection for an Ant project component.
- Since:
- Ant 1.6
- 
Constructor SummaryConstructorsConstructorDescriptionRedirector(ProjectComponent managingTask) Create a redirector instance for the given taskRedirector(Task managingTask) Create a redirector instance for the given task
- 
Method SummaryModifier and TypeMethodDescriptionvoidcomplete()Complete redirection.Create the StreamHandler to use with our Execute instance.voidCreate the input, error and output streams based on the configuration options.Get the error stream for the redirectorGet the input stream for the redirectorGet the output stream for the redirectorprotected voidhandleErrorFlush(String output) Handle a flush operation on the error streamprotected voidhandleErrorOutput(String output) Process error outputprotected voidhandleFlush(String output) Process data due to a flush operation.protected inthandleInput(byte[] buffer, int offset, int length) Handle an input requestprotected voidhandleOutput(String output) Pass output sent to System.out to specified output.voidsetAlwaysLog(boolean alwaysLog) If true, (error and non-error) output will be "teed", redirected as specified while being sent to Ant's logging mechanism as if no redirection had taken place.voidsetAppend(boolean append) Whether output should be appended to or overwrite an existing file.voidsetAppendProperties(boolean appendProperties) ThisRedirector's subordinatePropertyOutputStreams will not set their respective propertieswhile (appendProperties && append).voidsetBinaryOutput(boolean b) Whether to consider the output created by the process binary.voidsetCreateEmptyFiles(boolean createEmptyFiles) Whether output and error files should be created even when empty.voidsetDiscardError(boolean discard) Whether error output should be discarded.voidsetDiscardOutput(boolean discard) Whether output should be discarded.voidSet the file to which standard error is to be redirected.voidSet the files to which standard error is to be redirected.voidsetErrorEncoding(String errorEncoding) Set the error encoding.voidsetErrorFilterChains(Vector<FilterChain> errorFilterChains) Set the errorFilterChains.voidsetErrorProperty(String errorProperty) Property name whose value should be set to the error of the process.voidSet the input to use for the taskvoidSet the input to use for the taskvoidsetInputEncoding(String inputEncoding) Set the input encoding.voidsetInputFilterChains(Vector<FilterChain> inputFilterChains) Set the inputFilterChains.voidsetInputString(String inputString) Set the string to use as inputvoidsetLogError(boolean logError) Controls whether error output of exec is logged.voidsetLogInputString(boolean logInputString) Set whether to include the value of the input string in log messages.voidFile the output of the process is redirected to.voidFiles the output of the process is redirected to.voidsetOutputEncoding(String outputEncoding) Set the output encoding.voidsetOutputFilterChains(Vector<FilterChain> outputFilterChains) Set the outputFilterChains.voidsetOutputProperty(String outputProperty) Property name whose value should be set to the output of the process.voidNotify theRedirectorthat it is now okay to set any output and/or error properties.
- 
Constructor Details- 
RedirectorCreate a redirector instance for the given task- Parameters:
- managingTask- the task for which the redirector is to work
 
- 
RedirectorCreate a redirector instance for the given task- Parameters:
- managingTask- the project component for which the redirector is to work
- Since:
- Ant 1.6.3
 
 
- 
- 
Method Details- 
setInputSet the input to use for the task- Parameters:
- input- the file from which input is read.
 
- 
setInputSet the input to use for the task- Parameters:
- input- the files from which input is read.
 
- 
setInputStringSet the string to use as input- Parameters:
- inputString- the string which is used as the input source
 
- 
setLogInputStringpublic void setLogInputString(boolean logInputString) Set whether to include the value of the input string in log messages. Defaults to true.- Parameters:
- logInputString- true or false.
- Since:
- Ant 1.7
 
- 
setOutputFile the output of the process is redirected to. If error is not redirected, it too will appear in the output- Parameters:
- out- the file to which output stream is written
 
- 
setOutputFiles the output of the process is redirected to. If error is not redirected, it too will appear in the output- Parameters:
- out- the files to which output stream is written
 
- 
setOutputEncodingSet the output encoding.- Parameters:
- outputEncoding-- String.
 
- 
setErrorEncodingSet the error encoding.- Parameters:
- errorEncoding-- String.
 
- 
setInputEncodingSet the input encoding.- Parameters:
- inputEncoding-- String.
 
- 
setLogErrorpublic 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- Parameters:
- logError- if true the standard error is sent to the Ant log system and not sent to output.
 
- 
setAppendPropertiespublic void setAppendProperties(boolean appendProperties) ThisRedirector's subordinatePropertyOutputStreams will not set their respective propertieswhile (appendProperties && append).- Parameters:
- appendProperties- whether to append properties.
 
- 
setErrorSet the file to which standard error is to be redirected.- Parameters:
- error- the file to which error is to be written
 
- 
setErrorSet the files to which standard error is to be redirected.- Parameters:
- error- the file to which error is to be written
 
- 
setOutputPropertyProperty name whose value should be set to the output of the process.- Parameters:
- outputProperty- the name of the property to be set with the task's output.
 
- 
setAppendpublic void setAppend(boolean append) Whether output should be appended to or overwrite an existing file. Defaults to false.- Parameters:
- append- if true output and error streams are appended to their respective files, if specified.
 
- 
setDiscardOutputpublic void setDiscardOutput(boolean discard) Whether output should be discarded.Defaults to false. - Parameters:
- discard- if true output streams are discarded.
- Since:
- Ant 1.10.10
- See Also:
 
- 
setDiscardErrorpublic void setDiscardError(boolean discard) Whether error output should be discarded.Defaults to false. - Parameters:
- discard- if true error streams are discarded.
- Since:
- Ant 1.10.10
- See Also:
 
- 
setAlwaysLogpublic void setAlwaysLog(boolean alwaysLog) If true, (error and non-error) output will be "teed", redirected as specified while being sent to Ant's logging mechanism as if no redirection had taken place. Defaults to false.- Parameters:
- alwaysLog-- boolean
- Since:
- Ant 1.6.3
 
- 
setCreateEmptyFilespublic void setCreateEmptyFiles(boolean createEmptyFiles) Whether output and error files should be created even when empty. Defaults to true.- Parameters:
- createEmptyFiles-- boolean.
 
- 
setErrorPropertyProperty name whose value should be set to the error of the process.- Parameters:
- errorProperty- the name of the property to be set with the error output.
 
- 
setInputFilterChainsSet the inputFilterChains.- Parameters:
- inputFilterChains-- Vectorcontaining- FilterChain.
 
- 
setOutputFilterChainsSet the outputFilterChains.- Parameters:
- outputFilterChains-- Vectorcontaining- FilterChain.
 
- 
setErrorFilterChainsSet the errorFilterChains.- Parameters:
- errorFilterChains-- Vectorcontaining- FilterChain.
 
- 
setBinaryOutputpublic void setBinaryOutput(boolean b) Whether to consider the output created by the process binary.Binary output will not be split into lines which may make error and normal output look mixed up when they get written to the same stream. - Parameters:
- b- boolean
- Since:
- 1.9.4
 
- 
createStreamspublic void createStreams()Create the input, error and output streams based on the configuration options.
- 
createHandlerCreate the StreamHandler to use with our Execute instance.- Returns:
- the execute stream handler to manage the input, output and error streams.
- Throws:
- BuildException- if the execute stream handler cannot be created.
 
- 
handleOutputPass output sent to System.out to specified output.- Parameters:
- output- the data to be output
 
- 
handleInputHandle an input request- Parameters:
- 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
- Returns:
- the number of bytes read
- Throws:
- IOException- if the data cannot be read
 
- 
handleFlushProcess data due to a flush operation.- Parameters:
- output- the data being flushed.
 
- 
handleErrorOutputProcess error output- Parameters:
- output- the error output data.
 
- 
handleErrorFlushHandle a flush operation on the error stream- Parameters:
- output- the error information being flushed.
 
- 
getOutputStreamGet the output stream for the redirector- Returns:
- the redirector's output stream or null if no output has been configured
 
- 
getErrorStreamGet the error stream for the redirector- Returns:
- the redirector's error stream or null if no output has been configured
 
- 
getInputStreamGet the input stream for the redirector- Returns:
- the redirector's input stream or null if no output has been configured
 
- 
completeComplete redirection. This operation will close any streams and create any specified property values.- Throws:
- IOException- if the output properties cannot be read from their output streams.
 
- 
setPropertiespublic void setProperties()Notify theRedirectorthat it is now okay to set any output and/or error properties.
 
-