[izpack-changes] izpack-src/src/lib/com/izforge/izpack/util Console.java,1.9,1.10 Debug.java,1.9,1.10 FileExecutor.java,1.20,1.21 FileUtil.java,1.1,1.2 HostAddressValidator.java,1.5,1.6 IoHelper.java,1.25,1.26 IsPortValidator.java,1.4,1.5 JarOutputStream.java,1.4,1.5 OSClassHelper.java,1.6,1.7 OsConstraint.java,1.13,1.14 OsVersion.java,1.14,1.15 PortValidator.java,1.4,1.5 StringTool.java,1.8,1.9 TargetFactory.java,1.19,1.20

jponge nobody at sheep.berlios.de
Tue Mar 21 19:15:06 CET 2006


Update of /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util
In directory sheep:/tmp/cvs-serv3622/src/lib/com/izforge/izpack/util

Modified Files:
	Console.java Debug.java FileExecutor.java FileUtil.java 
	HostAddressValidator.java IoHelper.java IsPortValidator.java 
	JarOutputStream.java OSClassHelper.java OsConstraint.java 
	OsVersion.java PortValidator.java StringTool.java 
	TargetFactory.java 
Log Message:
Some fixes adviced by IntelliJ IDEA 5.1 code inspector.

Index: Console.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/Console.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Console.java	12 Mar 2006 16:32:27 -0000	1.9
+++ Console.java	21 Mar 2006 18:14:51 -0000	1.10
@@ -296,7 +296,7 @@
     {
         textArea.write(str);
     }
-};
+}
 
 class ConsoleWriter extends java.io.OutputStream
 {
@@ -351,7 +351,7 @@
         buffer.setLength(0);
         SwingUtilities.invokeLater(new ConsoleWrite(textArea, str));
     }
-};
+}
 
 class ConsoleTextArea extends JTextArea implements KeyListener, DocumentListener
 {
@@ -363,8 +363,6 @@
 
     private ConsoleWriter console1;
 
-    private ConsoleWriter console2;
-
     private PrintStream out;
 
     private PrintStream err;
@@ -390,7 +388,7 @@
         super();
         history = new java.util.Vector();
         console1 = new ConsoleWriter(this);
-        console2 = new ConsoleWriter(this);
+        ConsoleWriter console2 = new ConsoleWriter(this);
         out = new PrintStream(console1);
         err = new PrintStream(console2);
         PipedOutputStream outPipe = new PipedOutputStream();
@@ -629,4 +627,4 @@
         return err;
     }
 
-};
+}
\ No newline at end of file

Index: Debug.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/Debug.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Debug.java	12 Mar 2006 16:32:28 -0000	1.9
+++ Debug.java	21 Mar 2006 18:14:51 -0000	1.10
@@ -112,15 +112,9 @@
   public static String LOGFILENAME = LOGFILE_PREFIX + System.currentTimeMillis(  ) +
                                      LOGFILE_EXTENSION;
 
-  /** internal used File writer */
-  private static BufferedWriter fw;
-
-  /** internal used Printfile writer */
-  private static PrintWriter logfile;
-
-  /**
-   * The log initializion bloc.
-   */
+    /**
+     * The log initializion bloc.
+     */
   static
   {
     boolean st = false;
@@ -172,7 +166,7 @@
     if( LOG )
     {
       System.out.println( DLOG + " enabled." );
-      logfile = createLogFile(  );
+      PrintWriter logfile = createLogFile();
 
       Debug.log( Installer.class.getName(  ) + " LogFile created at " +
                  new Date( System.currentTimeMillis(  ) ) );
@@ -255,12 +249,13 @@
   public static void log( Object o )
   {
     //if LOG was given 
-    if( LOG == true )
+    if(LOG )
     {
-      if( ( logfile = getLogFile(  ) ) == null )
-      {
-        logfile = createLogFile(  );
-      }
+        PrintWriter logfile;
+        if( ( logfile = getLogFile(  ) ) == null )
+        {
+          logfile = createLogFile(  );
+        }
 
       if( logfile != null )
       {
@@ -314,26 +309,27 @@
 
     File out = new File( tempDir, logfilename );
 
-    if( tempDirFile.canWrite(  ) )
-    {
-      try
+      PrintWriter logfile;
+      if( tempDirFile.canWrite(  ) )
       {
-        fw      = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( out ),
-                                                              "UTF-8" ) );
-        logfile = setLogFile( new PrintWriter( fw ) );
+        try
+        {
+            BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(out),
+                    "UTF-8"));
+          logfile = setLogFile( new PrintWriter( fw ) );
+        }
+        catch( Exception e )
+        {
+          logfile = null;
+          e.printStackTrace(  );
+        }
       }
-      catch( Exception e )
+      else
       {
         logfile = null;
-        e.printStackTrace(  );
+        System.err.println( "Fatal: cannot write File: '" + logfilename + "' into: " +
+                            tempDirFile );
       }
-    }
-    else
-    {
-      logfile = null;
-      System.err.println( "Fatal: cannot write File: '" + logfilename + "' into: " +
-                          tempDirFile );
-    }
 
     return logfile;
   }
@@ -428,7 +424,7 @@
    */
   public static PrintWriter getLogFile(  )
   {
-    logfile = (PrintWriter) System.getProperties(  ).get( IZPACK_LOGFILE );
+    PrintWriter logfile = (PrintWriter) System.getProperties().get(IZPACK_LOGFILE);
 
     return logfile;
   }
@@ -443,7 +439,7 @@
   {
     System.getProperties(  ).put( IZPACK_LOGFILE, aLogFile );
 
-    logfile = (PrintWriter) System.getProperties(  ).get( IZPACK_LOGFILE );
+    PrintWriter logfile = (PrintWriter) System.getProperties().get(IZPACK_LOGFILE);
 
     if( logfile == null )
     {

Index: FileExecutor.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/FileExecutor.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- FileExecutor.java	12 Mar 2006 16:32:28 -0000	1.20
+++ FileExecutor.java	21 Mar 2006 18:14:51 -0000	1.21
@@ -152,7 +152,7 @@
         {
             for (int i = 0; i < params.length; i++)
             {
-                retval.append("\tparams: " + params[i]);
+                retval.append("\tparams: ").append(params[i]);
                 retval.append("\n");
             }
         }

Index: FileUtil.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/FileUtil.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- FileUtil.java	26 Aug 2005 08:28:47 -0000	1.1
+++ FileUtil.java	21 Mar 2006 18:14:52 -0000	1.2
@@ -106,8 +106,8 @@
   {
     boolean result = false;
 
-    String  searchString = new String( caseInSensitiveSearch
-                                       ? aSearchString.toLowerCase() : aSearchString );
+    String  searchString = caseInSensitiveSearch
+            ? aSearchString.toLowerCase() : aSearchString;
 
     ArrayList fileContent = new ArrayList();
 
@@ -127,7 +127,7 @@
     {
       String currentline = (String) linesIter.next(  );
 
-      if( caseInSensitiveSearch == true )
+      if(caseInSensitiveSearch )
       {
         currentline = currentline.toLowerCase(  );
       }

Index: HostAddressValidator.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/HostAddressValidator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- HostAddressValidator.java	12 Mar 2006 16:32:28 -0000	1.5
+++ HostAddressValidator.java	21 Mar 2006 18:14:52 -0000	1.6
@@ -59,14 +59,7 @@
         {
             inet = InetAddress.getByName(host);
             ServerSocket socket = new ServerSocket(port, 0, inet);
-            if (socket.getLocalPort() > 0)
-            {
-                retValue = true;
-            }
-            else
-            {
-                retValue = false;
-            }
+            retValue = socket.getLocalPort() > 0;
             socket.close();
         }
         catch (Exception ex)

Index: IoHelper.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/IoHelper.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- IoHelper.java	12 Mar 2006 16:32:28 -0000	1.25
+++ IoHelper.java	21 Mar 2006 18:14:52 -0000	1.26
@@ -325,7 +325,7 @@
      */
     public static boolean supported(String method)
     {
-        if (method.equals("getFreeSpace"))
+        if ("getFreeSpace".equals(method))
         {
             if (OsVersion.IS_UNIX) return true;
             if (OsVersion.IS_WINDOWS)
@@ -335,19 +335,19 @@
                 return (true);
             }
         }
-        else if (method.equals("chmod"))
+        else if ("chmod".equals(method))
         {
             if (OsVersion.IS_UNIX) return true;
         }
-        else if (method.equals("copyFile"))
+        else if ("copyFile".equals(method))
         {
             return true;
         }
-        else if (method.equals("getPrimaryGroup"))
+        else if ("getPrimaryGroup".equals(method))
         {
             if (OsVersion.IS_UNIX) return true;
         }
-        else if (method.equals("getenv"))
+        else if ("getenv".equals(method))
         {
             return true;
         }

Index: IsPortValidator.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/IsPortValidator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- IsPortValidator.java	12 Mar 2006 16:32:28 -0000	1.4
+++ IsPortValidator.java	21 Mar 2006 18:14:52 -0000	1.5
@@ -36,7 +36,7 @@
     {
         int port = 0;
 
-        if (client.getFieldContents(0).equals("")) { return false; }
+        if ("".equals(client.getFieldContents(0))) { return false; }
 
         try
         {

Index: JarOutputStream.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/JarOutputStream.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- JarOutputStream.java	12 Mar 2006 16:32:28 -0000	1.4
+++ JarOutputStream.java	21 Mar 2006 18:14:52 -0000	1.5
@@ -234,7 +234,7 @@
      */
     private static void set16(byte[] b, int off, int value) 
     {
-		b[off+0] = (byte)value;
+		b[off] = (byte)value;
 		b[off+1] = (byte)(value >> 8);
     }
 

Index: OSClassHelper.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/OSClassHelper.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- OSClassHelper.java	12 Mar 2006 16:32:28 -0000	1.6
+++ OSClassHelper.java	21 Mar 2006 18:14:52 -0000	1.7
@@ -88,7 +88,7 @@
 
     public boolean good()
     {
-        return (worker != null ? true : false);
+        return (worker != null);
     }
 
     public boolean verify(AutomatedInstallData idata) throws Exception

Index: OsConstraint.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/OsConstraint.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- OsConstraint.java	12 Mar 2006 16:32:28 -0000	1.13
+++ OsConstraint.java	21 Mar 2006 18:14:52 -0000	1.14
@@ -96,15 +96,15 @@
         }
         if (match && family != null)
         {
-            if (family.equals("windows"))
+            if ("windows".equals(family))
             {
                 match = OsVersion.IS_WINDOWS;
             }
-            else if (family.equals("mac") || family.equals("osx"))
+            else if ("mac".equals(family) || "osx".equals(family))
             {
                 match = OsVersion.IS_OSX;
             }
-            else if (family.equals("unix"))
+            else if ("unix".equals(family))
             {
                 match = OsVersion.IS_UNIX;
             }
@@ -236,10 +236,10 @@
     {
         StringBuffer retval = new StringBuffer();
         retval.append("[Os ");
-        retval.append(" family " + family);
-        retval.append(" name " + name);
-        retval.append(" version " + version);
-        retval.append(" arch " + arch);
+        retval.append(" family ").append(family);
+        retval.append(" name ").append(name);
+        retval.append(" version ").append(version);
+        retval.append(" arch ").append(arch);
         retval.append(" ]");
         return retval.toString();
     }

Index: OsVersion.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/OsVersion.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- OsVersion.java	12 Mar 2006 16:32:28 -0000	1.14
+++ OsVersion.java	21 Mar 2006 18:14:52 -0000	1.15
@@ -102,7 +102,7 @@
      */
     private static String getReleaseFileName()
     {
-        String result = new String();
+        String result = "";
 
         File[] etcList = new File("/etc").listFiles();
         
@@ -227,19 +227,19 @@
     public static String getOsDetails()
     {
         StringBuffer result = new StringBuffer();
-        result.append( "OS_NAME=" + OS_NAME + NL );
+        result.append("OS_NAME=").append(OS_NAME).append(NL);
 
         if( IS_UNIX )
         {
             if( IS_LINUX )
             {
-              result.append( getLinuxDistribution() + NL );
+                result.append(getLinuxDistribution()).append(NL);
             }
             else
             {
                 try
                 {
-                  result.append( FileUtil.getFileContent( getReleaseFileName() ) + NL );
+                    result.append(FileUtil.getFileContent(getReleaseFileName())).append(NL);
                 }
                 catch (IOException e)
                 {
@@ -250,8 +250,7 @@
 
         if( IS_WINDOWS )
         {
-            result.append( System.getProperty( OSNAME ) + SP
-                    + System.getProperty( "sun.os.patch.level", "" ) + NL );
+            result.append(System.getProperty(OSNAME)).append(SP).append(System.getProperty("sun.os.patch.level", "")).append(NL);
         }
         return result.toString();
     }

Index: PortValidator.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/PortValidator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- PortValidator.java	12 Mar 2006 16:32:28 -0000	1.4
+++ PortValidator.java	21 Mar 2006 18:14:52 -0000	1.5
@@ -55,14 +55,7 @@
             {
                 inet = InetAddress.getByName(host);
                 ServerSocket socket = new ServerSocket(Integer.parseInt(value), 0, inet);
-                if (socket.getLocalPort() > 0)
-                {
-                    retValue = true;
-                }
-                else
-                {
-                    retValue = false;
-                }
+                retValue = socket.getLocalPort() > 0;
                 if (!retValue)
                 {
                     break;

Index: StringTool.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/StringTool.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- StringTool.java	12 Mar 2006 16:32:28 -0000	1.8
+++ StringTool.java	21 Mar 2006 18:14:52 -0000	1.9
@@ -207,7 +207,7 @@
     
         for (int idx = 0; idx < aStringList.size(); idx++)
         {
-            temp.append(aStringList.get(idx) + "\n");
+            temp.append(aStringList.get(idx)).append("\n");
         }
     
         return temp.toString();

Index: TargetFactory.java
===================================================================
RCS file: /cvsroot/izpack/izpack-src/src/lib/com/izforge/izpack/util/TargetFactory.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- TargetFactory.java	12 Mar 2006 16:32:28 -0000	1.19
+++ TargetFactory.java	21 Mar 2006 18:14:52 -0000	1.20
@@ -612,7 +612,7 @@
                 while (line != null)
                 {
                     line = line.trim();
-                    if (!line.equals(""))
+                    if (!"".equals(line))
                     {
                         break;
                     }
@@ -637,7 +637,7 @@
         // if we were unable to obtain a path from a resource,
         // use the default for the traget operating system.
         // ----------------------------------------------------
-        if (path == null || path.equals(""))
+        if (path == null || "".equals(path))
         {
             path = "";
 




More information about the izpack-changes mailing list