tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r695273 - /tomcat/trunk/java/org/apache/catalina/util/
Date Sun, 14 Sep 2008 19:45:08 GMT
Author: markt
Date: Sun Sep 14 12:45:08 2008
New Revision: 695273

URL: http://svn.apache.org/viewvc?rev=695273&view=rev
Log:
Some clean up in o.a.c.util
Use generics, remove unused code, fix various Eclipse warnings.

Removed:
    tomcat/trunk/java/org/apache/catalina/util/Queue.java
Modified:
    tomcat/trunk/java/org/apache/catalina/util/Base64.java
    tomcat/trunk/java/org/apache/catalina/util/CustomObjectInputStream.java
    tomcat/trunk/java/org/apache/catalina/util/DOMWriter.java
    tomcat/trunk/java/org/apache/catalina/util/DateTool.java
    tomcat/trunk/java/org/apache/catalina/util/ExtensionValidator.java
    tomcat/trunk/java/org/apache/catalina/util/HexUtils.java
    tomcat/trunk/java/org/apache/catalina/util/MD5Encoder.java
    tomcat/trunk/java/org/apache/catalina/util/MIME2Java.java
    tomcat/trunk/java/org/apache/catalina/util/ManifestResource.java
    tomcat/trunk/java/org/apache/catalina/util/SchemaResolver.java
    tomcat/trunk/java/org/apache/catalina/util/ServerInfo.java
    tomcat/trunk/java/org/apache/catalina/util/StringManager.java
    tomcat/trunk/java/org/apache/catalina/util/URLEncoder.java

Modified: tomcat/trunk/java/org/apache/catalina/util/Base64.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/Base64.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/Base64.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/Base64.java Sun Sep 14 12:45:08 2008
@@ -37,7 +37,6 @@
     static private final int  TWENTYFOURBITGROUP = 24;
     static private final int  EIGHTBIT           = 8;
     static private final int  SIXTEENBIT         = 16;
-    static private final int  SIXBIT             = 6;
     static private final int  FOURBYTE           = 4;
     static private final int  SIGN               = -128;
     static private final byte PAD                = (byte) '=';

Modified: tomcat/trunk/java/org/apache/catalina/util/CustomObjectInputStream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/CustomObjectInputStream.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/CustomObjectInputStream.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/CustomObjectInputStream.java Sun Sep 14 12:45:08
2008
@@ -69,7 +69,7 @@
      * @exception ClassNotFoundException if this class cannot be found
      * @exception IOException if an input/output error occurs
      */
-    public Class resolveClass(ObjectStreamClass classDesc)
+    public Class<?> resolveClass(ObjectStreamClass classDesc)
         throws ClassNotFoundException, IOException {
         try {
             return Class.forName(classDesc.getName(), false, classLoader);
@@ -85,10 +85,10 @@
      * class descriptor. Do this using the class loader assigned to this
      * Context.
      */
-    protected Class resolveProxyClass(String[] interfaces)
+    protected Class<?> resolveProxyClass(String[] interfaces)
         throws IOException, ClassNotFoundException {
 
-        Class[] cinterfaces = new Class[interfaces.length];
+        Class<?>[] cinterfaces = new Class[interfaces.length];
         for (int i = 0; i < interfaces.length; i++)
             cinterfaces[i] = classLoader.loadClass(interfaces[i]);
 

Modified: tomcat/trunk/java/org/apache/catalina/util/DOMWriter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/DOMWriter.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/DOMWriter.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/DOMWriter.java Sun Sep 14 12:45:08 2008
@@ -332,18 +332,4 @@
 
    } // normalize(String):String
 
-   private static void printValidJavaEncoding() {
-      System.err.println( "    ENCODINGS:" );
-      System.err.print( "   " );
-      for( int i = 0;
-                     i < MIME2JAVA_ENCODINGS.length; i++) {
-         System.err.print( MIME2JAVA_ENCODINGS[i] + " " );
-      if( (i % 7 ) == 0 ){
-         System.err.println();
-         System.err.print( "   " );
-         }
-      }
-
-   } // printJavaEncoding()
-
 }

Modified: tomcat/trunk/java/org/apache/catalina/util/DateTool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/DateTool.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/DateTool.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/DateTool.java Sun Sep 14 12:45:08 2008
@@ -33,9 +33,6 @@
  */
 public class DateTool {
 
-    private static StringManager sm =
-        StringManager.getManager("org.apache.catalina.util");
-
     /**
      * US locale - all HTTP dates are in english
      */

Modified: tomcat/trunk/java/org/apache/catalina/util/ExtensionValidator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/ExtensionValidator.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/ExtensionValidator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/ExtensionValidator.java Sun Sep 14 12:45:08
2008
@@ -61,8 +61,9 @@
     private static StringManager sm =
         StringManager.getManager("org.apache.catalina.util");
     
-    private static ArrayList containerAvailableExtensions = null;
-    private static ArrayList containerManifestResources = new ArrayList();
+    private static ArrayList<Extension> containerAvailableExtensions = null;
+    private static ArrayList<ManifestResource> containerManifestResources =
+        new ArrayList<ManifestResource>();
 
 
     // ----------------------------------------------------- Static Initializer
@@ -133,15 +134,17 @@
                     throws IOException {
 
         String appName = context.getPath();
-        ArrayList appManifestResources = new ArrayList();
+        ArrayList<ManifestResource> appManifestResources =
+            new ArrayList<ManifestResource>();
         // If the application context is null it does not exist and 
         // therefore is not valid
         if (dirContext == null) return false;
         // Find the Manifest for the Web Applicaiton
         InputStream inputStream = null;
         try {
-            NamingEnumeration wne = dirContext.listBindings("/META-INF/");
-            Binding binding = (Binding) wne.nextElement();
+            NamingEnumeration<Binding> wne =
+                dirContext.listBindings("/META-INF/");
+            Binding binding = wne.nextElement();
             if (binding.getName().toUpperCase().equals("MANIFEST.MF")) {
                 Resource resource = (Resource)dirContext.lookup
                                     ("/META-INF/" + binding.getName());
@@ -169,13 +172,11 @@
         }
 
         // Locate the Manifests for all bundled JARs
-        NamingEnumeration ne = null;
+        NamingEnumeration<Binding> ne = null;
         try {
-            if (dirContext != null) {
-                ne = dirContext.listBindings("WEB-INF/lib/");
-            }
+            ne = dirContext.listBindings("WEB-INF/lib/");
             while ((ne != null) && ne.hasMoreElements()) {
-                Binding binding = (Binding)ne.nextElement();
+                Binding binding = ne.nextElement();
                 if (!binding.getName().toLowerCase().endsWith(".jar")) {
                     continue;
                 }
@@ -239,16 +240,16 @@
      *
      * @return true if manifest resource file requirements are met
      */
-    private static boolean validateManifestResources(String appName, 
-                                                     ArrayList resources) {
+    private static boolean validateManifestResources(String appName,
+            ArrayList<ManifestResource> resources) {
         boolean passes = true;
         int failureCount = 0;        
-        ArrayList availableExtensions = null;
+        ArrayList<Extension> availableExtensions = null;
 
-        Iterator it = resources.iterator();
+        Iterator<ManifestResource> it = resources.iterator();
         while (it.hasNext()) {
-            ManifestResource mre = (ManifestResource)it.next();
-            ArrayList requiredList = mre.getRequiredExtensions();
+            ManifestResource mre = it.next();
+            ArrayList<Extension> requiredList = mre.getRequiredExtensions();
             if (requiredList == null) {
                 continue;
             }
@@ -266,15 +267,15 @@
             }
 
             // iterate through the list of required extensions
-            Iterator rit = requiredList.iterator();
+            Iterator<Extension> rit = requiredList.iterator();
             while (rit.hasNext()) {
                 boolean found = false;
-                Extension requiredExt = (Extension)rit.next();
+                Extension requiredExt = rit.next();
                 // check the applicaion itself for the extension
                 if (availableExtensions != null) {
-                    Iterator ait = availableExtensions.iterator();
+                    Iterator<Extension> ait = availableExtensions.iterator();
                     while (ait.hasNext()) {
-                        Extension targetExt = (Extension) ait.next();
+                        Extension targetExt = ait.next();
                         if (targetExt.isCompatibleWith(requiredExt)) {
                             requiredExt.setFulfilled(true);
                             found = true;
@@ -284,9 +285,10 @@
                 }
                 // check the container level list for the extension
                 if (!found && containerAvailableExtensions != null) {
-                    Iterator cit = containerAvailableExtensions.iterator();
+                    Iterator<Extension> cit =
+                        containerAvailableExtensions.iterator();
                     while (cit.hasNext()) {
-                        Extension targetExt = (Extension) cit.next();
+                        Extension targetExt = cit.next();
                         if (targetExt.isCompatibleWith(requiredExt)) {
                             requiredExt.setFulfilled(true);
                             found = true;
@@ -332,20 +334,21 @@
     *
     * @return HashMap Map of available extensions
     */
-    private static ArrayList buildAvailableExtensionsList(ArrayList resources) {
+    private static ArrayList<Extension> buildAvailableExtensionsList(
+            ArrayList<ManifestResource> resources) {
 
-        ArrayList availableList = null;
+        ArrayList<Extension> availableList = null;
 
-        Iterator it = resources.iterator();
+        Iterator<ManifestResource> it = resources.iterator();
         while (it.hasNext()) {
-            ManifestResource mre = (ManifestResource)it.next();
-            ArrayList list = mre.getAvailableExtensions();
+            ManifestResource mre = it.next();
+            ArrayList<Extension> list = mre.getAvailableExtensions();
             if (list != null) {
-                Iterator values = list.iterator();
+                Iterator<Extension> values = list.iterator();
                 while (values.hasNext()) {
-                    Extension ext = (Extension) values.next();
+                    Extension ext = values.next();
                     if (availableList == null) {
-                        availableList = new ArrayList();
+                        availableList = new ArrayList<Extension>();
                         availableList.add(ext);
                     } else {
                         availableList.add(ext);

Modified: tomcat/trunk/java/org/apache/catalina/util/HexUtils.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/HexUtils.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/HexUtils.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/HexUtils.java Sun Sep 14 12:45:08 2008
@@ -114,8 +114,8 @@
 
         StringBuffer sb = new StringBuffer(bytes.length * 2);
         for (int i = 0; i < bytes.length; i++) {
-            sb.append(convertDigit((int) (bytes[i] >> 4)));
-            sb.append(convertDigit((int) (bytes[i] & 0x0f)));
+            sb.append(convertDigit(bytes[i] >> 4));
+            sb.append(convertDigit(bytes[i] & 0x0f));
         }
         return (sb.toString());
 

Modified: tomcat/trunk/java/org/apache/catalina/util/MD5Encoder.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/MD5Encoder.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/MD5Encoder.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/MD5Encoder.java Sun Sep 14 12:45:08 2008
@@ -58,8 +58,8 @@
         char[] buffer = new char[32];
 
         for (int i=0; i<16; i++) {
-            int low = (int) (binaryData[i] & 0x0f);
-            int high = (int) ((binaryData[i] & 0xf0) >> 4);
+            int low = binaryData[i] & 0x0f;
+            int high = (binaryData[i] & 0xf0) >> 4;
             buffer[i*2] = hexadecimal[high];
             buffer[i*2 + 1] = hexadecimal[low];
         }

Modified: tomcat/trunk/java/org/apache/catalina/util/MIME2Java.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/MIME2Java.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/MIME2Java.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/MIME2Java.java Sun Sep 14 12:45:08 2008
@@ -471,11 +471,11 @@
  */
 public class MIME2Java {
 
-    static private Hashtable s_enchash;
-    static private Hashtable s_revhash;
+    static private Hashtable<String,String> s_enchash;
+    static private Hashtable<String,String> s_revhash;
 
     static {
-        s_enchash = new Hashtable();
+        s_enchash = new Hashtable<String,String>();
         //    <preferred MIME name>, <Java encoding name>
         s_enchash.put("UTF-8", "UTF8");
         s_enchash.put("US-ASCII",        "8859_1");    // ?
@@ -519,7 +519,7 @@
                                                 // j:CNS11643 -> EUC-TW?
                                                 // ISO-2022-CN? ISO-2022-CN-EXT?
 
-        s_revhash = new Hashtable();
+        s_revhash = new Hashtable<String,String>();
         //    <Java encoding name>, <preferred MIME name>
         s_revhash.put("UTF8", "UTF-8");
         //s_revhash.put("8859_1", "US-ASCII");    // ?
@@ -580,7 +580,7 @@
      * @see #reverse
      */
     public static String convert(String mimeCharsetName) {
-        return (String)s_enchash.get(mimeCharsetName.toUpperCase());
+        return s_enchash.get(mimeCharsetName.toUpperCase());
     }
 
     /**
@@ -598,6 +598,6 @@
      * @see #convert
      */
     public static String reverse(String encoding) {
-        return (String)s_revhash.get(encoding.toUpperCase());
+        return s_revhash.get(encoding.toUpperCase());
     }
 }

Modified: tomcat/trunk/java/org/apache/catalina/util/ManifestResource.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/ManifestResource.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/ManifestResource.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/ManifestResource.java Sun Sep 14 12:45:08 2008
@@ -39,8 +39,8 @@
     public static final int WAR = 2;
     public static final int APPLICATION = 3;
     
-    private ArrayList availableExtensions = null;
-    private ArrayList requiredExtensions = null;
+    private ArrayList<Extension> availableExtensions = null;
+    private ArrayList<Extension> requiredExtensions = null;
     
     private String resourceName = null;
     private int resourceType = -1;
@@ -66,7 +66,7 @@
      *
      * @return List of available extensions
      */
-    public ArrayList getAvailableExtensions() {
+    public ArrayList<Extension> getAvailableExtensions() {
         return availableExtensions;
     }
     
@@ -75,7 +75,7 @@
      *
      * @return List of required extensions
      */
-    public ArrayList getRequiredExtensions() {
+    public ArrayList<Extension> getRequiredExtensions() {
         return requiredExtensions;   
     }
     
@@ -119,9 +119,9 @@
         if (requiredExtensions == null) {
             return true;
         }
-        Iterator it = requiredExtensions.iterator();
+        Iterator<Extension> it = requiredExtensions.iterator();
         while (it.hasNext()) {
-            Extension ext = (Extension)it.next();
+            Extension ext = it.next();
             if (!ext.isFulfilled()) return false;            
         }
         return true;
@@ -165,14 +165,14 @@
      * @return List of required extensions, or null if the application
      * does not require any extensions
      */
-    private ArrayList getRequiredExtensions(Manifest manifest) {
+    private ArrayList<Extension> getRequiredExtensions(Manifest manifest) {
 
         Attributes attributes = manifest.getMainAttributes();
         String names = attributes.getValue("Extension-List");
         if (names == null)
             return null;
 
-        ArrayList extensionList = new ArrayList();
+        ArrayList<Extension> extensionList = new ArrayList<Extension>();
         names += " ";
 
         while (true) {
@@ -212,14 +212,14 @@
      * @return List of available extensions, or null if the web application
      * does not bundle any extensions
      */
-    private ArrayList getAvailableExtensions(Manifest manifest) {
+    private ArrayList<Extension> getAvailableExtensions(Manifest manifest) {
 
         Attributes attributes = manifest.getMainAttributes();
         String name = attributes.getValue("Extension-Name");
         if (name == null)
             return null;
 
-        ArrayList extensionList = new ArrayList();
+        ArrayList<Extension> extensionList = new ArrayList<Extension>();
 
         Extension extension = new Extension();
         extension.setExtensionName(name);

Modified: tomcat/trunk/java/org/apache/catalina/util/SchemaResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/SchemaResolver.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/SchemaResolver.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/SchemaResolver.java Sun Sep 14 12:45:08 2008
@@ -43,7 +43,8 @@
      * The URLs of dtds and schemas that have been registered, keyed by the
      * public identifier that corresponds.
      */
-    protected HashMap entityValidator = new HashMap();
+    protected HashMap<String,String> entityValidator =
+        new HashMap<String,String>();
 
 
     /**
@@ -109,14 +110,14 @@
         // Has this system identifier been registered?
         String entityURL = null;
         if (publicId != null) {
-            entityURL = (String) entityValidator.get(publicId);
+            entityURL = entityValidator.get(publicId);
         }
 
         // Redirect the schema location to a local destination
         String key = null;
         if (entityURL == null && systemId != null) {
             key = systemId.substring(systemId.lastIndexOf('/')+1);
-            entityURL = (String)entityValidator.get(key);
+            entityURL = entityValidator.get(key);
         }
 
         if (entityURL == null) {

Modified: tomcat/trunk/java/org/apache/catalina/util/ServerInfo.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/ServerInfo.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/ServerInfo.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/ServerInfo.java Sun Sep 14 12:45:08 2008
@@ -64,7 +64,7 @@
             serverBuilt = props.getProperty("server.built");
             serverNumber = props.getProperty("server.number");
         } catch (Throwable t) {
-            ;
+            //Ignore
         }
         if (serverInfo == null)
             serverInfo = "Apache Tomcat";

Modified: tomcat/trunk/java/org/apache/catalina/util/StringManager.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/StringManager.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/StringManager.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/StringManager.java Sun Sep 14 12:45:08 2008
@@ -147,7 +147,7 @@
             Object nonNullArgs[] = args;
             for (int i=0; i<args.length; i++) {
                 if (args[i] == null) {
-                    if (nonNullArgs==args) nonNullArgs=(Object[])args.clone();
+                    if (nonNullArgs==args) nonNullArgs = args.clone();
                     nonNullArgs[i] = "null";
                 }
             }
@@ -231,7 +231,8 @@
     // STATIC SUPPORT METHODS
     // --------------------------------------------------------------
 
-    private static Hashtable managers = new Hashtable();
+    private static Hashtable<String,StringManager> managers =
+        new Hashtable<String,StringManager>();
 
     /**
      * Get the StringManager for a particular package. If a manager for
@@ -242,7 +243,7 @@
      */
 
     public synchronized static StringManager getManager(String packageName) {
-        StringManager mgr = (StringManager)managers.get(packageName);
+        StringManager mgr = managers.get(packageName);
 
         if (mgr == null) {
             mgr = new StringManager(packageName);

Modified: tomcat/trunk/java/org/apache/catalina/util/URLEncoder.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/URLEncoder.java?rev=695273&r1=695272&r2=695273&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/URLEncoder.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/URLEncoder.java Sun Sep 14 12:45:08 2008
@@ -59,7 +59,6 @@
 
     public String encode( String path ) {
         int maxBytesPerChar = 10;
-        int caseDiff = ('a' - 'A');
         StringBuffer rewrittenPath = new StringBuffer(path.length());
         ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar);
         OutputStreamWriter writer = null;
@@ -71,7 +70,7 @@
         }
 
         for (int i = 0; i < path.length(); i++) {
-            int c = (int) path.charAt(i);
+            int c = path.charAt(i);
             if (safeCharacters.get(c)) {
                 rewrittenPath.append((char)c);
             } else {
@@ -88,8 +87,8 @@
                     // Converting each byte in the buffer
                     byte toEncode = ba[j];
                     rewrittenPath.append('%');
-                    int low = (int) (toEncode & 0x0f);
-                    int high = (int) ((toEncode & 0xf0) >> 4);
+                    int low = toEncode & 0x0f;
+                    int high = (toEncode & 0xf0) >> 4;
                     rewrittenPath.append(hexadecimal[high]);
                     rewrittenPath.append(hexadecimal[low]);
                 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message