Hello

Since this mailing list is rather still, I don't know if somebody still
works on this project.

I read about the classpath project and took a look at the package. From the
source it looks quite impressive. Yes I haven't run it. However I found a
thing which I think could be done better:
Instead of doing:
  someIntVariable=defaultValue;
  String prop = = System.getProperty(somePropertyName);
  try
  {
     someIntVariable = Integer.parseInt(prop);
  }
  catch (NumberFormatException e) 
  { ; }
it is possible to do:
  someIntVariable = Integer.getInteger(somePropertyName,defaultValue);
advantages:
 - shorter
 - no code duplication

If you see disadvanteges, please tell me, else please consider my patch.

        Raimar

-- 
 email: [EMAIL PROTECTED] or [EMAIL PROTECTED]
 pgp 2: ID:0F9D7955 Len:1024 Fingerprint:7760F933D5478009 4FA0C56F1DC2FB8E
 "Transported to a surreal landscape, a young girl kills the first woman
  she meets and then teams up with three complete strangers to kill again."
      -- TV listing for the Wizard of Oz in the Marin Independent Journal
diff -ru -x *~ classpath-0.00/gnu/java/io/EncodingManager.java 
classpath-0.00.mod/gnu/java/io/EncodingManager.java
--- classpath-0.00/gnu/java/io/EncodingManager.java     Sat Jan 30 21:34:42 1999
+++ classpath-0.00.mod/gnu/java/io/EncodingManager.java Sat May 29 18:09:00 1999
@@ -120,9 +120,7 @@
     encoding_path = encoding_path + ":gnu.java.io";
 
   // Find the system default encoding name
-  String default_encoding = System.getProperty("file.encoding");
-  if (default_encoding == null)
-    default_encoding = "8859_1";
+  String default_encoding = System.getProperty("file.encoding","8859_1");
 
   // Load the class
   try
diff -ru -x *~ classpath-0.00/java/io/ByteArrayOutputStream.java 
classpath-0.00.mod/java/io/ByteArrayOutputStream.java
--- classpath-0.00/java/io/ByteArrayOutputStream.java   Sat Jan 30 21:35:43 1999
+++ classpath-0.00.mod/java/io/ByteArrayOutputStream.java       Sat May 29 18:31:00 
+1999
@@ -82,22 +82,12 @@
 
 static
 {
-  String ibs_str = System.getProperty(
-                      "gnu.java.io.ByteArrayOutputStream.initialBufferSize");
-  String bis_str = System.getProperty(
-                      "gnu.java.io.ByteArrayOutputStream.bufferIncrementSize");
-
-  try
-    {
-      initial_buffer_size = Integer.parseInt(ibs_str);
-    }
-  catch (NumberFormatException e) { ; }
-
-  try
-    {
-      buffer_increment_size = Integer.parseInt(bis_str);
-    }
-  catch (NumberFormatException e) { ; }
+  initial_buffer_size = Integer.getInteger(
+                      "gnu.java.io.ByteArrayOutputStream.initialBufferSize",
+                      DEFAULT_INITIAL_BUFFER_SIZE);
+  buffer_increment_size = Integer.getInteger(
+                      "gnu.java.io.ByteArrayOutputStream.bufferIncrementSize",
+                      DEFAULT_BUFFER_INCREMENT_SIZE);
 
   if (initial_buffer_size <= 0)
     initial_buffer_size = DEFAULT_INITIAL_BUFFER_SIZE;
diff -ru -x *~ classpath-0.00/java/io/CharArrayWriter.java 
classpath-0.00.mod/java/io/CharArrayWriter.java
--- classpath-0.00/java/io/CharArrayWriter.java Sat Jan 30 21:35:47 1999
+++ classpath-0.00.mod/java/io/CharArrayWriter.java     Sat May 29 18:30:49 1999
@@ -78,22 +78,12 @@
 
 static
 {
-  String ibs_str = System.getProperty(
-                      "gnu.java.io.CharArrayWriter.initialBufferSize");
-  String bis_str = System.getProperty(
-                      "gnu.java.io.CharArrayWriter.bufferIncrementSize");
-
-  try
-    {
-      initial_buffer_size = Integer.parseInt(ibs_str);
-    }
-  catch (NumberFormatException e) { ; }
-
-  try
-    {
-      buffer_increment_size = Integer.parseInt(bis_str);
-    }
-  catch (NumberFormatException e) { ; }
+  initial_buffer_size = Integer.getInteger(
+                      "gnu.java.io.CharArrayWriter.initialBufferSize",
+                      DEFAULT_INITIAL_BUFFER_SIZE);
+  buffer_increment_size = Integer.getInteger(
+                      "gnu.java.io.CharArrayWriter.bufferIncrementSize",
+                      DEFAULT_BUFFER_INCREMENT_SIZE);
 
   if (initial_buffer_size <= 0)
     initial_buffer_size = DEFAULT_INITIAL_BUFFER_SIZE;
diff -ru -x *~ classpath-0.00/java/io/PipedInputStream.java 
classpath-0.00.mod/java/io/PipedInputStream.java
--- classpath-0.00/java/io/PipedInputStream.java        Sat Jan 30 21:37:03 1999
+++ classpath-0.00.mod/java/io/PipedInputStream.java    Sat May 29 18:28:22 1999
@@ -72,23 +72,8 @@
 
 static
 {
-  String pipe_prop = System.getProperty("gnu.java.io.PipedInputStream.pipe_size");
-
-  if (pipe_prop == null)
-    {
-      pipe_size = PIPE_SIZE;
-    }
-  else
-    {
-      try
-        {
-          pipe_size = Integer.parseInt(pipe_prop);
-        }
-      catch (NumberFormatException e)
-        {
-          pipe_size = PIPE_SIZE;
-        }
-    }
+  pipe_size = Integer.getInteger("gnu.java.io.PipedInputStream.pipe_size",
+                                 PIPE_SIZE);
 
   String block_prop = System.getProperty("gnu.java.io.try_not_to_block");
   if (block_prop != null)
diff -ru -x *~ classpath-0.00/java/io/PipedReader.java 
classpath-0.00.mod/java/io/PipedReader.java
--- classpath-0.00/java/io/PipedReader.java     Sat Jan 30 21:37:16 1999
+++ classpath-0.00.mod/java/io/PipedReader.java Sat May 29 18:27:47 1999
@@ -72,23 +72,8 @@
 
 static
 {
-  String pipe_prop = System.getProperty("gnu.java.io.PipedReader.pipe_size");
-
-  if (pipe_prop == null)
-    {
-      pipe_size = PIPE_SIZE;
-    }
-  else
-    {
-      try
-        {
-          pipe_size = Integer.parseInt(pipe_prop);
-        }
-      catch (NumberFormatException e)
-        {
-          pipe_size = PIPE_SIZE;
-        }
-    }
+  pipe_size =  Integer.getInteger("gnu.java.io.PipedReader.pipe_size",
+                                  PIPE_SIZE);
 
   String block_prop = System.getProperty("gnu.java.io.try_not_to_block");
   if (block_prop != null)
diff -ru -x *~ classpath-0.00/java/net/InetAddress.java 
classpath-0.00.mod/java/net/InetAddress.java
--- classpath-0.00/java/net/InetAddress.java    Sat Jan 30 21:40:47 1999
+++ classpath-0.00.mod/java/net/InetAddress.java        Sat May 29 18:27:37 1999
@@ -98,35 +98,22 @@
 // Static initializer for the cache
 static
 {
-  cache_size = DEFAULT_CACHE_SIZE; 
-  cache_period = DEFAULT_CACHE_PERIOD * 60 * 1000; 
-  cache_purge_pct = DEFAULT_CACHE_PURGE_PCT;
-
   // Look for properties that override default caching behavior
-  try
-    {
-      String propval;
-
-      propval = System.getProperty("gnu.java.net.dns_cache_size");
-      if (propval != null)
-        cache_size = Integer.parseInt(propval);
-
-      propval = System.getProperty("gnu.java.net.dns_cache_period");
-        cache_period = Integer.parseInt(propval) * 60 * 1000;
-
-      propval = System.getProperty("gnu.java.net.dns_cache_purge_pct");
-        cache_purge_pct = Integer.parseInt(propval);
-    }
-   catch (SecurityException e) { ; }
-   catch (NumberFormatException e) { ; }
-
-   // Fallback to  defaults if necessary
-   if ((cache_purge_pct < 1) || (cache_purge_pct > 100))
-     cache_purge_pct = DEFAULT_CACHE_PURGE_PCT;
-
-   // Create the cache
-   if (cache_size != 0)
-     cache = new Hashtable(cache_size);
+  cache_size = Integer.getInteger("gnu.java.net.dns_cache_size",
+                                  DEFAULT_CACHE_SIZE);
+  cache_period = Integer.getInteger("gnu.java.net.dns_cache_period",
+                                    DEFAULT_CACHE_PERIOD * 60 * 1000);
+
+  cache_purge_pct =  Integer.getInteger("gnu.java.net.dns_cache_purge_pct",
+                                        DEFAULT_CACHE_PURGE_PCT);
+
+  // Fallback to  defaults if necessary
+  if ((cache_purge_pct < 1) || (cache_purge_pct > 100))
+      cache_purge_pct = DEFAULT_CACHE_PURGE_PCT;
+
+  // Create the cache
+  if (cache_size != 0)
+      cache = new Hashtable(cache_size);
 }      
 
 /*************************************************************************/

Reply via email to