LeadPipeInputStreampublic class LeadPipeInputStream extends PipedInputStream Special PipedInputStream that will not die
when the writing Thread is no longer alive. |
Fields Summary |
---|
private org.apache.tools.ant.ProjectComponent | managingPc |
Constructors Summary |
---|
public LeadPipeInputStream()Construct a new LeadPipeInputStream .
super();
| public LeadPipeInputStream(int size)Construct a new LeadPipeInputStream
with the specified buffer size.
super();
setBufferSize(size);
| public LeadPipeInputStream(PipedOutputStream src)Construct a new LeadPipeInputStream to pull
from the specified PipedOutputStream .
super(src);
| public LeadPipeInputStream(PipedOutputStream src, int size)Construct a new LeadPipeInputStream to pull
from the specified PipedOutputStream , using a
circular buffer of the specified size.
super(src);
setBufferSize(size);
|
Methods Summary |
---|
public void | log(java.lang.String message, int loglevel)Log a message with the specified logging level.
if (managingPc != null) {
managingPc.log(message, loglevel);
} else {
if (loglevel > Project.MSG_WARN) {
System.out.println(message);
} else {
System.err.println(message);
}
}
| public synchronized int | read()Read a byte from the stream.
int result = -1;
try {
result = super.read();
} catch (IOException eyeOhEx) {
if ("write end dead".equalsIgnoreCase(eyeOhEx.getMessage())) {
if (super.in > 0 && super.out < super.buffer.length
&& super.out > super.in) {
result = super.buffer[super.out++] & 0xFF;
}
} else {
log("error at LeadPipeInputStream.read(): "
+ eyeOhEx.getMessage(), Project.MSG_INFO);
}
}
return result;
| public synchronized void | setBufferSize(int size)Set the size of the buffer.
if (size > buffer.length) {
byte[] newBuffer = new byte[size];
if (in >= 0) {
if (in > out) {
System.arraycopy(buffer, out, newBuffer, out, in - out);
} else {
int outlen = buffer.length - out;
System.arraycopy(buffer, out, newBuffer, 0, outlen);
System.arraycopy(buffer, 0, newBuffer, outlen, in);
in += outlen;
out = 0;
}
}
buffer = newBuffer;
}
| public void | setManagingComponent(org.apache.tools.ant.ProjectComponent pc)Set a managing ProjectComponent for
this LeadPipeInputStream .
this.managingPc = pc;
| public void | setManagingTask(org.apache.tools.ant.Task task)Set a managing Task for
this LeadPipeInputStream .
setManagingComponent(task);
|
|