Browse Source

reduce size of big method

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@567593 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
8f4a67608a
1 changed files with 58 additions and 50 deletions
  1. +58
    -50
      src/main/org/apache/tools/ant/taskdefs/Redirector.java

+ 58
- 50
src/main/org/apache/tools/ant/taskdefs/Redirector.java View File

@@ -458,56 +458,8 @@ public class Redirector {
* configuration options. * configuration options.
*/ */
public synchronized void createStreams() { public synchronized void createStreams() {
if (out != null && out.length > 0) {
String logHead = new StringBuffer("Output ").append(
((append) ? "appended" : "redirected")).append(
" to ").toString();
outputStream = foldFiles(out, logHead, Project.MSG_VERBOSE);
}
if (outputProperty != null) {
if (baos == null) {
baos = new PropertyOutputStream(outputProperty);
managingTask.log("Output redirected to property: "
+ outputProperty, Project.MSG_VERBOSE);
}
//shield it from being closed by a filtering StreamPumper
OutputStream keepAliveOutput = new KeepAliveOutputStream(baos);
outputStream = (outputStream == null) ? keepAliveOutput
: new TeeOutputStream(outputStream, keepAliveOutput);
} else {
baos = null;
}

if (error != null && error.length > 0) {
String logHead = new StringBuffer("Error ").append(
((append) ? "appended" : "redirected")).append(
" to ").toString();
errorStream = foldFiles(error, logHead, Project.MSG_VERBOSE);
} else if (!(logError || outputStream == null)) {
long funnelTimeout = 0L;
OutputStreamFunneler funneler
= new OutputStreamFunneler(outputStream, funnelTimeout);
try {
outputStream = funneler.getFunnelInstance();
errorStream = funneler.getFunnelInstance();
} catch (IOException eyeOhEx) {
throw new BuildException(
"error splitting output/error streams", eyeOhEx);
}
}
if (errorProperty != null) {
if (errorBaos == null) {
errorBaos = new PropertyOutputStream(errorProperty);
managingTask.log("Error redirected to property: " + errorProperty,
Project.MSG_VERBOSE);
}
//shield it from being closed by a filtering StreamPumper
OutputStream keepAliveError = new KeepAliveOutputStream(errorBaos);
errorStream = (error == null || error.length == 0) ? keepAliveError
: new TeeOutputStream(errorStream, keepAliveError);
} else {
errorBaos = null;
}
outStreams();
errorStreams();
if (alwaysLog || outputStream == null) { if (alwaysLog || outputStream == null) {
OutputStream outputLog OutputStream outputLog
= new LogOutputStream(managingTask, Project.MSG_INFO); = new LogOutputStream(managingTask, Project.MSG_INFO);
@@ -620,6 +572,62 @@ public class Redirector {
} }
} }


/** outStreams */
private void outStreams() {
if (out != null && out.length > 0) {
String logHead = new StringBuffer("Output ").append(
((append) ? "appended" : "redirected")).append(
" to ").toString();
outputStream = foldFiles(out, logHead, Project.MSG_VERBOSE);
}
if (outputProperty != null) {
if (baos == null) {
baos = new PropertyOutputStream(outputProperty);
managingTask.log("Output redirected to property: "
+ outputProperty, Project.MSG_VERBOSE);
}
//shield it from being closed by a filtering StreamPumper
OutputStream keepAliveOutput = new KeepAliveOutputStream(baos);
outputStream = (outputStream == null) ? keepAliveOutput
: new TeeOutputStream(outputStream, keepAliveOutput);
} else {
baos = null;
}
}

private void errorStreams() {
if (error != null && error.length > 0) {
String logHead = new StringBuffer("Error ").append(
((append) ? "appended" : "redirected")).append(
" to ").toString();
errorStream = foldFiles(error, logHead, Project.MSG_VERBOSE);
} else if (!(logError || outputStream == null)) {
long funnelTimeout = 0L;
OutputStreamFunneler funneler
= new OutputStreamFunneler(outputStream, funnelTimeout);
try {
outputStream = funneler.getFunnelInstance();
errorStream = funneler.getFunnelInstance();
} catch (IOException eyeOhEx) {
throw new BuildException(
"error splitting output/error streams", eyeOhEx);
}
}
if (errorProperty != null) {
if (errorBaos == null) {
errorBaos = new PropertyOutputStream(errorProperty);
managingTask.log("Error redirected to property: " + errorProperty,
Project.MSG_VERBOSE);
}
//shield it from being closed by a filtering StreamPumper
OutputStream keepAliveError = new KeepAliveOutputStream(errorBaos);
errorStream = (error == null || error.length == 0) ? keepAliveError
: new TeeOutputStream(errorStream, keepAliveError);
} else {
errorBaos = null;
}
}

/** /**
* Create the StreamHandler to use with our Execute instance. * Create the StreamHandler to use with our Execute instance.
* *


Loading…
Cancel
Save