conor 2003/07/17 06:02:57 Modified: src/main/org/apache/tools/ant DemuxOutputStream.java src/main/org/apache/tools/ant/taskdefs LogOutputStream.java Log: Implement array writes for output processing Revision Changes Path 1.16 +30 -1 ant/src/main/org/apache/tools/ant/DemuxOutputStream.java Index: DemuxOutputStream.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/DemuxOutputStream.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -u -r1.15 -r1.16 --- DemuxOutputStream.java 17 Jul 2003 10:20:13 -0000 1.15 +++ DemuxOutputStream.java 17 Jul 2003 13:02:56 -0000 1.16 @@ -89,6 +89,9 @@ /** Maximum buffer size. */ private static final int MAX_SIZE = 1024; + /** Initial buffer size. */ + private static final int INTIAL_SIZE = 132; + /** Mapping from thread to buffer (Thread to BufferInfo). */ private Hashtable buffers = new Hashtable(); @@ -127,7 +130,7 @@ BufferInfo bufferInfo = (BufferInfo) buffers.get(current); if (bufferInfo == null) { bufferInfo = new BufferInfo(); - bufferInfo.buffer = new ByteArrayOutputStream(); + bufferInfo.buffer = new ByteArrayOutputStream(INTIAL_SIZE); bufferInfo.crSeen = false; buffers.put(current, bufferInfo); } @@ -237,6 +240,32 @@ BufferInfo bufferInfo = getBufferInfo(); if (bufferInfo.buffer.size() > 0) { processFlush(bufferInfo.buffer); + } + } + + public void write(byte b[], int off, int len) throws IOException { + // find the line breaks and pass other chars through in blocks + int offset = off; + int blockStartOffset = offset; + int remaining = len; + BufferInfo bufferInfo = getBufferInfo(); + while (remaining > 0) { + while (remaining > 0 && b[offset] != 0x0a && b[offset] != 0x0d) { + offset++; + remaining--; + } + // either end of buffer or a line separator char + int blockLength = offset - blockStartOffset; + if (blockLength > 0) { + project.log("Sending " + blockLength); + bufferInfo.buffer.write(b, blockStartOffset, blockLength); + } + while(remaining > 0 && (b[offset] == 0x0a || b[offset] == 0x0d)) { + write(b[offset]); + offset++; + remaining--; + } + blockStartOffset = offset; } } } 1.13 +30 -1 ant/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java Index: LogOutputStream.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -u -r1.12 -r1.13 --- LogOutputStream.java 6 Jul 2003 09:57:36 -0000 1.12 +++ LogOutputStream.java 17 Jul 2003 13:02:57 -0000 1.13 @@ -73,7 +73,11 @@ */ public class LogOutputStream extends OutputStream { - private ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + /** Initial buffer size. */ + private static final int INTIAL_SIZE = 132; + + private ByteArrayOutputStream buffer + = new ByteArrayOutputStream(INTIAL_SIZE); private boolean skip = false; private Task task; @@ -157,4 +161,29 @@ public int getMessageLevel() { return level; } + + public void write(byte b[], int off, int len) throws IOException { + // find the line breaks and pass other chars through in blocks + int offset = off; + int blockStartOffset = offset; + int remaining = len; + while (remaining > 0) { + while (remaining > 0 && b[offset] != 0x0a && b[offset] != 0x0d) { + offset++; + remaining--; + } + // either end of buffer or a line separator char + int blockLength = offset - blockStartOffset; + if (blockLength > 0) { + buffer.write(b, blockStartOffset, blockLength); + } + while(remaining > 0 && (b[offset] == 0x0a || b[offset] == 0x0d)) { + write(b[offset]); + offset++; + remaining--; + } + blockStartOffset = offset; + } + } + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]