commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Tripodi <simonetrip...@apache.org>
Subject Re: svn commit: r1102086 - in /incubator/ognl/trunk/src/java/org/apache/commons/ognl: ASTChain.java ASTCtor.java ASTList.java ASTMap.java ASTMethod.java ASTSequence.java ASTStaticMethod.java ExpressionNode.java NumericExpression.java ParseException.j
Date Wed, 11 May 2011 21:14:42 GMT
Salut Olivier!!!
since AST* classes are generated by JavaCC, I suggest you to don't pay
so much attention on fixing this stuff, sorry for not having warned
before :(
Indeed, build process has to be reviewed in a way to include the
JavaCC plugin and remove generated classes from SCM.
I'll write a more detailed report tomorrow when I find spare time, now
off to bed, it has been a long day and tomorrow morning I'm waking up
at 6 o' clock :P
Thanks for your hard work!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Wed, May 11, 2011 at 10:56 PM,  <olamy@apache.org> wrote:
> Author: olamy
> Date: Wed May 11 20:56:14 2011
> New Revision: 1102086
>
> URL: http://svn.apache.org/viewvc?rev=1102086&view=rev
> Log:
> use StringBuilder rather than + operand for String concat
>
> Modified:
>    incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTChain.java
>    incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTCtor.java
>    incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTList.java
>    incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTMap.java
>    incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTMethod.java
>    incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTSequence.java
>    incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTStaticMethod.java
>    incubator/ognl/trunk/src/java/org/apache/commons/ognl/ExpressionNode.java
>    incubator/ognl/trunk/src/java/org/apache/commons/ognl/NumericExpression.java
>    incubator/ognl/trunk/src/java/org/apache/commons/ognl/ParseException.java
>
> Modified: incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTChain.java
> URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTChain.java?rev=1102086&r1=1102085&r2=1102086&view=diff
> ==============================================================================
> --- incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTChain.java (original)
> +++ incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTChain.java Wed May 11 20:56:14
2011
> @@ -258,19 +258,19 @@ public class ASTChain extends SimpleNode
>
>     public String toString()
>     {
> -        String result = "";
> +        StringBuilder result = new StringBuilder("");
>
>         if ((_children != null) && (_children.length > 0)) {
>             for(int i = 0; i < _children.length; i++) {
>                 if (i > 0) {
>                     if (!(_children[i] instanceof ASTProperty) || !((ASTProperty)
_children[i]).isIndexedAccess()) {
> -                        result = result + ".";
> +                        result.append(".");
>                     }
>                 }
> -                result += _children[i].toString();
> +                result.append(_children[i].toString());
>             }
>         }
> -        return result;
> +        return result.toString();
>     }
>
>     public String toGetSourceString(OgnlContext context, Object target)
>
> Modified: incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTCtor.java
> URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTCtor.java?rev=1102086&r1=1102085&r2=1102086&view=diff
> ==============================================================================
> --- incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTCtor.java (original)
> +++ incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTCtor.java Wed May 11 20:56:14
2011
> @@ -129,27 +129,27 @@ public class ASTCtor extends SimpleNode
>
>     public String toString()
>     {
> -        String result = "new " + className;
> +        StringBuilder result = new StringBuilder("new ").append(className);
>
>         if (isArray) {
>             if (_children[0] instanceof ASTConst) {
> -                result = result + "[" + _children[0] + "]";
> +                result.append("[").append(_children[0]).append("]");
>             } else {
> -                result = result + "[] " + _children[0];
> +                result.append("[] ").append(_children[0]);
>             }
>         } else {
> -            result = result + "(";
> +            result.append("(");
>             if ((_children != null) && (_children.length > 0)) {
>                 for(int i = 0; i < _children.length; i++) {
>                     if (i > 0) {
> -                        result = result + ", ";
> +                        result.append(", ");
>                     }
> -                    result = result + _children[i];
> +                    result.append(_children[i]);
>                 }
>             }
> -            result = result + ")";
> +            result.append(")");
>         }
> -        return result;
> +        return result.toString();
>     }
>
>     public String toGetSourceString(OgnlContext context, Object target)
>
> Modified: incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTList.java
> URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTList.java?rev=1102086&r1=1102085&r2=1102086&view=diff
> ==============================================================================
> --- incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTList.java (original)
> +++ incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTList.java Wed May 11 20:56:14
2011
> @@ -73,15 +73,15 @@ public class ASTList extends SimpleNode
>
>     public String toString()
>     {
> -        String result = "{ ";
> +        StringBuilder result = new StringBuilder("{ ");
>
>         for(int i = 0; i < jjtGetNumChildren(); ++i) {
>             if (i > 0) {
> -                result = result + ", ";
> +                result.append(", ");
>             }
> -            result = result + _children[i].toString();
> +            result.append(_children[i].toString());
>         }
> -        return result + " }";
> +        return result.append(" }").toString();
>     }
>
>     public String toGetSourceString(OgnlContext context, Object target)
>
> Modified: incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTMap.java
> URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTMap.java?rev=1102086&r1=1102085&r2=1102086&view=diff
> ==============================================================================
> --- incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTMap.java (original)
> +++ incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTMap.java Wed May 11 20:56:14
2011
> @@ -102,22 +102,22 @@ class ASTMap extends SimpleNode
>
>     public String toString()
>     {
> -        String result = "#";
> +        StringBuilder result = new StringBuilder("#");
>
>         if (className != null) {
> -            result = result + "@" + className + "@";
> +            result.append("@").append(className).append("@");
>         }
>
> -        result = result + "{ ";
> +        result.append("{ ");
>         for(int i = 0; i < jjtGetNumChildren(); ++i) {
>             ASTKeyValue kv = (ASTKeyValue) _children[i];
>
>             if (i > 0) {
> -                result = result + ", ";
> +                result.append(", ");
>             }
> -            result = result + kv.getKey() + " : " + kv.getValue();
> +            result.append(kv.getKey()).append(" : ").append(kv.getValue());
>         }
> -        return result + " }";
> +        return result.append(" }").toString();
>     }
>
>     public String toGetSourceString(OgnlContext context, Object target)
>
> Modified: incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTMethod.java
> URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTMethod.java?rev=1102086&r1=1102085&r2=1102086&view=diff
> ==============================================================================
> --- incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTMethod.java (original)
> +++ incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTMethod.java Wed May 11 20:56:14
2011
> @@ -124,22 +124,22 @@ public class ASTMethod extends SimpleNod
>
>     public String toString()
>     {
> -        String result = _methodName;
> +        StringBuilder result = new StringBuilder(_methodName);
>
> -        result = result + "(";
> +        result.append("(");
>         if ((_children != null) && (_children.length > 0)) {
>
>             for(int i = 0; i < _children.length; i++) {
>                 if (i > 0) {
> -                    result = result + ", ";
> +                    result.append(", ");
>                 }
>
> -                result = result + _children[i];
> +                result.append(_children[i]);
>             }
>         }
>
> -        result = result + ")";
> -        return result;
> +        result.append(")");
> +        return result.toString();
>     }
>
>     public String toGetSourceString(OgnlContext context, Object target)
>
> Modified: incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTSequence.java
> URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTSequence.java?rev=1102086&r1=1102085&r2=1102086&view=diff
> ==============================================================================
> --- incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTSequence.java (original)
> +++ incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTSequence.java Wed May 11
20:56:14 2011
> @@ -96,15 +96,15 @@ public class ASTSequence extends SimpleN
>
>     public String toString()
>     {
> -        String      result = "";
> +        StringBuilder result = new StringBuilder("");
>
>         for ( int i=0; i < _children.length; ++i ) {
>             if (i > 0) {
> -                result = result + ", ";
> +                result.append (", ");
>             }
> -            result = result + _children[i];
> +            result.append(_children[i]);
>         }
> -        return result;
> +        return result.toString();
>     }
>
>     public String toSetSourceString(OgnlContext context, Object target)
>
> Modified: incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTStaticMethod.java
> URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTStaticMethod.java?rev=1102086&r1=1102085&r2=1102086&view=diff
> ==============================================================================
> --- incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTStaticMethod.java (original)
> +++ incubator/ognl/trunk/src/java/org/apache/commons/ognl/ASTStaticMethod.java Wed May
11 20:56:14 2011
> @@ -92,19 +92,19 @@ public class ASTStaticMethod extends Sim
>
>     public String toString()
>     {
> -        String result = "@" + _className + "@" + _methodName;
> +        StringBuilder result = new StringBuilder("@").append(_className).append("@").append(_methodName);
>
> -        result = result + "(";
> +        result.append("(");
>         if ((_children != null) && (_children.length > 0)) {
>             for(int i = 0; i < _children.length; i++) {
>                 if (i > 0) {
> -                    result = result + ", ";
> +                    result.append(", ");
>                 }
> -                result = result + _children[i];
> +                result.append(_children[i]);
>             }
>         }
> -        result = result + ")";
> -        return result;
> +        result.append(")");
> +        return result.toString();
>     }
>
>     public String toGetSourceString(OgnlContext context, Object target)
>
> Modified: incubator/ognl/trunk/src/java/org/apache/commons/ognl/ExpressionNode.java
> URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/java/org/apache/commons/ognl/ExpressionNode.java?rev=1102086&r1=1102085&r2=1102086&view=diff
> ==============================================================================
> --- incubator/ognl/trunk/src/java/org/apache/commons/ognl/ExpressionNode.java (original)
> +++ incubator/ognl/trunk/src/java/org/apache/commons/ognl/ExpressionNode.java Wed May
11 20:56:14 2011
> @@ -77,30 +77,30 @@ public abstract class ExpressionNode ext
>
>     public String toString()
>     {
> -        String result = (_parent == null) ? "" : "(";
> +        StringBuilder result = new StringBuilder (_parent == null ? "" : "(" );
>
>         if ((_children != null) && (_children.length > 0)) {
>             for ( int i = 0; i < _children.length; ++i ) {
>                 if (i > 0) {
> -                    result += " " + getExpressionOperator(i) + " ";
> +                    result.append(" ").append(getExpressionOperator(i)).append("
");
>                 }
> -                result += _children[i].toString();
> +                result.append(_children[i].toString());
>             }
>         }
>         if (_parent != null) {
> -            result = result + ")";
> +            result.append(')');
>         }
> -        return result;
> +        return result.toString();
>     }
>
>     public String toGetSourceString(OgnlContext context, Object target)
>     {
> -        String result = (_parent == null || NumericExpression.class.isAssignableFrom(_parent.getClass()))
? "" : "(";
> +        StringBuilder result = new StringBuilder ((_parent == null || NumericExpression.class.isAssignableFrom(_parent.getClass()))
? "" : "(");
>
>         if ((_children != null) && (_children.length > 0)) {
>             for ( int i = 0; i < _children.length; ++i ) {
>                 if (i > 0) {
> -                    result += " " + getExpressionOperator(i) + " ";
> +                    result.append(" ").append(getExpressionOperator(i)).append("
");
>                 }
>
>                 String value = _children[i].toGetSourceString(context, target);
> @@ -125,15 +125,15 @@ public abstract class ExpressionNode ext
>                     value = cast + ExpressionCompiler.getRootExpression(_children[i],
context.getRoot(), context) + pre + value;
>                 }
>
> -                result += value;
> +                result.append(value);
>             }
>         }
>
>         if (_parent != null && !NumericExpression.class.isAssignableFrom(_parent.getClass()))
{
> -            result = result + ")";
> +            result.append(")");
>         }
>
> -        return result;
> +        return result.toString();
>     }
>
>     public String toSetSourceString(OgnlContext context, Object target)
>
> Modified: incubator/ognl/trunk/src/java/org/apache/commons/ognl/NumericExpression.java
> URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/java/org/apache/commons/ognl/NumericExpression.java?rev=1102086&r1=1102085&r2=1102086&view=diff
> ==============================================================================
> --- incubator/ognl/trunk/src/java/org/apache/commons/ognl/NumericExpression.java (original)
> +++ incubator/ognl/trunk/src/java/org/apache/commons/ognl/NumericExpression.java Wed
May 11 20:56:14 2011
> @@ -37,7 +37,7 @@ public abstract class NumericExpression
>     public String toGetSourceString(OgnlContext context, Object target)
>     {
>         Object value = null;
> -        String result = "";
> +        StringBuilder result = new StringBuilder("");
>
>         try {
>
> @@ -49,11 +49,11 @@ public abstract class NumericExpression
>             for (int i=0; i < _children.length; i++)
>             {
>                 if (i > 0)
> -                    result += " " + getExpressionOperator(i) + " ";
> +                    result.append(" ").append(getExpressionOperator(i)).append("
");
>
>                 String str = OgnlRuntime.getChildSource(context, target, _children[i]);
>
> -                result += coerceToNumeric(str, context, _children[i]);
> +                result.append(coerceToNumeric(str, context, _children[i]));
>             }
>
>         } catch (Throwable t)
> @@ -61,7 +61,7 @@ public abstract class NumericExpression
>             throw OgnlOps.castToRuntime(t);
>         }
>
> -        return result;
> +        return result.toString();
>     }
>
>     public String coerceToNumeric(String source, OgnlContext context, Node child)
>
> Modified: incubator/ognl/trunk/src/java/org/apache/commons/ognl/ParseException.java
> URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/java/org/apache/commons/ognl/ParseException.java?rev=1102086&r1=1102085&r2=1102086&view=diff
> ==============================================================================
> --- incubator/ognl/trunk/src/java/org/apache/commons/ognl/ParseException.java (original)
> +++ incubator/ognl/trunk/src/java/org/apache/commons/ognl/ParseException.java Wed May
11 20:56:14 2011
> @@ -114,29 +114,29 @@ public class ParseException extends Exce
>       }
>       expected.append(eol).append("    ");
>     }
> -    String retval = "Encountered \"";
> +    StringBuilder retval = new StringBuilder("Encountered \"");
>     Token tok = currentToken.next;
>     for (int i = 0; i < maxSize; i++) {
> -      if (i != 0) retval += " ";
> +      if (i != 0) retval.append(" ");
>       if (tok.kind == 0) {
> -        retval += tokenImage[0];
> +        retval.append(tokenImage[0]);
>         break;
>       }
> -      retval += " " + tokenImage[tok.kind];
> -      retval += " \"";
> -      retval += add_escapes(tok.image);
> -      retval += " \"";
> +      retval.append(" ").append(tokenImage[tok.kind]);
> +      retval.append(" \"");
> +      retval.append(add_escapes(tok.image));
> +      retval.append(" \"");
>       tok = tok.next;
>     }
> -    retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
> -    retval += "." + eol;
> +    retval.append("\" at line ").append(currentToken.next.beginLine).append(", column
").append(currentToken.next.beginColumn);
> +    retval.append(".").append(eol);
>     if (expectedTokenSequences.length == 1) {
> -      retval += "Was expecting:" + eol + "    ";
> +      retval.append("Was expecting:").append(eol).append("    ");
>     } else {
> -      retval += "Was expecting one of:" + eol + "    ";
> +      retval.append("Was expecting one of:").append(eol).append("    ");
>     }
> -    retval += expected.toString();
> -    return retval;
> +    retval.append(expected.toString());
> +    return retval.toString();
>   }
>
>   /**
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message