remm 2005/03/24 07:39:56 Modified: jasper2/src/share/org/apache/jasper/runtime JspWriterImpl.java Log: - Indentation. No change. Revision Changes Path 1.15 +91 -92 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspWriterImpl.java Index: JspWriterImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspWriterImpl.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- JspWriterImpl.java 22 Nov 2004 16:35:52 -0000 1.14 +++ JspWriterImpl.java 24 Mar 2005 15:39:56 -0000 1.15 @@ -42,7 +42,7 @@ * @author Anil K. Vijendran */ public class JspWriterImpl extends JspWriter { - + private Writer out; private ServletResponse response; private char cb[]; @@ -51,9 +51,9 @@ private boolean closed = false; public JspWriterImpl() { - super( Constants.DEFAULT_BUFFER_SIZE, true ); + super( Constants.DEFAULT_BUFFER_SIZE, true ); } - + /** * Create a buffered character-output stream that uses a default-sized * output buffer. @@ -63,7 +63,7 @@ public JspWriterImpl(ServletResponse response) { this(response, Constants.DEFAULT_BUFFER_SIZE, true); } - + /** * Create a new buffered character-output stream that uses an output * buffer of the given size. @@ -74,34 +74,34 @@ * @exception IllegalArgumentException If sz is <= 0 */ public JspWriterImpl(ServletResponse response, int sz, - boolean autoFlush) { + boolean autoFlush) { super(sz, autoFlush); if (sz < 0) throw new IllegalArgumentException("Buffer size <= 0"); - this.response = response; + this.response = response; cb = sz == 0 ? null : new char[sz]; - nextChar = 0; + nextChar = 0; } - + void init( ServletResponse response, int sz, boolean autoFlush ) { - this.response= response; - if( sz > 0 && ( cb == null || sz > cb.length ) ) - cb=new char[sz]; - nextChar = 0; - this.autoFlush=autoFlush; - this.bufferSize=sz; + this.response= response; + if( sz > 0 && ( cb == null || sz > cb.length ) ) + cb=new char[sz]; + nextChar = 0; + this.autoFlush=autoFlush; + this.bufferSize=sz; } - + /** Package-level access */ void recycle() { - flushed = false; + flushed = false; closed = false; out = null; - nextChar = 0; + nextChar = 0; response = null; } - + /** * Flush the output buffer to the underlying character stream, without * flushing the stream itself. This method is non-private only so that it @@ -118,25 +118,25 @@ out.write(cb, 0, nextChar); nextChar = 0; } - + private void initOut() throws IOException { if (out == null) { out = response.getWriter(); - } + } } - + private String getLocalizeMessage(final String message){ if (SecurityUtil.isPackageProtectionEnabled()){ - return (String)AccessController.doPrivileged(new PrivilegedAction(){ + return (String)AccessController.doPrivileged(new PrivilegedAction(){ public Object run(){ return Localizer.getMessage(message); } - }); + }); } else { return Localizer.getMessage(message); } } - + /** * Discard the output buffer. */ @@ -151,7 +151,7 @@ ensureOpen(); nextChar = 0; } - + public void clearBuffer() throws IOException { if (bufferSize == 0) throw new IllegalStateException( @@ -159,11 +159,11 @@ ensureOpen(); nextChar = 0; } - + private final void bufferOverflow() throws IOException { throw new IOException(getLocalizeMessage("jsp.error.overflow")); } - + /** * Flush the stream. * @@ -174,7 +174,7 @@ out.flush(); } } - + /** * Close the stream. * @@ -188,23 +188,22 @@ out.close(); out = null; closed = true; - // cb = null; } - + /** * @return the number of bytes unused in the buffer */ public int getRemaining() { return bufferSize - nextChar; } - + /** check to make sure that the stream has not been closed */ private void ensureOpen() throws IOException { - if (response == null || closed) - throw new IOException("Stream closed"); + if (response == null || closed) + throw new IOException("Stream closed"); } - - + + /** * Write a single character. */ @@ -223,16 +222,16 @@ cb[nextChar++] = (char) c; } } - + /** * Our own little min method, to avoid loading java.lang.Math if we've run * out of file descriptors and we're trying to print a stack trace. */ private int min(int a, int b) { - if (a < b) return a; - return b; + if (a < b) return a; + return b; } - + /** * Write a portion of an array of characters. * @@ -248,27 +247,27 @@ * @param len Number of characters to write */ public void write(char cbuf[], int off, int len) - throws IOException + throws IOException { ensureOpen(); - + if (bufferSize == 0) { initOut(); out.write(cbuf, off, len); return; } - + if ((off < 0) || (off > cbuf.length) || (len < 0) || - ((off + len) > cbuf.length) || ((off + len) < 0)) { + ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } - + if (len >= bufferSize) { /* If the request length exceeds the size of the output buffer, - flush the buffer and then write the data directly. In this - way buffered streams will cascade harmlessly. */ + flush the buffer and then write the data directly. In this + way buffered streams will cascade harmlessly. */ if (autoFlush) flushBuffer(); else @@ -277,7 +276,7 @@ out.write(cbuf, off, len); return; } - + int b = off, t = off + len; while (b < t) { int d = min(bufferSize - nextChar, t - b); @@ -290,17 +289,17 @@ else bufferOverflow(); } - + } - + /** * Write an array of characters. This method cannot be inherited from the * Writer class because it must suppress I/O exceptions. */ public void write(char buf[]) throws IOException { - write(buf, 0, buf.length); + write(buf, 0, buf.length); } - + /** * Write a portion of a String. * @@ -328,18 +327,18 @@ bufferOverflow(); } } - + /** * Write a string. This method cannot be inherited from the Writer class * because it must suppress I/O exceptions. */ public void write(String s) throws IOException { - write(s, 0, s.length()); + write(s, 0, s.length()); } - - + + static String lineSeparator = System.getProperty("line.separator"); - + /** * Write a line separator. The line separator string is defined by the * system property <tt>line.separator</tt>, and is not necessarily a single @@ -351,10 +350,10 @@ public void newLine() throws IOException { write(lineSeparator); } - - + + /* Methods that do not terminate lines */ - + /** * Print a boolean value. The string produced by <code>[EMAIL PROTECTED] * java.lang.String#valueOf(boolean)}</code> is translated into bytes @@ -365,9 +364,9 @@ * @param b The <code>boolean</code> to be printed */ public void print(boolean b) throws IOException { - write(b ? "true" : "false"); + write(b ? "true" : "false"); } - + /** * Print a character. The character is translated into one or more bytes * according to the platform's default character encoding, and these bytes @@ -377,9 +376,9 @@ * @param c The <code>char</code> to be printed */ public void print(char c) throws IOException { - write(String.valueOf(c)); + write(String.valueOf(c)); } - + /** * Print an integer. The string produced by <code>[EMAIL PROTECTED] * java.lang.String#valueOf(int)}</code> is translated into bytes according @@ -390,9 +389,9 @@ * @param i The <code>int</code> to be printed */ public void print(int i) throws IOException { - write(String.valueOf(i)); + write(String.valueOf(i)); } - + /** * Print a long integer. The string produced by <code>[EMAIL PROTECTED] * java.lang.String#valueOf(long)}</code> is translated into bytes @@ -403,9 +402,9 @@ * @param l The <code>long</code> to be printed */ public void print(long l) throws IOException { - write(String.valueOf(l)); + write(String.valueOf(l)); } - + /** * Print a floating-point number. The string produced by <code>[EMAIL PROTECTED] * java.lang.String#valueOf(float)}</code> is translated into bytes @@ -416,9 +415,9 @@ * @param f The <code>float</code> to be printed */ public void print(float f) throws IOException { - write(String.valueOf(f)); + write(String.valueOf(f)); } - + /** * Print a double-precision floating-point number. The string produced by * <code>[EMAIL PROTECTED] java.lang.String#valueOf(double)}</code> is translated into @@ -429,9 +428,9 @@ * @param d The <code>double</code> to be printed */ public void print(double d) throws IOException { - write(String.valueOf(d)); + write(String.valueOf(d)); } - + /** * Print an array of characters. The characters are converted into bytes * according to the platform's default character encoding, and these bytes @@ -443,9 +442,9 @@ * @throws NullPointerException If <code>s</code> is <code>null</code> */ public void print(char s[]) throws IOException { - write(s); + write(s); } - + /** * Print a string. If the argument is <code>null</code> then the string * <code>"null"</code> is printed. Otherwise, the string's characters are @@ -456,12 +455,12 @@ * @param s The <code>String</code> to be printed */ public void print(String s) throws IOException { - if (s == null) { - s = "null"; - } - write(s); + if (s == null) { + s = "null"; + } + write(s); } - + /** * Print an object. The string produced by the <code>[EMAIL PROTECTED] * java.lang.String#valueOf(Object)}</code> method is translated into bytes @@ -472,11 +471,11 @@ * @param obj The <code>Object</code> to be printed */ public void print(Object obj) throws IOException { - write(String.valueOf(obj)); + write(String.valueOf(obj)); } - + /* Methods that do terminate lines */ - + /** * Terminate the current line by writing the line separator string. The * line separator string is defined by the system property @@ -488,9 +487,9 @@ * write method... */ public void println() throws IOException { - newLine(); + newLine(); } - + /** * Print a boolean value and then terminate the line. This method behaves * as though it invokes <code>[EMAIL PROTECTED] #print(boolean)}</code> and then @@ -500,7 +499,7 @@ print(x); println(); } - + /** * Print a character and then terminate the line. This method behaves as * though it invokes <code>[EMAIL PROTECTED] #print(char)}</code> and then <code>[EMAIL PROTECTED] @@ -510,7 +509,7 @@ print(x); println(); } - + /** * Print an integer and then terminate the line. This method behaves as * though it invokes <code>[EMAIL PROTECTED] #print(int)}</code> and then <code>[EMAIL PROTECTED] @@ -520,7 +519,7 @@ print(x); println(); } - + /** * Print a long integer and then terminate the line. This method behaves * as though it invokes <code>[EMAIL PROTECTED] #print(long)}</code> and then @@ -530,7 +529,7 @@ print(x); println(); } - + /** * Print a floating-point number and then terminate the line. This method * behaves as though it invokes <code>[EMAIL PROTECTED] #print(float)}</code> and then @@ -540,7 +539,7 @@ print(x); println(); } - + /** * Print a double-precision floating-point number and then terminate the * line. This method behaves as though it invokes <code>[EMAIL PROTECTED] @@ -550,7 +549,7 @@ print(x); println(); } - + /** * Print an array of characters and then terminate the line. This method * behaves as though it invokes <code>[EMAIL PROTECTED] #print(char[])}</code> and then @@ -560,7 +559,7 @@ print(x); println(); } - + /** * Print a String and then terminate the line. This method behaves as * though it invokes <code>[EMAIL PROTECTED] #print(String)}</code> and then @@ -570,7 +569,7 @@ print(x); println(); } - + /** * Print an Object and then terminate the line. This method behaves as * though it invokes <code>[EMAIL PROTECTED] #print(Object)}</code> and then @@ -580,5 +579,5 @@ print(x); println(); } - + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]