luehe 2003/01/13 17:56:05 Modified: jasper2/src/share/org/apache/jasper/runtime BodyContentImpl.java Log: Removed redundant 'isBodyContent' and added comment about 'bufferSizeSave' Revision Changes Path 1.8 +24 -19 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/BodyContentImpl.java Index: BodyContentImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/BodyContentImpl.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- BodyContentImpl.java 10 Oct 2002 15:33:29 -0000 1.7 +++ BodyContentImpl.java 14 Jan 2003 01:56:05 -0000 1.8 @@ -83,13 +83,7 @@ // Enclosed writer to which any output is written private Writer writer; - /* - * Indicates whether this BodyContentImpl is returned as the result of a - * call to JspContext.pushBody(java.io.Writer) (FALSE) or - * PageContext.pushBody() (TRUE) - */ - private boolean isBodyContent; - + // See comment in setWriter() private int bufferSizeSave; /** @@ -505,10 +499,10 @@ * @throws IOException If an I/O error occurs */ public void clear() throws IOException { - if (isBodyContent) { - nextChar = 0; - } else { + if (writer != null) { throw new IOException(); + } else { + nextChar = 0; } } @@ -521,7 +515,9 @@ * @throws IOException If an I/O error occurs */ public void clearBuffer() throws IOException { - if (isBodyContent) this.clear(); + if (writer == null) { + this.clear(); + } } /** @@ -544,7 +540,7 @@ * @return the number of bytes unused in the buffer */ public int getRemaining() { - return isBodyContent ? bufferSize-nextChar : 0; + return (writer == null) ? bufferSize-nextChar : 0; } /** @@ -555,7 +551,7 @@ * @return the value of this BodyJspWriter as a Reader */ public Reader getReader() { - return isBodyContent ? new CharArrayReader (cb, 0, nextChar) : null; + return (writer == null) ? new CharArrayReader (cb, 0, nextChar) : null; } /** @@ -566,7 +562,7 @@ * @return the value of the BodyJspWriter as a String */ public String getString() { - return isBodyContent ? new String(cb, 0, nextChar) : null; + return (writer == null) ? new String(cb, 0, nextChar) : null; } /** @@ -578,7 +574,7 @@ * evaluation */ public void writeOut(Writer out) throws IOException { - if (isBodyContent) { + if (writer == null) { out.write(cb, 0, nextChar); // Flush not called as the writer passed could be a BodyContent and // it doesn't allow to flush. @@ -600,11 +596,20 @@ void setWriter(Writer writer) { this.writer = writer; if (writer != null) { - isBodyContent = false; - bufferSizeSave = bufferSize; - bufferSize = 0; + // According to the spec, the JspWriter returned by + // JspContext.pushBody(java.io.Writer writer) must behave as + // though it were unbuffered. This means that its getBufferSize() + // must always return 0. The implementation of + // JspWriter.getBufferSize() returns the value of JspWriter's + // 'bufferSize' field, which is inherited by this class. + // Therefore, we simply save the current 'bufferSize' (so we can + // later restore it should this BodyContentImpl ever be reused by + // a call to PageContext.pushBody()) before setting it to 0. + if (bufferSize != 0) { + bufferSizeSave = bufferSize; + bufferSize = 0; + } } else { - isBodyContent = true; bufferSize = bufferSizeSave; clearBody(); }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>