From 56e892b3832bc405f0399c6d976952335ec6a075 Mon Sep 17 00:00:00 2001 From: markt Date: Sat, 7 Mar 2009 20:39:58 +0000 Subject: [PATCH] Fix Eclipse warnings in this package git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@751326 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/jasper/xmlparser/TreeNode.java | 47 ++++++++++++---------- java/org/apache/jasper/xmlparser/UTF8Reader.java | 36 ++++++++--------- .../jasper/xmlparser/XMLEncodingDetector.java | 6 +-- 3 files changed, 47 insertions(+), 42 deletions(-) diff --git a/java/org/apache/jasper/xmlparser/TreeNode.java b/java/org/apache/jasper/xmlparser/TreeNode.java index a765c44f2..fc2afaaec 100644 --- a/java/org/apache/jasper/xmlparser/TreeNode.java +++ b/java/org/apache/jasper/xmlparser/TreeNode.java @@ -20,6 +20,7 @@ package org.apache.jasper.xmlparser; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Iterator; @@ -79,7 +80,7 @@ public class TreeNode { * The attributes of this node, keyed by attribute name, * Instantiated only if required. */ - protected HashMap attributes = null; + protected HashMap attributes = null; /** @@ -119,7 +120,7 @@ public class TreeNode { public void addAttribute(String name, String value) { if (attributes == null) - attributes = new HashMap(); + attributes = new HashMap(); attributes.put(name, value); } @@ -148,9 +149,9 @@ public class TreeNode { public String findAttribute(String name) { if (attributes == null) - return (null); + return null; else - return ((String) attributes.get(name)); + return attributes.get(name); } @@ -159,12 +160,13 @@ public class TreeNode { * Return an Iterator of the attribute names of this node. If there are * no attributes, an empty Iterator is returned. */ - public Iterator findAttributes() { + public Iterator findAttributes() { - if (attributes == null) - return (Collections.EMPTY_LIST.iterator()); - else - return (attributes.keySet().iterator()); + if (attributes == null) { + List empty = Collections.emptyList(); + return empty.iterator(); + } else + return attributes.keySet().iterator(); } @@ -179,9 +181,9 @@ public class TreeNode { if (children == null) return (null); - Iterator items = children.iterator(); + Iterator items = children.iterator(); while (items.hasNext()) { - TreeNode item = (TreeNode) items.next(); + TreeNode item = items.next(); if (name.equals(item.getName())) return (item); } @@ -196,10 +198,11 @@ public class TreeNode { */ public Iterator findChildren() { - if (children == null) - return (Collections.EMPTY_LIST.iterator()); - else - return (children.iterator()); + if (children == null) { + List empty = Collections.emptyList(); + return empty.iterator(); + } else + return children.iterator(); } @@ -213,8 +216,10 @@ public class TreeNode { */ public Iterator findChildren(String name) { - if (children == null) - return (Collections.EMPTY_LIST.iterator()); + if (children == null) { + List empty = Collections.emptyList(); + return empty.iterator(); + } ArrayList results = new ArrayList(); Iterator items = children.iterator(); @@ -319,10 +324,10 @@ public class TreeNode { sb.append(' '); sb.append('<'); sb.append(node.getName()); - Iterator names = node.findAttributes(); + Iterator names = node.findAttributes(); while (names.hasNext()) { sb.append(' '); - String name = (String) names.next(); + String name = names.next(); sb.append(name); sb.append("=\""); String value = node.findAttribute(name); @@ -341,9 +346,9 @@ public class TreeNode { } // Reconstruct child nodes with extra indentation - Iterator children = node.findChildren(); + Iterator children = node.findChildren(); while (children.hasNext()) { - TreeNode child = (TreeNode) children.next(); + TreeNode child = children.next(); toString(sb, indent2, child); } diff --git a/java/org/apache/jasper/xmlparser/UTF8Reader.java b/java/org/apache/jasper/xmlparser/UTF8Reader.java index c562e4c53..b4d3ba3c0 100644 --- a/java/org/apache/jasper/xmlparser/UTF8Reader.java +++ b/java/org/apache/jasper/xmlparser/UTF8Reader.java @@ -126,7 +126,7 @@ public class UTF8Reader expectedByte(2, 2); } if ((b1 & 0xC0) != 0x80) { - invalidByte(2, 2, b1); + invalidByte(2, 2); } c = ((b0 << 6) & 0x07C0) | (b1 & 0x003F); } @@ -140,7 +140,7 @@ public class UTF8Reader expectedByte(2, 3); } if ((b1 & 0xC0) != 0x80) { - invalidByte(2, 3, b1); + invalidByte(2, 3); } int b2 = index == fOffset ? fInputStream.read() : fBuffer[index++] & 0x00FF; @@ -148,7 +148,7 @@ public class UTF8Reader expectedByte(3, 3); } if ((b2 & 0xC0) != 0x80) { - invalidByte(3, 3, b2); + invalidByte(3, 3); } c = ((b0 << 12) & 0xF000) | ((b1 << 6) & 0x0FC0) | (b2 & 0x003F); @@ -165,7 +165,7 @@ public class UTF8Reader expectedByte(2, 4); } if ((b1 & 0xC0) != 0x80) { - invalidByte(2, 3, b1); + invalidByte(2, 3); } int b2 = index == fOffset ? fInputStream.read() : fBuffer[index++] & 0x00FF; @@ -173,7 +173,7 @@ public class UTF8Reader expectedByte(3, 4); } if ((b2 & 0xC0) != 0x80) { - invalidByte(3, 3, b2); + invalidByte(3, 3); } int b3 = index == fOffset ? fInputStream.read() : fBuffer[index++] & 0x00FF; @@ -181,7 +181,7 @@ public class UTF8Reader expectedByte(4, 4); } if ((b3 & 0xC0) != 0x80) { - invalidByte(4, 4, b3); + invalidByte(4, 4); } int uuuuu = ((b0 << 2) & 0x001C) | ((b1 >> 4) & 0x0003); if (uuuuu > 0x10) { @@ -198,7 +198,7 @@ public class UTF8Reader // error else { - invalidByte(1, 1, b0); + invalidByte(1, 1); } } @@ -307,7 +307,7 @@ public class UTF8Reader fOffset = 2; return out - offset; } - invalidByte(2, 2, b1); + invalidByte(2, 2); } int c = ((b0 << 6) & 0x07C0) | (b1 & 0x003F); ch[out++] = (char)c; @@ -341,7 +341,7 @@ public class UTF8Reader fOffset = 2; return out - offset; } - invalidByte(2, 3, b1); + invalidByte(2, 3); } int b2 = -1; if (++in < total) { @@ -368,7 +368,7 @@ public class UTF8Reader fOffset = 3; return out - offset; } - invalidByte(3, 3, b2); + invalidByte(3, 3); } int c = ((b0 << 12) & 0xF000) | ((b1 << 6) & 0x0FC0) | (b2 & 0x003F); @@ -405,7 +405,7 @@ public class UTF8Reader fOffset = 2; return out - offset; } - invalidByte(2, 4, b1); + invalidByte(2, 4); } int b2 = -1; if (++in < total) { @@ -432,7 +432,7 @@ public class UTF8Reader fOffset = 3; return out - offset; } - invalidByte(3, 4, b2); + invalidByte(3, 4); } int b3 = -1; if (++in < total) { @@ -461,7 +461,7 @@ public class UTF8Reader fOffset = 4; return out - offset; } - invalidByte(4, 4, b2); + invalidByte(4, 4); } // decode bytes into surrogate characters @@ -489,7 +489,7 @@ public class UTF8Reader fOffset = 1; return out - offset; } - invalidByte(1, 1, b0); + invalidByte(1, 1); } // return number of characters converted @@ -612,17 +612,17 @@ public class UTF8Reader 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) + private void invalidByte(int position, int count) throws UTFDataFormatException { throw new UTFDataFormatException( Localizer.getMessage("jsp.error.xml.invalidByte", Integer.toString(position), Integer.toString(count))); - } // invalidByte(int,int,int,int) + } /** Throws an exception for invalid surrogate bits. */ private void invalidSurrogate(int uuuuu) throws UTFDataFormatException { @@ -630,6 +630,6 @@ public class UTF8Reader throw new UTFDataFormatException( Localizer.getMessage("jsp.error.xml.invalidHighSurrogate", Integer.toHexString(uuuuu))); - } // invalidSurrogate(int) + } } // class UTF8Reader diff --git a/java/org/apache/jasper/xmlparser/XMLEncodingDetector.java b/java/org/apache/jasper/xmlparser/XMLEncodingDetector.java index a5c8a9308..7acef653f 100644 --- a/java/org/apache/jasper/xmlparser/XMLEncodingDetector.java +++ b/java/org/apache/jasper/xmlparser/XMLEncodingDetector.java @@ -153,11 +153,11 @@ public class XMLEncodingDetector { isBigEndian = (Boolean)(encodingDesc[1]); if (encodingDesc.length > 3) { - isBomPresent = (Boolean)(encodingDesc[2]); - skip = (Integer)(encodingDesc[3]); + isBomPresent = ((Boolean)(encodingDesc[2])).booleanValue(); + skip = ((Integer)(encodingDesc[3])).intValue(); } else { isBomPresent = true; - skip = (Integer)(encodingDesc[2]); + skip = ((Integer)(encodingDesc[2])).intValue(); } stream.reset(); -- 2.11.0