[izpack-devel] New file parsing type needed
Julien Ponge
julien.ponge at gmail.com
Tue Apr 17 08:34:02 CEST 2007
Can you please send a patch instead? Thanks a lot.
On 4/12/07, Max Fedorov <mfedorov at netflexity.com> wrote:
> 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.xml
> or 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();
> _______________________________________________
> izpack-devel mailing list
> izpack-devel at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/izpack-devel
>
>
More information about the izpack-devel
mailing list