Author: markt
Date: Thu Jul  5 19:36:32 2007
New Revision: 553700

URL: http://svn.apache.org/viewvc?view=rev&rev=553700
Log:
o.a.t.util.http
Tabs -> 8 spaces
Fix compiler warnings
No functional change

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/AcceptLanguage.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/BaseRequest.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Cookies.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/MimeMap.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/ServerCookie.java

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/AcceptLanguage.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/AcceptLanguage.java?view=diff&rev=553700&r1=553699&r2=553700
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/AcceptLanguage.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/AcceptLanguage.java 
Thu Jul  5 19:36:32 2007
@@ -38,44 +38,46 @@
 public class AcceptLanguage {
 
     public static Locale getLocale(String acceptLanguage) {
-       if( acceptLanguage == null ) return Locale.getDefault();
+        if( acceptLanguage == null ) return Locale.getDefault();
 
-        Hashtable languages = new Hashtable();
-        Vector quality=new Vector();
-        processAcceptLanguage(acceptLanguage, languages,quality);
+        Hashtable<String,Vector<String>> languages =
+            new Hashtable<String,Vector<String>>();
+        Vector<Double> quality = new Vector<Double>();
+        processAcceptLanguage(acceptLanguage, languages, quality);
 
         if (languages.size() == 0) return Locale.getDefault();
 
-        Vector l = new Vector();
+        Vector<Locale> l = new Vector<Locale>();
         extractLocales( languages,quality, l);
 
         return (Locale)l.elementAt(0);
     }
 
     public static Enumeration getLocales(String acceptLanguage) {
-       // Short circuit with an empty enumeration if null header
+            // Short circuit with an empty enumeration if null header
         if (acceptLanguage == null) {
-            Vector v = new Vector();
+            Vector<Locale> v = new Vector<Locale>();
             v.addElement(Locale.getDefault());
             return v.elements();
         }
-       
-        Hashtable languages = new Hashtable();
-        Vector quality=new Vector();
-       processAcceptLanguage(acceptLanguage, languages , quality);
+        
+        Hashtable<String,Vector<String>> languages =
+            new Hashtable<String,Vector<String>>();
+        Vector<Double> quality=new Vector<Double>();
+            processAcceptLanguage(acceptLanguage, languages , quality);
 
         if (languages.size() == 0) {
-            Vector v = new Vector();
+            Vector<Locale> v = new Vector<Locale>();
             v.addElement(Locale.getDefault());
             return v.elements();
         }
-       Vector l = new Vector();
-       extractLocales( languages, quality , l);
-       return l.elements();
+            Vector<Locale> l = new Vector<Locale>();
+            extractLocales( languages, quality , l);
+            return l.elements();
     }
 
     private static void processAcceptLanguage( String acceptLanguage,
-                                             Hashtable languages, Vector q)
+            Hashtable<String,Vector<String>> languages, Vector<Double> q)
     {
         StringTokenizer languageTokenizer =
             new StringTokenizer(acceptLanguage, ",");
@@ -90,7 +92,7 @@
             if (qValueIndex > -1 &&
                     qValueIndex < qIndex &&
                     qIndex < equalIndex) {
-               String qValueStr = language.substring(qValueIndex + 1);
+                    String qValueStr = language.substring(qValueIndex + 1);
                 language = language.substring(0, qValueIndex);
                 qValueStr = qValueStr.trim().toLowerCase();
                 qValueIndex = qValueStr.indexOf('=');
@@ -110,11 +112,11 @@
 
             if (! language.equals("*")) {
                 String key = qValue.toString();
-                Vector v;
+                Vector<String> v;
                 if (languages.containsKey(key)) {
-                    v = (Vector)languages.get(key) ;
+                    v = languages.get(key) ;
                 } else {
-                    v= new Vector();
+                    v= new Vector<String>();
                     q.addElement(qValue);
                 }
                 v.addElement(language);
@@ -123,7 +125,8 @@
         }
     }
 
-    private static void extractLocales(Hashtable languages, Vector q,Vector l)
+    private static void extractLocales(Hashtable languages, Vector q,
+            Vector<Locale> l)
     {
         // XXX We will need to order by q value Vector in the Future ?
         Enumeration e = q.elements();
@@ -132,9 +135,9 @@
                 (Vector)languages.get(((Double)e.nextElement()).toString());
             Enumeration le = v.elements();
             while (le.hasMoreElements()) {
-               String language = (String)le.nextElement();
-                       String country = "";
-                       int countryIndex = language.indexOf("-");
+                    String language = (String)le.nextElement();
+                        String country = "";
+                        int countryIndex = language.indexOf("-");
                 if (countryIndex > -1) {
                     country = language.substring(countryIndex + 1).trim();
                     language = language.substring(0, countryIndex).trim();

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/BaseRequest.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/BaseRequest.java?view=diff&rev=553700&r1=553699&r2=553700
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/BaseRequest.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/BaseRequest.java Thu 
Jul  5 19:36:32 2007
@@ -59,7 +59,7 @@
     MessageBytes contentType = MessageBytes.newInstance();
     MimeHeaders headers = new MimeHeaders();
     Cookies cookies = new Cookies();
-    HashMap attributes = new HashMap();
+    HashMap<String,Object> attributes = new HashMap<String,Object>();
 
     MessageBytes tomcatInstanceId = MessageBytes.newInstance();
     

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Cookies.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Cookies.java?view=diff&rev=553700&r1=553699&r2=553700
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Cookies.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Cookies.java Thu Jul  
5 19:36:32 2007
@@ -343,7 +343,6 @@
     */
     public static int findDelim3( byte bytes[], int off, int end, byte cc )
     {
-        byte prev = bytes[off]; 
         while( off < end ) {
             byte b=bytes[off];
             if ( b== '\\' ) {

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/MimeMap.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/MimeMap.java?view=diff&rev=553700&r1=553699&r2=553700
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/MimeMap.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/MimeMap.java Thu Jul  
5 19:36:32 2007
@@ -32,7 +32,8 @@
     // Defaults - all of them are "well-known" types,
     // you can add using normal web.xml.
     
-    public static Hashtable defaultMap=new Hashtable(101);
+    public static Hashtable<String,String> defaultMap =
+        new Hashtable<String,String>(101);
     static {
         defaultMap.put("txt", "text/plain");
         defaultMap.put("html","text/html");
@@ -42,7 +43,7 @@
         defaultMap.put("jpe", "image/jpeg");
         defaultMap.put("jpeg", "image/jpeg");
         defaultMap.put("png", "image/png");
-               defaultMap.put("java", "text/plain");
+                defaultMap.put("java", "text/plain");
         defaultMap.put("body", "text/html");
         defaultMap.put("rtx", "text/richtext");
         defaultMap.put("tsv", "text/tab-separated-values");
@@ -133,7 +134,7 @@
     }
     
 
-    private Hashtable map = new Hashtable();
+    private Hashtable<String,String> map = new Hashtable<String,String>();
 
     public void addContentType(String extn, String type) {
         map.put(extn, type.toLowerCase());
@@ -145,8 +146,8 @@
 
     public String getContentType(String extn) {
         String type = (String)map.get(extn.toLowerCase());
-       if( type == null ) type=(String)defaultMap.get( extn );
-       return type;
+        if( type == null ) type=(String)defaultMap.get( extn );
+        return type;
     }
 
     public void removeContentType(String extn) {
@@ -158,14 +159,14 @@
     public static String getExtension( String fileName ) {
         // play it safe and get rid of any fragment id
         // that might be there
-       int length=fileName.length();
-       
+        int length=fileName.length();
+        
         int newEnd = fileName.lastIndexOf('#');
-       if( newEnd== -1 ) newEnd=length;
-       // Instead of creating a new string.
-       //         if (i != -1) {
-       //             fileName = fileName.substring(0, i);
-       //         }
+        if( newEnd== -1 ) newEnd=length;
+        // Instead of creating a new string.
+        //         if (i != -1) {
+        //             fileName = fileName.substring(0, i);
+        //         }
         int i = fileName.lastIndexOf('.', newEnd );
         if (i != -1) {
              return  fileName.substring(i + 1, newEnd );
@@ -176,7 +177,7 @@
     }
     
     public String getContentTypeFor(String fileName) {
-       String extn=getExtension( fileName );
+        String extn=getExtension( fileName );
         if (extn!=null) {
             return getContentType(extn);
         } else {

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java?view=diff&rev=553700&r1=553699&r2=553700
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java Thu 
Jul  5 19:36:32 2007
@@ -40,7 +40,8 @@
     // Transition: we'll use the same Hashtable( String->String[] )
     // for the beginning. When we are sure all accesses happen through
     // this class - we can switch to MultiMap
-    private Hashtable paramHashStringArray=new Hashtable();
+    private Hashtable<String,String[]> paramHashStringArray =
+        new Hashtable<String,String[]>();
     private boolean didQueryParameters=false;
     private boolean didMerge=false;
     
@@ -225,7 +226,7 @@
 
         // Add the parent props to the child ( lower precedence )
         parent.merge();
-        Hashtable parentProps=parent.paramHashStringArray;
+        Hashtable<String,String[]> parentProps=parent.paramHashStringArray;
         merge2( paramHashStringArray , parentProps);
         didMerge=true;
         if(debug > 0 )
@@ -273,13 +274,14 @@
      *  Used to combine child parameters ( RequestDispatcher's query )
      *  with parent parameters ( original query or parent dispatcher )
      */
-    private static void merge2(Hashtable one, Hashtable two ) {
+    private static void merge2(Hashtable<String,String[]> one,
+            Hashtable<String,String[]> two ) {
         Enumeration e = two.keys();
 
         while (e.hasMoreElements()) {
             String name = (String) e.nextElement();
-            String[] oneValue = (String[]) one.get(name);
-            String[] twoValue = (String[]) two.get(name);
+            String[] oneValue = one.get(name);
+            String[] twoValue = two.get(name);
             String[] combinedValue;
 
             if (twoValue == null) {

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/ServerCookie.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/ServerCookie.java?view=diff&rev=553700&r1=553699&r2=553700
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/ServerCookie.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/ServerCookie.java Thu 
Jul  5 19:36:32 2007
@@ -43,15 +43,15 @@
     private MessageBytes name=MessageBytes.newInstance();
     private MessageBytes value=MessageBytes.newInstance();
 
-    private MessageBytes comment=MessageBytes.newInstance();    // 
;Comment=VALUE
-    private MessageBytes domain=MessageBytes.newInstance();    // 
;Domain=VALUE ...
+    private MessageBytes comment=MessageBytes.newInstance();   // 
;Comment=VALUE
+    private MessageBytes domain=MessageBytes.newInstance();    // ;Domain=VALUE
 
-    private int maxAge = -1;   // ;Max-Age=VALUE
-                               // ;Discard ... implied by maxAge < 0
+    private int maxAge = -1;        // ;Max-Age=VALUE
+                                // ;Discard ... implied by maxAge < 0
     // RFC2109: maxAge=0 will end a session
-    private MessageBytes path=MessageBytes.newInstance();      // ;Path=VALUE .
-    private boolean secure;    // ;Secure
-    private int version = 0;   // ;Version=1
+    private MessageBytes path=MessageBytes.newInstance();        // ;Path=VALUE
+    private boolean secure;        // ;Secure
+    private int version = 0;        // ;Version=1
 
     //XXX CommentURL, Port -> use notes ?
     
@@ -61,68 +61,68 @@
 
     public void recycle() {
         path.recycle();
-       name.recycle();
-       value.recycle();
-       comment.recycle();
-       maxAge=-1;
-       path.recycle();
+            name.recycle();
+            value.recycle();
+            comment.recycle();
+            maxAge=-1;
+            path.recycle();
         domain.recycle();
-       version=0;
-       secure=false;
+            version=0;
+            secure=false;
     }
 
     public MessageBytes getComment() {
-       return comment;
+        return comment;
     }
 
     public MessageBytes getDomain() {
-       return domain;
+        return domain;
     }
 
     public void setMaxAge(int expiry) {
-       maxAge = expiry;
+        maxAge = expiry;
     }
 
     public int getMaxAge() {
-       return maxAge;
+        return maxAge;
     }
 
 
     public MessageBytes getPath() {
-       return path;
+        return path;
     }
 
     public void setSecure(boolean flag) {
-       secure = flag;
+        secure = flag;
     }
 
     public boolean getSecure() {
-       return secure;
+        return secure;
     }
 
     public MessageBytes getName() {
-       return name;
+        return name;
     }
 
     public MessageBytes getValue() {
-       return value;
+        return value;
     }
 
     public int getVersion() {
-       return version;
+        return version;
     }
 
 
     public void setVersion(int v) {
-       version = v;
+        version = v;
     }
 
 
     // -------------------- utils --------------------
 
     public String toString() {
-       return "Cookie " + getName() + "=" + getValue() + " ; "
-           + getVersion() + " " + getPath() + " " + getDomain();
+        return "Cookie " + getName() + "=" + getValue() + " ; "
+            + getVersion() + " " + getPath() + " " + getDomain();
     }
     
     // Note -- disabled for now to allow full Netscape compatibility
@@ -136,52 +136,51 @@
      * Tests a string and returns true if the string counts as a
      * reserved token in the Java language.
      *
-     * @param value            the <code>String</code> to be tested
+     * @param value the <code>String</code> to be tested
      *
-     * @return                 <code>true</code> if the <code>String</code> is
-     *                         a reserved token; <code>false</code>
-     *                         if it is not
+     * @return      <code>true</code> if the <code>String</code> is a reserved
+     *              token; <code>false</code> if it is not
      */
     public static boolean isToken(String value) {
-       if( value==null) return true;
-       int len = value.length();
+        if( value==null) return true;
+        int len = value.length();
 
-       for (int i = 0; i < len; i++) {
-           char c = value.charAt(i);
+        for (int i = 0; i < len; i++) {
+            char c = value.charAt(i);
 
-           if (c < 0x20 || c >= 0x7f || tspecials.indexOf(c) != -1)
-               return false;
-       }
-       return true;
+            if (c < 0x20 || c >= 0x7f || tspecials.indexOf(c) != -1)
+                return false;
+        }
+        return true;
     }
 
     public static boolean isToken2(String value) {
-       if( value==null) return true;
-       int len = value.length();
+        if( value==null) return true;
+        int len = value.length();
 
-       for (int i = 0; i < len; i++) {
-           char c = value.charAt(i);
+        for (int i = 0; i < len; i++) {
+            char c = value.charAt(i);
 
-           if (c < 0x20 || c >= 0x7f || tspecials2.indexOf(c) != -1)
-               return false;
-       }
-       return true;
+            if (c < 0x20 || c >= 0x7f || tspecials2.indexOf(c) != -1)
+                return false;
+        }
+        return true;
     }
 
     public static boolean checkName( String name ) {
-       if (!isToken(name)
-               || name.equalsIgnoreCase("Comment")     // rfc2019
-               || name.equalsIgnoreCase("Discard")     // 2019++
-               || name.equalsIgnoreCase("Domain")
-               || name.equalsIgnoreCase("Expires")     // (old cookies)
-               || name.equalsIgnoreCase("Max-Age")     // rfc2019
-               || name.equalsIgnoreCase("Path")
-               || name.equalsIgnoreCase("Secure")
-               || name.equalsIgnoreCase("Version")
-           ) {
-           return false;
-       }
-       return true;
+        if (!isToken(name)
+                || name.equalsIgnoreCase("Comment")        // rfc2019
+                || name.equalsIgnoreCase("Discard")        // 2019++
+                || name.equalsIgnoreCase("Domain")
+                || name.equalsIgnoreCase("Expires")        // (old cookies)
+                || name.equalsIgnoreCase("Max-Age")        // rfc2019
+                || name.equalsIgnoreCase("Path")
+                || name.equalsIgnoreCase("Secure")
+                || name.equalsIgnoreCase("Version")
+            ) {
+            return false;
+        }
+        return true;
     }
 
     // -------------------- Cookie parsing tools
@@ -191,99 +190,100 @@
      *  version
      */
     public String getCookieHeaderName() {
-       return getCookieHeaderName(version);
+        return getCookieHeaderName(version);
     }
 
     /** Return the header name to set the cookie, based on cookie
      *  version
      */
     public static String getCookieHeaderName(int version) {
-       if( dbg>0 ) log( (version==1) ? "Set-Cookie2" : "Set-Cookie");
+        if( dbg>0 ) log( (version==1) ? "Set-Cookie2" : "Set-Cookie");
         if (version == 1) {
-           // RFC2109
-           return "Set-Cookie";
-           // XXX RFC2965 is not standard yet, and Set-Cookie2
-           // is not supported by Netscape 4, 6, IE 3, 5 .
-           // It is supported by Lynx, and there is hope 
-           //      return "Set-Cookie2";
+            // RFC2109
+            return "Set-Cookie";
+            // XXX RFC2965 is not standard yet, and Set-Cookie2
+            // is not supported by Netscape 4, 6, IE 3, 5 .
+            // It is supported by Lynx, and there is hope 
+            //            return "Set-Cookie2";
         } else {
-           // Old Netscape
-           return "Set-Cookie";
+            // Old Netscape
+            return "Set-Cookie";
         }
     }
 
-    private static final String ancientDate=DateTool.formatOldCookie(new 
Date(10000));
+    private static final String ancientDate =
+        DateTool.formatOldCookie(new Date(10000));
 
     public static void appendCookieValue( StringBuffer buf,
-                                         int version,
-                                         String name,
-                                         String value,
-                                         String path,
-                                         String domain,
-                                         String comment,
-                                         int maxAge,
-                                         boolean isSecure )
+                                          int version,
+                                          String name,
+                                          String value,
+                                          String path,
+                                          String domain,
+                                          String comment,
+                                          int maxAge,
+                                          boolean isSecure )
     {
         // this part is the same for all cookies
-       buf.append( name );
+        buf.append( name );
         buf.append("=");
         maybeQuote2(version, buf, value);
 
-       // XXX Netscape cookie: "; "
-       // add version 1 specific information
-       if (version == 1) {
-           // Version=1 ... required
-           buf.append ("; Version=1");
-
-           // Comment=comment
-           if ( comment!=null ) {
-               buf.append ("; Comment=");
-               maybeQuote (version, buf, comment);
-           }
-       }
-       
-       // add domain information, if present
-
-       if (domain!=null) {
-           buf.append("; Domain=");
-           maybeQuote (version, buf, domain);
-       }
-
-       // Max-Age=secs/Discard ... or use old "Expires" format
-       if (maxAge >= 0) {
-           if (version == 0) {
-               // XXX XXX XXX We need to send both, for
-               // interoperatibility (long word )
-               buf.append ("; Expires=");
-               // Wdy, DD-Mon-YY HH:MM:SS GMT ( Expires netscape format )
-               // To expire we need to set the time back in future
-               // ( [EMAIL PROTECTED] )
+        // XXX Netscape cookie: "; "
+         // add version 1 specific information
+        if (version == 1) {
+            // Version=1 ... required
+            buf.append ("; Version=1");
+
+            // Comment=comment
+            if ( comment!=null ) {
+                buf.append ("; Comment=");
+                maybeQuote (version, buf, comment);
+            }
+        }
+        
+        // add domain information, if present
+
+        if (domain!=null) {
+            buf.append("; Domain=");
+            maybeQuote (version, buf, domain);
+        }
+
+        // Max-Age=secs/Discard ... or use old "Expires" format
+        if (maxAge >= 0) {
+            if (version == 0) {
+                // XXX XXX XXX We need to send both, for
+                // interoperatibility (long word )
+                buf.append ("; Expires=");
+                // Wdy, DD-Mon-YY HH:MM:SS GMT ( Expires netscape format )
+                // To expire we need to set the time back in future
+                // ( [EMAIL PROTECTED] )
                 if (maxAge == 0)
-                   buf.append( ancientDate );
-               else
+                    buf.append( ancientDate );
+                else
                     DateTool.formatOldCookie
                         (new Date( System.currentTimeMillis() +
                                    maxAge *1000L), buf,
                          new FieldPosition(0));
 
-           } else {
-               buf.append ("; Max-Age=");
-               buf.append (maxAge);
-           }
-       }
-
-       // Path=path
-       if (path!=null) {
-           buf.append ("; Path=");
-           maybeQuote (version, buf, path);
-       }
-
-       // Secure
-       if (isSecure) {
-         buf.append ("; Secure");
-       }
-       
-       
+            } else {
+                buf.append ("; Max-Age=");
+                buf.append (maxAge);
+            }
+        }
+
+        // Path=path
+        if (path!=null) {
+            buf.append ("; Path=");
+            maybeQuote (version, buf, path);
+        }
+
+        // Secure
+        if (isSecure) {
+          buf.append ("; Secure");
+        }
+        
+        
     }
 
     public static void maybeQuote (int version, StringBuffer buf,



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to