cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r490455 - in /cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components: language/markup/xsp/java/ language/programming/CompiledProgrammingLanguage.java language/programming/java/Javac.java xscript/xslt/
Date Wed, 27 Dec 2006 07:44:18 GMT
Author: cziegeler
Date: Tue Dec 26 23:44:17 2006
New Revision: 490455

URL: http://svn.apache.org/viewvc?view=rev&rev=490455
Log:
Code cleanup

Removed:
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/markup/xsp/java/
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/xscript/xslt/
Modified:
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/CompiledProgrammingLanguage.java
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/java/Javac.java

Modified: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/CompiledProgrammingLanguage.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/CompiledProgrammingLanguage.java?view=diff&rev=490455&r1=490454&r2=490455
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/CompiledProgrammingLanguage.java
(original)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/CompiledProgrammingLanguage.java
Tue Dec 26 23:44:17 2006
@@ -23,7 +23,6 @@
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.parameters.ParameterException;
 
-import org.apache.cocoon.Constants;
 import org.apache.cocoon.components.language.LanguageException;
 import org.apache.cocoon.components.language.programming.java.JavaProgram;
 import org.apache.cocoon.util.ClassUtils;

Modified: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/java/Javac.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/java/Javac.java?view=diff&rev=490455&r1=490454&r2=490455
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/java/Javac.java
(original)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/components/language/programming/java/Javac.java
Tue Dec 26 23:44:17 2006
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,7 +27,6 @@
 import java.util.StringTokenizer;
 
 import org.apache.cocoon.components.language.programming.CompilerError;
-import org.apache.commons.lang.SystemUtils;
 
 /**
  * This class wraps the Sun's Javac Compiler.
@@ -35,102 +34,91 @@
  * @version $Id$
  * @since 2.0
  */
-
 public class Javac extends AbstractJavaCompiler {
 
-  //private boolean modern = false;
+    /**
+     * Compile a source file yielding a loadable class file.
+     *
+     * <code>null</code> if it is the platform's default encoding
+     * @exception IOException If an error occurs during compilation
+     */
+    public boolean compile() throws IOException {
+
+        final ByteArrayOutputStream err = new ByteArrayOutputStream();
+
+        final PrintWriter pw = new PrintWriter(err);
+        boolean result = com.sun.tools.javac.Main.compile(toStringArray(fillArguments(new
ArrayList())), pw) == 0;
+        this.errors = new ByteArrayInputStream(err.toByteArray());
+        return result;
+    }
+
+    /**
+     * Parse the compiler error stream to produce a list of
+     * <code>CompilerError</code>s
+     *
+     * @param input The error stream
+     * @return The list of compiler error messages
+     * @exception IOException If an error occurs during message collection
+     */
+    protected List parseStream(BufferedReader input) throws IOException {
+        List errors = new ArrayList();
+        String line = null;
+        StringBuffer buffer = null;
+
+        while (true) {
+            // cleanup the buffer
+            buffer = new StringBuffer(); // this is quicker than clearing it
+
+            // most errors terminate with the '^' char
+            do {
+                if ((line = input.readLine()) == null) {
+                    if (buffer.length() > 0) {
+                        // There's an error which doesn't end with a '^'
+                        errors.add(new CompilerError("\n" + buffer.toString()));
+                    }
+                    return errors;
+                }
+                buffer.append(line);
+                buffer.append('\n');
+            } while (!line.endsWith("^"));
 
-  public Javac() {
-      //modern = true;
-  }
-
-  /**
-   * Compile a source file yielding a loadable class file.
-   *
-   * <code>null</code> if it is the platform's default encoding
-   * @exception IOException If an error occurs during compilation
-   */
-  public boolean compile() throws IOException {
-      
-    ByteArrayOutputStream err = new ByteArrayOutputStream();
-    
-    boolean result;
-    if (!SystemUtils.IS_JAVA_1_3) { // For Java 1.4 and 1.5
-        PrintWriter pw = new PrintWriter(err);
-        result = com.sun.tools.javac.Main.compile(toStringArray(fillArguments(new ArrayList())),
pw) == 0;
-    } else {
-        sun.tools.javac.Main compiler = new sun.tools.javac.Main(err, "javac");
-        result = compiler.compile(toStringArray(fillArguments(new ArrayList())));
+            // add the error bean
+            errors.add(parseModernError(buffer.toString()));
+        }
     }
-    this.errors = new ByteArrayInputStream(err.toByteArray());
-    return result;
-  }
-
-  /**
-   * Parse the compiler error stream to produce a list of
-   * <code>CompilerError</code>s
-   *
-   * @param input The error stream
-   * @return The list of compiler error messages
-   * @exception IOException If an error occurs during message collection
-   */
-  protected List parseStream(BufferedReader input) throws IOException {
-    List errors = new ArrayList();
-    String line = null;
-    StringBuffer buffer = null;
-
-    while (true) {
-      // cleanup the buffer
-      buffer = new StringBuffer(); // this is quicker than clearing it
-
-      // most errors terminate with the '^' char
-      do {
-        if ((line = input.readLine()) == null) {
-            if (buffer.length() > 0) {
-                // There's an error which doesn't end with a '^'
-                errors.add(new CompilerError("\n" + buffer.toString()));
+
+    /**
+     * Parse an individual compiler error message with modern style.
+     *
+     * @param error The error text
+     * @return A messaged <code>CompilerError</code>
+     */
+    private CompilerError parseModernError(String error) {
+        final StringTokenizer tokens = new StringTokenizer(error, ":");
+        try {
+            String file = tokens.nextToken();
+            if (file.length() == 1) {
+                file = new StringBuffer(file).append(":").append(tokens.nextToken()).toString();
             }
-            return errors;
-        }
-        buffer.append(line);
-        buffer.append('\n');
-      } while (!line.endsWith("^"));
+            int line = Integer.parseInt(tokens.nextToken());
 
-      // add the error bean
-      errors.add(parseModernError(buffer.toString()));
+            String message = tokens.nextToken("\n").substring(1);
+            String context = tokens.nextToken("\n");
+            String pointer = tokens.nextToken("\n");
+            int startcolumn = pointer.indexOf("^");
+            int endcolumn = context.indexOf(" ", startcolumn);
+            if (endcolumn == -1) {
+                endcolumn = context.length();
+            }
+            return new CompilerError(file, false, line, startcolumn, line, endcolumn, message);
+        } catch(NoSuchElementException nse) {
+            return new CompilerError("no more tokens - could not parse error message: " +
error);
+        } catch(Exception nse) {
+            return new CompilerError("could not parse error message: " + error);
+        }
     }
-  }
 
-  /**
-   * Parse an individual compiler error message with modern style.
-   *
-   * @param error The error text
-   * @return A messaged <code>CompilerError</code>
-   */
-  private CompilerError parseModernError(String error) {
-    StringTokenizer tokens = new StringTokenizer(error, ":");
-    try {
-      String file = tokens.nextToken();
-      if (file.length() == 1) file = new StringBuffer(file).append(":").append(tokens.nextToken()).toString();
-      int line = Integer.parseInt(tokens.nextToken());
-
-      String message = tokens.nextToken("\n").substring(1);
-      String context = tokens.nextToken("\n");
-      String pointer = tokens.nextToken("\n");
-      int startcolumn = pointer.indexOf("^");
-      int endcolumn = context.indexOf(" ", startcolumn);
-      if (endcolumn == -1) {
-          endcolumn = context.length();
-      }
-      return new CompilerError(file, false, line, startcolumn, line, endcolumn, message);
-    } catch(NoSuchElementException nse) {
-      return new CompilerError("no more tokens - could not parse error message: " + error);
-    } catch(Exception nse) {
-      return new CompilerError("could not parse error message: " + error);
+    public String toString() {
+        return "Sun Javac Compiler";
     }
-  }
-
-  public String toString() {
-    return "Sun Javac Compiler";
-  }
 }



Mime
View raw message