cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r123808 - /cocoon/branches/BRANCH_2_1_X/src/blocks/velocity/java/org/apache/cocoon/generation/VelocityGenerator.java /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xpointer/parser/ParseException.java
Date Fri, 31 Dec 2004 16:23:32 GMT
Author: antonio
Date: Fri Dec 31 08:23:30 2004
New Revision: 123808

URL: http://svn.apache.org/viewcvs?view=rev&rev=123808
Log:
Use StringBuffer()
Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/velocity/java/org/apache/cocoon/generation/VelocityGenerator.java
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xpointer/parser/ParseException.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/velocity/java/org/apache/cocoon/generation/VelocityGenerator.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/velocity/java/org/apache/cocoon/generation/VelocityGenerator.java?view=diff&rev=123808&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/velocity/java/org/apache/cocoon/generation/VelocityGenerator.java&r1=123807&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/velocity/java/org/apache/cocoon/generation/VelocityGenerator.java&r2=123808
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/velocity/java/org/apache/cocoon/generation/VelocityGenerator.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/velocity/java/org/apache/cocoon/generation/VelocityGenerator.java
Fri Dec 31 08:23:30 2004
@@ -50,6 +50,7 @@
 import org.apache.commons.jxpath.DynamicPropertyHandler;
 import org.apache.commons.jxpath.JXPathBeanInfo;
 import org.apache.commons.jxpath.JXPathIntrospector;
+import org.apache.commons.lang.StringUtils;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.xml.sax.SAXParser;
 import org.apache.velocity.VelocityContext;
@@ -1025,23 +1026,20 @@
             }
             BufferedReader reader = 
                 new BufferedReader(new StringReader(w.toString()));
-            String message = e.getMessage() +" In generated document:\n";
+            StringBuffer message = new StringBuffer(e.getMessage());
+            message.append(" In generated document:\n");
             for (int i = 0; i < line; i++) {
                 String lineStr = reader.readLine();
                 if (lineStr == null) {
                     break;
                 }
-                message += lineStr + "\n";
+                message.append(lineStr);
+                message.append("\n");
             }
             if (column > 0) {
-                String columnIndicator = "";
-                for (int i = 1; i < column; i++) {
-                    columnIndicator += " ";
-                }
-                columnIndicator += "^" + "\n";
-                message += columnIndicator;
+                message.append(StringUtils.leftPad("^\n", column + 1));
             }
-            SAXException pe = new SAXParseException(message, 
+            SAXException pe = new SAXParseException(message.toString(), 
                                                     e.getPublicId(),
                                                     "(Document generated from template "+e.getSystemId()
+ ")",
                                                     e.getLineNumber(),

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xpointer/parser/ParseException.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xpointer/parser/ParseException.java?view=diff&rev=123808&p1=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xpointer/parser/ParseException.java&r1=123807&p2=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xpointer/parser/ParseException.java&r2=123808
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xpointer/parser/ParseException.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xpointer/parser/ParseException.java
Fri Dec 31 08:23:30 2004
@@ -111,45 +111,50 @@
         if (!specialConstructor) {
             return super.getMessage();
         }
-        String expected = "";
+        StringBuffer expected = new StringBuffer();
         int maxSize = 0;
         for (int i = 0; i < expectedTokenSequences.length; i++) {
             if (maxSize < expectedTokenSequences[i].length) {
                 maxSize = expectedTokenSequences[i].length;
             }
             for (int j = 0; j < expectedTokenSequences[i].length; j++) {
-                expected += tokenImage[expectedTokenSequences[i][j]] + " ";
+                expected.append(tokenImage[expectedTokenSequences[i][j]]);
+                expected.append(" ");
             }
             if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1]
                 != 0) {
-                expected += "...";
+                expected.append("...");
             }
-            expected += eol + "    ";
+            expected.append(eol);
+            expected.append("    ");
         }
-        String retval = "Encountered \"";
+        StringBuffer retval = new StringBuffer("Encountered \"");
         Token tok = currentToken.next;
         for (int i = 0; i < maxSize; i++) {
             if (i != 0)
-                retval += " ";
+                retval.append(" ");
             if (tok.kind == 0) {
-                retval += tokenImage[0];
+                retval.append(tokenImage[0]);
                 break;
             }
-            retval += add_escapes(tok.image);
+            retval.append(add_escapes(tok.image));
             tok = tok.next;
         }
-        retval += "\" at line "
-            + currentToken.next.beginLine
-            + ", column "
-            + currentToken.next.beginColumn;
-        retval += "." + eol;
-        if (expectedTokenSequences.length == 1) {
-            retval += "Was expecting:" + eol + "    ";
-        } else {
-            retval += "Was expecting one of:" + eol + "    ";
+        retval.append("\" at line ");
+        retval.append(currentToken.next.beginLine);
+        retval.append(", column ");
+        retval.append(currentToken.next.beginColumn);
+        retval.append(".");
+        retval.append(eol);
+        retval.append("Was expecting");
+        if (expectedTokenSequences.length != 1) {
+            retval.append(" one of");
         }
-        retval += expected;
-        return retval;
+        retval.append(":");
+        retval.append(eol);
+        retval.append("    ");
+        retval.append(expected);
+        return retval.toString();
     }
 
     /**

Mime
View raw message