tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick J. McNerthney" <...@mcnerthney.com>
Subject Re: Jasper code generation problem (bug?)
Date Wed, 19 Jul 2000 03:30:58 GMT
> This does turn out to be a bug in Tomcat.  I'm not sure it can get
> addressed
> in a 3.2 timeframe, but will definitely be addressed in a subsequent
> version.


The following changes to TagGeneratorBase.java fixes the issue (I also
attached the .java file).  I can understand if this still doesn't make
it into 3.2 if you have QA issues.

Thanks,
Patrick J. McNerthney
Icicle Software, Inc.


<code>

    protected String getTagVarName(String prefix, String shortTagName) {
        // Fix: Can probably remove the synchronization now when no vars
or method is static
        synchronized (tagVarNumbers) {
            prefix = javaizeName(prefix);
            shortTagName = javaizeName(shortTagName);
            String tag = prefix+":"+shortTagName;
            String varName = prefix+"_"+shortTagName+"_";
            if (tagVarNumbers.get(tag) != null) {
                Integer i = (Integer) tagVarNumbers.get(tag);
                varName = varName + i.intValue();
                tagVarNumbers.put(tag, new Integer(i.intValue()+1));
                return varName;
            } else {
                tagVarNumbers.put(tag, new Integer(1));
                return varName+"0";
            }
        }
    }

    private String javaizeName(String name) {
        int length = name.length();
        for (int i = 0; i < length; ++i) {
            if (!Character.isJavaIdentifierPart(name.charAt(i))) {
                char[] chars = name.toCharArray();
                chars[i] = '_';
                for (++i; i < length; ++i) {
                    if (!Character.isJavaIdentifierPart(chars[i])) {
                        chars[i] = '_';
                    }
                }
                return new String(chars);
            }
        }
        return name;
    }

</code>
Mime
View raw message