Author: markt Date: Sat Dec 17 11:35:25 2016 New Revision: 1774742 URL: http://svn.apache.org/viewvc?rev=1774742&view=rev Log: Simplify. Jasper doesn't need to BE vs LE
Modified: tomcat/trunk/java/org/apache/jasper/compiler/EncodingDetector.java Modified: tomcat/trunk/java/org/apache/jasper/compiler/EncodingDetector.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/EncodingDetector.java?rev=1774742&r1=1774741&r2=1774742&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/EncodingDetector.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/EncodingDetector.java Sat Dec 17 11:35:25 2016 @@ -68,11 +68,6 @@ class EncodingDetector { } - Boolean getBigEndian() { - return bomResult.bigEndian; - } - - int getSkip() { return bomResult.skip; } @@ -114,7 +109,7 @@ class EncodingDetector { return parseBom(b4, count); } catch (IOException ioe) { // Failed. - return new BomResult("UTF-8", null, 0); + return new BomResult("UTF-8", 0); } } @@ -122,7 +117,7 @@ class EncodingDetector { private BomResult parseBom(byte[] b4, int count) { if (count < 2) { - return new BomResult("UTF-8", null, 0); + return new BomResult("UTF-8", 0); } // UTF-16, with BOM @@ -130,82 +125,80 @@ class EncodingDetector { int b1 = b4[1] & 0xFF; if (b0 == 0xFE && b1 == 0xFF) { // UTF-16, big-endian - return new BomResult("UTF-16BE", Boolean.TRUE, 2); + return new BomResult("UTF-16BE", 2); } if (b0 == 0xFF && b1 == 0xFE) { // UTF-16, little-endian - return new BomResult("UTF-16LE", Boolean.FALSE, 2); + return new BomResult("UTF-16LE", 2); } // default to UTF-8 if we don't have enough bytes to make a // good determination of the encoding if (count < 3) { - return new BomResult("UTF-8", null, 0); + return new BomResult("UTF-8", 0); } // UTF-8 with a BOM int b2 = b4[2] & 0xFF; if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) { - return new BomResult("UTF-8", null, 3); + return new BomResult("UTF-8", 3); } // default to UTF-8 if we don't have enough bytes to make a // good determination of the encoding if (count < 4) { - return new BomResult("UTF-8", null, 0); + return new BomResult("UTF-8", 0); } // other encodings int b3 = b4[3] & 0xFF; if (b0 == 0x00 && b1 == 0x00 && b2 == 0x00 && b3 == 0x3C) { // UCS-4, big endian (1234) - return new BomResult("ISO-10646-UCS-4", Boolean.TRUE, 4); + return new BomResult("ISO-10646-UCS-4", 4); } if (b0 == 0x3C && b1 == 0x00 && b2 == 0x00 && b3 == 0x00) { // UCS-4, little endian (4321) - return new BomResult("ISO-10646-UCS-4", Boolean.FALSE, 4); + return new BomResult("ISO-10646-UCS-4", 4); } if (b0 == 0x00 && b1 == 0x00 && b2 == 0x3C && b3 == 0x00) { // UCS-4, unusual octet order (2143) // REVISIT: What should this be? - return new BomResult("ISO-10646-UCS-4", null, 4); + return new BomResult("ISO-10646-UCS-4", 4); } if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x00) { // UCS-4, unusual octect order (3412) // REVISIT: What should this be? - return new BomResult("ISO-10646-UCS-4", null, 4); + return new BomResult("ISO-10646-UCS-4", 4); } if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x3F) { // UTF-16, big-endian, no BOM // (or could turn out to be UCS-2... // REVISIT: What should this be? - return new BomResult("UTF-16BE", Boolean.TRUE, 4); + return new BomResult("UTF-16BE", 4); } if (b0 == 0x3C && b1 == 0x00 && b2 == 0x3F && b3 == 0x00) { // UTF-16, little-endian, no BOM // (or could turn out to be UCS-2... - return new BomResult("UTF-16LE", Boolean.FALSE, 4); + return new BomResult("UTF-16LE", 4); } if (b0 == 0x4C && b1 == 0x6F && b2 == 0xA7 && b3 == 0x94) { // EBCDIC // a la xerces1, return CP037 instead of EBCDIC here - return new BomResult("CP037", null, 4); + return new BomResult("CP037", 4); } // default encoding - return new BomResult("UTF-8", null, 0); + return new BomResult("UTF-8", 0); } private static class BomResult { public final String encoding; - public final Boolean bigEndian; public final int skip; - public BomResult(String encoding, Boolean bigEndian, int skip) { + public BomResult(String encoding, int skip) { this.encoding = encoding; - this.bigEndian = bigEndian; this.skip = skip; } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org