cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rica...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/processor/xsp/language/java XSPJavaProcessor.java
Date Sun, 07 May 2000 00:44:06 GMT
ricardo     00/05/06 17:44:06

  Modified:    src/org/apache/cocoon/processor/xsp/language/java
                        XSPJavaProcessor.java
  Log:
  Added support for encodings (Pavel Karassev <paul@soft.tlt.ru>)
  
  Revision  Changes    Path
  1.9       +46 -13    xml-cocoon/src/org/apache/cocoon/processor/xsp/language/java/XSPJavaProcessor.java
  
  Index: XSPJavaProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xsp/language/java/XSPJavaProcessor.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XSPJavaProcessor.java	2000/04/27 17:57:43	1.8
  +++ XSPJavaProcessor.java	2000/05/07 00:44:05	1.9
  @@ -1,4 +1,4 @@
  -/*-- $Id: XSPJavaProcessor.java,v 1.8 2000/04/27 17:57:43 stefano Exp $ --
  +/*-- $Id: XSPJavaProcessor.java,v 1.9 2000/05/07 00:44:05 ricardo Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -62,11 +62,12 @@
   
   /**
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version $Revision: 1.8 $ $Date: 2000/04/27 17:57:43 $
  + * @version $Revision: 1.9 $ $Date: 2000/05/07 00:44:05 $
    */
   public class XSPJavaProcessor implements XSPLanguageProcessor {
     // Create class loader
     protected File repository;
  +  protected String encoding;
     protected XSPClassLoader classLoader;
   
     protected boolean format;
  @@ -83,6 +84,10 @@
       return "class";
     }
   
  +  public void setEncoding(String encoding) {
  +    this.encoding = encoding;
  +  }
  +
     public void setRepository(File repository) throws Exception {
       this.repository = repository;
       this.classLoader = new XSPClassLoader(this.repository);
  @@ -104,17 +109,31 @@
       String repositoryName = this.repository.getCanonicalPath();
       String fullFilename = repositoryName + File.separator + filename;
   
  -    String[] compilerArgs = {
  -      "-classpath",
  -        repositoryName +
  -        File.pathSeparator +
  -        System.getProperty("java.class.path"),
  -      "-O",
  -      // "-deprecation",
  -      // "-verbose",
  -      fullFilename
  -    };
  +    String[] compilerArgs = null;
   
  +    if (this.encoding == null) {
  +      compilerArgs = new String[] {
  +        "-classpath",
  +          repositoryName +
  +          File.pathSeparator +
  +          System.getProperty("java.class.path"),
  +        "-O",
  +        // "-deprecation",
  +        // "-verbose",
  +        fullFilename
  +      };
  +    } else {
  +      compilerArgs = new String[] {
  +        "-classpath",
  +          repositoryName +
  +          File.pathSeparator +
  +          System.getProperty("java.class.path"),
  +        "-O",
  +	"-encoding", this.encoding,
  +        fullFilename
  +      };
  +    }
  +
       ByteArrayOutputStream err = new ByteArrayOutputStream();
       
       // FIXME: we should make this reflection based and also allow other
  @@ -122,8 +141,10 @@
       // Tomcat code for this :) (SM)
       
       Main compiler = new Main(err, "javac");
  +
  +    boolean compilationResult = compiler.compile(compilerArgs);
   
  -    if (!compiler.compile(compilerArgs)) {
  +    if (!compilationResult) {
         // Massage message
         int pos = fullFilename.length() + 1;
         StringBuffer buffer = new StringBuffer();
  @@ -141,6 +162,18 @@
           buffer.toString()
         );
       }
  +/* 
  + int pos = fullFilename.length() + 1;
  + StringBuffer buffer = new StringBuffer();
  + String[] errorLines = XSPUtil.split(err.toString(), "\r\n");
  + for (int i = 0; i < errorLines.length; i++) {
  +   if (errorLines[i].startsWith(fullFilename)) {
  +     errorLines[i] = errorLines[i].substring(pos);
  +   }
  +   buffer.append(errorLines[i] + "\n");
  + }
  + System.err.println(buffer.toString());
  +*/
     }
   
     public XSPPage load(String filename) throws Exception {
  
  
  

Mime
View raw message