[izpack-changes] r1590 - izpack-src/branches/branch-3.9/src/lib/com/izforge/izpack/util/os/unix

noreply at berlios.de noreply at berlios.de
Tue Sep 12 22:41:13 CEST 2006


Author: eppelman
Date: 2006-09-12 22:41:12 +0200 (Tue, 12 Sep 2006)
New Revision: 1590

Modified:
   izpack-src/branches/branch-3.9/src/lib/com/izforge/izpack/util/os/unix/ShellScript.java
Log:
Added needed append*(char) methods

Modified: izpack-src/branches/branch-3.9/src/lib/com/izforge/izpack/util/os/unix/ShellScript.java
===================================================================
--- izpack-src/branches/branch-3.9/src/lib/com/izforge/izpack/util/os/unix/ShellScript.java	2006-09-12 20:40:01 UTC (rev 1589)
+++ izpack-src/branches/branch-3.9/src/lib/com/izforge/izpack/util/os/unix/ShellScript.java	2006-09-12 20:41:12 UTC (rev 1590)
@@ -35,6 +35,8 @@
 {
 
     // ~ Static fields/initializers *********************************************************
+
+    // ~ Static fields/initializers *********************************************************
     /** Author = "marc.eppelmann_at_gmx.de" */
     private final static String Author = "Author: marc.eppelmann_at_gmx.de";
 
@@ -71,6 +73,7 @@
     private final static String header = lf + explanation + lf + H + Generator + lf + H + SCM_ID
             + lf + H + Author + lf + H + Revision + lf + H + currentDateMsg + lf + lf;
 
+    // ~ Instance fields ********************************************************************
 
     // ~ Instance fields ********************************************************************
     /** Internal ContentBuffer of this ShellScript */
@@ -80,6 +83,8 @@
     private String itsLocation;
 
     // ~ Constructors ***********************************************************************
+
+    // ~ Constructors ***********************************************************************
     /**
      * Creates and initializes the ShellScript for running on the given shell.
      * 
@@ -100,6 +105,8 @@
     }
 
     // ~ Methods ****************************************************************************
+
+    // ~ Methods ****************************************************************************
     /**
      * Appends an Object or String to this ShellScript.
      * 
@@ -111,16 +118,84 @@
     }
 
     /**
+     * Appends a Char to this ShellScript.
+     * 
+     * @param aChar a char to append
+     */
+    public void append(char aChar)
+    {
+        content.append(aChar);
+    }
+
+    /**
      * Appends an Object or String to this ShellScript with unix linefeed ("\n").
      * 
      * @param anObject the Object to append
      */
     public void appendln(Object anObject)
     {
-        append(anObject + lf);
+        append(anObject);
+        append(lf);
     }
 
     /**
+     * Appends a Char Object or String to this ShellScript with unix linefeed ("\n").
+     * 
+     * @param aChar a char to append
+     */
+    public void appendln(char aChar)
+    {
+        append(aChar);
+        append(lf);
+    }
+
+    /**
+     * Appends an Object or String to this ShellScript with unix linefeed ("\n").
+     */
+    public void appendln()
+    {
+        append(lf);
+    }
+
+    /**
+     * gets the Content of this Script.
+     * 
+     * @return the Content
+     */
+    public StringBuffer getContent()
+    {
+        return content;
+    }
+
+    /**
+     * Gets the Content of this Script as String 
+     * 
+     * @return the script as String
+     */
+    public String getContentAsString()
+    {
+        return content.toString();
+    }
+
+    /**
+     * Dumps the ShellScript Content, and Location.
+     * Use getContentAsString() to get this ShellScripts Content 
+     * 
+     * @return The ShellScript as Object dump.
+     */
+    public String toString()
+    {
+        StringBuffer result = new StringBuffer();
+        result.append(getClass().getName());
+        result.append('\n');
+        result.append(itsLocation);
+        result.append('\n');
+        result.append(content);
+
+        return result.toString();
+    }
+
+    /**
      * write this to the given Destination FileName
      * 
      * @param aDestination a destination filename
@@ -272,8 +347,11 @@
          * ShellScript s = new ShellScript( ); s.append( "ls $HOME" ); s.write( System.getProperty(
          * "user.home", "." ) + File.separator + "test.sh" );
          */
-        System.out.println(ShellScript.execute(new StringBuffer("ls $HOME"), System.getProperty(
-                "user.home", ".")
-                + File.separator + Long.toString(System.currentTimeMillis()) + "test.sh"));
+
+        /*
+         * System.out.println(ShellScript.execute(new StringBuffer("ls $HOME"), System.getProperty(
+         * "user.home", ".") + File.separator + Long.toString(System.currentTimeMillis()) +
+         * "test.sh"));
+         */
     }
 }




More information about the izpack-changes mailing list