maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r514376 - /maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
Date Sun, 04 Mar 2007 08:50:14 GMT
Author: brett
Date: Sun Mar  4 00:50:14 2007
New Revision: 514376

URL: http://svn.apache.org/viewvc?view=rev&rev=514376
Log:
use constants instead of magic numbers

Modified:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java?view=diff&rev=514376&r1=514375&r2=514376
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java
Sun Mar  4 00:50:14 2007
@@ -30,19 +30,28 @@
  */
 public class UrlUtils
 {
-    private static final BitSet UNRESERVED = new BitSet( 256 );
+    private static final BitSet UNRESERVED = new BitSet( Byte.MAX_VALUE - Byte.MIN_VALUE
+ 1 );
+
+    private static final int RADIX = 16;
+
+    private static final int MASK = 0xf;
+
+    private UrlUtils()
+    {
+    }
+
+    private static final String ENCODING = "US-ASCII";
 
     static
     {
         try
         {
             byte[] bytes =
-                "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'():/".getBytes(
"US-ASCII" );
+                "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'():/".getBytes(
ENCODING );
             for ( int i = 0; i < bytes.length; i++ )
             {
                 UNRESERVED.set( bytes[i] );
             }
-
         }
         catch ( UnsupportedEncodingException e )
         {
@@ -58,7 +67,7 @@
         // this is primarily to handle Windows where the user's home directory contains spaces
         try
         {
-            byte[] bytes = url.toString().getBytes( "US-ASCII" );
+            byte[] bytes = url.toString().getBytes( ENCODING );
             StringBuffer buf = new StringBuffer( bytes.length );
             for ( int i = 0; i < bytes.length; i++ )
             {
@@ -70,8 +79,8 @@
                 else
                 {
                     buf.append( '%' );
-                    buf.append( Character.forDigit( b >>> 4 & 0xf, 16 ) );
-                    buf.append( Character.forDigit( b & 0xf, 16 ) );
+                    buf.append( Character.forDigit( b >>> 4 & MASK, RADIX )
);
+                    buf.append( Character.forDigit( b & MASK, RADIX ) );
                 }
             }
             return new URL( buf.toString() );



Mime
View raw message