[izpack-changes] r1814 - in izpack-src/branches/3.10: . src/lib/com/izforge/izpack/util

noreply at berlios.de noreply at berlios.de
Thu Apr 19 22:08:19 CEST 2007


Author: jponge
Date: 2007-04-19 22:08:13 +0200 (Thu, 19 Apr 2007)
New Revision: 1814

Modified:
   izpack-src/branches/3.10/Versions.txt
   izpack-src/branches/3.10/src/lib/com/izforge/izpack/util/VariableSubstitutor.java
Log:
VariableSubstitutor: new Java source files support (Max Fedorov via Julien Ponge)


Modified: izpack-src/branches/3.10/Versions.txt
===================================================================
--- izpack-src/branches/3.10/Versions.txt	2007-04-19 19:44:35 UTC (rev 1813)
+++ izpack-src/branches/3.10/Versions.txt	2007-04-19 20:08:13 UTC (rev 1814)
@@ -6,8 +6,8 @@
 - Dutch Langpack fixes (Hans Aikema)
 - Fix NPE for pack.id == null in dependencies/excludes (Hans Aikema)
 - Indonesian Langpack fixes (Thomas Santosa via Hans Aikema)
-- UserInputPanel and InstallerFrame: enable the next button for search dialogs
-  (Michael Hagedorn via Julien Ponge)
+- UserInputPanel and InstallerFrame: enable the next button for search dialogs (Michael Hagedorn via Julien Ponge)
+- VariableSubstitutor: new Java source files support (Max Fedorov via Julien Ponge)
 
   > 3.10.1 (build 2007.03.29)
 

Modified: izpack-src/branches/3.10/src/lib/com/izforge/izpack/util/VariableSubstitutor.java
===================================================================
--- izpack-src/branches/3.10/src/lib/com/izforge/izpack/util/VariableSubstitutor.java	2007-04-19 19:44:35 UTC (rev 1813)
+++ izpack-src/branches/3.10/src/lib/com/izforge/izpack/util/VariableSubstitutor.java	2007-04-19 20:08:13 UTC (rev 1814)
@@ -77,6 +77,9 @@
     /** A constant for file type. Plain file with '@' start char. */
     protected final static int TYPE_AT = 4;
     
+    /** A constant for file type. Java file, where \ have to be escaped. */
+    protected final static int TYPE_JAVA = 5;
+    
     /** PLAIN = "plain" */
     public final static String PLAIN = "plain";
 
@@ -89,6 +92,7 @@
         typeNameToConstantMap = new HashMap();
         typeNameToConstantMap.put("plain", new Integer(TYPE_PLAIN));
         typeNameToConstantMap.put("javaprop", new Integer(TYPE_JAVA_PROPERTIES));
+        typeNameToConstantMap.put("java", new Integer(TYPE_JAVA));
         typeNameToConstantMap.put("xml", new Integer(TYPE_XML));
         typeNameToConstantMap.put("shell", new Integer(TYPE_SHELL));
         typeNameToConstantMap.put("at", new Integer(TYPE_AT));
@@ -399,32 +403,42 @@
         case TYPE_AT:
             return str;
         case TYPE_JAVA_PROPERTIES:
+        case TYPE_JAVA:
             buffer = new StringBuffer(str);
             len = str.length();
             for (i = 0; i < len; i++)
             {
                 // Check for control characters
                 char c = buffer.charAt(i);
-                if (c == '\t' || c == '\n' || c == '\r')
-                {
-                    char tag;
-                    if (c == '\t')
-                        tag = 't';
-                    else if (c == '\n')
-                        tag = 'n';
-                    else
-                        tag = 'r';
-                    buffer.replace(i, i + 1, "\\" + tag);
-                    len++;
-                    i++;
+                if (type == TYPE_JAVA_PROPERTIES){
+                    if(c == '\t' || c == '\n' || c == '\r')
+                    {
+                        char tag;
+                        if (c == '\t')
+                            tag = 't';
+                        else if (c == '\n')
+                            tag = 'n';
+                        else
+                            tag = 'r';
+                        buffer.replace(i, i + 1, "\\" + tag);
+                        len++;
+                        i++;
+                    }
+    
+                    // Check for special characters
+                    if (c == '\\' || c == '"' || c == '\'' || c == ' ')
+                    {
+                        buffer.insert(i, '\\');
+                        len++;
+                        i++;
+                    }
                 }
-
-                // Check for special characters
-                if (c == '\\' || c == '"' || c == '\'' || c == ' ')
-                {
-                    buffer.insert(i, '\\');
-                    len++;
-                    i++;
+                else{
+                    if (c == '\\'){
+                        buffer.replace(i, i + 1, "\\\\");
+                        len++;
+                        i++;
+                    }
                 }
             }
             return buffer.toString();




More information about the izpack-changes mailing list