[izpack-devel] New file parsing type needed

Max Fedorov mfedorov at netflexity.com
Tue Apr 17 14:46:20 CEST 2007


Hi, Julien. Not sure what you mean by a patch, but here is my code merged
with latest (3.10.1) VariableSubstitutor.java.

Thanks a lot.
-Max

On 4/17/07, Julien Ponge <julien.ponge at gmail.com> wrote:
>
> 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
> >
> >
> _______________________________________________
> izpack-devel mailing list
> izpack-devel at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/izpack-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.berlios.de/pipermail/izpack-devel/attachments/20070417/e5d27d94/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: VariableSubstitutor.java
Type: application/octet-stream
Size: 15990 bytes
Desc: not available
Url : https://lists.berlios.de/pipermail/izpack-devel/attachments/20070417/e5d27d94/attachment.obj 


More information about the izpack-devel mailing list