| Method from org.apache.catalina.connector.OutputBuffer Detail: |
public void checkConverter() throws IOException {
if (!gotEnc)
setConverter();
}
|
public void clearEncoders() {
encoders.clear();
}
Clear cached encoders (to save memory for Comet requests). |
public void close() throws IOException {
if (closed)
return;
if (suspended)
return;
if ((!coyoteResponse.isCommitted())
&& (coyoteResponse.getContentLengthLong() == -1)) {
// If this didn't cause a commit of the response, the final content
// length can be calculated
if (!coyoteResponse.isCommitted()) {
coyoteResponse.setContentLength(bb.getLength());
}
}
doFlush(false);
closed = true;
coyoteResponse.finish();
}
Close the output buffer. This tries to calculate the response size if
the response has not been committed yet. |
protected void doFlush(boolean realFlush) throws IOException {
if (suspended)
return;
doFlush = true;
if (initial) {
coyoteResponse.sendHeaders();
initial = false;
}
if (bb.getLength() > 0) {
bb.flushBuffer();
}
doFlush = false;
if (realFlush) {
coyoteResponse.action(ActionCode.ACTION_CLIENT_FLUSH,
coyoteResponse);
// If some exception occurred earlier, or if some IOE occurred
// here, notify the servlet with an IOE
if (coyoteResponse.isExceptionPresent()) {
throw new ClientAbortException
(coyoteResponse.getErrorException());
}
}
}
Flush bytes or chars contained in the buffer. |
public void flush() throws IOException {
doFlush(true);
}
Flush bytes or chars contained in the buffer. |
public void flushBytes() throws IOException {
bb.flushBuffer();
}
Real write - this buffer will be sent to the client |
public int getBufferSize() {
return bb.getLimit();
}
|
public int getBytesWritten() {
if (bytesWritten < Integer.MAX_VALUE) {
return (int) bytesWritten;
}
return -1;
}
|
public int getCharsWritten() {
if (charsWritten < Integer.MAX_VALUE) {
return (int) charsWritten;
}
return -1;
}
|
public int getContentWritten() {
long size = bytesWritten + charsWritten ;
if (size < Integer.MAX_VALUE) {
return (int) size;
}
return -1;
}
|
public long getContentWrittenLong() {
return bytesWritten + charsWritten;
}
|
public Response getResponse() {
return this.coyoteResponse;
}
Get associated Coyote response. |
public boolean isClosed() {
return this.closed;
}
Is the response output closed ? |
public boolean isNew() {
return (bytesWritten == 0) && (charsWritten == 0);
}
True if this buffer hasn't been used ( since recycle() ) -
i.e. no chars or bytes have been added to the buffer. |
public boolean isSuspended() {
return this.suspended;
}
Is the response output suspended ? |
public void realWriteBytes(byte[] buf,
int off,
int cnt) throws IOException {
if (closed)
return;
if (coyoteResponse == null)
return;
// If we really have something to write
if (cnt > 0) {
// real write to the adapter
outputChunk.setBytes(buf, off, cnt);
try {
coyoteResponse.doWrite(outputChunk);
} catch (IOException e) {
// An IOException on a write is almost always due to
// the remote client aborting the request. Wrap this
// so that it can be handled better by the error dispatcher.
throw new ClientAbortException(e);
}
}
}
Sends the buffer data to the client output, checking the
state of Response and calling the right interceptors. |
public void recycle() {
initial = true;
bytesWritten = 0;
charsWritten = 0;
bb.recycle();
closed = false;
suspended = false;
if (conv!= null) {
conv.recycle();
}
gotEnc = false;
enc = null;
}
Recycle the output buffer. |
public void reset() {
bb.recycle();
bytesWritten = 0;
charsWritten = 0;
gotEnc = false;
enc = null;
initial = true;
}
|
public void setBufferSize(int size) {
if (size > bb.getLimit()) {// ??????
bb.setLimit(size);
}
}
|
protected void setConverter() throws IOException {
if (coyoteResponse != null)
enc = coyoteResponse.getCharacterEncoding();
gotEnc = true;
if (enc == null)
enc = DEFAULT_ENCODING;
conv = (C2BConverter) encoders.get(enc);
if (conv == null) {
if (Globals.IS_SECURITY_ENABLED){
try{
conv = (C2BConverter)AccessController.doPrivileged(
new PrivilegedExceptionAction(){
public Object run() throws IOException{
return new C2BConverter(bb, enc);
}
}
);
}catch(PrivilegedActionException ex){
Exception e = ex.getException();
if (e instanceof IOException)
throw (IOException)e;
}
} else {
conv = new C2BConverter(bb, enc);
}
encoders.put(enc, conv);
}
}
|
public void setEncoding(String s) {
enc = s;
}
|
public void setResponse(Response coyoteResponse) {
this.coyoteResponse = coyoteResponse;
}
Associated Coyote response. |
public void setSuspended(boolean suspended) {
this.suspended = suspended;
}
|
public void write(int c) throws IOException {
if (suspended)
return;
conv.convert((char) c);
conv.flushBuffer();
charsWritten++;
}
|
public void write(char[] c) throws IOException {
if (suspended)
return;
write(c, 0, c.length);
}
|
public void write(String s) throws IOException {
if (suspended)
return;
if (s == null)
s = "null";
conv.convert(s);
conv.flushBuffer();
}
|
public void write(byte[] b,
int off,
int len) throws IOException {
if (suspended)
return;
writeBytes(b, off, len);
}
|
public void write(char[] c,
int off,
int len) throws IOException {
if (suspended)
return;
conv.convert(c, off, len);
conv.flushBuffer();
charsWritten += len;
}
|
public void write(String s,
int off,
int len) throws IOException {
if (suspended)
return;
charsWritten += len;
if (s == null)
s = "null";
conv.convert(s, off, len);
conv.flushBuffer();
}
Append a string to the buffer |
public void writeByte(int b) throws IOException {
if (suspended)
return;
bb.append((byte) b);
bytesWritten++;
}
|