[izpack-devel] New file parsing type needed

Max Fedorov mfedorov at netflexity.com
Thu Apr 12 19:25:19 CEST 2007


I've been using IzPack for some time and very glad with it, but sick of
rebuilding it for every new version to incorporate my enhancements. I use
IzPack to deploy a java web application to Unix and Windows environments.
The problem that I have is with backslashes "\", which are returned by
$INSTALL_PATH variable on Windows, for example, and are not going to work if
substituted in files that are used by java application, for example,
web.xmlor other configuration files. What I added is another file type
called
JAVA_TYPE in VariableSubstitutor.java with a tiny if. Thank you very much
for your product. Hope this will help other people as well!!!

Here are the changes:

/** A constant for file type. Java file, where \ have to be escaped. */
*protected final static int TYPE_JAVA = 5;*

// Initialize the file type map
    static
    {
        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));
    }

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 (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++;
                    }
                *}
                else{
                    if (c == '\\'){
                        buffer.replace(i, i + 1, "**\\\\**");
                        len++;
                        i++;
                    }
                }*
            }
            return buffer.toString();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.berlios.de/pipermail/izpack-devel/attachments/20070412/1a501864/attachment.html 


More information about the izpack-devel mailing list