You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mu...@apache.org on 2009/08/14 23:02:36 UTC
svn commit: r804373 [16/19] - in /struts/sandbox/trunk/struts2-jsp-plugin:
./ src/main/java/org/apache/struts2/ src/main/java/org/apache/struts2/jasper/
src/main/java/org/apache/struts2/jasper/compiler/
src/main/java/org/apache/struts2/jasper/compiler/...
Modified: struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UCSReader.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UCSReader.java?rev=804373&r1=804372&r2=804373&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UCSReader.java (original)
+++ struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UCSReader.java Fri Aug 14 21:02:33 2009
@@ -17,30 +17,32 @@
package org.apache.struts2.jasper.xmlparser;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
-/**
+/**
* Reader for UCS-2 and UCS-4 encodings.
* (i.e., encodings from ISO-10646-UCS-(2|4)).
*
* @author Neil Graham, IBM
- *
* @version $Id: UCSReader.java 466606 2006-10-21 23:07:12Z markt $
*/
public class UCSReader extends Reader {
- private org.apache.commons.logging.Log log=
- org.apache.commons.logging.LogFactory.getLog( UCSReader.class );
-
+ private Logger log = LoggerFactory.getLogger(UCSReader.class);
+
//
// Constants
//
- /** Default byte buffer size (8192, larger than that of ASCIIReader
+ /**
+ * Default byte buffer size (8192, larger than that of ASCIIReader
* since it's reasonable to surmise that the average UCS-4-encoded
- * file should be 4 times as large as the average ASCII-encoded file).
+ * file should be 4 times as large as the average ASCII-encoded file).
*/
public static final int DEFAULT_BUFFER_SIZE = 8192;
@@ -53,10 +55,14 @@
// Data
//
- /** Input stream. */
+ /**
+ * Input stream.
+ */
protected InputStream fInputStream;
- /** Byte buffer. */
+ /**
+ * Byte buffer.
+ */
protected byte[] fBuffer;
// what kind of data we're dealing with
@@ -66,26 +72,26 @@
// Constructors
//
- /**
- * Constructs an ASCII reader from the specified input stream
+ /**
+ * Constructs an ASCII reader from the specified input stream
* using the default buffer size. The Endian-ness and whether this is
* UCS-2 or UCS-4 needs also to be known in advance.
*
* @param inputStream The input stream.
- * @param encoding One of UCS2LE, UCS2BE, UCS4LE or UCS4BE.
+ * @param encoding One of UCS2LE, UCS2BE, UCS4LE or UCS4BE.
*/
public UCSReader(InputStream inputStream, short encoding) {
this(inputStream, DEFAULT_BUFFER_SIZE, encoding);
} // <init>(InputStream, short)
- /**
- * Constructs an ASCII reader from the specified input stream
+ /**
+ * Constructs an ASCII reader from the specified input stream
* and buffer size. The Endian-ness and whether this is
* UCS-2 or UCS-4 needs also to be known in advance.
*
* @param inputStream The input stream.
* @param size The initial buffer size.
- * @param encoding One of UCS2LE, UCS2BE, UCS4LE or UCS4BE.
+ * @param encoding One of UCS2LE, UCS2BE, UCS4LE or UCS4BE.
*/
public UCSReader(InputStream inputStream, int size, short encoding) {
fInputStream = inputStream;
@@ -100,24 +106,23 @@
/**
* Read a single character. This method will block until a character is
* available, an I/O error occurs, or the end of the stream is reached.
- *
+ * <p/>
* <p> Subclasses that intend to support efficient single-character input
* should override this method.
*
- * @return The character read, as an integer in the range 0 to 127
- * (<tt>0x00-0x7f</tt>), or -1 if the end of the stream has
- * been reached
- *
- * @exception IOException If an I/O error occurs
+ * @return The character read, as an integer in the range 0 to 127
+ * (<tt>0x00-0x7f</tt>), or -1 if the end of the stream has
+ * been reached
+ * @throws IOException If an I/O error occurs
*/
- public int read() throws IOException {
+ public int read() throws IOException {
int b0 = fInputStream.read() & 0xff;
if (b0 == 0xff)
return -1;
int b1 = fInputStream.read() & 0xff;
if (b1 == 0xff)
return -1;
- if(fEncoding >=4) {
+ if (fEncoding >= 4) {
int b2 = fInputStream.read() & 0xff;
if (b2 == 0xff)
return -1;
@@ -127,14 +132,14 @@
if (log.isDebugEnabled())
log.debug("b0 is " + (b0 & 0xff) + " b1 " + (b1 & 0xff) + " b2 " + (b2 & 0xff) + " b3 " + (b3 & 0xff));
if (fEncoding == UCS4BE)
- return (b0<<24)+(b1<<16)+(b2<<8)+b3;
+ return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
else
- return (b3<<24)+(b2<<16)+(b1<<8)+b0;
+ return (b3 << 24) + (b2 << 16) + (b1 << 8) + b0;
} else { // UCS-2
if (fEncoding == UCS2BE)
- return (b0<<8)+b1;
+ return (b0 << 8) + b1;
else
- return (b1<<8)+b0;
+ return (b1 << 8) + b0;
}
} // read():int
@@ -143,68 +148,66 @@
* until some input is available, an I/O error occurs, or the end of the
* stream is reached.
*
- * @param ch Destination buffer
- * @param offset Offset at which to start storing characters
- * @param length Maximum number of characters to read
- *
- * @return The number of characters read, or -1 if the end of the
- * stream has been reached
- *
- * @exception IOException If an I/O error occurs
+ * @param ch Destination buffer
+ * @param offset Offset at which to start storing characters
+ * @param length Maximum number of characters to read
+ * @return The number of characters read, or -1 if the end of the
+ * stream has been reached
+ * @throws IOException If an I/O error occurs
*/
public int read(char ch[], int offset, int length) throws IOException {
- int byteLength = length << ((fEncoding >= 4)?2:1);
+ int byteLength = length << ((fEncoding >= 4) ? 2 : 1);
if (byteLength > fBuffer.length) {
byteLength = fBuffer.length;
}
int count = fInputStream.read(fBuffer, 0, byteLength);
- if(count == -1) return -1;
+ if (count == -1) return -1;
// try and make count be a multiple of the number of bytes we're looking for
- if(fEncoding >= 4) { // BigEndian
+ if (fEncoding >= 4) { // BigEndian
// this looks ugly, but it avoids an if at any rate...
int numToRead = (4 - (count & 3) & 3);
- for(int i=0; i<numToRead; i++) {
+ for (int i = 0; i < numToRead; i++) {
int charRead = fInputStream.read();
- if(charRead == -1) { // end of input; something likely went wrong!A Pad buffer with nulls.
- for (int j = i;j<numToRead; j++)
- fBuffer[count+j] = 0;
+ if (charRead == -1) { // end of input; something likely went wrong!A Pad buffer with nulls.
+ for (int j = i; j < numToRead; j++)
+ fBuffer[count + j] = 0;
break;
} else {
- fBuffer[count+i] = (byte)charRead;
+ fBuffer[count + i] = (byte) charRead;
}
}
count += numToRead;
} else {
int numToRead = count & 1;
- if(numToRead != 0) {
+ if (numToRead != 0) {
count++;
int charRead = fInputStream.read();
- if(charRead == -1) { // end of input; something likely went wrong!A Pad buffer with nulls.
+ if (charRead == -1) { // end of input; something likely went wrong!A Pad buffer with nulls.
fBuffer[count] = 0;
} else {
- fBuffer[count] = (byte)charRead;
+ fBuffer[count] = (byte) charRead;
}
}
}
// now count is a multiple of the right number of bytes
- int numChars = count >> ((fEncoding >= 4)?2:1);
+ int numChars = count >> ((fEncoding >= 4) ? 2 : 1);
int curPos = 0;
for (int i = 0; i < numChars; i++) {
int b0 = fBuffer[curPos++] & 0xff;
int b1 = fBuffer[curPos++] & 0xff;
- if(fEncoding >=4) {
+ if (fEncoding >= 4) {
int b2 = fBuffer[curPos++] & 0xff;
int b3 = fBuffer[curPos++] & 0xff;
if (fEncoding == UCS4BE)
- ch[offset+i] = (char)((b0<<24)+(b1<<16)+(b2<<8)+b3);
+ ch[offset + i] = (char) ((b0 << 24) + (b1 << 16) + (b2 << 8) + b3);
else
- ch[offset+i] = (char)((b3<<24)+(b2<<16)+(b1<<8)+b0);
+ ch[offset + i] = (char) ((b3 << 24) + (b2 << 16) + (b1 << 8) + b0);
} else { // UCS-2
if (fEncoding == UCS2BE)
- ch[offset+i] = (char)((b0<<8)+b1);
+ ch[offset + i] = (char) ((b0 << 8) + b1);
else
- ch[offset+i] = (char)((b1<<8)+b0);
+ ch[offset + i] = (char) ((b1 << 8) + b0);
}
}
return numChars;
@@ -214,11 +217,9 @@
* Skip characters. This method will block until some characters are
* available, an I/O error occurs, or the end of the stream is reached.
*
- * @param n The number of characters to skip
- *
- * @return The number of characters actually skipped
- *
- * @exception IOException If an I/O error occurs
+ * @param n The number of characters to skip
+ * @return The number of characters actually skipped
+ * @throws IOException If an I/O error occurs
*/
public long skip(long n) throws IOException {
// charWidth will represent the number of bits to move
@@ -227,9 +228,9 @@
// The trick with &'ing, as with elsewhere in this dcode, is
// intended to avoid an expensive use of / that might not be optimized
// away.
- int charWidth = (fEncoding >=4)?2:1;
- long bytesSkipped = fInputStream.skip(n<<charWidth);
- if((bytesSkipped & (charWidth | 1)) == 0) return bytesSkipped >> charWidth;
+ int charWidth = (fEncoding >= 4) ? 2 : 1;
+ long bytesSkipped = fInputStream.skip(n << charWidth);
+ if ((bytesSkipped & (charWidth | 1)) == 0) return bytesSkipped >> charWidth;
return (bytesSkipped >> charWidth) + 1;
} // skip(long):long
@@ -237,20 +238,19 @@
* Tell whether this stream is ready to be read.
*
* @return True if the next read() is guaranteed not to block for input,
- * false otherwise. Note that returning false does not guarantee that the
- * next read will block.
- *
- * @exception IOException If an I/O error occurs
+ * false otherwise. Note that returning false does not guarantee that the
+ * next read will block.
+ * @throws IOException If an I/O error occurs
*/
public boolean ready() throws IOException {
- return false;
+ return false;
} // ready()
/**
* Tell whether this stream supports the mark() operation.
*/
public boolean markSupported() {
- return fInputStream.markSupported();
+ return fInputStream.markSupported();
} // markSupported()
/**
@@ -258,16 +258,15 @@
* will attempt to reposition the stream to this point. Not all
* character-input streams support the mark() operation.
*
- * @param readAheadLimit Limit on the number of characters that may be
- * read while still preserving the mark. After
- * reading this many characters, attempting to
- * reset the stream may fail.
- *
- * @exception IOException If the stream does not support mark(),
- * or if some other I/O error occurs
+ * @param readAheadLimit Limit on the number of characters that may be
+ * read while still preserving the mark. After
+ * reading this many characters, attempting to
+ * reset the stream may fail.
+ * @throws IOException If the stream does not support mark(),
+ * or if some other I/O error occurs
*/
public void mark(int readAheadLimit) throws IOException {
- fInputStream.mark(readAheadLimit);
+ fInputStream.mark(readAheadLimit);
} // mark(int)
/**
@@ -278,10 +277,10 @@
* character-input streams support the reset() operation, and some support
* reset() without supporting mark().
*
- * @exception IOException If the stream has not been marked,
- * or if the mark has been invalidated,
- * or if the stream does not support reset(),
- * or if some other I/O error occurs
+ * @throws IOException If the stream has not been marked,
+ * or if the mark has been invalidated,
+ * or if the stream does not support reset(),
+ * or if some other I/O error occurs
*/
public void reset() throws IOException {
fInputStream.reset();
@@ -292,10 +291,10 @@
* ready(), mark(), or reset() invocations will throw an IOException.
* Closing a previously-closed stream, however, has no effect.
*
- * @exception IOException If an I/O error occurs
+ * @throws IOException If an I/O error occurs
*/
- public void close() throws IOException {
- fInputStream.close();
- } // close()
+ public void close() throws IOException {
+ fInputStream.close();
+ } // close()
} // class UCSReader
Modified: struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UTF8Reader.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UTF8Reader.java?rev=804373&r1=804372&r2=804373&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UTF8Reader.java (original)
+++ struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UTF8Reader.java Fri Aug 14 21:02:33 2009
@@ -17,6 +17,8 @@
package org.apache.struts2.jasper.xmlparser;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.compiler.Localizer;
import java.io.IOException;
@@ -26,49 +28,59 @@
/**
* @author Andy Clark, IBM
- *
* @version $Id: UTF8Reader.java 466606 2006-10-21 23:07:12Z markt $
*/
public class UTF8Reader
- extends Reader {
+ extends Reader {
+
+ private Logger log = LoggerFactory.getLogger(UTF8Reader.class);
- private org.apache.commons.logging.Log log=
- org.apache.commons.logging.LogFactory.getLog( UTF8Reader.class );
-
//
// Constants
//
- /** Default byte buffer size (2048). */
+ /**
+ * Default byte buffer size (2048).
+ */
public static final int DEFAULT_BUFFER_SIZE = 2048;
// debugging
- /** Debug read. */
+ /**
+ * Debug read.
+ */
private static final boolean DEBUG_READ = false;
//
// Data
//
- /** Input stream. */
+ /**
+ * Input stream.
+ */
protected InputStream fInputStream;
- /** Byte buffer. */
+ /**
+ * Byte buffer.
+ */
protected byte[] fBuffer;
- /** Offset into buffer. */
+ /**
+ * Offset into buffer.
+ */
protected int fOffset;
- /** Surrogate character. */
+ /**
+ * Surrogate character.
+ */
private int fSurrogate = -1;
//
// Constructors
//
- /**
- * Constructs a UTF-8 reader from the specified input stream,
+ /**
+ * Constructs a UTF-8 reader from the specified input stream,
* buffer size and MessageFormatter.
*
* @param inputStream The input stream.
@@ -86,15 +98,14 @@
/**
* Read a single character. This method will block until a character is
* available, an I/O error occurs, or the end of the stream is reached.
- *
+ * <p/>
* <p> Subclasses that intend to support efficient single-character input
* should override this method.
*
- * @return The character read, as an integer in the range 0 to 16383
- * (<tt>0x00-0xffff</tt>), or -1 if the end of the stream has
- * been reached
- *
- * @exception IOException If an I/O error occurs
+ * @return The character read, as an integer in the range 0 to 16383
+ * (<tt>0x00-0xffff</tt>), or -1 if the end of the stream has
+ * been reached
+ * @throws IOException If an I/O error occurs
*/
public int read() throws IOException {
@@ -106,8 +117,8 @@
int index = 0;
// get first byte
- int b0 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b0 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b0 == -1) {
return -1;
}
@@ -115,14 +126,14 @@
// UTF-8: [0xxx xxxx]
// Unicode: [0000 0000] [0xxx xxxx]
if (b0 < 0x80) {
- c = (char)b0;
+ c = (char) b0;
}
// UTF-8: [110y yyyy] [10xx xxxx]
// Unicode: [0000 0yyy] [yyxx xxxx]
else if ((b0 & 0xE0) == 0xC0) {
- int b1 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b1 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b1 == -1) {
expectedByte(2, 2);
}
@@ -136,15 +147,15 @@
// Unicode: [zzzz yyyy] [yyxx xxxx]
else if ((b0 & 0xF0) == 0xE0) {
int b1 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b1 == -1) {
expectedByte(2, 3);
}
if ((b1 & 0xC0) != 0x80) {
invalidByte(2, 3, b1);
}
- int b2 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b2 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b2 == -1) {
expectedByte(3, 3);
}
@@ -152,7 +163,7 @@
invalidByte(3, 3, b2);
}
c = ((b0 << 12) & 0xF000) | ((b1 << 6) & 0x0FC0) |
- (b2 & 0x003F);
+ (b2 & 0x003F);
}
// UTF-8: [1111 0uuu] [10uu zzzz] [10yy yyyy] [10xx xxxx]*
@@ -160,24 +171,24 @@
// [1101 11yy] [yyxx xxxx] (low surrogate)
// * uuuuu = wwww + 1
else if ((b0 & 0xF8) == 0xF0) {
- int b1 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b1 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b1 == -1) {
expectedByte(2, 4);
}
if ((b1 & 0xC0) != 0x80) {
invalidByte(2, 3, b1);
}
- int b2 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b2 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b2 == -1) {
expectedByte(3, 4);
}
if ((b2 & 0xC0) != 0x80) {
invalidByte(3, 3, b2);
}
- int b3 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b3 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b3 == -1) {
expectedByte(4, 4);
}
@@ -189,9 +200,9 @@
invalidSurrogate(uuuuu);
}
int wwww = uuuuu - 1;
- int hs = 0xD800 |
- ((wwww << 6) & 0x03C0) | ((b1 << 2) & 0x003C) |
- ((b2 >> 4) & 0x0003);
+ int hs = 0xD800 |
+ ((wwww << 6) & 0x03C0) | ((b1 << 2) & 0x003C) |
+ ((b2 >> 4) & 0x0003);
int ls = 0xDC00 | ((b2 << 6) & 0x03C0) | (b3 & 0x003F);
c = hs;
fSurrogate = ls;
@@ -211,7 +222,7 @@
// return character
if (DEBUG_READ) {
if (log.isDebugEnabled())
- log.debug("read(): 0x"+Integer.toHexString(c));
+ log.debug("read(): 0x" + Integer.toHexString(c));
}
return c;
@@ -222,21 +233,19 @@
* until some input is available, an I/O error occurs, or the end of the
* stream is reached.
*
- * @param ch Destination buffer
- * @param offset Offset at which to start storing characters
- * @param length Maximum number of characters to read
- *
- * @return The number of characters read, or -1 if the end of the
- * stream has been reached
- *
- * @exception IOException If an I/O error occurs
+ * @param ch Destination buffer
+ * @param offset Offset at which to start storing characters
+ * @param length Maximum number of characters to read
+ * @return The number of characters read, or -1 if the end of the
+ * stream has been reached
+ * @throws IOException If an I/O error occurs
*/
public int read(char ch[], int offset, int length) throws IOException {
// handle surrogate
int out = offset;
if (fSurrogate != -1) {
- ch[offset + 1] = (char)fSurrogate;
+ ch[offset + 1] = (char) fSurrogate;
fSurrogate = -1;
length--;
out++;
@@ -278,7 +287,7 @@
// UTF-8: [0xxx xxxx]
// Unicode: [0000 0000] [0xxx xxxx]
if (b0 < 0x80) {
- ch[out++] = (char)b0;
+ ch[out++] = (char) b0;
continue;
}
@@ -286,14 +295,13 @@
// Unicode: [0000 0yyy] [yyxx xxxx]
if ((b0 & 0xE0) == 0xC0) {
int b1 = -1;
- if (++in < total) {
- b1 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b1 = fBuffer[in] & 0x00FF;
+ } else {
b1 = fInputStream.read();
if (b1 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
+ fBuffer[0] = (byte) b0;
fOffset = 1;
return out - offset;
}
@@ -303,15 +311,15 @@
}
if ((b1 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
fOffset = 2;
return out - offset;
}
invalidByte(2, 2, b1);
}
int c = ((b0 << 6) & 0x07C0) | (b1 & 0x003F);
- ch[out++] = (char)c;
+ ch[out++] = (char) c;
count -= 1;
continue;
}
@@ -320,14 +328,13 @@
// Unicode: [zzzz yyyy] [yyxx xxxx]
if ((b0 & 0xF0) == 0xE0) {
int b1 = -1;
- if (++in < total) {
- b1 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b1 = fBuffer[in] & 0x00FF;
+ } else {
b1 = fInputStream.read();
if (b1 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
+ fBuffer[0] = (byte) b0;
fOffset = 1;
return out - offset;
}
@@ -337,23 +344,22 @@
}
if ((b1 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
fOffset = 2;
return out - offset;
}
invalidByte(2, 3, b1);
}
int b2 = -1;
- if (++in < total) {
- b2 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b2 = fBuffer[in] & 0x00FF;
+ } else {
b2 = fInputStream.read();
if (b2 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
fOffset = 2;
return out - offset;
}
@@ -363,9 +369,9 @@
}
if ((b2 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
- fBuffer[2] = (byte)b2;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
+ fBuffer[2] = (byte) b2;
fOffset = 3;
return out - offset;
}
@@ -373,7 +379,7 @@
}
int c = ((b0 << 12) & 0xF000) | ((b1 << 6) & 0x0FC0) |
(b2 & 0x003F);
- ch[out++] = (char)c;
+ ch[out++] = (char) c;
count -= 2;
continue;
}
@@ -384,14 +390,13 @@
// * uuuuu = wwww + 1
if ((b0 & 0xF8) == 0xF0) {
int b1 = -1;
- if (++in < total) {
- b1 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b1 = fBuffer[in] & 0x00FF;
+ } else {
b1 = fInputStream.read();
if (b1 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
+ fBuffer[0] = (byte) b0;
fOffset = 1;
return out - offset;
}
@@ -401,23 +406,22 @@
}
if ((b1 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
fOffset = 2;
return out - offset;
}
invalidByte(2, 4, b1);
}
int b2 = -1;
- if (++in < total) {
- b2 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b2 = fBuffer[in] & 0x00FF;
+ } else {
b2 = fInputStream.read();
if (b2 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
fOffset = 2;
return out - offset;
}
@@ -427,25 +431,24 @@
}
if ((b2 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
- fBuffer[2] = (byte)b2;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
+ fBuffer[2] = (byte) b2;
fOffset = 3;
return out - offset;
}
invalidByte(3, 4, b2);
}
int b3 = -1;
- if (++in < total) {
- b3 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b3 = fBuffer[in] & 0x00FF;
+ } else {
b3 = fInputStream.read();
if (b3 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
- fBuffer[2] = (byte)b2;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
+ fBuffer[2] = (byte) b2;
fOffset = 3;
return out - offset;
}
@@ -455,10 +458,10 @@
}
if ((b3 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
- fBuffer[2] = (byte)b2;
- fBuffer[3] = (byte)b3;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
+ fBuffer[2] = (byte) b2;
+ fBuffer[3] = (byte) b3;
fOffset = 4;
return out - offset;
}
@@ -478,15 +481,15 @@
int ls = 0xDC00 | ((yyyyyy << 6) & 0x03C0) | xxxxxx;
// set characters
- ch[out++] = (char)hs;
- ch[out++] = (char)ls;
+ ch[out++] = (char) hs;
+ ch[out++] = (char) ls;
count -= 2;
continue;
}
// error
if (out > offset) {
- fBuffer[0] = (byte)b0;
+ fBuffer[0] = (byte) b0;
fOffset = 1;
return out - offset;
}
@@ -496,7 +499,7 @@
// return number of characters converted
if (DEBUG_READ) {
if (log.isDebugEnabled())
- log.debug("read(char[],"+offset+','+length+"): count="+count);
+ log.debug("read(char[]," + offset + ',' + length + "): count=" + count);
}
return count;
@@ -506,23 +509,20 @@
* Skip characters. This method will block until some characters are
* available, an I/O error occurs, or the end of the stream is reached.
*
- * @param n The number of characters to skip
- *
- * @return The number of characters actually skipped
- *
- * @exception IOException If an I/O error occurs
+ * @param n The number of characters to skip
+ * @return The number of characters actually skipped
+ * @throws IOException If an I/O error occurs
*/
public long skip(long n) throws IOException {
long remaining = n;
final char[] ch = new char[fBuffer.length];
do {
- int length = ch.length < remaining ? ch.length : (int)remaining;
+ int length = ch.length < remaining ? ch.length : (int) remaining;
int count = read(ch, 0, length);
if (count > 0) {
remaining -= count;
- }
- else {
+ } else {
break;
}
} while (remaining > 0);
@@ -536,20 +536,19 @@
* Tell whether this stream is ready to be read.
*
* @return True if the next read() is guaranteed not to block for input,
- * false otherwise. Note that returning false does not guarantee that the
- * next read will block.
- *
- * @exception IOException If an I/O error occurs
+ * false otherwise. Note that returning false does not guarantee that the
+ * next read will block.
+ * @throws IOException If an I/O error occurs
*/
public boolean ready() throws IOException {
- return false;
+ return false;
} // ready()
/**
* Tell whether this stream supports the mark() operation.
*/
public boolean markSupported() {
- return false;
+ return false;
} // markSupported()
/**
@@ -557,18 +556,17 @@
* will attempt to reposition the stream to this point. Not all
* character-input streams support the mark() operation.
*
- * @param readAheadLimit Limit on the number of characters that may be
- * read while still preserving the mark. After
- * reading this many characters, attempting to
- * reset the stream may fail.
- *
- * @exception IOException If the stream does not support mark(),
- * or if some other I/O error occurs
+ * @param readAheadLimit Limit on the number of characters that may be
+ * read while still preserving the mark. After
+ * reading this many characters, attempting to
+ * reset the stream may fail.
+ * @throws IOException If the stream does not support mark(),
+ * or if some other I/O error occurs
*/
public void mark(int readAheadLimit) throws IOException {
- throw new IOException(
+ throw new IOException(
Localizer.getMessage("jsp.error.xml.operationNotSupported",
- "mark()", "UTF-8"));
+ "mark()", "UTF-8"));
}
/**
@@ -579,10 +577,10 @@
* character-input streams support the reset() operation, and some support
* reset() without supporting mark().
*
- * @exception IOException If the stream has not been marked,
- * or if the mark has been invalidated,
- * or if the stream does not support reset(),
- * or if some other I/O error occurs
+ * @throws IOException If the stream has not been marked,
+ * or if the mark has been invalidated,
+ * or if the stream does not support reset(),
+ * or if some other I/O error occurs
*/
public void reset() throws IOException {
fOffset = 0;
@@ -594,7 +592,7 @@
* ready(), mark(), or reset() invocations will throw an IOException.
* Closing a previously-closed stream, however, has no effect.
*
- * @exception IOException If an I/O error occurs
+ * @throws IOException If an I/O error occurs
*/
public void close() throws IOException {
fInputStream.close();
@@ -604,33 +602,39 @@
// Private methods
//
- /** Throws an exception for expected byte. */
+ /**
+ * Throws an exception for expected byte.
+ */
private void expectedByte(int position, int count)
- throws UTFDataFormatException {
+ throws UTFDataFormatException {
throw new UTFDataFormatException(
Localizer.getMessage("jsp.error.xml.expectedByte",
- Integer.toString(position),
- Integer.toString(count)));
+ Integer.toString(position),
+ Integer.toString(count)));
} // expectedByte(int,int,int)
- /** Throws an exception for invalid byte. */
- private void invalidByte(int position, int count, int c)
- throws UTFDataFormatException {
+ /**
+ * Throws an exception for invalid byte.
+ */
+ private void invalidByte(int position, int count, int c)
+ throws UTFDataFormatException {
throw new UTFDataFormatException(
Localizer.getMessage("jsp.error.xml.invalidByte",
- Integer.toString(position),
- Integer.toString(count)));
+ Integer.toString(position),
+ Integer.toString(count)));
} // invalidByte(int,int,int,int)
- /** Throws an exception for invalid surrogate bits. */
+ /**
+ * Throws an exception for invalid surrogate bits.
+ */
private void invalidSurrogate(int uuuuu) throws UTFDataFormatException {
-
+
throw new UTFDataFormatException(
Localizer.getMessage("jsp.error.xml.invalidHighSurrogate",
- Integer.toHexString(uuuuu)));
+ Integer.toHexString(uuuuu)));
} // invalidSurrogate(int)
} // class UTF8Reader