You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2002/02/09 04:43:01 UTC
cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/language/programming/java AbstractJavaCompiler.java JavaLanguage.java
vgritsenko 02/02/08 19:43:01
Modified: src/java/org/apache/cocoon/components/language/markup/xsp/java
XSLTExtension.java
src/java/org/apache/cocoon/components/language/programming/java
AbstractJavaCompiler.java JavaLanguage.java
Log:
Add static escapeString method to XSLTExtension
Remove duplicated method escapeString from JavaCompiler
Reformat
Revision Changes Path
1.2 +10 -2 xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/XSLTExtension.java
Index: XSLTExtension.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/XSLTExtension.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSLTExtension.java 6 Feb 2002 04:40:28 -0000 1.1
+++ XSLTExtension.java 9 Feb 2002 03:43:01 -0000 1.2
@@ -60,7 +60,7 @@
* generation stylesheet to escape XML characters to make a valid Java strings.
*
* @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
- * @version CVS $Id: XSLTExtension.java,v 1.1 2002/02/06 04:40:28 vgritsenko Exp $
+ * @version CVS $Id: XSLTExtension.java,v 1.2 2002/02/09 03:43:01 vgritsenko Exp $
*/
public class XSLTExtension {
@@ -68,7 +68,7 @@
* Escapes '"' and '\' characters in a String (add a '\' before them) so that it can
* be inserted in java source.
*/
- public String escape(String string) {
+ public static String escapeString(String string) {
char chr[] = string.toCharArray();
StringBuffer buffer = new StringBuffer();
@@ -94,5 +94,13 @@
}
return buffer.toString();
+ }
+
+ /**
+ * Escapes '"' and '\' characters in a String (add a '\' before them) so that it can
+ * be inserted in java source.
+ */
+ public String escape(String string) {
+ return escapeString(string);
}
}
1.5 +164 -164 xml-cocoon2/src/java/org/apache/cocoon/components/language/programming/java/AbstractJavaCompiler.java
Index: AbstractJavaCompiler.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/programming/java/AbstractJavaCompiler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractJavaCompiler.java 4 Feb 2002 12:22:24 -0000 1.4
+++ AbstractJavaCompiler.java 9 Feb 2002 03:43:01 -0000 1.5
@@ -56,8 +56,8 @@
package org.apache.cocoon.components.language.programming.java;
-import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.avalon.framework.logger.AbstractLoggable;
+import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.cocoon.components.language.programming.LanguageCompiler;
import java.io.BufferedReader;
@@ -69,171 +69,171 @@
/**
* This class implements the functionality common to all Java compilers.
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version CVS $Id: AbstractJavaCompiler.java,v 1.4 2002/02/04 12:22:24 cziegeler Exp $
+ * @version CVS $Id: AbstractJavaCompiler.java,v 1.5 2002/02/09 03:43:01 vgritsenko Exp $
* @since 2.0
*/
public abstract class AbstractJavaCompiler extends AbstractLoggable implements LanguageCompiler, Recyclable {
- /**
- * The source program filename
- */
- protected String file;
-
- /**
- * The name of the directory containing the source program file
- */
- protected String srcDir;
-
- /**
- * The name of the directory to contain the resulting object program file
- */
- protected String destDir;
-
- /**
- * The classpath to be used for compilation
- */
- protected String classpath;
-
- /**
- * The encoding of the source program or <code>null</code> to use the
- * platform's default encoding
- */
- protected String encoding = null;
-
- /**
- * The input stream to output compilation errors
- */
- protected InputStream errors;
-
- /**
- * Set the name of the file containing the source program
- *
- * @param file The name of the file containing the source program
- */
- public void setFile(String file) {
- this.file = file;
- }
-
- /**
- * Set the name of the directory containing the source program file
- *
- * @param srcDir The name of the directory containing the source program file
- */
- public void setSource(String srcDir) {
- this.srcDir = srcDir;
- }
-
- /**
- * Set the name of the directory to contain the resulting object program file
- *
- * @param destDir The name of the directory to contain the resulting object
- * program file
- */
- public void setDestination(String destDir) {
- this.destDir = destDir;
- }
-
- /**
- * Set the classpath to be used for this compilation
- *
- * @param classpath The classpath to be used for this compilation
- */
- public void setClasspath(String classpath) {
- this.classpath = classpath;
- }
-
- /**
- * Set the encoding of the input source file or <code>null</code> to use the
- * platform's default encoding
- *
- * @param encoding The encoding of the input source file or <code>null</code>
- * to use the platform's default encoding
- */
- public void setEncoding(String encoding) {
- this.encoding = encoding;
- }
-
- /**
- * Return the list of errors generated by this compilation
- *
- * @return The list of errors generated by this compilation
- * @exception IOException If an error occurs during message collection
- */
- public List getErrors() throws IOException {
- return parseStream(new BufferedReader(new InputStreamReader(errors)));
- }
-
- /**
- * Parse the compiler error stream to produce a list of
- * <code>CompilerError</code>s
- *
- * @param errors The error stream
- * @return The list of compiler error messages
- * @exception IOException If an error occurs during message collection
- */
- protected abstract List parseStream(BufferedReader errors)
- throws IOException;
-
- /**
- * Fill the arguments taken by the Java compiler
- *
- * @param argument The list of compilation arguments
- * @return The prepared list of compilation arguments
- */
- protected List fillArguments(List arguments) {
- // destination directory
- arguments.add("-d");
- arguments.add(destDir);
-
- // classpath
- arguments.add("-classpath");
- arguments.add(classpath);
-
- // sourcepath
- arguments.add("-sourcepath");
- arguments.add(srcDir);
-
- // add optimization (for what is worth)
- arguments.add("-O");
-
- // add encoding if set
- if (encoding != null) {
- arguments.add("-encoding");
- arguments.add(encoding);
- }
-
- return arguments;
- }
-
- /**
- * Copy arguments to a string array
- *
- * @param arguments The compiler arguments
- * @return A string array containing compilation arguments
- */
- protected String[] toStringArray(List arguments) {
- int i;
- String[] args = new String[arguments.size() + 1];
-
- for (i = 0; i < arguments.size(); i++) {
- args[i] = (String) arguments.get(i);
- }
-
- args[i] = file;
-
- return args;
- }
-
- /** Reset all internal state.
- * This method is called by the component manager before this
- * component is return to its pool.
- */
- public void recycle() {
- file = null;
- srcDir = null;
- destDir = null;
- classpath = null;
- encoding = null;
- errors = null;
- }
+ /**
+ * The source program filename
+ */
+ protected String file;
+
+ /**
+ * The name of the directory containing the source program file
+ */
+ protected String srcDir;
+
+ /**
+ * The name of the directory to contain the resulting object program file
+ */
+ protected String destDir;
+
+ /**
+ * The classpath to be used for compilation
+ */
+ protected String classpath;
+
+ /**
+ * The encoding of the source program or <code>null</code> to use the
+ * platform's default encoding
+ */
+ protected String encoding = null;
+
+ /**
+ * The input stream to output compilation errors
+ */
+ protected InputStream errors;
+
+ /**
+ * Set the name of the file containing the source program
+ *
+ * @param file The name of the file containing the source program
+ */
+ public void setFile(String file) {
+ this.file = file;
+ }
+
+ /**
+ * Set the name of the directory containing the source program file
+ *
+ * @param srcDir The name of the directory containing the source program file
+ */
+ public void setSource(String srcDir) {
+ this.srcDir = srcDir;
+ }
+
+ /**
+ * Set the name of the directory to contain the resulting object program file
+ *
+ * @param destDir The name of the directory to contain the resulting object
+ * program file
+ */
+ public void setDestination(String destDir) {
+ this.destDir = destDir;
+ }
+
+ /**
+ * Set the classpath to be used for this compilation
+ *
+ * @param classpath The classpath to be used for this compilation
+ */
+ public void setClasspath(String classpath) {
+ this.classpath = classpath;
+ }
+
+ /**
+ * Set the encoding of the input source file or <code>null</code> to use the
+ * platform's default encoding
+ *
+ * @param encoding The encoding of the input source file or <code>null</code>
+ * to use the platform's default encoding
+ */
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ /**
+ * Return the list of errors generated by this compilation
+ *
+ * @return The list of errors generated by this compilation
+ * @exception IOException If an error occurs during message collection
+ */
+ public List getErrors() throws IOException {
+ return parseStream(new BufferedReader(new InputStreamReader(errors)));
+ }
+
+ /**
+ * Parse the compiler error stream to produce a list of
+ * <code>CompilerError</code>s
+ *
+ * @param errors The error stream
+ * @return The list of compiler error messages
+ * @exception IOException If an error occurs during message collection
+ */
+ protected abstract List parseStream(BufferedReader errors)
+ throws IOException;
+
+ /**
+ * Fill the arguments taken by the Java compiler
+ *
+ * @param argument The list of compilation arguments
+ * @return The prepared list of compilation arguments
+ */
+ protected List fillArguments(List arguments) {
+ // destination directory
+ arguments.add("-d");
+ arguments.add(destDir);
+
+ // classpath
+ arguments.add("-classpath");
+ arguments.add(classpath);
+
+ // sourcepath
+ arguments.add("-sourcepath");
+ arguments.add(srcDir);
+
+ // add optimization (for what is worth)
+ arguments.add("-O");
+
+ // add encoding if set
+ if (encoding != null) {
+ arguments.add("-encoding");
+ arguments.add(encoding);
+ }
+
+ return arguments;
+ }
+
+ /**
+ * Copy arguments to a string array
+ *
+ * @param arguments The compiler arguments
+ * @return A string array containing compilation arguments
+ */
+ protected String[] toStringArray(List arguments) {
+ int i;
+ String[] args = new String[arguments.size() + 1];
+
+ for (i = 0; i < arguments.size(); i++) {
+ args[i] = (String) arguments.get(i);
+ }
+
+ args[i] = file;
+
+ return args;
+ }
+
+ /** Reset all internal state.
+ * This method is called by the component manager before this
+ * component is return to its pool.
+ */
+ public void recycle() {
+ file = null;
+ srcDir = null;
+ destDir = null;
+ classpath = null;
+ encoding = null;
+ errors = null;
+ }
}
1.7 +222 -256 xml-cocoon2/src/java/org/apache/cocoon/components/language/programming/java/JavaLanguage.java
Index: JavaLanguage.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/programming/java/JavaLanguage.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JavaLanguage.java 7 Feb 2002 04:07:28 -0000 1.6
+++ JavaLanguage.java 9 Feb 2002 03:43:01 -0000 1.7
@@ -56,18 +56,17 @@
package org.apache.cocoon.components.language.programming.java;
import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
-import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
+
import org.apache.cocoon.components.classloader.ClassLoaderManager;
import org.apache.cocoon.components.language.LanguageException;
-import org.apache.cocoon.components.language.generator.CompiledComponent;
+import org.apache.cocoon.components.language.markup.xsp.java.XSLTExtension;
import org.apache.cocoon.components.language.programming.CompiledProgrammingLanguage;
import org.apache.cocoon.components.language.programming.CompilerError;
-import org.apache.cocoon.components.language.programming.Program;
import org.apache.cocoon.util.ClassUtils;
import org.apache.cocoon.util.JavaArchiveFilter;
@@ -80,278 +79,245 @@
* The Java programming language processor
*
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
- * @version CVS $Id: JavaLanguage.java,v 1.6 2002/02/07 04:07:28 vgritsenko Exp $
+ * @version CVS $Id: JavaLanguage.java,v 1.7 2002/02/09 03:43:01 vgritsenko Exp $
*/
-public class JavaLanguage extends CompiledProgrammingLanguage implements ThreadSafe, Composable, Disposable {
+public class JavaLanguage extends CompiledProgrammingLanguage
+ implements ThreadSafe, Composable, Disposable {
- /** The class loader */
- private ClassLoaderManager classLoaderManager;
+ /** The class loader */
+ private ClassLoaderManager classLoaderManager;
- /** The component manager */
- protected ComponentManager manager = null;
+ /** The component manager */
+ protected ComponentManager manager = null;
- /**
- * Return the language name
- *
- * @return The language name
- */
- public String getName() {
- return "java";
- }
-
- /**
- * Return the language's canonical source file extension.
- *
- * @return The source file extension
- */
- public String getSourceExtension() {
- return "java";
- }
-
- /**
- * Return the language's canonical object file extension.
- *
- * @return The object file extension
- */
- public String getObjectExtension() {
- return "class";
- }
-
- /**
- * Set the configuration parameters. This method instantiates the
- * sitemap-specified <code>ClassLoaderManager</code>
- *
- * @param params The configuration parameters
- * @exception Exception If the class loader manager cannot be instantiated
- */
- public void parameterize(Parameters params) throws ParameterException {
- super.parameterize(params);
-
- String compilerClass = params.getParameter("class-loader",
- "org.apache.cocoon.components.classloader.ClassLoaderManagerImpl");
- if (compilerClass != null) {
- try {
- this.classLoaderManager = (ClassLoaderManager) ClassUtils.newInstance(compilerClass);
- } catch (Exception e) {
- throw new ParameterException("Unable to load compiler: " + compilerClass, e);
- }
+ /**
+ * Return the language's canonical source file extension.
+ *
+ * @return The source file extension
+ */
+ public String getSourceExtension() {
+ return "java";
}
- }
- /**
- * Set the global component manager. This methods initializes the class
- * loader manager if it was not (successfully) specified in the language
- * parameters
- *
- * @param manager The global component manager
- */
- public void compose(ComponentManager manager) {
- this.manager = manager;
- if (this.classLoaderManager == null) {
- try {
- getLogger().debug("Looking up " + ClassLoaderManager.ROLE);
- this.classLoaderManager =
- (ClassLoaderManager) manager.lookup(ClassLoaderManager.ROLE);
- } catch (Exception e) {
- getLogger().error("Could not find component", e);
- }
+ /**
+ * Return the language's canonical object file extension.
+ *
+ * @return The object file extension
+ */
+ public String getObjectExtension() {
+ return "class";
}
- }
- /**
- * Actually load an object program from a class file.
- *
- * @param filename The object program base file name
- * @param baseDirectory The directory containing the object program file
- * @return The loaded object program
- * @exception LanguageException If an error occurs during loading
- */
- protected Class loadProgram(String name, File baseDirectory)
- throws LanguageException
- {
- try {
- this.classLoaderManager.addDirectory(baseDirectory);
- return
- this.classLoaderManager.loadClass(name.replace(File.separatorChar, '.'));
- } catch (Exception e) {
- getLogger().warn("Could not load class for program '" + name + "'", e);
- throw new LanguageException("Could not load class for program '" + name + "' due to a " + e.getClass().getName() + ": " + e.getMessage());
+ /**
+ * Set the configuration parameters. This method instantiates the
+ * sitemap-specified <code>ClassLoaderManager</code>
+ *
+ * @param params The configuration parameters
+ * @exception Exception If the class loader manager cannot be instantiated
+ */
+ public void parameterize(Parameters params) throws ParameterException {
+ super.parameterize(params);
+
+ String classLoaderClass = params.getParameter("class-loader",
+ "org.apache.cocoon.components.classloader.ClassLoaderManagerImpl");
+ if (classLoaderClass != null) {
+ try {
+ this.classLoaderManager = (ClassLoaderManager) ClassUtils.newInstance(classLoaderClass);
+ } catch (Exception e) {
+ throw new ParameterException("Unable to load class loader: " + classLoaderClass, e);
+ }
+ }
}
- }
- /**
- * Compile a source file yielding a loadable class file.
- *
- * @param filename The object program base file name
- * @param baseDirectory The directory containing the object program file
- * @param encoding The encoding expected in the source file or
- * <code>null</code> if it is the platform's default encoding
- * @exception LanguageException If an error occurs during compilation
- */
- protected void compile(
- String name, File baseDirectory, String encoding
- ) throws LanguageException {
-
- try {
-
- AbstractJavaCompiler compiler = (AbstractJavaCompiler) this.compilerClass.newInstance();
- // AbstractJavaCompiler is Loggable
- compiler.setLogger(getLogger());
-
- int pos = name.lastIndexOf(File.separatorChar);
- String filename = name.substring(pos + 1);
- String pathname =
- baseDirectory.getCanonicalPath() + File.separator +
- name.substring(0, pos).replace(File.separatorChar, '/');
- String filename_abs =
- new StringBuffer(pathname).append(File.separator).append(filename)
- .append(".").append(this.getSourceExtension()).toString();
-
- compiler.setFile(filename_abs);
-
- compiler.setSource(pathname);
-
- compiler.setDestination(baseDirectory.getCanonicalPath());
-
- String systemBootClasspath = System.getProperty("sun.boot.class.path");
- String systemClasspath = System.getProperty("java.class.path");
- String systemExtDirs = System.getProperty("java.ext.dirs");
- String systemExtClasspath = null;
-
- try {
- systemExtClasspath = expandDirs(systemExtDirs);
- } catch (Exception e) {
- getLogger().warn("Could not expand Directory:" + systemExtDirs, e);
- }
-
- compiler.setClasspath(
- baseDirectory.getCanonicalPath() +
- ((classpath != null) ? File.pathSeparator + classpath : "") +
- ((systemBootClasspath != null) ? File.pathSeparator + systemBootClasspath : "") +
- ((systemClasspath != null) ? File.pathSeparator + systemClasspath : "") +
- ((systemExtClasspath != null) ? File.pathSeparator + systemExtClasspath : "")
- );
-
- if (encoding != null) {
- compiler.setEncoding(encoding);
- }
-
- getLogger().debug("Compiling " + filename_abs);
-
- if (!compiler.compile()) {
- StringBuffer message = new StringBuffer("Error compiling ");
- message.append(filename);
- message.append(":\n");
-
- List errors = compiler.getErrors();
- int count = errors.size();
- for (int i = 0; i < count; i++) {
- CompilerError error = (CompilerError) errors.get(i);
- if (i > 0) message.append("\n");
- message.append("Line ");
- message.append(error.getStartLine());
- message.append(", column ");
- message.append(error.getStartColumn());
- message.append(": ");
- message.append(error.getMessage());
+ /**
+ * Set the global component manager. This methods initializes the class
+ * loader manager if it was not (successfully) specified in the language
+ * parameters
+ *
+ * @param manager The global component manager
+ */
+ public void compose(ComponentManager manager) {
+ this.manager = manager;
+ if (this.classLoaderManager == null) {
+ try {
+ getLogger().debug("Looking up " + ClassLoaderManager.ROLE);
+ this.classLoaderManager =
+ (ClassLoaderManager) manager.lookup(ClassLoaderManager.ROLE);
+ } catch (Exception e) {
+ getLogger().error("Could not find component", e);
+ }
}
+ }
+
+ /**
+ * Actually load an object program from a class file.
+ *
+ * @param filename The object program base file name
+ * @param baseDirectory The directory containing the object program file
+ * @return The loaded object program
+ * @exception LanguageException If an error occurs during loading
+ */
+ protected Class loadProgram(String name, File baseDirectory)
+ throws LanguageException {
+ try {
+ this.classLoaderManager.addDirectory(baseDirectory);
+ return
+ this.classLoaderManager.loadClass(name.replace(File.separatorChar, '.'));
+ } catch (Exception e) {
+ getLogger().warn("Could not load class for program '" + name + "'", e);
+ throw new LanguageException("Could not load class for program '" + name + "' due to a " + e.getClass().getName() + ": " + e.getMessage());
+ }
+ }
- throw new LanguageException(message.toString());
- }
+ /**
+ * Compile a source file yielding a loadable class file.
+ *
+ * @param filename The object program base file name
+ * @param baseDirectory The directory containing the object program file
+ * @param encoding The encoding expected in the source file or
+ * <code>null</code> if it is the platform's default encoding
+ * @exception LanguageException If an error occurs during compilation
+ */
+ protected void compile(
+ String name, File baseDirectory, String encoding
+ ) throws LanguageException {
- } catch (InstantiationException e) {
- getLogger().warn("Could not instantiate the compiler", e);
- throw new LanguageException("Could not instantiate the compiler: " + e.getMessage());
- } catch (IllegalAccessException e) {
- getLogger().warn("Could not access the compiler class", e);
- throw new LanguageException("Could not access the compiler class: " + e.getMessage());
- } catch (IOException e) {
- getLogger().warn("Error during compilation", e);
- throw new LanguageException("Error during compilation: " + e.getMessage());
+ try {
+
+ AbstractJavaCompiler compiler = (AbstractJavaCompiler) this.compilerClass.newInstance();
+ // AbstractJavaCompiler is Loggable
+ compiler.setLogger(getLogger());
+
+ int pos = name.lastIndexOf(File.separatorChar);
+ String filename = name.substring(pos + 1);
+ String pathname =
+ baseDirectory.getCanonicalPath() + File.separator +
+ name.substring(0, pos).replace(File.separatorChar, '/');
+ String filename_abs =
+ new StringBuffer(pathname).append(File.separator).append(filename)
+ .append(".").append(this.getSourceExtension()).toString();
+
+ compiler.setFile(filename_abs);
+
+ compiler.setSource(pathname);
+
+ compiler.setDestination(baseDirectory.getCanonicalPath());
+
+ String systemBootClasspath = System.getProperty("sun.boot.class.path");
+ String systemClasspath = System.getProperty("java.class.path");
+ String systemExtDirs = System.getProperty("java.ext.dirs");
+ String systemExtClasspath = null;
+
+ try {
+ systemExtClasspath = expandDirs(systemExtDirs);
+ } catch (Exception e) {
+ getLogger().warn("Could not expand Directory:" + systemExtDirs, e);
+ }
+
+ compiler.setClasspath(
+ baseDirectory.getCanonicalPath() +
+ ((classpath != null) ? File.pathSeparator + classpath : "") +
+ ((systemBootClasspath != null) ? File.pathSeparator + systemBootClasspath : "") +
+ ((systemClasspath != null) ? File.pathSeparator + systemClasspath : "") +
+ ((systemExtClasspath != null) ? File.pathSeparator + systemExtClasspath : "")
+ );
+
+ if (encoding != null) {
+ compiler.setEncoding(encoding);
+ }
+
+ getLogger().debug("Compiling " + filename_abs);
+
+ if (!compiler.compile()) {
+ StringBuffer message = new StringBuffer("Error compiling ");
+ message.append(filename);
+ message.append(":\n");
+
+ List errors = compiler.getErrors();
+ int count = errors.size();
+ for (int i = 0; i < count; i++) {
+ CompilerError error = (CompilerError) errors.get(i);
+ if (i > 0) message.append("\n");
+ message.append("Line ");
+ message.append(error.getStartLine());
+ message.append(", column ");
+ message.append(error.getStartColumn());
+ message.append(": ");
+ message.append(error.getMessage());
+ }
+
+ throw new LanguageException(message.toString());
+ }
+
+ } catch (InstantiationException e) {
+ getLogger().warn("Could not instantiate the compiler", e);
+ throw new LanguageException("Could not instantiate the compiler: " + e.getMessage());
+ } catch (IllegalAccessException e) {
+ getLogger().warn("Could not access the compiler class", e);
+ throw new LanguageException("Could not access the compiler class: " + e.getMessage());
+ } catch (IOException e) {
+ getLogger().warn("Error during compilation", e);
+ throw new LanguageException("Error during compilation: " + e.getMessage());
+ }
}
- }
- /**
- * Unload a previously loaded class. This method simply reinstantiates the
- * class loader to ensure that a new version of the same class will be
- * correctly loaded in a future loading operation
- *
- * @param program A previously loaded class
- * @exception LanguageException If an error occurs during unloading
- */
- public void doUnload(Object program) throws LanguageException {
- this.classLoaderManager.reinstantiate();
- }
-
- /**
- * Escape a <code>String</code> according to the Java string constant
- * encoding rules.
- *
- * @param constant The string to be escaped
- * @return The escaped string
- */
- public String quoteString(String constant) {
- char chr[] = constant.toCharArray();
- StringBuffer buffer = new StringBuffer();
-
- for (int i = 0; i < chr.length; i++) {
- switch (chr[i]) {
- case '\t':
- buffer.append("\\t");
- break;
- case '\r':
- buffer.append("\\r");
- break;
- case '\n':
- buffer.append("\\n");
- break;
- case '"':
- case '\\':
- buffer.append('\\');
- // Fall through
- default:
- buffer.append(chr[i]);
- break;
- }
+ /**
+ * Unload a previously loaded class. This method simply reinstantiates the
+ * class loader to ensure that a new version of the same class will be
+ * correctly loaded in a future loading operation
+ *
+ * @param program A previously loaded class
+ * @exception LanguageException If an error occurs during unloading
+ */
+ public void doUnload(Object program) throws LanguageException {
+ this.classLoaderManager.reinstantiate();
}
- return buffer.toString();
- }
+ /**
+ * Escape a <code>String</code> according to the Java string constant
+ * encoding rules.
+ *
+ * @param constant The string to be escaped
+ * @return The escaped string
+ */
+ public String quoteString(String constant) {
+ return XSLTExtension.escapeString(constant);
+ }
- /**
- * Expand a directory path or list of directory paths (File.pathSeparator
- * delimited) into a list of file paths of all the jar files in those
- * directories.
- *
- * @param dirPaths The string containing the directory path or list of
- * directory paths.
- * @return The file paths of the jar files in the directories. This is an
- * empty string if no files were found, and is terminated by an
- * additional pathSeparator in all other cases.
- */
- private String expandDirs(String dirPaths) throws LanguageException {
- StringTokenizer st = new StringTokenizer(dirPaths, File.pathSeparator);
- StringBuffer buffer = new StringBuffer();
- while (st.hasMoreTokens()) {
- String d = st.nextToken();
- File dir = new File(d);
- if ( ! dir.isDirectory() ) {
- // The absence of a listed directory may not be an error.
- if (getLogger().isWarnEnabled()) getLogger().warn("Attempted to retrieve directory listing of non-directory " + dir.toString());
- } else {
- File[] files = dir.listFiles(new JavaArchiveFilter());
- for (int i = 0; i < files.length; i++) {
- buffer.append(files[i]).append(File.pathSeparator);
+ /**
+ * Expand a directory path or list of directory paths (File.pathSeparator
+ * delimited) into a list of file paths of all the jar files in those
+ * directories.
+ *
+ * @param dirPaths The string containing the directory path or list of
+ * directory paths.
+ * @return The file paths of the jar files in the directories. This is an
+ * empty string if no files were found, and is terminated by an
+ * additional pathSeparator in all other cases.
+ */
+ private String expandDirs(String dirPaths) throws LanguageException {
+ StringTokenizer st = new StringTokenizer(dirPaths, File.pathSeparator);
+ StringBuffer buffer = new StringBuffer();
+ while (st.hasMoreTokens()) {
+ String d = st.nextToken();
+ File dir = new File(d);
+ if (!dir.isDirectory()) {
+ // The absence of a listed directory may not be an error.
+ if (getLogger().isWarnEnabled()) getLogger().warn("Attempted to retrieve directory listing of non-directory " + dir.toString());
+ } else {
+ File[] files = dir.listFiles(new JavaArchiveFilter());
+ for (int i = 0; i < files.length; i++) {
+ buffer.append(files[i]).append(File.pathSeparator);
+ }
}
}
+ return buffer.toString();
}
- return buffer.toString();
- }
- /**
- * dispose
- */
- public void dispose() {
- manager.release(this.classLoaderManager);
- }
+ /**
+ * dispose
+ */
+ public void dispose() {
+ manager.release(this.classLoaderManager);
+ }
}
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org