Lines 51-59
Link Here
|
51 |
// Enclosed writer to which any output is written |
51 |
// Enclosed writer to which any output is written |
52 |
private Writer writer; |
52 |
private Writer writer; |
53 |
|
53 |
|
54 |
// See comment in setWriter() |
|
|
55 |
private int bufferSizeSave; |
56 |
|
57 |
/** |
54 |
/** |
58 |
* Constructor. |
55 |
* Constructor. |
59 |
*/ |
56 |
*/ |
Lines 508-513
Link Here
|
508 |
} |
505 |
} |
509 |
|
506 |
|
510 |
/** |
507 |
/** |
|
|
508 |
* This method returns the size of the buffer used by the JspWriter. |
509 |
* |
510 |
* @return the size of the buffer in bytes, or 0 is unbuffered. |
511 |
*/ |
512 |
public int getBufferSize() { |
513 |
// According to the spec, the JspWriter returned by |
514 |
// JspContext.pushBody(java.io.Writer writer) must behave as |
515 |
// though it were unbuffered. This means that its getBufferSize() |
516 |
// must always return 0. |
517 |
return (writer == null) ? bufferSize : 0; |
518 |
} |
519 |
|
520 |
/** |
511 |
* @return the number of bytes unused in the buffer |
521 |
* @return the number of bytes unused in the buffer |
512 |
*/ |
522 |
*/ |
513 |
public int getRemaining() { |
523 |
public int getRemaining() { |
Lines 558-579
Link Here
|
558 |
void setWriter(Writer writer) { |
568 |
void setWriter(Writer writer) { |
559 |
this.writer = writer; |
569 |
this.writer = writer; |
560 |
closed = false; |
570 |
closed = false; |
561 |
if (writer != null) { |
571 |
if (writer == null) { |
562 |
// According to the spec, the JspWriter returned by |
|
|
563 |
// JspContext.pushBody(java.io.Writer writer) must behave as |
564 |
// though it were unbuffered. This means that its getBufferSize() |
565 |
// must always return 0. The implementation of |
566 |
// JspWriter.getBufferSize() returns the value of JspWriter's |
567 |
// 'bufferSize' field, which is inherited by this class. |
568 |
// Therefore, we simply save the current 'bufferSize' (so we can |
569 |
// later restore it should this BodyContentImpl ever be reused by |
570 |
// a call to PageContext.pushBody()) before setting it to 0. |
571 |
if (bufferSize != 0) { |
572 |
bufferSizeSave = bufferSize; |
573 |
bufferSize = 0; |
574 |
} |
575 |
} else { |
576 |
bufferSize = bufferSizeSave; |
577 |
clearBody(); |
572 |
clearBody(); |
578 |
} |
573 |
} |
579 |
} |
574 |
} |