Fix Eclipse warnings in this package
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 7 Mar 2009 20:39:58 +0000 (20:39 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 7 Mar 2009 20:39:58 +0000 (20:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@751326 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/xmlparser/TreeNode.java
java/org/apache/jasper/xmlparser/UTF8Reader.java
java/org/apache/jasper/xmlparser/XMLEncodingDetector.java

index a765c44..fc2afaa 100644 (file)
@@ -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<String,String> 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<String,String>();
         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<String> findAttributes() {
 
-        if (attributes == null)
-            return (Collections.EMPTY_LIST.iterator());
-        else
-            return (attributes.keySet().iterator());
+        if (attributes == null) {
+            List<String> 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<TreeNode> 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<TreeNode> findChildren() {
 
-        if (children == null)
-            return (Collections.EMPTY_LIST.iterator());
-        else
-            return (children.iterator());
+        if (children == null) {
+            List<TreeNode> empty = Collections.emptyList(); 
+            return empty.iterator();
+        } else
+            return children.iterator();
 
     }
 
@@ -213,8 +216,10 @@ public class TreeNode {
      */
     public Iterator<TreeNode> findChildren(String name) {
 
-        if (children == null)
-            return (Collections.EMPTY_LIST.iterator());
+        if (children == null) {
+            List<TreeNode> empty = Collections.emptyList(); 
+            return empty.iterator();
+        } 
 
         ArrayList<TreeNode> results = new ArrayList<TreeNode>();
         Iterator<TreeNode> items = children.iterator();
@@ -319,10 +324,10 @@ public class TreeNode {
             sb.append(' ');
         sb.append('<');
         sb.append(node.getName());
-        Iterator names = node.findAttributes();
+        Iterator<String> 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<TreeNode> children = node.findChildren();
         while (children.hasNext()) {
-            TreeNode child = (TreeNode) children.next();
+            TreeNode child = children.next();
             toString(sb, indent2, child);
         }
 
index c562e4c..b4d3ba3 100644 (file)
@@ -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
index a5c8a93..7acef65 100644 (file)
@@ -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();