rubys       00/07/29 11:30:46

  Modified:    src/org/apache/cocoon Tag: xml-cocoon2
                        ProcessingException.java
               src/org/apache/cocoon/components/classloader Tag:
                        xml-cocoon2 ClassLoaderManager.java
                        ClassLoaderManagerImpl.java
                        RepositoryClassLoader.java
               src/org/apache/cocoon/components/language Tag: xml-cocoon2
                        LanguageException.java
               src/org/apache/cocoon/components/language/markup Tag:
                        xml-cocoon2 Logicsheet.java
                        LogicsheetCodeGenerator.java
                        MarkupCodeGenerator.java NamedLogicsheet.java
               src/org/apache/cocoon/components/language/markup/sitemap
                        Tag: xml-cocoon2 SitemapMarkupLanguage.java
               src/org/apache/cocoon/components/language/markup/xsp Tag:
                        xml-cocoon2 Constants.java XSPGenerator.java
                        XSPMarkupLanguage.java XSPObjectHelper.java
               src/org/apache/cocoon/components/language/programming Tag:
                        xml-cocoon2 AbstractProgrammingLanguage.java
                        CodeFormatter.java CompiledProgrammingLanguage.java
                        CompilerError.java LanguageCompiler.java
                        ProgrammingLanguage.java
               src/org/apache/cocoon/components/language/programming/java
                        Tag: xml-cocoon2 AbstractJavaCompiler.java
                        JavaLanguage.java Javac.java Jikes.java
                        JstyleFormatter.java
               src/org/apache/cocoon/components/language/programming/javascript
                        Tag: xml-cocoon2 JavascriptLanguage.java
               src/org/apache/cocoon/components/parser Tag: xml-cocoon2
                        Parser.java XercesParser.java
               src/org/apache/cocoon/components/store Tag: xml-cocoon2
                        FilesystemStore.java MemoryStore.java Store.java
               src/org/apache/cocoon/environment/http Tag: xml-cocoon2
                        HttpRequest.java HttpResponse.java
               src/org/apache/cocoon/generation Tag: xml-cocoon2
                        AbstractServerPage.java
                        ImageDirectoryGenerator.java RequestGenerator.java
                        StatusGenerator.java
               src/org/apache/cocoon/matching Tag: xml-cocoon2
                        AuthenticationMatcher.java
                        FileAuthenticationMatcher.java Matcher.java
               src/org/apache/cocoon/matching/helpers Tag: xml-cocoon2
                        WildcardURIMatcher.java
               src/org/apache/cocoon/selection Tag: xml-cocoon2
                        Selector.java
               src/org/apache/cocoon/serialization Tag: xml-cocoon2
                        AbstractSerializer.java FO2PDFSerializer.java
                        HTMLSerializer.java ImageSerializer.java
                        SVGSerializer.java Serializer.java
                        XMLSerializer.java
               src/org/apache/cocoon/servlet Tag: xml-cocoon2
                        CocoonServlet.java
               src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        SitemapComponent.java
               src/org/apache/cocoon/sitemap/patterns Tag: xml-cocoon2
                        PatternException.java PatternMatcher.java
                        PatternTranslator.java
               src/org/apache/cocoon/transformation Tag: xml-cocoon2
                        AbstractTransformer.java LogTransformer.java
                        SQLTransformer.java Transformer.java
                        XIncludeTransformer.java XalanTransformer.java
               src/org/apache/cocoon/util Tag: xml-cocoon2 ClassUtils.java
                        DOMUtils.java IOUtils.java StringUtils.java
                        Tokenizer.java
               src/org/apache/cocoon/xml Tag: xml-cocoon2
                        AbstractXMLConsumer.java AbstractXMLProducer.java
                        XMLConsumer.java XMLProducer.java package.html
               src/org/apache/cocoon/xml/util Tag: xml-cocoon2
                        DOMBuilder.java DOMFactory.java DOMStreamer.java
                        DocumentHandlerAdapter.java
                        DocumentHandlerWrapper.java NamespacesTable.java
                        XPathAPI.java package.html
  Log:
  Fix double CR problems
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +23 -23    
xml-cocoon/src/org/apache/cocoon/Attic/ProcessingException.java
  
  Index: ProcessingException.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/ProcessingException.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- ProcessingException.java  2000/07/22 20:41:29     1.1.2.5
  +++ ProcessingException.java  2000/07/29 18:30:26     1.1.2.6
  @@ -1,24 +1,24 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:29 $
  - */
  -public class ProcessingException extends Exception {
  -
  -    /**
  -     * Construct a new <code>ProcessingException</code> instance.
  -     */
  -    public ProcessingException(String message) {
  -        super(message);
  -    }
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/29 18:30:26 $
  + */
  +public class ProcessingException extends Exception {
  +
  +    /**
  +     * Construct a new <code>ProcessingException</code> instance.
  +     */
  +    public ProcessingException(String message) {
  +        super(message);
  +    }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +46 -46    
xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/ClassLoaderManager.java
  
  Index: ClassLoaderManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/ClassLoaderManager.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- ClassLoaderManager.java   2000/07/22 20:41:30     1.1.2.3
  +++ ClassLoaderManager.java   2000/07/29 18:30:26     1.1.2.4
  @@ -1,46 +1,46 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.classloader;
  -
  -import org.apache.avalon.Component;
  -
  -import java.io.IOException;
  -
  -/**
  - * A class loader manager acting as a proxy for a <b>single</b>
  - * <code>RepositoryClassLoader</code>.
  - * This class guarantees that a single class loader instance exists so
  - * that it can be safely reinstantiated for dynamic class reloading
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:30 $
  - */
  -public interface ClassLoaderManager extends Component {
  -  /**
  -   * Add a directory to the proxied class loader
  -   *
  -   * @param directoryName The repository name
  -   * @exception IOException If the directory is invalid
  -   */
  -  public void addDirectory(String directoryName) throws IOException;
  -
  -  /**
  -   * Load a class through the proxied class loader
  -   *
  -   * @param className The name of the class to be loaded
  -   * @return The loaded class
  -   * @exception ClassNotFoundException If the class is not found
  -   */
  -  public Class loadClass(String className) throws ClassNotFoundException;
  -
  -  /**
  -   * Reinstantiate the proxied class loader to allow for class reloading
  -   *
  -   */
  -  public void reinstantiate();
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.classloader;
  +
  +import org.apache.avalon.Component;
  +
  +import java.io.IOException;
  +
  +/**
  + * A class loader manager acting as a proxy for a <b>single</b>
  + * <code>RepositoryClassLoader</code>.
  + * This class guarantees that a single class loader instance exists so
  + * that it can be safely reinstantiated for dynamic class reloading
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:26 $
  + */
  +public interface ClassLoaderManager extends Component {
  +  /**
  +   * Add a directory to the proxied class loader
  +   *
  +   * @param directoryName The repository name
  +   * @exception IOException If the directory is invalid
  +   */
  +  public void addDirectory(String directoryName) throws IOException;
  +
  +  /**
  +   * Load a class through the proxied class loader
  +   *
  +   * @param className The name of the class to be loaded
  +   * @return The loaded class
  +   * @exception ClassNotFoundException If the class is not found
  +   */
  +  public Class loadClass(String className) throws ClassNotFoundException;
  +
  +  /**
  +   * Reinstantiate the proxied class loader to allow for class reloading
  +   *
  +   */
  +  public void reinstantiate();
  +}
  
  
  
  1.1.2.3   +62 -62    
xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/ClassLoaderManagerImpl.java
  
  Index: ClassLoaderManagerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/ClassLoaderManagerImpl.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ClassLoaderManagerImpl.java       2000/07/22 20:41:30     1.1.2.2
  +++ ClassLoaderManagerImpl.java       2000/07/29 18:30:26     1.1.2.3
  @@ -1,62 +1,62 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.classloader;
  -
  -import java.io.IOException;
  -
  -/**
  - * A singleton-like implementation of <code>ClassLoaderManager</code>
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:30 $
  - */
  -public class ClassLoaderManagerImpl implements ClassLoaderManager {
  -  /**
  -   * The single class loader instance
  -   */
  -  protected static RepositoryClassLoader instance = null;
  -
  -  /**
  -   * A constructor that ensures only a single class loader instance exists
  -   *
  -   */
  -  public ClassLoaderManagerImpl() {
  -    if (instance == null) {
  -      instance = new RepositoryClassLoader();
  -    }
  -  }
  -
  -  /**
  -   * Add a directory to the proxied class loader
  -   *
  -   * @param directoryName The repository name
  -   * @exception IOException If the directory is invalid
  -   */
  -  public void addDirectory(String directoryName) throws IOException {
  -    instance.addDirectory(directoryName);
  -  }
  -
  -  /**
  -   * Load a class through the proxied class loader
  -   *
  -   * @param className The name of the class to be loaded
  -   * @return The loaded class
  -   * @exception ClassNotFoundException If the class is not found
  -   */
  -  public Class loadClass(String className) throws ClassNotFoundException {
  -    return instance.loadClass(className);
  -  }
  -
  -  /**
  -   * Reinstantiate the proxied class loader to allow for class reloading
  -   *
  -   */
  -  public synchronized void reinstantiate() {
  -    instance = new RepositoryClassLoader();
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.classloader;
  +
  +import java.io.IOException;
  +
  +/**
  + * A singleton-like implementation of <code>ClassLoaderManager</code>
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:26 $
  + */
  +public class ClassLoaderManagerImpl implements ClassLoaderManager {
  +  /**
  +   * The single class loader instance
  +   */
  +  protected static RepositoryClassLoader instance = null;
  +
  +  /**
  +   * A constructor that ensures only a single class loader instance exists
  +   *
  +   */
  +  public ClassLoaderManagerImpl() {
  +    if (instance == null) {
  +      instance = new RepositoryClassLoader();
  +    }
  +  }
  +
  +  /**
  +   * Add a directory to the proxied class loader
  +   *
  +   * @param directoryName The repository name
  +   * @exception IOException If the directory is invalid
  +   */
  +  public void addDirectory(String directoryName) throws IOException {
  +    instance.addDirectory(directoryName);
  +  }
  +
  +  /**
  +   * Load a class through the proxied class loader
  +   *
  +   * @param className The name of the class to be loaded
  +   * @return The loaded class
  +   * @exception ClassNotFoundException If the class is not found
  +   */
  +  public Class loadClass(String className) throws ClassNotFoundException {
  +    return instance.loadClass(className);
  +  }
  +
  +  /**
  +   * Reinstantiate the proxied class loader to allow for class reloading
  +   *
  +   */
  +  public synchronized void reinstantiate() {
  +    instance = new RepositoryClassLoader();
  +  }
  +}
  
  
  
  1.1.2.3   +187 -187  
xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/RepositoryClassLoader.java
  
  Index: RepositoryClassLoader.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/RepositoryClassLoader.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- RepositoryClassLoader.java        2000/07/22 20:41:30     1.1.2.2
  +++ RepositoryClassLoader.java        2000/07/29 18:30:26     1.1.2.3
  @@ -1,187 +1,187 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.classloader;
  -
  -import java.util.Vector;
  -
  -import java.io.File;
  -import java.io.FileInputStream;
  -
  -import java.io.IOException;
  -
  -import org.apache.cocoon.util.IOUtils;
  -
  -/**
  - * A class loader with a growable list of path search directories
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:30 $
  - */
  -class RepositoryClassLoader extends ClassLoader {
  -  /**
  -   * The list of searchable directories
  -   */
  -  protected Vector repositories;
  -
  -  /**
  -   * Create an empty new class loader.
  -   */
  -  public RepositoryClassLoader() {
  -    this.repositories = new Vector();
  -  }
  -
  -  /**
  -   * Create a class loader from a list of directories
  -   *
  -   * @param repositories List of searchable directories
  -   */
  -  protected RepositoryClassLoader(Vector repositories) {
  -    this.repositories = repositories;
  -  }
  -
  -  /**
  -   * Add a directory to the list of searchable repositories.
  -   * This methods ensures that no directory is specified more than once.
  -   *
  -   * @param directoryName The path directory
  -   * @exception IOException Non-existent, non-readable or non-directory
  -   * repository
  -   */
  -  public void addDirectory(String directoryName) throws IOException {
  -    File repository = new File(directoryName);
  -
  -    // Ensure the same directory isn't specified twice
  -    int count = this.repositories.size();
  -    String fullFilename = IOUtils.getFullFilename(repository);
  -    for (int i = 0; i < count; i++) {
  -      File directory = (File) this.repositories.elementAt(i);
  -      if (fullFilename.equals(IOUtils.getFullFilename(directory))) {
  -        return;
  -      }
  -    }
  -
  -    if (!repository.exists()) {
  -      throw new IOException("Non-existent: " + directoryName);
  -    }
  -
  -    if (!repository.isDirectory()) {
  -      throw new IOException("Not a directory: " + directoryName);
  -    }
  -
  -    if (!(repository.canRead() && repository.canWrite())) {
  -      throw new IOException("Not readable/writable: " + directoryName);
  -    }
  -
  -    this.repositories.addElement(repository);
  -  }
  -
  -  /**
  -   * Load a class using the parent class loader or, failing that,
  -   * from one of the stored repositories in definition order
  -   *
  -   * @param name The class name
  -   * @param resolve Whether the class name must be resolved
  -   * @return The loaded class
  -   * @exception ClassNotFoundException If the class is not found in any of 
the
  -   * repositories
  -   */
  -  protected Class loadClass (String name, boolean resolve)
  -    throws ClassNotFoundException
  -  {
  -    Class c = findLoadedClass(name);
  -
  -    if (c == null) {
  -      try {
  -        c = findSystemClass(name);
  -      } catch (ClassNotFoundException e) {
  -        byte[] bits = this.loadClassData (name);
  -
  -        if (bits == null) {
  -          // ClassLoader cl = getParent();
  -          ClassLoader cl = this.getClass().getClassLoader();
  -
  -          if (cl != null)  {
  -            c = cl.loadClass (name);
  -          }
  -        } else {
  -          c = defineClass (null, bits, 0, bits.length);
  -
  -          if (resolve) {
  -            resolveClass (c);
  -          }
  -        }
  -      }
  -
  -      if (c == null) {
  -        throw new ClassNotFoundException (name);
  -      }
  -    }
  -
  -    return c;
  -  }
  -
  -  /**
  -   * Load class from a file contained in a repository.
  -   *
  -   * @param className The class name
  -   * @return An array of byes containing the class data or <code>null</code> 
if
  -   * not founfd
  -   */
  -  protected byte[] loadClassData (String className) {
  -    int count = this.repositories.size();
  -    for (int i = 0; i < count; i++) {
  -      File repository = (File) this.repositories.elementAt(i);
  -      File file = new File(this.getClassFilename(className, repository));
  -
  -      if (file.exists() && file.isFile() && file.canRead()) {
  -        byte[] buffer = null;
  -        FileInputStream in = null;
  -    
  -        int n = 0;
  -        int pos = 0;
  -        buffer = new byte [(int) file.length ()];
  -  
  -        try {
  -          in = new FileInputStream(file);
  -  
  -          while (
  -            pos < buffer.length &&
  -            (n = in.read (buffer, pos, buffer.length - pos)) != -1
  -          ) {
  -            pos += n;
  -          }
  -
  -       return buffer;
  -     } catch (IOException e) {
  -        } finally {
  -          if (in != null) {
  -            try { in.close(); }
  -            catch (IOException e) { }
  -          }
  -        }
  -      }
  -    }
  -
  -    return null;
  -  }
  -
  -  /**
  -   * Return the filename associated with a given class name in a given
  -   * directory
  -   *
  -   * @param className The class name for which a filename is to be generated
  -   * @param repository The directory containing the class file
  -   * @return The filename associated with a given class name in a given
  -   * directory
  -   */
  -  protected String getClassFilename(String className, File repository) {
  -    return
  -      repository.getAbsolutePath() + File.separator +
  -      className.replace('.', File.separatorChar) + ".class";
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.classloader;
  +
  +import java.util.Vector;
  +
  +import java.io.File;
  +import java.io.FileInputStream;
  +
  +import java.io.IOException;
  +
  +import org.apache.cocoon.util.IOUtils;
  +
  +/**
  + * A class loader with a growable list of path search directories
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:26 $
  + */
  +class RepositoryClassLoader extends ClassLoader {
  +  /**
  +   * The list of searchable directories
  +   */
  +  protected Vector repositories;
  +
  +  /**
  +   * Create an empty new class loader.
  +   */
  +  public RepositoryClassLoader() {
  +    this.repositories = new Vector();
  +  }
  +
  +  /**
  +   * Create a class loader from a list of directories
  +   *
  +   * @param repositories List of searchable directories
  +   */
  +  protected RepositoryClassLoader(Vector repositories) {
  +    this.repositories = repositories;
  +  }
  +
  +  /**
  +   * Add a directory to the list of searchable repositories.
  +   * This methods ensures that no directory is specified more than once.
  +   *
  +   * @param directoryName The path directory
  +   * @exception IOException Non-existent, non-readable or non-directory
  +   * repository
  +   */
  +  public void addDirectory(String directoryName) throws IOException {
  +    File repository = new File(directoryName);
  +
  +    // Ensure the same directory isn't specified twice
  +    int count = this.repositories.size();
  +    String fullFilename = IOUtils.getFullFilename(repository);
  +    for (int i = 0; i < count; i++) {
  +      File directory = (File) this.repositories.elementAt(i);
  +      if (fullFilename.equals(IOUtils.getFullFilename(directory))) {
  +        return;
  +      }
  +    }
  +
  +    if (!repository.exists()) {
  +      throw new IOException("Non-existent: " + directoryName);
  +    }
  +
  +    if (!repository.isDirectory()) {
  +      throw new IOException("Not a directory: " + directoryName);
  +    }
  +
  +    if (!(repository.canRead() && repository.canWrite())) {
  +      throw new IOException("Not readable/writable: " + directoryName);
  +    }
  +
  +    this.repositories.addElement(repository);
  +  }
  +
  +  /**
  +   * Load a class using the parent class loader or, failing that,
  +   * from one of the stored repositories in definition order
  +   *
  +   * @param name The class name
  +   * @param resolve Whether the class name must be resolved
  +   * @return The loaded class
  +   * @exception ClassNotFoundException If the class is not found in any of 
the
  +   * repositories
  +   */
  +  protected Class loadClass (String name, boolean resolve)
  +    throws ClassNotFoundException
  +  {
  +    Class c = findLoadedClass(name);
  +
  +    if (c == null) {
  +      try {
  +        c = findSystemClass(name);
  +      } catch (ClassNotFoundException e) {
  +        byte[] bits = this.loadClassData (name);
  +
  +        if (bits == null) {
  +          // ClassLoader cl = getParent();
  +          ClassLoader cl = this.getClass().getClassLoader();
  +
  +          if (cl != null)  {
  +            c = cl.loadClass (name);
  +          }
  +        } else {
  +          c = defineClass (null, bits, 0, bits.length);
  +
  +          if (resolve) {
  +            resolveClass (c);
  +          }
  +        }
  +      }
  +
  +      if (c == null) {
  +        throw new ClassNotFoundException (name);
  +      }
  +    }
  +
  +    return c;
  +  }
  +
  +  /**
  +   * Load class from a file contained in a repository.
  +   *
  +   * @param className The class name
  +   * @return An array of byes containing the class data or <code>null</code> 
if
  +   * not founfd
  +   */
  +  protected byte[] loadClassData (String className) {
  +    int count = this.repositories.size();
  +    for (int i = 0; i < count; i++) {
  +      File repository = (File) this.repositories.elementAt(i);
  +      File file = new File(this.getClassFilename(className, repository));
  +
  +      if (file.exists() && file.isFile() && file.canRead()) {
  +        byte[] buffer = null;
  +        FileInputStream in = null;
  +    
  +        int n = 0;
  +        int pos = 0;
  +        buffer = new byte [(int) file.length ()];
  +  
  +        try {
  +          in = new FileInputStream(file);
  +  
  +          while (
  +            pos < buffer.length &&
  +            (n = in.read (buffer, pos, buffer.length - pos)) != -1
  +          ) {
  +            pos += n;
  +          }
  +
  +       return buffer;
  +     } catch (IOException e) {
  +        } finally {
  +          if (in != null) {
  +            try { in.close(); }
  +            catch (IOException e) { }
  +          }
  +        }
  +      }
  +    }
  +
  +    return null;
  +  }
  +
  +  /**
  +   * Return the filename associated with a given class name in a given
  +   * directory
  +   *
  +   * @param className The class name for which a filename is to be generated
  +   * @param repository The directory containing the class file
  +   * @return The filename associated with a given class name in a given
  +   * directory
  +   */
  +  protected String getClassFilename(String className, File repository) {
  +    return
  +      repository.getAbsolutePath() + File.separator +
  +      className.replace('.', File.separatorChar) + ".class";
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +23 -23    
xml-cocoon/src/org/apache/cocoon/components/language/Attic/LanguageException.java
  
  Index: LanguageException.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/Attic/LanguageException.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- LanguageException.java    2000/07/22 20:41:31     1.1.2.2
  +++ LanguageException.java    2000/07/29 18:30:27     1.1.2.3
  @@ -1,23 +1,23 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language;
  -
  -/**
  - * The language exception.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:31 $
  - */
  -public class LanguageException extends Exception {
  -  /**
  -   * The default constructor.
  -   */
  -  public LanguageException(String message) {
  -    super(message);
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language;
  +
  +/**
  + * The language exception.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:27 $
  + */
  +public class LanguageException extends Exception {
  +  /**
  +   * The default constructor.
  +   */
  +  public LanguageException(String message) {
  +    super(message);
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +101 -101  
xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/Logicsheet.java
  
  Index: Logicsheet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/Logicsheet.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Logicsheet.java   2000/07/22 20:41:32     1.1.2.2
  +++ Logicsheet.java   2000/07/29 18:30:27     1.1.2.3
  @@ -1,101 +1,101 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.markup;
  -
  -import java.net.URL;
  -import java.util.Vector;
  -
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.NamedNodeMap;
  -
  -import org.xml.sax.InputSource;
  -
  -import org.apache.cocoon.util.DOMUtils;
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -import java.net.MalformedURLException;
  -
  -/**
  - * A code-generation logicsheet. This class is actually a wrapper for
  - * a "standard" XSLT stylesheet though this will change shortly: a new markup
  - * language will be used for logicsheet authoring; logicsheets written in 
this
  - * language will be transformed into an equivalent XSLT stylesheet anyway...
  - * This class should probably be based on an interface...
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:32 $
  - */
  -public class Logicsheet {
  -  /**
  -   * The wrapped XSLT stylesheet
  -   */
  -  protected Document stylesheet;
  -
  -  /**
  -   * The list of preserved namespaces
  -   */
  -  protected Vector namespaces;
  -  /**
  -   * A time-saving trick: this is actually the namespace's vector size()
  -   */
  -  protected int namespaceCount;
  -
  -  /**
  -   * The constructor. This method scans the logicsheet collecting namespaces 
to
  -   * be preserved on output; this ensures that no namespaces will be dropped
  -   * from the original document
  -   *
  -   * @param inputSource The stylesheet's input source
  -   * @exception IOException IOError processing input source
  -   * @exception SAXException Input source parse error
  -   */
  -  public void setInputSource(InputSource inputSource)
  -    throws SAXException, IOException
  -  {
  -    this.stylesheet = DOMUtils.DOMParse(inputSource);
  -    this.namespaces = 
DOMUtils.namespaces(this.stylesheet.getDocumentElement());
  -    this.namespaceCount = this.namespaces.size();
  -  }
  -
  -  /**
  -   * Apply this logicsheet to an input document. This method does additional
  -   * namesapace preserving as stylsheet processing may drop namespaces 
required
  -   * by further code-generation steps
  -   *
  -   * @param input Param The input document
  -   * @return The transformed document
  -   * @exception SAXException If a stylesheet processing error occurs
  -   */
  -  public Document apply(Document input) throws SAXException {
  -    // Save original namespaces
  -    Vector inputNamespaces = DOMUtils.namespaces(input.getDocumentElement());
  -    int inputCount = inputNamespaces.size();
  -
  -    // Transform input document
  -    Document output = DOMUtils.transformDocument(input, this.stylesheet);
  -
  -    // Restore original namespaces
  -    Element root = output.getDocumentElement();
  -
  -    for (int i = 0; i < inputCount; i++) {
  -      String[] pair = (String[]) inputNamespaces.elementAt(i);
  -      root.setAttribute(pair[0], pair[1]);
  -    }
  -
  -    // Restore stylesheet namespaces
  -    for (int i = 0; i < this.namespaceCount; i++) {
  -      String[] pair = (String[]) this.namespaces.elementAt(i);
  -      root.setAttribute(pair[0], pair[1]);
  -    }
  -
  -    return output;
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.markup;
  +
  +import java.net.URL;
  +import java.util.Vector;
  +
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.NamedNodeMap;
  +
  +import org.xml.sax.InputSource;
  +
  +import org.apache.cocoon.util.DOMUtils;
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +import java.net.MalformedURLException;
  +
  +/**
  + * A code-generation logicsheet. This class is actually a wrapper for
  + * a "standard" XSLT stylesheet though this will change shortly: a new markup
  + * language will be used for logicsheet authoring; logicsheets written in 
this
  + * language will be transformed into an equivalent XSLT stylesheet anyway...
  + * This class should probably be based on an interface...
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:27 $
  + */
  +public class Logicsheet {
  +  /**
  +   * The wrapped XSLT stylesheet
  +   */
  +  protected Document stylesheet;
  +
  +  /**
  +   * The list of preserved namespaces
  +   */
  +  protected Vector namespaces;
  +  /**
  +   * A time-saving trick: this is actually the namespace's vector size()
  +   */
  +  protected int namespaceCount;
  +
  +  /**
  +   * The constructor. This method scans the logicsheet collecting namespaces 
to
  +   * be preserved on output; this ensures that no namespaces will be dropped
  +   * from the original document
  +   *
  +   * @param inputSource The stylesheet's input source
  +   * @exception IOException IOError processing input source
  +   * @exception SAXException Input source parse error
  +   */
  +  public void setInputSource(InputSource inputSource)
  +    throws SAXException, IOException
  +  {
  +    this.stylesheet = DOMUtils.DOMParse(inputSource);
  +    this.namespaces = 
DOMUtils.namespaces(this.stylesheet.getDocumentElement());
  +    this.namespaceCount = this.namespaces.size();
  +  }
  +
  +  /**
  +   * Apply this logicsheet to an input document. This method does additional
  +   * namesapace preserving as stylsheet processing may drop namespaces 
required
  +   * by further code-generation steps
  +   *
  +   * @param input Param The input document
  +   * @return The transformed document
  +   * @exception SAXException If a stylesheet processing error occurs
  +   */
  +  public Document apply(Document input) throws SAXException {
  +    // Save original namespaces
  +    Vector inputNamespaces = DOMUtils.namespaces(input.getDocumentElement());
  +    int inputCount = inputNamespaces.size();
  +
  +    // Transform input document
  +    Document output = DOMUtils.transformDocument(input, this.stylesheet);
  +
  +    // Restore original namespaces
  +    Element root = output.getDocumentElement();
  +
  +    for (int i = 0; i < inputCount; i++) {
  +      String[] pair = (String[]) inputNamespaces.elementAt(i);
  +      root.setAttribute(pair[0], pair[1]);
  +    }
  +
  +    // Restore stylesheet namespaces
  +    for (int i = 0; i < this.namespaceCount; i++) {
  +      String[] pair = (String[]) this.namespaces.elementAt(i);
  +      root.setAttribute(pair[0], pair[1]);
  +    }
  +
  +    return output;
  +  }
  +}
  
  
  
  1.1.2.3   +68 -68    
xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/LogicsheetCodeGenerator.java
  
  Index: LogicsheetCodeGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/LogicsheetCodeGenerator.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- LogicsheetCodeGenerator.java      2000/07/22 20:41:33     1.1.2.2
  +++ LogicsheetCodeGenerator.java      2000/07/29 18:30:28     1.1.2.3
  @@ -1,68 +1,68 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.markup;
  -
  -import java.util.Vector;
  -
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Document;
  -import org.xml.sax.InputSource;
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * A logicsheet-based implementation of <code>MarkupGenerator</code>
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:33 $
  - */
  -public class LogicsheetCodeGenerator implements MarkupCodeGenerator {
  -  /**
  -   * Ordered list of logicsheet to be used in code generation
  -   */
  -  protected Vector logicsheets;
  -
  -  /**
  -   * The default constructor
  -   */
  -  public LogicsheetCodeGenerator() {
  -    this.logicsheets = new Vector();
  -  }
  -
  -  /**
  -   * Add a logicsheet to the logicsheet list
  -   *
  -   * @param logicsheet The logicsheet to be added
  -   */
  -  public void addLogicsheet(Logicsheet logicsheet) {
  -    this.logicsheets.addElement(logicsheet);
  -  }
  -
  -  /**
  -   * Generate source code from the input document. Filename information is
  -   * ignored in the logicsheet-based code generation approach
  -   *
  -   * @param input The input document
  -   * @param filename The input source original filename
  -   * @return The generated source code
  -   * @exception Exception If an error occurs during code generation
  -   */
  -  public String generateCode(Document input, String filename) throws 
Exception {
  -    int count = this.logicsheets.size();
  -    for (int i = 0; i < count; i++) {
  -      Logicsheet logicsheet = (Logicsheet) this.logicsheets.elementAt(i);
  -      input = logicsheet.apply(input);
  -    }
  -
  -    Element result = input.getDocumentElement();
  -    result.normalize();
  -
  -    return result.getFirstChild().getNodeValue();
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.markup;
  +
  +import java.util.Vector;
  +
  +import org.w3c.dom.Element;
  +import org.w3c.dom.Document;
  +import org.xml.sax.InputSource;
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * A logicsheet-based implementation of <code>MarkupGenerator</code>
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:28 $
  + */
  +public class LogicsheetCodeGenerator implements MarkupCodeGenerator {
  +  /**
  +   * Ordered list of logicsheet to be used in code generation
  +   */
  +  protected Vector logicsheets;
  +
  +  /**
  +   * The default constructor
  +   */
  +  public LogicsheetCodeGenerator() {
  +    this.logicsheets = new Vector();
  +  }
  +
  +  /**
  +   * Add a logicsheet to the logicsheet list
  +   *
  +   * @param logicsheet The logicsheet to be added
  +   */
  +  public void addLogicsheet(Logicsheet logicsheet) {
  +    this.logicsheets.addElement(logicsheet);
  +  }
  +
  +  /**
  +   * Generate source code from the input document. Filename information is
  +   * ignored in the logicsheet-based code generation approach
  +   *
  +   * @param input The input document
  +   * @param filename The input source original filename
  +   * @return The generated source code
  +   * @exception Exception If an error occurs during code generation
  +   */
  +  public String generateCode(Document input, String filename) throws 
Exception {
  +    int count = this.logicsheets.size();
  +    for (int i = 0; i < count; i++) {
  +      Logicsheet logicsheet = (Logicsheet) this.logicsheets.elementAt(i);
  +      input = logicsheet.apply(input);
  +    }
  +
  +    Element result = input.getDocumentElement();
  +    result.normalize();
  +
  +    return result.getFirstChild().getNodeValue();
  +  }
  +}
  
  
  
  1.1.2.3   +30 -30    
xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/MarkupCodeGenerator.java
  
  Index: MarkupCodeGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/MarkupCodeGenerator.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- MarkupCodeGenerator.java  2000/07/22 20:41:33     1.1.2.2
  +++ MarkupCodeGenerator.java  2000/07/29 18:30:28     1.1.2.3
  @@ -1,30 +1,30 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.markup;
  -
  -import org.w3c.dom.Document;
  -
  -/**
  - * This interfaces defines the functionality of a source code generator
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:33 $
  - */
  -public interface MarkupCodeGenerator {
  -  /**
  -   * Generate source code from the input document. Filename information may 
be
  -   * needed by certain code-generation approaches and programming languages
  -   *
  -   * @param input The input document
  -   * @param filename The input source original filename
  -   * @return The generated source code
  -   * @exception Exception If an error occurs during code generation
  -   */
  -  public String generateCode(Document document, String filename)
  -    throws Exception;
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.markup;
  +
  +import org.w3c.dom.Document;
  +
  +/**
  + * This interfaces defines the functionality of a source code generator
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:28 $
  + */
  +public interface MarkupCodeGenerator {
  +  /**
  +   * Generate source code from the input document. Filename information may 
be
  +   * needed by certain code-generation approaches and programming languages
  +   *
  +   * @param input The input document
  +   * @param filename The input source original filename
  +   * @return The generated source code
  +   * @exception Exception If an error occurs during code generation
  +   */
  +  public String generateCode(Document document, String filename)
  +    throws Exception;
  +}
  
  
  
  1.1.2.3   +70 -70    
xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/NamedLogicsheet.java
  
  Index: NamedLogicsheet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/NamedLogicsheet.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- NamedLogicsheet.java      2000/07/22 20:41:33     1.1.2.2
  +++ NamedLogicsheet.java      2000/07/29 18:30:28     1.1.2.3
  @@ -1,70 +1,70 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.markup;
  -
  -import org.xml.sax.InputSource;
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * An extension to <code>Logicsheet</code> that is associated with a 
namespace.
  - * Named logicsheets are implicitly declared (and automagically applied) when
  - * the markup language document's root element declares the same logichseet's
  - * namespace 
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:33 $
  - */
  -public class NamedLogicsheet extends Logicsheet {
  -  /**
  -   * The namespace uri
  -   */
  -  protected String uri;
  -
  -  /**
  -   * The namespace prefix
  -   */
  -  protected String prefix;
  -
  -  /**
  -   * Set the logichseet's namespace prefix
  -   *
  -   * @param prefix The namespace prefix
  -   */
  -  public void setPrefix(String prefix) {
  -    this.prefix = prefix;
  -  }
  -
  -  /**
  -   * Return the logicsheet's namespace prefix
  -   *
  -   * @return The logicsheet's namespace prefix
  -   */
  -  public String getPrefix() {
  -    return this.prefix;
  -  }
  -
  -  /**
  -   * Set the logichseet's namespace uri
  -   *
  -   * @param prefix The namespace uri
  -   */
  -  public void setUri(String uri) {
  -    this.uri = uri;
  -  }
  -
  -  /**
  -   * Return the logicsheet's namespace uri
  -   *
  -   * @return The logicsheet's namespace uri
  -   */
  -  public String getUri() {
  -    return this.uri;
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.markup;
  +
  +import org.xml.sax.InputSource;
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * An extension to <code>Logicsheet</code> that is associated with a 
namespace.
  + * Named logicsheets are implicitly declared (and automagically applied) when
  + * the markup language document's root element declares the same logichseet's
  + * namespace 
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:28 $
  + */
  +public class NamedLogicsheet extends Logicsheet {
  +  /**
  +   * The namespace uri
  +   */
  +  protected String uri;
  +
  +  /**
  +   * The namespace prefix
  +   */
  +  protected String prefix;
  +
  +  /**
  +   * Set the logichseet's namespace prefix
  +   *
  +   * @param prefix The namespace prefix
  +   */
  +  public void setPrefix(String prefix) {
  +    this.prefix = prefix;
  +  }
  +
  +  /**
  +   * Return the logicsheet's namespace prefix
  +   *
  +   * @return The logicsheet's namespace prefix
  +   */
  +  public String getPrefix() {
  +    return this.prefix;
  +  }
  +
  +  /**
  +   * Set the logichseet's namespace uri
  +   *
  +   * @param prefix The namespace uri
  +   */
  +  public void setUri(String uri) {
  +    this.uri = uri;
  +  }
  +
  +  /**
  +   * Return the logicsheet's namespace uri
  +   *
  +   * @return The logicsheet's namespace uri
  +   */
  +  public String getUri() {
  +    return this.uri;
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +258 -258  
xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java
  
  Index: SitemapMarkupLanguage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- SitemapMarkupLanguage.java        2000/07/22 20:41:34     1.1.2.4
  +++ SitemapMarkupLanguage.java        2000/07/29 18:30:28     1.1.2.5
  @@ -1,258 +1,258 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.markup.sitemap;
  -
  -import java.io.File;
  -import java.util.Date;
  -import java.util.Vector;
  -import java.util.Hashtable;
  -
  -import org.w3c.dom.Node;
  -import org.w3c.dom.Text;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.ProcessingInstruction;
  -
  -import org.apache.cocoon.util.DOMUtils;
  -import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
  -
  -import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  -
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * This class implements <code>MarkupLanguage</code> for Cocoon's
  - * <a href="http://xml.apache.org/cocoon/sitemap.html";>Sitemap</a>.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:34 $
  - */
  -public class SitemapMarkupLanguage extends AbstractMarkupLanguage {
  -  /**
  -   * The default constructor.
  -   */
  -  public SitemapMarkupLanguage() throws SAXException, IOException {
  -    super();
  -  }
  -
  -  /**
  -   * Return the Sitemap language name: <i>map</i> :-)
  -   *
  -   * @return The <i>map</i> constant
  -   */
  -  public String getName() {
  -    return "map";
  -  }
  -
  -  /**
  -   * Return the document-declared encoding or <code>null</code> if it's the
  -   * platform's default encoding
  -   *
  -   * @param document The input document
  -   * @return The document-declared encoding
  -   */
  -  public String getEncoding(Document document) {
  -    String encoding = document.getDocumentElement().getAttribute("encoding");
  -
  -    if (encoding.length() > 0) {
  -      return encoding;
  -    }
  -
  -    return null;
  -  }
  -
  -  /**
  -   * Prepare the document for logicsheet processing and code generation. This
  -   * method sets the base filename, file path and creation date as root 
element
  -   * attibutes and encodes text nodes as strings.
  -   *
  -   * @param document The input document
  -   * @param filename The input source filename
  -   * @param language The target programming language
  -   * @return The augmented document
  -   */
  -  protected Document preprocessDocument(
  -    Document document, String filename, ProgrammingLanguage language
  -  )
  -  {
  -    // Store path and file name
  -    int pos = filename.lastIndexOf(File.separatorChar);
  -    String name = filename.substring(pos + 1);
  -    String path = filename.substring(0, pos).replace(File.separatorChar, 
'/');
  -
  -    Element root = document.getDocumentElement();
  -
  -    root.setAttribute("file-name", name);
  -    root.setAttribute("file-path", path);
  -    root.setAttribute("creation-date", String.valueOf(new Date().getTime()));
  -
  -    this.quoteStrings(document, language);
  -
  -    return document;
  -  }
  -
  -  /**
  -   * Encode text nodes as strings according to the target programming 
languages
  -   * string constant escaping rules.
  -   *
  -   * @param node The node to be escaped
  -   * @param language The target programming language
  -   */
  -  protected void quoteStrings(Node node, ProgrammingLanguage language) {
  -    switch (node.getNodeType()) {
  -      case Node.PROCESSING_INSTRUCTION_NODE:
  -        ProcessingInstruction pi = (ProcessingInstruction) node;
  -     if (!pi.getTarget().equals("xml-logicsheet")) {
  -          pi.setData(language.quoteString(pi.getData()));
  -     }
  -        break;
  -      case Node.TEXT_NODE:
  -        if (true) break; // the sitemap shouldn't have any text node
  -        Element parent = (Element) node.getParentNode();
  -
  -        String tagName = parent.getTagName();
  -
  -        if (
  -          tagName.equals("xsp:expr") ||
  -          tagName.equals("xsp:logic") ||
  -          tagName.equals("xsp:structure") ||
  -          tagName.equals("xsp:include")
  -        ) {
  -          return;
  -        }
  -
  -        String value = language.quoteString(node.getNodeValue());
  -        Text textNode = node.getOwnerDocument().createTextNode(value);
  -
  -        Element textElement = 
node.getOwnerDocument().createElement("xsp:text");
  -
  -        textElement.appendChild(textNode);
  -        parent.replaceChild(textElement, node);
  -
  -        break;
  -      case Node.ELEMENT_NODE:
  -        ((Element) node).normalize();
  -        // Fall through
  -      default:
  -        NodeList childList = node.getChildNodes();
  -        int childCount = childList.getLength();
  -
  -        for (int i = 0; i < childCount; i++) {
  -          this.quoteStrings(childList.item(i), language);
  -        }
  -
  -        break;
  -    }
  -  }
  -
  -  /**
  -   * Returns a list of logicsheets to be applied to this document for source
  -   * code generation. This method scans the input document for
  -   * &lt;?xml-logicsheet?&gt; processing instructions and top-level
  -   * &lt;xsp:logicsheet&gt; elements. Logicsheet declarations are removed 
from
  -   * the input document.
  -   *
  -   * @param document The input document
  -   * @return An array of logicsheet <i>names</i>
  -   */
  -  protected String[] getLogicsheets(Document document) {
  -    Vector removedNodes = new Vector();
  -    Vector logicsheetList = new Vector();
  -    Element root = document.getDocumentElement();
  -
  -    // Retrieve logicsheets declared by processing-instruction
  -    NodeList nodeList = document.getChildNodes();
  -    int count = nodeList.getLength();
  -    for (int i = 0; i < count; i++) {
  -      Node node = nodeList.item(i);
  -      if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
  -     ProcessingInstruction pi = (ProcessingInstruction) node;
  -
  -     if (pi.getTarget().equals("xml-logicsheet")) {
  -          Hashtable attrs = DOMUtils.getPIPseudoAttributes(pi);
  -       logicsheetList.addElement(attrs.get("href"));
  -
  -       removedNodes.addElement(pi);
  -     }
  -      }
  -    }
  -
  -    // Retrieve logicsheets declared by top-level elements
  -    nodeList = root.getElementsByTagName("map:logicsheet");
  -    count = nodeList.getLength();
  -
  -    for (int i = 0; i < count; i++) {
  -      Element logicsheetElement = (Element) nodeList.item(i);
  -      removedNodes.addElement(logicsheetElement);
  -      logicsheetList.addElement(logicsheetElement.getAttribute("location"));
  -    }
  -
  -    String[] logicsheetLocations = new String[logicsheetList.size()];
  -    logicsheetList.copyInto(logicsheetLocations);
  -
  -
  -    // Remove logicsheet directives
  -    count = removedNodes.size();
  -    for (int i = 0; i < count; i++) {
  -      Node node = (Node) removedNodes.elementAt(i); 
  -      Node parent = node.getParentNode();
  -      parent.removeChild(node);
  -    }
  -
  -    return logicsheetLocations;
  -  }
  -
  -  /**
  -   * Add a dependency on an external file to the document for inclusion in
  -   * generated code. This is used by 
<code>AbstractServerPagesGenerator</code>
  -   * to populate a list of <code>File</code>'s tested for change on each
  -   * invocation; this information, in turn, is used by
  -   * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
  -   * necessary. XSP uses &lt;xsp:dependency&gt; elements for this purpose
  -   *
  -   * @param PARAM_NAME Param description
  -   * @return the value
  -   * @exception EXCEPTION_NAME If an error occurs
  -   * @see ServerPages <code>AbstractServerPagesGenerator</code>
  -   *      and <code>ServerPagesLoaderImpl</code>
  -   */
  -/** Sitemaps don't (yet) have dependencies */
  -  protected void addDependency(Document document, String location) {
  -    Element root = document.getDocumentElement();
  -    Element dependency = document.createElement("xsp:dependency");
  -    dependency.appendChild(document.createTextNode(location));
  -    root.appendChild(dependency);
  -  }
  -/* */
  -
  -  /**
  -   * Scan top-level document elements for non-xsp tag names returning the 
first
  -   * (and hopefully <i>only</i>) user-defined element
  -   *
  -   * @param document The input document
  -   * @return The first non-xsp element
  -   */
  -/** Sitemaps don't have a user root
  -  protected Element getUserRoot(Document document) {
  -    Element root = document.getDocumentElement();
  -    NodeList elements = root.getElementsByTagName("*");
  -    int elementCount = elements.getLength();
  -    for (int i = 0; i < elementCount; i++) {
  -      Element userRoot = (Element) elements.item(i);
  -      if (!userRoot.getTagName().startsWith("map:")) {
  -        return userRoot;
  -      }
  -    }
  -
  -    return null;
  -  }
  -*/
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.markup.sitemap;
  +
  +import java.io.File;
  +import java.util.Date;
  +import java.util.Vector;
  +import java.util.Hashtable;
  +
  +import org.w3c.dom.Node;
  +import org.w3c.dom.Text;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.ProcessingInstruction;
  +
  +import org.apache.cocoon.util.DOMUtils;
  +import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
  +
  +import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  +
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * This class implements <code>MarkupLanguage</code> for Cocoon's
  + * <a href="http://xml.apache.org/cocoon/sitemap.html";>Sitemap</a>.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/29 18:30:28 $
  + */
  +public class SitemapMarkupLanguage extends AbstractMarkupLanguage {
  +  /**
  +   * The default constructor.
  +   */
  +  public SitemapMarkupLanguage() throws SAXException, IOException {
  +    super();
  +  }
  +
  +  /**
  +   * Return the Sitemap language name: <i>map</i> :-)
  +   *
  +   * @return The <i>map</i> constant
  +   */
  +  public String getName() {
  +    return "map";
  +  }
  +
  +  /**
  +   * Return the document-declared encoding or <code>null</code> if it's the
  +   * platform's default encoding
  +   *
  +   * @param document The input document
  +   * @return The document-declared encoding
  +   */
  +  public String getEncoding(Document document) {
  +    String encoding = document.getDocumentElement().getAttribute("encoding");
  +
  +    if (encoding.length() > 0) {
  +      return encoding;
  +    }
  +
  +    return null;
  +  }
  +
  +  /**
  +   * Prepare the document for logicsheet processing and code generation. This
  +   * method sets the base filename, file path and creation date as root 
element
  +   * attibutes and encodes text nodes as strings.
  +   *
  +   * @param document The input document
  +   * @param filename The input source filename
  +   * @param language The target programming language
  +   * @return The augmented document
  +   */
  +  protected Document preprocessDocument(
  +    Document document, String filename, ProgrammingLanguage language
  +  )
  +  {
  +    // Store path and file name
  +    int pos = filename.lastIndexOf(File.separatorChar);
  +    String name = filename.substring(pos + 1);
  +    String path = filename.substring(0, pos).replace(File.separatorChar, 
'/');
  +
  +    Element root = document.getDocumentElement();
  +
  +    root.setAttribute("file-name", name);
  +    root.setAttribute("file-path", path);
  +    root.setAttribute("creation-date", String.valueOf(new Date().getTime()));
  +
  +    this.quoteStrings(document, language);
  +
  +    return document;
  +  }
  +
  +  /**
  +   * Encode text nodes as strings according to the target programming 
languages
  +   * string constant escaping rules.
  +   *
  +   * @param node The node to be escaped
  +   * @param language The target programming language
  +   */
  +  protected void quoteStrings(Node node, ProgrammingLanguage language) {
  +    switch (node.getNodeType()) {
  +      case Node.PROCESSING_INSTRUCTION_NODE:
  +        ProcessingInstruction pi = (ProcessingInstruction) node;
  +     if (!pi.getTarget().equals("xml-logicsheet")) {
  +          pi.setData(language.quoteString(pi.getData()));
  +     }
  +        break;
  +      case Node.TEXT_NODE:
  +        if (true) break; // the sitemap shouldn't have any text node
  +        Element parent = (Element) node.getParentNode();
  +
  +        String tagName = parent.getTagName();
  +
  +        if (
  +          tagName.equals("xsp:expr") ||
  +          tagName.equals("xsp:logic") ||
  +          tagName.equals("xsp:structure") ||
  +          tagName.equals("xsp:include")
  +        ) {
  +          return;
  +        }
  +
  +        String value = language.quoteString(node.getNodeValue());
  +        Text textNode = node.getOwnerDocument().createTextNode(value);
  +
  +        Element textElement = 
node.getOwnerDocument().createElement("xsp:text");
  +
  +        textElement.appendChild(textNode);
  +        parent.replaceChild(textElement, node);
  +
  +        break;
  +      case Node.ELEMENT_NODE:
  +        ((Element) node).normalize();
  +        // Fall through
  +      default:
  +        NodeList childList = node.getChildNodes();
  +        int childCount = childList.getLength();
  +
  +        for (int i = 0; i < childCount; i++) {
  +          this.quoteStrings(childList.item(i), language);
  +        }
  +
  +        break;
  +    }
  +  }
  +
  +  /**
  +   * Returns a list of logicsheets to be applied to this document for source
  +   * code generation. This method scans the input document for
  +   * &lt;?xml-logicsheet?&gt; processing instructions and top-level
  +   * &lt;xsp:logicsheet&gt; elements. Logicsheet declarations are removed 
from
  +   * the input document.
  +   *
  +   * @param document The input document
  +   * @return An array of logicsheet <i>names</i>
  +   */
  +  protected String[] getLogicsheets(Document document) {
  +    Vector removedNodes = new Vector();
  +    Vector logicsheetList = new Vector();
  +    Element root = document.getDocumentElement();
  +
  +    // Retrieve logicsheets declared by processing-instruction
  +    NodeList nodeList = document.getChildNodes();
  +    int count = nodeList.getLength();
  +    for (int i = 0; i < count; i++) {
  +      Node node = nodeList.item(i);
  +      if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
  +     ProcessingInstruction pi = (ProcessingInstruction) node;
  +
  +     if (pi.getTarget().equals("xml-logicsheet")) {
  +          Hashtable attrs = DOMUtils.getPIPseudoAttributes(pi);
  +       logicsheetList.addElement(attrs.get("href"));
  +
  +       removedNodes.addElement(pi);
  +     }
  +      }
  +    }
  +
  +    // Retrieve logicsheets declared by top-level elements
  +    nodeList = root.getElementsByTagName("map:logicsheet");
  +    count = nodeList.getLength();
  +
  +    for (int i = 0; i < count; i++) {
  +      Element logicsheetElement = (Element) nodeList.item(i);
  +      removedNodes.addElement(logicsheetElement);
  +      logicsheetList.addElement(logicsheetElement.getAttribute("location"));
  +    }
  +
  +    String[] logicsheetLocations = new String[logicsheetList.size()];
  +    logicsheetList.copyInto(logicsheetLocations);
  +
  +
  +    // Remove logicsheet directives
  +    count = removedNodes.size();
  +    for (int i = 0; i < count; i++) {
  +      Node node = (Node) removedNodes.elementAt(i); 
  +      Node parent = node.getParentNode();
  +      parent.removeChild(node);
  +    }
  +
  +    return logicsheetLocations;
  +  }
  +
  +  /**
  +   * Add a dependency on an external file to the document for inclusion in
  +   * generated code. This is used by 
<code>AbstractServerPagesGenerator</code>
  +   * to populate a list of <code>File</code>'s tested for change on each
  +   * invocation; this information, in turn, is used by
  +   * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
  +   * necessary. XSP uses &lt;xsp:dependency&gt; elements for this purpose
  +   *
  +   * @param PARAM_NAME Param description
  +   * @return the value
  +   * @exception EXCEPTION_NAME If an error occurs
  +   * @see ServerPages <code>AbstractServerPagesGenerator</code>
  +   *      and <code>ServerPagesLoaderImpl</code>
  +   */
  +/** Sitemaps don't (yet) have dependencies */
  +  protected void addDependency(Document document, String location) {
  +    Element root = document.getDocumentElement();
  +    Element dependency = document.createElement("xsp:dependency");
  +    dependency.appendChild(document.createTextNode(location));
  +    root.appendChild(dependency);
  +  }
  +/* */
  +
  +  /**
  +   * Scan top-level document elements for non-xsp tag names returning the 
first
  +   * (and hopefully <i>only</i>) user-defined element
  +   *
  +   * @param document The input document
  +   * @return The first non-xsp element
  +   */
  +/** Sitemaps don't have a user root
  +  protected Element getUserRoot(Document document) {
  +    Element root = document.getDocumentElement();
  +    NodeList elements = root.getElementsByTagName("*");
  +    int elementCount = elements.getLength();
  +    for (int i = 0; i < elementCount; i++) {
  +      Element userRoot = (Element) elements.item(i);
  +      if (!userRoot.getTagName().startsWith("map:")) {
  +        return userRoot;
  +      }
  +    }
  +
  +    return null;
  +  }
  +*/
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +25 -25    
xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/Constants.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Constants.java    2000/07/22 20:41:36     1.1.2.2
  +++ Constants.java    2000/07/29 18:30:29     1.1.2.3
  @@ -1,25 +1,25 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.markup.xsp;
  -
  -/**
  - * Constants used by XSP classes
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:36 $
  - */
  -public interface Constants {
  -  public static final String XSP_PREFIX = "xsp";
  -  public static final String XSP_URI = "http://xml.apache.org/xsp";;
  -
  -  public static final String XSP_REQUEST_PREFIX = "xsp-request";
  -  public static final String XSP_REQUEST_URI = XSP_URI + "/request";
  -
  -  public static final String XSP_RESPONSE_PREFIX = "xsp-response";
  -  public static final String XSP_RESPONSE_URI = XSP_URI + "/response";
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.markup.xsp;
  +
  +/**
  + * Constants used by XSP classes
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:29 $
  + */
  +public interface Constants {
  +  public static final String XSP_PREFIX = "xsp";
  +  public static final String XSP_URI = "http://xml.apache.org/xsp";;
  +
  +  public static final String XSP_REQUEST_PREFIX = "xsp-request";
  +  public static final String XSP_REQUEST_URI = XSP_URI + "/request";
  +
  +  public static final String XSP_RESPONSE_PREFIX = "xsp-response";
  +  public static final String XSP_RESPONSE_URI = XSP_URI + "/response";
  +}
  
  
  
  1.1.2.6   +40 -40    
xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPGenerator.java
  
  Index: XSPGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPGenerator.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- XSPGenerator.java 2000/07/22 20:41:36     1.1.2.5
  +++ XSPGenerator.java 2000/07/29 18:30:29     1.1.2.6
  @@ -1,40 +1,40 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.markup.xsp;
  -
  -import org.apache.cocoon.Cocoon;
  -import org.apache.avalon.ComponentManager;
  -import org.apache.cocoon.components.parser.Parser;
  -
  -import org.apache.cocoon.generation.AbstractServerPage;
  -
  -/**
  - * Base class for XSP-generated <code>ServerPagesGenerator</code> classes
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:36 $
  - */
  -public abstract class XSPGenerator extends AbstractServerPage {
  -  /** The XSP Object Model */
  -  protected Cocoon cocoon;
  -  protected Parser parser;
  -  // Request and Response are inherited from AbstractGenerator 
  -
  -  /**
  -   * Set the current <code>ComponentManager</code> instance used by this
  -   * <code>Generator</code> and initialize relevant instance variables.
  -   *
  -   * @param manager The global component manager
  -   */
  -  public void setComponentManager(ComponentManager manager) {
  -    super.setComponentManager(manager);
  -
  -    this.cocoon = (Cocoon) this.manager.getComponent("cocoon");
  -    this.parser = (Parser) this.manager.getComponent("parser");
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.markup.xsp;
  +
  +import org.apache.cocoon.Cocoon;
  +import org.apache.avalon.ComponentManager;
  +import org.apache.cocoon.components.parser.Parser;
  +
  +import org.apache.cocoon.generation.AbstractServerPage;
  +
  +/**
  + * Base class for XSP-generated <code>ServerPagesGenerator</code> classes
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/29 18:30:29 $
  + */
  +public abstract class XSPGenerator extends AbstractServerPage {
  +  /** The XSP Object Model */
  +  protected Cocoon cocoon;
  +  protected Parser parser;
  +  // Request and Response are inherited from AbstractGenerator 
  +
  +  /**
  +   * Set the current <code>ComponentManager</code> instance used by this
  +   * <code>Generator</code> and initialize relevant instance variables.
  +   *
  +   * @param manager The global component manager
  +   */
  +  public void setComponentManager(ComponentManager manager) {
  +    super.setComponentManager(manager);
  +
  +    this.cocoon = (Cocoon) this.manager.getComponent("cocoon");
  +    this.parser = (Parser) this.manager.getComponent("parser");
  +  }
  +}
  
  
  
  1.1.2.3   +252 -252  
xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPMarkupLanguage.java
  
  Index: XSPMarkupLanguage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPMarkupLanguage.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- XSPMarkupLanguage.java    2000/07/22 20:41:36     1.1.2.2
  +++ XSPMarkupLanguage.java    2000/07/29 18:30:29     1.1.2.3
  @@ -1,252 +1,252 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.markup.xsp;
  -
  -import java.io.File;
  -import java.util.Date;
  -import java.util.Vector;
  -import java.util.Hashtable;
  -
  -import org.w3c.dom.Node;
  -import org.w3c.dom.Text;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.ProcessingInstruction;
  -
  -import org.apache.cocoon.util.DOMUtils;
  -import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
  -
  -import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  -
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * This class implements <code>MarkupLanguage</code> for Cocoon's
  - * <a href="http://xml.apache.org/cocoon/xsp.html";>XSP</a>.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:36 $
  - */
  -public class XSPMarkupLanguage extends AbstractMarkupLanguage {
  -  /**
  -   * The default constructor.
  -   */
  -  public XSPMarkupLanguage() throws SAXException, IOException {
  -    super();
  -  }
  -
  -  /**
  -   * Return the XSP language name: <i>xsp</i> :-)
  -   *
  -   * @return The <i>xsp</i> constant
  -   */
  -  public String getName() {
  -    return "xsp";
  -  }
  -
  -  /**
  -   * Return the document-declared encoding or <code>null</code> if it's the
  -   * platform's default encoding
  -   *
  -   * @param document The input document
  -   * @return The document-declared encoding
  -   */
  -  public String getEncoding(Document document) {
  -    String encoding = document.getDocumentElement().getAttribute("encoding");
  -
  -    if (encoding.length() > 0) {
  -      return encoding;
  -    }
  -
  -    return null;
  -  }
  -
  -  /**
  -   * Prepare the document for logicsheet processing and code generation. This
  -   * method sets the base filename, file path and creation date as root 
element
  -   * attibutes and encodes text nodes as strings.
  -   *
  -   * @param document The input document
  -   * @param filename The input source filename
  -   * @param language The target programming language
  -   * @return The augmented document
  -   */
  -  protected Document preprocessDocument(
  -    Document document, String filename, ProgrammingLanguage language
  -  )
  -  {
  -    // Store path and file name
  -    int pos = filename.lastIndexOf(File.separatorChar);
  -    String name = filename.substring(pos + 1);
  -    String path = filename.substring(0, pos).replace(File.separatorChar, 
'/');
  -
  -    Element root = document.getDocumentElement();
  -
  -    root.setAttribute("file-name", name);
  -    root.setAttribute("file-path", path);
  -    root.setAttribute("creation-date", String.valueOf(new Date().getTime()));
  -
  -    this.quoteStrings(document, language);
  -
  -    return document;
  -  }
  -
  -  /**
  -   * Encode text nodes as strings according to the target programming 
languages
  -   * string constant escaping rules.
  -   *
  -   * @param node The node to be escaped
  -   * @param language The target programming language
  -   */
  -  protected void quoteStrings(Node node, ProgrammingLanguage language) {
  -    switch (node.getNodeType()) {
  -      case Node.PROCESSING_INSTRUCTION_NODE:
  -        ProcessingInstruction pi = (ProcessingInstruction) node;
  -     if (!pi.getTarget().equals("xml-logicsheet")) {
  -          pi.setData(language.quoteString(pi.getData()));
  -     }
  -        break;
  -      case Node.TEXT_NODE:
  -        Element parent = (Element) node.getParentNode();
  -
  -        String tagName = parent.getTagName();
  -
  -        if (
  -          tagName.equals("xsp:expr") ||
  -          tagName.equals("xsp:logic") ||
  -          tagName.equals("xsp:structure") ||
  -          tagName.equals("xsp:include")
  -        ) {
  -          return;
  -        }
  -
  -        String value = language.quoteString(node.getNodeValue());
  -        Text textNode = node.getOwnerDocument().createTextNode(value);
  -
  -        Element textElement = 
node.getOwnerDocument().createElement("xsp:text");
  -
  -        textElement.appendChild(textNode);
  -        parent.replaceChild(textElement, node);
  -
  -        break;
  -      case Node.ELEMENT_NODE:
  -        ((Element) node).normalize();
  -        // Fall through
  -      default:
  -        NodeList childList = node.getChildNodes();
  -        int childCount = childList.getLength();
  -
  -        for (int i = 0; i < childCount; i++) {
  -          this.quoteStrings(childList.item(i), language);
  -        }
  -
  -        break;
  -    }
  -  }
  -
  -  /**
  -   * Returns a list of logicsheets to be applied to this document for source
  -   * code generation. This method scans the input document for
  -   * &lt;?xml-logicsheet?&gt; processing instructions and top-level
  -   * &lt;xsp:logicsheet&gt; elements. Logicsheet declarations are removed 
from
  -   * the input document.
  -   *
  -   * @param document The input document
  -   * @return An array of logicsheet <i>names</i>
  -   */
  -  protected String[] getLogicsheets(Document document) {
  -    Vector removedNodes = new Vector();
  -    Vector logicsheetList = new Vector();
  -    Element root = document.getDocumentElement();
  -
  -    // Retrieve logicsheets declared by processing-instruction
  -    NodeList nodeList = document.getChildNodes();
  -    int count = nodeList.getLength();
  -    for (int i = 0; i < count; i++) {
  -      Node node = nodeList.item(i);
  -      if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
  -     ProcessingInstruction pi = (ProcessingInstruction) node;
  -
  -     if (pi.getTarget().equals("xml-logicsheet")) {
  -          Hashtable attrs = DOMUtils.getPIPseudoAttributes(pi);
  -       logicsheetList.addElement(attrs.get("href"));
  -
  -       removedNodes.addElement(pi);
  -     }
  -      }
  -    }
  -
  -    // Retrieve logicsheets declared by top-level elements
  -    nodeList = root.getElementsByTagName("xsp:logicsheet");
  -    count = nodeList.getLength();
  -
  -    for (int i = 0; i < count; i++) {
  -      Element logicsheetElement = (Element) nodeList.item(i);
  -      removedNodes.addElement(logicsheetElement);
  -      logicsheetList.addElement(logicsheetElement.getAttribute("location"));
  -    }
  -
  -    String[] logicsheetLocations = new String[logicsheetList.size()];
  -    logicsheetList.copyInto(logicsheetLocations);
  -
  -    // Remove logicsheet directives
  -    count = removedNodes.size();
  -    for (int i = 0; i < count; i++) {
  -      Node node = (Node) removedNodes.elementAt(i); 
  -      Node parent = node.getParentNode();
  -      parent.removeChild(node);
  -    }
  -
  -    return logicsheetLocations;
  -  }
  -
  -  /**
  -   * Add a dependency on an external file to the document for inclusion in
  -   * generated code. This is used by 
<code>AbstractServerPagesGenerator</code>
  -   * to populate a list of <code>File</code>'s tested for change on each
  -   * invocation; this information, in turn, is used by
  -   * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
  -   * necessary. XSP uses &lt;xsp:dependency&gt; elements for this purpose
  -   *
  -   * @param PARAM_NAME Param description
  -   * @return the value
  -   * @exception EXCEPTION_NAME If an error occurs
  -   * @see ServerPages <code>AbstractServerPagesGenerator</code>
  -   *      and <code>ServerPagesLoaderImpl</code>
  -   */
  -  protected void addDependency(Document document, String location) {
  -    Element root = document.getDocumentElement();
  -    Element dependency = document.createElement("xsp:dependency");
  -    dependency.appendChild(document.createTextNode(location));
  -    root.appendChild(dependency);
  -  }
  -
  -  /**
  -   * Scan top-level document elements for non-xsp tag names returning the 
first
  -   * (and hopefully <i>only</i>) user-defined element
  -   *
  -   * @param document The input document
  -   * @return The first non-xsp element
  -   */
  -  protected Element getUserRoot(Document document) {
  -    Element root = document.getDocumentElement();
  -    NodeList elements = root.getElementsByTagName("*");
  -    int elementCount = elements.getLength();
  -    for (int i = 0; i < elementCount; i++) {
  -      Element userRoot = (Element) elements.item(i);
  -      if (!userRoot.getTagName().startsWith("xsp:")) {
  -        return userRoot;
  -      }
  -    }
  -
  -    return null;
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.markup.xsp;
  +
  +import java.io.File;
  +import java.util.Date;
  +import java.util.Vector;
  +import java.util.Hashtable;
  +
  +import org.w3c.dom.Node;
  +import org.w3c.dom.Text;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.ProcessingInstruction;
  +
  +import org.apache.cocoon.util.DOMUtils;
  +import org.apache.cocoon.components.language.markup.AbstractMarkupLanguage;
  +
  +import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  +
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * This class implements <code>MarkupLanguage</code> for Cocoon's
  + * <a href="http://xml.apache.org/cocoon/xsp.html";>XSP</a>.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:29 $
  + */
  +public class XSPMarkupLanguage extends AbstractMarkupLanguage {
  +  /**
  +   * The default constructor.
  +   */
  +  public XSPMarkupLanguage() throws SAXException, IOException {
  +    super();
  +  }
  +
  +  /**
  +   * Return the XSP language name: <i>xsp</i> :-)
  +   *
  +   * @return The <i>xsp</i> constant
  +   */
  +  public String getName() {
  +    return "xsp";
  +  }
  +
  +  /**
  +   * Return the document-declared encoding or <code>null</code> if it's the
  +   * platform's default encoding
  +   *
  +   * @param document The input document
  +   * @return The document-declared encoding
  +   */
  +  public String getEncoding(Document document) {
  +    String encoding = document.getDocumentElement().getAttribute("encoding");
  +
  +    if (encoding.length() > 0) {
  +      return encoding;
  +    }
  +
  +    return null;
  +  }
  +
  +  /**
  +   * Prepare the document for logicsheet processing and code generation. This
  +   * method sets the base filename, file path and creation date as root 
element
  +   * attibutes and encodes text nodes as strings.
  +   *
  +   * @param document The input document
  +   * @param filename The input source filename
  +   * @param language The target programming language
  +   * @return The augmented document
  +   */
  +  protected Document preprocessDocument(
  +    Document document, String filename, ProgrammingLanguage language
  +  )
  +  {
  +    // Store path and file name
  +    int pos = filename.lastIndexOf(File.separatorChar);
  +    String name = filename.substring(pos + 1);
  +    String path = filename.substring(0, pos).replace(File.separatorChar, 
'/');
  +
  +    Element root = document.getDocumentElement();
  +
  +    root.setAttribute("file-name", name);
  +    root.setAttribute("file-path", path);
  +    root.setAttribute("creation-date", String.valueOf(new Date().getTime()));
  +
  +    this.quoteStrings(document, language);
  +
  +    return document;
  +  }
  +
  +  /**
  +   * Encode text nodes as strings according to the target programming 
languages
  +   * string constant escaping rules.
  +   *
  +   * @param node The node to be escaped
  +   * @param language The target programming language
  +   */
  +  protected void quoteStrings(Node node, ProgrammingLanguage language) {
  +    switch (node.getNodeType()) {
  +      case Node.PROCESSING_INSTRUCTION_NODE:
  +        ProcessingInstruction pi = (ProcessingInstruction) node;
  +     if (!pi.getTarget().equals("xml-logicsheet")) {
  +          pi.setData(language.quoteString(pi.getData()));
  +     }
  +        break;
  +      case Node.TEXT_NODE:
  +        Element parent = (Element) node.getParentNode();
  +
  +        String tagName = parent.getTagName();
  +
  +        if (
  +          tagName.equals("xsp:expr") ||
  +          tagName.equals("xsp:logic") ||
  +          tagName.equals("xsp:structure") ||
  +          tagName.equals("xsp:include")
  +        ) {
  +          return;
  +        }
  +
  +        String value = language.quoteString(node.getNodeValue());
  +        Text textNode = node.getOwnerDocument().createTextNode(value);
  +
  +        Element textElement = 
node.getOwnerDocument().createElement("xsp:text");
  +
  +        textElement.appendChild(textNode);
  +        parent.replaceChild(textElement, node);
  +
  +        break;
  +      case Node.ELEMENT_NODE:
  +        ((Element) node).normalize();
  +        // Fall through
  +      default:
  +        NodeList childList = node.getChildNodes();
  +        int childCount = childList.getLength();
  +
  +        for (int i = 0; i < childCount; i++) {
  +          this.quoteStrings(childList.item(i), language);
  +        }
  +
  +        break;
  +    }
  +  }
  +
  +  /**
  +   * Returns a list of logicsheets to be applied to this document for source
  +   * code generation. This method scans the input document for
  +   * &lt;?xml-logicsheet?&gt; processing instructions and top-level
  +   * &lt;xsp:logicsheet&gt; elements. Logicsheet declarations are removed 
from
  +   * the input document.
  +   *
  +   * @param document The input document
  +   * @return An array of logicsheet <i>names</i>
  +   */
  +  protected String[] getLogicsheets(Document document) {
  +    Vector removedNodes = new Vector();
  +    Vector logicsheetList = new Vector();
  +    Element root = document.getDocumentElement();
  +
  +    // Retrieve logicsheets declared by processing-instruction
  +    NodeList nodeList = document.getChildNodes();
  +    int count = nodeList.getLength();
  +    for (int i = 0; i < count; i++) {
  +      Node node = nodeList.item(i);
  +      if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
  +     ProcessingInstruction pi = (ProcessingInstruction) node;
  +
  +     if (pi.getTarget().equals("xml-logicsheet")) {
  +          Hashtable attrs = DOMUtils.getPIPseudoAttributes(pi);
  +       logicsheetList.addElement(attrs.get("href"));
  +
  +       removedNodes.addElement(pi);
  +     }
  +      }
  +    }
  +
  +    // Retrieve logicsheets declared by top-level elements
  +    nodeList = root.getElementsByTagName("xsp:logicsheet");
  +    count = nodeList.getLength();
  +
  +    for (int i = 0; i < count; i++) {
  +      Element logicsheetElement = (Element) nodeList.item(i);
  +      removedNodes.addElement(logicsheetElement);
  +      logicsheetList.addElement(logicsheetElement.getAttribute("location"));
  +    }
  +
  +    String[] logicsheetLocations = new String[logicsheetList.size()];
  +    logicsheetList.copyInto(logicsheetLocations);
  +
  +    // Remove logicsheet directives
  +    count = removedNodes.size();
  +    for (int i = 0; i < count; i++) {
  +      Node node = (Node) removedNodes.elementAt(i); 
  +      Node parent = node.getParentNode();
  +      parent.removeChild(node);
  +    }
  +
  +    return logicsheetLocations;
  +  }
  +
  +  /**
  +   * Add a dependency on an external file to the document for inclusion in
  +   * generated code. This is used by 
<code>AbstractServerPagesGenerator</code>
  +   * to populate a list of <code>File</code>'s tested for change on each
  +   * invocation; this information, in turn, is used by
  +   * <code>ServerPagesLoaderImpl</code> to assert whether regeneration is
  +   * necessary. XSP uses &lt;xsp:dependency&gt; elements for this purpose
  +   *
  +   * @param PARAM_NAME Param description
  +   * @return the value
  +   * @exception EXCEPTION_NAME If an error occurs
  +   * @see ServerPages <code>AbstractServerPagesGenerator</code>
  +   *      and <code>ServerPagesLoaderImpl</code>
  +   */
  +  protected void addDependency(Document document, String location) {
  +    Element root = document.getDocumentElement();
  +    Element dependency = document.createElement("xsp:dependency");
  +    dependency.appendChild(document.createTextNode(location));
  +    root.appendChild(dependency);
  +  }
  +
  +  /**
  +   * Scan top-level document elements for non-xsp tag names returning the 
first
  +   * (and hopefully <i>only</i>) user-defined element
  +   *
  +   * @param document The input document
  +   * @return The first non-xsp element
  +   */
  +  protected Element getUserRoot(Document document) {
  +    Element root = document.getDocumentElement();
  +    NodeList elements = root.getElementsByTagName("*");
  +    int elementCount = elements.getLength();
  +    for (int i = 0; i < elementCount; i++) {
  +      Element userRoot = (Element) elements.item(i);
  +      if (!userRoot.getTagName().startsWith("xsp:")) {
  +        return userRoot;
  +      }
  +    }
  +
  +    return null;
  +  }
  +}
  
  
  
  1.1.2.3   +154 -154  
xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPObjectHelper.java
  
  Index: XSPObjectHelper.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPObjectHelper.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- XSPObjectHelper.java      2000/07/22 20:41:36     1.1.2.2
  +++ XSPObjectHelper.java      2000/07/29 18:30:29     1.1.2.3
  @@ -1,154 +1,154 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.markup.xsp;
  -
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.helpers.AttributesImpl;
  -
  -import org.xml.sax.SAXException;
  -
  -/**
  - * Base class for XSP's object model manipulation logicsheets
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:36 $
  - */
  -public class XSPObjectHelper implements Constants {
  -  /**
  -   * Empty attributes used for contentHandler.startElement()
  -   */
  -  protected static final AttributesImpl emptyAttr = new AttributesImpl();
  -
  -  /**
  -   * Uri and prefix associated with object helper. Derived classes must 
assign
  -   * these variables to their proper values
  -   */
  -  protected static String URI;
  -  protected static String PREFIX;
  -
  -  /**
  -   * Output an element containing text only and no attributes
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param name The element name
  -   * @param data The data contained by the element
  -   */
  -  protected static void elementData(
  -    ContentHandler contentHandler,
  -    String name,
  -    String data
  -  )
  -    throws SAXException
  -  {
  -    start(contentHandler, name);
  -    data(contentHandler, data);
  -    end(contentHandler, name);
  -  }
  -
  -  /**
  -   * Output an element containing text only and attributes
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param name The element name
  -   * @param data The data contained by the element
  -   * @param attr The element attributes
  -   */
  -  protected static void elementData(
  -    ContentHandler contentHandler,
  -    String name,
  -    String data,
  -    AttributesImpl attr
  -  )
  -    throws SAXException
  -  {
  -    start(contentHandler, name, attr);
  -    data(contentHandler, data);
  -    end(contentHandler, name);
  -  }
  -
  -  /**
  -   * Start an element with the proper object's uri and prefix and no
  -   * attributes
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param name The element name
  -   */
  -  protected static void start(
  -    ContentHandler contentHandler,
  -    String name
  -  )
  -    throws SAXException
  -  {
  -    contentHandler.startElement(URI, name, PREFIX + ":" + name, emptyAttr);
  -  }
  -
  -  /**
  -   * Start an element with the proper object's uri and prefix and with
  -   * attributes
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param name The element name
  -   * @param attr The element attributes
  -   */
  -  protected static void start(
  -    ContentHandler contentHandler,
  -    String name,
  -    AttributesImpl attr
  -  )
  -    throws SAXException
  -  {
  -    contentHandler.startElement(URI, name, PREFIX + ":" + name, attr);
  -  }
  -
  -  /**
  -   * End an element with the proper object's uri and prefix
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param name The element name
  -   */
  -  protected static void end(
  -    ContentHandler contentHandler,
  -    String name
  -  )
  -    throws SAXException
  -  {
  -    contentHandler.endElement(URI, name, PREFIX + ":" + name);
  -  }
  -
  -  /**
  -   * Add an attribute
  -   *
  -   * @param attr The attribute list
  -   * @param name The attribute name
  -   * @param value The attribute value
  -   */
  -  protected static void addAttribute(
  -    AttributesImpl attr,
  -    String name,
  -    String value
  -  )
  -    throws SAXException
  -  {
  -    attr.addAttribute("", name, "", "CDATA", value);
  -  }
  -
  -  /**
  -   * Add string data
  -   *
  -   * @param contentHandler The SAX content handler
  -   * @param data The string data
  -   */
  -  protected static void data(
  -    ContentHandler contentHandler,
  -    String data
  -  )
  -    throws SAXException
  -  {
  -    contentHandler.characters(data.toCharArray(), 0, data.length());
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.markup.xsp;
  +
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.helpers.AttributesImpl;
  +
  +import org.xml.sax.SAXException;
  +
  +/**
  + * Base class for XSP's object model manipulation logicsheets
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:29 $
  + */
  +public class XSPObjectHelper implements Constants {
  +  /**
  +   * Empty attributes used for contentHandler.startElement()
  +   */
  +  protected static final AttributesImpl emptyAttr = new AttributesImpl();
  +
  +  /**
  +   * Uri and prefix associated with object helper. Derived classes must 
assign
  +   * these variables to their proper values
  +   */
  +  protected static String URI;
  +  protected static String PREFIX;
  +
  +  /**
  +   * Output an element containing text only and no attributes
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param name The element name
  +   * @param data The data contained by the element
  +   */
  +  protected static void elementData(
  +    ContentHandler contentHandler,
  +    String name,
  +    String data
  +  )
  +    throws SAXException
  +  {
  +    start(contentHandler, name);
  +    data(contentHandler, data);
  +    end(contentHandler, name);
  +  }
  +
  +  /**
  +   * Output an element containing text only and attributes
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param name The element name
  +   * @param data The data contained by the element
  +   * @param attr The element attributes
  +   */
  +  protected static void elementData(
  +    ContentHandler contentHandler,
  +    String name,
  +    String data,
  +    AttributesImpl attr
  +  )
  +    throws SAXException
  +  {
  +    start(contentHandler, name, attr);
  +    data(contentHandler, data);
  +    end(contentHandler, name);
  +  }
  +
  +  /**
  +   * Start an element with the proper object's uri and prefix and no
  +   * attributes
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param name The element name
  +   */
  +  protected static void start(
  +    ContentHandler contentHandler,
  +    String name
  +  )
  +    throws SAXException
  +  {
  +    contentHandler.startElement(URI, name, PREFIX + ":" + name, emptyAttr);
  +  }
  +
  +  /**
  +   * Start an element with the proper object's uri and prefix and with
  +   * attributes
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param name The element name
  +   * @param attr The element attributes
  +   */
  +  protected static void start(
  +    ContentHandler contentHandler,
  +    String name,
  +    AttributesImpl attr
  +  )
  +    throws SAXException
  +  {
  +    contentHandler.startElement(URI, name, PREFIX + ":" + name, attr);
  +  }
  +
  +  /**
  +   * End an element with the proper object's uri and prefix
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param name The element name
  +   */
  +  protected static void end(
  +    ContentHandler contentHandler,
  +    String name
  +  )
  +    throws SAXException
  +  {
  +    contentHandler.endElement(URI, name, PREFIX + ":" + name);
  +  }
  +
  +  /**
  +   * Add an attribute
  +   *
  +   * @param attr The attribute list
  +   * @param name The attribute name
  +   * @param value The attribute value
  +   */
  +  protected static void addAttribute(
  +    AttributesImpl attr,
  +    String name,
  +    String value
  +  )
  +    throws SAXException
  +  {
  +    attr.addAttribute("", name, "", "CDATA", value);
  +  }
  +
  +  /**
  +   * Add string data
  +   *
  +   * @param contentHandler The SAX content handler
  +   * @param data The string data
  +   */
  +  protected static void data(
  +    ContentHandler contentHandler,
  +    String data
  +  )
  +    throws SAXException
  +  {
  +    contentHandler.characters(data.toCharArray(), 0, data.length());
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +95 -95    
xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/AbstractProgrammingLanguage.java
  
  Index: AbstractProgrammingLanguage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/AbstractProgrammingLanguage.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- AbstractProgrammingLanguage.java  2000/07/22 20:41:39     1.1.2.3
  +++ AbstractProgrammingLanguage.java  2000/07/29 18:30:30     1.1.2.4
  @@ -1,95 +1,95 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.programming;
  -
  -import java.io.File;
  -
  -import org.apache.avalon.Configurable;
  -import org.apache.avalon.Configuration;
  -import org.apache.avalon.ConfigurationException;
  -
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.avalon.AbstractNamedComponent;
  -
  -import org.apache.cocoon.components.language.LanguageException;
  -
  -/**
  - * Base implementation of <code>ProgrammingLanguage</code>. This class sets 
the
  - * <code>CodeFormatter</code> instance and deletes source program files after
  - * unloading.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:39 $
  - */
  -public abstract class AbstractProgrammingLanguage
  -  extends AbstractNamedComponent
  -  implements ProgrammingLanguage
  -{
  -  /** The source code formatter */
  -  protected Class codeFormatter;
  -
  -  /**
  -   * Set the configuration parameters. This method instantiates the
  -   * sitemap-specified source code formatter
  -   *
  -   * @param params The configuration parameters
  -   * @exception Exception If the language compiler cannot be loaded
  -   */
  -  protected void setParameters(Parameters params) throws Exception
  -  {
  -    try {
  -      String className = params.getParameter("code-formatter", null);
  -      if (className != null) {
  -        this.codeFormatter =
  -       this.getClass().getClassLoader().loadClass(className);
  -      }
  -    } catch (Exception e) { }
  -  }
  -
  -  /**
  -   * Return this language's source code formatter. A new formatter instance 
is
  -   * created on each invocation.
  -   *
  -   * @return The language source code formatter
  -   */
  -  public CodeFormatter getCodeFormatter() {
  -    if (this.codeFormatter != null) {
  -      try {
  -        return (CodeFormatter) this.codeFormatter.newInstance();
  -      } catch (Exception e) { }
  -    }
  -
  -    return null;
  -  }
  -
  -  /**
  -   * Unload a previously loaded program
  -   *
  -   * @param program A previously loaded object program
  -   * @exception LanguageException If an error occurs during unloading
  -   */
  -  protected abstract void doUnload(
  -    Object program, String filename, String baseDirectory
  -  )
  -    throws LanguageException;
  -
  -  public final void unload(
  -    Object program, String filename, String baseDirectory
  -  )
  -    throws LanguageException
  -  {
  -    File file = new File (
  -      baseDirectory + File.separator +
  -      filename + "." + this.getSourceExtension()
  -    );
  -
  -    file.delete();
  -
  -    this.doUnload(program, filename, baseDirectory);
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.programming;
  +
  +import java.io.File;
  +
  +import org.apache.avalon.Configurable;
  +import org.apache.avalon.Configuration;
  +import org.apache.avalon.ConfigurationException;
  +
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.avalon.AbstractNamedComponent;
  +
  +import org.apache.cocoon.components.language.LanguageException;
  +
  +/**
  + * Base implementation of <code>ProgrammingLanguage</code>. This class sets 
the
  + * <code>CodeFormatter</code> instance and deletes source program files after
  + * unloading.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:30 $
  + */
  +public abstract class AbstractProgrammingLanguage
  +  extends AbstractNamedComponent
  +  implements ProgrammingLanguage
  +{
  +  /** The source code formatter */
  +  protected Class codeFormatter;
  +
  +  /**
  +   * Set the configuration parameters. This method instantiates the
  +   * sitemap-specified source code formatter
  +   *
  +   * @param params The configuration parameters
  +   * @exception Exception If the language compiler cannot be loaded
  +   */
  +  protected void setParameters(Parameters params) throws Exception
  +  {
  +    try {
  +      String className = params.getParameter("code-formatter", null);
  +      if (className != null) {
  +        this.codeFormatter =
  +       this.getClass().getClassLoader().loadClass(className);
  +      }
  +    } catch (Exception e) { }
  +  }
  +
  +  /**
  +   * Return this language's source code formatter. A new formatter instance 
is
  +   * created on each invocation.
  +   *
  +   * @return The language source code formatter
  +   */
  +  public CodeFormatter getCodeFormatter() {
  +    if (this.codeFormatter != null) {
  +      try {
  +        return (CodeFormatter) this.codeFormatter.newInstance();
  +      } catch (Exception e) { }
  +    }
  +
  +    return null;
  +  }
  +
  +  /**
  +   * Unload a previously loaded program
  +   *
  +   * @param program A previously loaded object program
  +   * @exception LanguageException If an error occurs during unloading
  +   */
  +  protected abstract void doUnload(
  +    Object program, String filename, String baseDirectory
  +  )
  +    throws LanguageException;
  +
  +  public final void unload(
  +    Object program, String filename, String baseDirectory
  +  )
  +    throws LanguageException
  +  {
  +    File file = new File (
  +      baseDirectory + File.separator +
  +      filename + "." + this.getSourceExtension()
  +    );
  +
  +    file.delete();
  +
  +    this.doUnload(program, filename, baseDirectory);
  +  }
  +}
  
  
  
  1.1.2.3   +26 -26    
xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CodeFormatter.java
  
  Index: CodeFormatter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CodeFormatter.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- CodeFormatter.java        2000/07/22 20:41:39     1.1.2.2
  +++ CodeFormatter.java        2000/07/29 18:30:30     1.1.2.3
  @@ -1,26 +1,26 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.programming;
  -
  -/**
  - * This interface defines source beautifying formatting
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:39 $
  - */
  -public interface CodeFormatter {
  -  /**
  -   * Format and beautify a <code>String</code> containing source code 
  -   *
  -   * @param code The input source code
  -   * @param encoding The encoding used for constant strings embedded in the
  -   * source code
  -   * @return The formatted source code
  -   */
  -  public String format(String code, String encoding);
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.programming;
  +
  +/**
  + * This interface defines source beautifying formatting
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:30 $
  + */
  +public interface CodeFormatter {
  +  /**
  +   * Format and beautify a <code>String</code> containing source code 
  +   *
  +   * @param code The input source code
  +   * @param encoding The encoding used for constant strings embedded in the
  +   * source code
  +   * @return The formatted source code
  +   */
  +  public String format(String code, String encoding);
  +}
  
  
  
  1.1.2.5   +182 -182  
xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CompiledProgrammingLanguage.java
  
  Index: CompiledProgrammingLanguage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CompiledProgrammingLanguage.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- CompiledProgrammingLanguage.java  2000/07/22 20:41:39     1.1.2.4
  +++ CompiledProgrammingLanguage.java  2000/07/29 18:30:30     1.1.2.5
  @@ -1,182 +1,182 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.programming;
  -
  -import java.io.File;
  -
  -import org.apache.avalon.utils.Parameters;
  -
  -import org.apache.avalon.Composer;
  -import org.apache.avalon.Component;
  -import org.apache.avalon.ComponentManager;
  -
  -import org.apache.cocoon.components.language.LanguageException;
  -
  -/**
  - * A compiled programming language. This class extends
  - * <code>AbstractProgrammingLanguage</code> adding support for compilation
  - * and object program files
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:39 $
  - */
  -public abstract class CompiledProgrammingLanguage
  -  extends AbstractProgrammingLanguage
  -  implements Composer
  -{
  -  /** The compiler */
  -  protected Class compilerClass;
  -
  -  /** The component manager */
  -  protected ComponentManager manager;
  -
  -  /** The source deletion option */
  -  protected boolean deleteSources = false;
  -
  -  /**
  -   * Set the configuration parameters. This method instantiates the
  -   * sitemap-specified language compiler
  -   *
  -   * @param params The configuration parameters
  -   * @exception Exception If the language compiler cannot be loaded
  -   */
  -  protected void setParameters(Parameters params) throws Exception {
  -    super.setParameters(params);
  -
  -    String compilerClass = params.getParameter("compiler", null);
  -    if (compilerClass == null) {
  -      throw new LanguageException(
  -        "Missing 'compiler' parameter for compiled language '" +
  -     this.getName() + "'"
  -      );
  -    }
  -    this.compilerClass =
  -      this.getClass().getClassLoader().loadClass(compilerClass);
  -
  -    this.deleteSources = params.getParameterAsBoolean("delete-sources", 
false);
  -  }
  -
  -  /**
  -   * Set the global component manager
  -   *
  -   * @param manager The global component manager
  -   */
  -  public void setComponentManager(ComponentManager manager) {
  -    this.manager = manager;
  -  }
  -
  -  /**
  -   * Return the language's canonical object file extension.
  -   *
  -   * @return The object file extension
  -   */
  -  public abstract String getObjectExtension();
  -
  -  /**
  -   * Unload a previously loaded program
  -   *
  -   * @param program A previously loaded object program
  -   * @exception LanguageException If an error occurs during unloading
  -   */
  -  public abstract void doUnload(Object program) throws LanguageException;
  -
  -  /**
  -   * Unload a previously loaded program given its original filesystem 
location
  -   *
  -   * @param program The previously loaded object program
  -   * @param filename The base filename of the object program
  -   * @param baseDirectory The directory contaning the object program file
  -   * @return the value
  -   * @exception EXCEPTION_NAME If an error occurs
  -   */
  -  protected final void doUnload(
  -    Object program, String filename, String baseDirectory
  -  )
  -    throws LanguageException
  -  {
  -    File file = new File (
  -      baseDirectory + File.separator +
  -      filename + "." + this.getObjectExtension()
  -    );
  -
  -    file.delete();
  -
  -    this.doUnload(program);
  -  }
  -
  -  /**
  -   * Actually load an object program from a 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 abstract Object loadProgram(String filename, String 
baseDirectory)
  -    throws LanguageException;
  -
  -  /**
  -   * Compile a source file yielding a loadable object 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 abstract void compile(
  -    String filename, String baseDirectory, String encoding
  -  ) throws LanguageException;
  -
  -  /**
  -   * Load an object program from a file. This method compiled the
  -   * corresponding source file if necessary
  -   *
  -   * @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
  -   * @return The loaded object program
  -   * @exception LanguageException If an error occurs during compilation
  -   */
  -  public Object load(String filename, String baseDirectory, String encoding)
  -    throws LanguageException
  -  {
  -
  -    // Does object file exist? Load and return instance
  -    File objectFile = new File(
  -      baseDirectory + File.separator +
  -      filename + "." + this.getObjectExtension()
  -    );
  -
  -    if (objectFile.exists() && objectFile.isFile() && objectFile.canRead()) {
  -      return this.loadProgram(filename, baseDirectory);
  -    }
  -
  -    // Does source file exist?
  -    File sourceFile = new File(
  -      baseDirectory + File.separator +
  -      filename + "." + this.getSourceExtension()
  -    );
  -
  -    if (sourceFile.exists() && sourceFile.isFile() && sourceFile.canRead()) {
  -      this.compile(filename, baseDirectory, encoding);
  -
  -      if (this.deleteSources) {
  -        sourceFile.delete();
  -      }
  -
  -      return this.loadProgram(filename, baseDirectory);
  -    }
  -
  -    throw new LanguageException(
  -      "Can't load program: " +
  -      baseDirectory + File.separator + filename
  -    );
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.programming;
  +
  +import java.io.File;
  +
  +import org.apache.avalon.utils.Parameters;
  +
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.Component;
  +import org.apache.avalon.ComponentManager;
  +
  +import org.apache.cocoon.components.language.LanguageException;
  +
  +/**
  + * A compiled programming language. This class extends
  + * <code>AbstractProgrammingLanguage</code> adding support for compilation
  + * and object program files
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/29 18:30:30 $
  + */
  +public abstract class CompiledProgrammingLanguage
  +  extends AbstractProgrammingLanguage
  +  implements Composer
  +{
  +  /** The compiler */
  +  protected Class compilerClass;
  +
  +  /** The component manager */
  +  protected ComponentManager manager;
  +
  +  /** The source deletion option */
  +  protected boolean deleteSources = false;
  +
  +  /**
  +   * Set the configuration parameters. This method instantiates the
  +   * sitemap-specified language compiler
  +   *
  +   * @param params The configuration parameters
  +   * @exception Exception If the language compiler cannot be loaded
  +   */
  +  protected void setParameters(Parameters params) throws Exception {
  +    super.setParameters(params);
  +
  +    String compilerClass = params.getParameter("compiler", null);
  +    if (compilerClass == null) {
  +      throw new LanguageException(
  +        "Missing 'compiler' parameter for compiled language '" +
  +     this.getName() + "'"
  +      );
  +    }
  +    this.compilerClass =
  +      this.getClass().getClassLoader().loadClass(compilerClass);
  +
  +    this.deleteSources = params.getParameterAsBoolean("delete-sources", 
false);
  +  }
  +
  +  /**
  +   * Set the global component manager
  +   *
  +   * @param manager The global component manager
  +   */
  +  public void setComponentManager(ComponentManager manager) {
  +    this.manager = manager;
  +  }
  +
  +  /**
  +   * Return the language's canonical object file extension.
  +   *
  +   * @return The object file extension
  +   */
  +  public abstract String getObjectExtension();
  +
  +  /**
  +   * Unload a previously loaded program
  +   *
  +   * @param program A previously loaded object program
  +   * @exception LanguageException If an error occurs during unloading
  +   */
  +  public abstract void doUnload(Object program) throws LanguageException;
  +
  +  /**
  +   * Unload a previously loaded program given its original filesystem 
location
  +   *
  +   * @param program The previously loaded object program
  +   * @param filename The base filename of the object program
  +   * @param baseDirectory The directory contaning the object program file
  +   * @return the value
  +   * @exception EXCEPTION_NAME If an error occurs
  +   */
  +  protected final void doUnload(
  +    Object program, String filename, String baseDirectory
  +  )
  +    throws LanguageException
  +  {
  +    File file = new File (
  +      baseDirectory + File.separator +
  +      filename + "." + this.getObjectExtension()
  +    );
  +
  +    file.delete();
  +
  +    this.doUnload(program);
  +  }
  +
  +  /**
  +   * Actually load an object program from a 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 abstract Object loadProgram(String filename, String 
baseDirectory)
  +    throws LanguageException;
  +
  +  /**
  +   * Compile a source file yielding a loadable object 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 abstract void compile(
  +    String filename, String baseDirectory, String encoding
  +  ) throws LanguageException;
  +
  +  /**
  +   * Load an object program from a file. This method compiled the
  +   * corresponding source file if necessary
  +   *
  +   * @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
  +   * @return The loaded object program
  +   * @exception LanguageException If an error occurs during compilation
  +   */
  +  public Object load(String filename, String baseDirectory, String encoding)
  +    throws LanguageException
  +  {
  +
  +    // Does object file exist? Load and return instance
  +    File objectFile = new File(
  +      baseDirectory + File.separator +
  +      filename + "." + this.getObjectExtension()
  +    );
  +
  +    if (objectFile.exists() && objectFile.isFile() && objectFile.canRead()) {
  +      return this.loadProgram(filename, baseDirectory);
  +    }
  +
  +    // Does source file exist?
  +    File sourceFile = new File(
  +      baseDirectory + File.separator +
  +      filename + "." + this.getSourceExtension()
  +    );
  +
  +    if (sourceFile.exists() && sourceFile.isFile() && sourceFile.canRead()) {
  +      this.compile(filename, baseDirectory, encoding);
  +
  +      if (this.deleteSources) {
  +        sourceFile.delete();
  +      }
  +
  +      return this.loadProgram(filename, baseDirectory);
  +    }
  +
  +    throw new LanguageException(
  +      "Can't load program: " +
  +      baseDirectory + File.separator + filename
  +    );
  +  }
  +}
  
  
  
  1.1.2.3   +145 -145  
xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CompilerError.java
  
  Index: CompilerError.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/CompilerError.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- CompilerError.java        2000/07/22 20:41:39     1.1.2.2
  +++ CompilerError.java        2000/07/29 18:30:30     1.1.2.3
  @@ -1,145 +1,145 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  - 
  -package org.apache.cocoon.components.language.programming;
  -
  -/**
  - * This class encapsulates an error message produced by a programming 
language
  - * processor (whether interpreted or compiled)
  - * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - * @version $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:39 $
  - * @since 2.0
  - */
  -
  -public class CompilerError {
  -  /**
  -   * Is this a severe error or a warning?
  -   */
  -  private boolean error;
  -  /**
  -   * The start line number of the offending program text
  -   */
  -  private int startline;
  -  /**
  -   * The start column number of the offending program text
  -   */
  -  private int startcolumn;
  -  /**
  -   * The end line number of the offending program text
  -   */
  -  private int endline;
  -  /**
  -   * The end column number of the offending program text
  -   */
  -  private int endcolumn;
  -  /**
  -   * The name of the file containing the offending program text
  -   */
  -  private String file;
  -  /**
  -   * The actual error text produced by the language processor
  -   */
  -  private String message;
  -    
  -  /**
  -   * The error message constructor.
  -   *
  -   * @param file The name of the file containing the offending program text
  -   * @param error The actual error text produced by the language processor
  -   * @param startline The start line number of the offending program text
  -   * @param startcolumn The start column number of the offending program text
  -   * @param endline The end line number of the offending program text
  -   * @param endcolumn The end column number of the offending program text
  -   * @param message The actual error text produced by the language processor
  -   */
  -  public CompilerError(
  -    String file,
  -    boolean error,
  -    int startline,
  -    int startcolumn,
  -    int endline,
  -    int endcolumn,
  -    String message
  -  ) 
  -  {
  -    this.file = file;
  -    this.error = error;
  -    this.startline = startline;
  -    this.startcolumn = startcolumn;
  -    this.endline = endline;
  -    this.endcolumn = endcolumn;
  -    this.message = message;
  -  }
  -
  -  /**
  -   * Return the filename associated with this compiler error.
  -   *
  -   * @return The filename associated with this compiler error
  -   */
  -  public String getFile() {
  -    return file;
  -  }
  -
  -  /**
  -   * Assert whether this is a severe error or a warning
  -   *
  -   * @return Whether the error is severe
  -   */
  -  public boolean isError() {
  -    return error;
  -  }
  -
  -  /**
  -   * Return the starting line number of the program text originating this 
error
  -   *
  -   * @return The starting line number of the program text originating this 
error
  -   */
  -  public int getStartLine() {
  -    return startline;
  -  }
  -
  -  /**
  -   * Return the starting column number of the program text originating this
  -   * error
  -   *
  -   * @return The starting column number of the program text originating this
  -   * error
  -   */
  -  public int getStartColumn() {
  -    return startcolumn;
  -  }
  -
  -  /**
  -   * Return the ending line number of the program text originating this error
  -   *
  -   * @return The ending line number of the program text originating this 
error
  -   */
  -  public int getEndLine() {
  -    return endline;
  -  }
  -
  -  /**
  -   * Return the ending column number of the program text originating this
  -   * error
  -   *
  -   * @return The ending column number of the program text originating this
  -   * error
  -   */
  -  public int getEndColumn() {
  -    return endcolumn;
  -  }
  -
  -  /**
  -   * Return the message produced by the language processor
  -   *
  -   * @return The message produced by the language processor
  -   */
  -  public String getMessage() {
  -    return message;
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  + 
  +package org.apache.cocoon.components.language.programming;
  +
  +/**
  + * This class encapsulates an error message produced by a programming 
language
  + * processor (whether interpreted or compiled)
  + * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  + * @version $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:30 $
  + * @since 2.0
  + */
  +
  +public class CompilerError {
  +  /**
  +   * Is this a severe error or a warning?
  +   */
  +  private boolean error;
  +  /**
  +   * The start line number of the offending program text
  +   */
  +  private int startline;
  +  /**
  +   * The start column number of the offending program text
  +   */
  +  private int startcolumn;
  +  /**
  +   * The end line number of the offending program text
  +   */
  +  private int endline;
  +  /**
  +   * The end column number of the offending program text
  +   */
  +  private int endcolumn;
  +  /**
  +   * The name of the file containing the offending program text
  +   */
  +  private String file;
  +  /**
  +   * The actual error text produced by the language processor
  +   */
  +  private String message;
  +    
  +  /**
  +   * The error message constructor.
  +   *
  +   * @param file The name of the file containing the offending program text
  +   * @param error The actual error text produced by the language processor
  +   * @param startline The start line number of the offending program text
  +   * @param startcolumn The start column number of the offending program text
  +   * @param endline The end line number of the offending program text
  +   * @param endcolumn The end column number of the offending program text
  +   * @param message The actual error text produced by the language processor
  +   */
  +  public CompilerError(
  +    String file,
  +    boolean error,
  +    int startline,
  +    int startcolumn,
  +    int endline,
  +    int endcolumn,
  +    String message
  +  ) 
  +  {
  +    this.file = file;
  +    this.error = error;
  +    this.startline = startline;
  +    this.startcolumn = startcolumn;
  +    this.endline = endline;
  +    this.endcolumn = endcolumn;
  +    this.message = message;
  +  }
  +
  +  /**
  +   * Return the filename associated with this compiler error.
  +   *
  +   * @return The filename associated with this compiler error
  +   */
  +  public String getFile() {
  +    return file;
  +  }
  +
  +  /**
  +   * Assert whether this is a severe error or a warning
  +   *
  +   * @return Whether the error is severe
  +   */
  +  public boolean isError() {
  +    return error;
  +  }
  +
  +  /**
  +   * Return the starting line number of the program text originating this 
error
  +   *
  +   * @return The starting line number of the program text originating this 
error
  +   */
  +  public int getStartLine() {
  +    return startline;
  +  }
  +
  +  /**
  +   * Return the starting column number of the program text originating this
  +   * error
  +   *
  +   * @return The starting column number of the program text originating this
  +   * error
  +   */
  +  public int getStartColumn() {
  +    return startcolumn;
  +  }
  +
  +  /**
  +   * Return the ending line number of the program text originating this error
  +   *
  +   * @return The ending line number of the program text originating this 
error
  +   */
  +  public int getEndLine() {
  +    return endline;
  +  }
  +
  +  /**
  +   * Return the ending column number of the program text originating this
  +   * error
  +   *
  +   * @return The ending column number of the program text originating this
  +   * error
  +   */
  +  public int getEndColumn() {
  +    return endcolumn;
  +  }
  +
  +  /**
  +   * Return the message produced by the language processor
  +   *
  +   * @return The message produced by the language processor
  +   */
  +  public String getMessage() {
  +    return message;
  +  }
  +}
  
  
  
  1.1.2.4   +80 -80    
xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/LanguageCompiler.java
  
  Index: LanguageCompiler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/LanguageCompiler.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- LanguageCompiler.java     2000/07/22 20:41:39     1.1.2.3
  +++ LanguageCompiler.java     2000/07/29 18:30:30     1.1.2.4
  @@ -1,80 +1,80 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -
  -package org.apache.cocoon.components.language.programming;
  -
  -import java.util.Vector;
  -import org.apache.avalon.Component;
  -
  -import java.io.IOException;
  -
  -/**
  - * This interface defines a compiler's functionality for all
  - * (Java-based) compiled languages
  - * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - * @version $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:39 $
  - * @since 2.0
  - */
  -public interface LanguageCompiler extends Component {
  -  /**
  -   * Set the name of the file containing the source program
  -   *
  -   * @param file The name of the file containing the source program
  -   */
  -  void setFile(String file);
  -
  -  /**
  -   * Set the name of the directory containing the source program file
  -   *
  -   * @param srcDir The name of the directory containing the source program 
file
  -   */
  -  void setSource(String 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
  -   */
  -  void setDestination(String destDir);
  -
  -  /**
  -   * Set the classpath to be used for this compilation
  -   *
  -   * @param classpath The classpath to be used for this compilation
  -   */
  -  void setClasspath(String 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
  -   */
  -  void setEncoding(String encoding);
  -
  -  /**
  -   * Compile a source file yielding a loadable program 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
  -   */
  -  boolean compile() throws IOException;
  -
  -  /**
  -   * 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
  -   */
  -  Vector getErrors() throws IOException;
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +
  +package org.apache.cocoon.components.language.programming;
  +
  +import java.util.Vector;
  +import org.apache.avalon.Component;
  +
  +import java.io.IOException;
  +
  +/**
  + * This interface defines a compiler's functionality for all
  + * (Java-based) compiled languages
  + * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  + * @version $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:30 $
  + * @since 2.0
  + */
  +public interface LanguageCompiler extends Component {
  +  /**
  +   * Set the name of the file containing the source program
  +   *
  +   * @param file The name of the file containing the source program
  +   */
  +  void setFile(String file);
  +
  +  /**
  +   * Set the name of the directory containing the source program file
  +   *
  +   * @param srcDir The name of the directory containing the source program 
file
  +   */
  +  void setSource(String 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
  +   */
  +  void setDestination(String destDir);
  +
  +  /**
  +   * Set the classpath to be used for this compilation
  +   *
  +   * @param classpath The classpath to be used for this compilation
  +   */
  +  void setClasspath(String 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
  +   */
  +  void setEncoding(String encoding);
  +
  +  /**
  +   * Compile a source file yielding a loadable program 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
  +   */
  +  boolean compile() throws IOException;
  +
  +  /**
  +   * 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
  +   */
  +  Vector getErrors() throws IOException;
  +}
  
  
  
  1.1.2.4   +78 -78    
xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/ProgrammingLanguage.java
  
  Index: ProgrammingLanguage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/Attic/ProgrammingLanguage.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- ProgrammingLanguage.java  2000/07/22 20:41:39     1.1.2.3
  +++ ProgrammingLanguage.java  2000/07/29 18:30:30     1.1.2.4
  @@ -1,78 +1,78 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.programming;
  -
  -import org.apache.avalon.NamedComponent;
  -
  -import org.apache.cocoon.components.language.LanguageException;
  -
  -/**
  - * This interface states the functionality of a programming language 
processor
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:39 $
  - */
  -public interface ProgrammingLanguage extends NamedComponent {
  -  /**
  -   * Return the programming language's source file extension
  -   *
  -   * @return The canonical source file extension
  -   */
  -  public String getSourceExtension();
  -
  -  /**
  -   * Load a program from a file
  -   *
  -   * @param filename The program base file name
  -   * @param baseDirectory The directory containing the program file
  -   * @param encoding The encoding expected in the source file or
  -   * <code>null</code> if it is the platform's default encoding
  -   * @return The loaded program
  -   * @exception LanguageException If an error occurs during loading
  -   */
  -  public Object load(String filename, String baseDirectory, String encoding)
  -    throws LanguageException;
  -
  -  /**
  -   * Create a new instance for the given program type
  -   *
  -   * @param program The program type
  -   * @return A new program type instance
  -   * @exception LanguageException If an instantiation error occurs
  -   */
  -  public Object instantiate(Object program) throws LanguageException;
  -
  -  /**
  -   * Unload from memory and invalidate a given program
  -   *
  -   * @param program The program
  -   * @param filename The name of the file this program was loaded from
  -   * @param baseDirectory The directory containing the program file
  -   * @exception LanguageException If an error occurs
  -   */
  -  public void unload (Object program, String filename, String baseDirectory)
  -    throws LanguageException;
  -
  -  /**
  -   * Return the <code>CodeFormatter</code> associated with this programming
  -   * language
  -   *
  -   * @return The code formatter object or <code>null</code> if none is
  -   * available
  -   */
  -  public CodeFormatter getCodeFormatter();
  -
  -  /**
  -   * Escape a <code>String</code> according to the programming language's
  -   * string constant encoding rules.
  -   *
  -   * @param constant The string to be escaped
  -   * @return The escaped string
  -   */
  -  public String quoteString(String constant);
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.programming;
  +
  +import org.apache.avalon.NamedComponent;
  +
  +import org.apache.cocoon.components.language.LanguageException;
  +
  +/**
  + * This interface states the functionality of a programming language 
processor
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:30 $
  + */
  +public interface ProgrammingLanguage extends NamedComponent {
  +  /**
  +   * Return the programming language's source file extension
  +   *
  +   * @return The canonical source file extension
  +   */
  +  public String getSourceExtension();
  +
  +  /**
  +   * Load a program from a file
  +   *
  +   * @param filename The program base file name
  +   * @param baseDirectory The directory containing the program file
  +   * @param encoding The encoding expected in the source file or
  +   * <code>null</code> if it is the platform's default encoding
  +   * @return The loaded program
  +   * @exception LanguageException If an error occurs during loading
  +   */
  +  public Object load(String filename, String baseDirectory, String encoding)
  +    throws LanguageException;
  +
  +  /**
  +   * Create a new instance for the given program type
  +   *
  +   * @param program The program type
  +   * @return A new program type instance
  +   * @exception LanguageException If an instantiation error occurs
  +   */
  +  public Object instantiate(Object program) throws LanguageException;
  +
  +  /**
  +   * Unload from memory and invalidate a given program
  +   *
  +   * @param program The program
  +   * @param filename The name of the file this program was loaded from
  +   * @param baseDirectory The directory containing the program file
  +   * @exception LanguageException If an error occurs
  +   */
  +  public void unload (Object program, String filename, String baseDirectory)
  +    throws LanguageException;
  +
  +  /**
  +   * Return the <code>CodeFormatter</code> associated with this programming
  +   * language
  +   *
  +   * @return The code formatter object or <code>null</code> if none is
  +   * available
  +   */
  +  public CodeFormatter getCodeFormatter();
  +
  +  /**
  +   * Escape a <code>String</code> according to the programming language's
  +   * string constant encoding rules.
  +   *
  +   * @param constant The string to be escaped
  +   * @return The escaped string
  +   */
  +  public String quoteString(String constant);
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +172 -172  
xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/AbstractJavaCompiler.java
  
  Index: AbstractJavaCompiler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/AbstractJavaCompiler.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- AbstractJavaCompiler.java 2000/07/22 20:41:40     1.1.2.3
  +++ AbstractJavaCompiler.java 2000/07/29 18:30:31     1.1.2.4
  @@ -1,172 +1,172 @@
  -/**
  -* ***************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.    *
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                             *
  - * **************************************************************************
  - */
  -package org.apache.cocoon.components.language.programming.java;
  -
  -import java.io.*;
  -import java.util.*;
  -import org.apache.avalon.*;
  -
  -import org.apache.cocoon.components.language.programming.*;
  -
  -/**
  - * This class implements the functionality common to all Java compilers.
  - * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - * @version $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:40 $
  - * @since 2.0
  - */
  -public abstract class AbstractJavaCompiler implements LanguageCompiler {
  -  /**
  -   * 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 Vector 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 Vector 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 Vector fillArguments(Vector arguments) {
  -    // destination directory
  -    arguments.addElement("-d");
  -    arguments.addElement(destDir);
  -
  -    // classpath
  -    arguments.addElement("-classpath");
  -
  -    if (System.getProperty("java.version").startsWith("1.1")) {
  -      arguments.addElement(classpath + File.pathSeparator + srcDir);
  -    } else {
  -      arguments.addElement(classpath);
  -      arguments.addElement("-sourcepath");
  -      arguments.addElement(srcDir);
  -    } 
  -
  -    // add optimization (for what is worth)
  -    arguments.addElement("-O");
  -
  -    // add encoding if set
  -    if (encoding != null) {
  -      arguments.addElement("-encoding");
  -      arguments.addElement(encoding);
  -    } 
  -
  -    return arguments;
  -  } 
  -
  -  /**
  -   * Copy arguments to a string array
  -   *
  -   * @param arguments The compiler arguments
  -   * @return A string array containing compilation arguments
  -   */
  -  protected String[] toStringArray(Vector arguments) {
  -    int    i;
  -    String[] args = new String[arguments.size() + 1];
  -
  -    for (i = 0; i < arguments.size(); i++) {
  -      args[i] = (String) arguments.elementAt(i);
  -    } 
  -
  -    args[i] = file;
  -
  -    return args;
  -  } 
  -}
  +/**
  +* ***************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.    *
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                             *
  + * **************************************************************************
  + */
  +package org.apache.cocoon.components.language.programming.java;
  +
  +import java.io.*;
  +import java.util.*;
  +import org.apache.avalon.*;
  +
  +import org.apache.cocoon.components.language.programming.*;
  +
  +/**
  + * This class implements the functionality common to all Java compilers.
  + * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  + * @version $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:31 $
  + * @since 2.0
  + */
  +public abstract class AbstractJavaCompiler implements LanguageCompiler {
  +  /**
  +   * 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 Vector 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 Vector 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 Vector fillArguments(Vector arguments) {
  +    // destination directory
  +    arguments.addElement("-d");
  +    arguments.addElement(destDir);
  +
  +    // classpath
  +    arguments.addElement("-classpath");
  +
  +    if (System.getProperty("java.version").startsWith("1.1")) {
  +      arguments.addElement(classpath + File.pathSeparator + srcDir);
  +    } else {
  +      arguments.addElement(classpath);
  +      arguments.addElement("-sourcepath");
  +      arguments.addElement(srcDir);
  +    } 
  +
  +    // add optimization (for what is worth)
  +    arguments.addElement("-O");
  +
  +    // add encoding if set
  +    if (encoding != null) {
  +      arguments.addElement("-encoding");
  +      arguments.addElement(encoding);
  +    } 
  +
  +    return arguments;
  +  } 
  +
  +  /**
  +   * Copy arguments to a string array
  +   *
  +   * @param arguments The compiler arguments
  +   * @return A string array containing compilation arguments
  +   */
  +  protected String[] toStringArray(Vector arguments) {
  +    int    i;
  +    String[] args = new String[arguments.size() + 1];
  +
  +    for (i = 0; i < arguments.size(); i++) {
  +      args[i] = (String) arguments.elementAt(i);
  +    } 
  +
  +    args[i] = file;
  +
  +    return args;
  +  } 
  +}
  
  
  
  1.1.2.4   +240 -240  
xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JavaLanguage.java
  
  Index: JavaLanguage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JavaLanguage.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- JavaLanguage.java 2000/07/22 20:41:40     1.1.2.3
  +++ JavaLanguage.java 2000/07/29 18:30:31     1.1.2.4
  @@ -1,240 +1,240 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.programming.java;
  -
  -import java.io.File;
  -import java.util.Vector;
  -
  -import org.apache.avalon.utils.Parameters;
  -
  -import org.apache.avalon.Composer;
  -import org.apache.avalon.Component;
  -import org.apache.avalon.ComponentManager;
  -
  -import org.apache.cocoon.components.classloader.ClassLoaderManager;
  -
  -import org.apache.cocoon.components.language.programming.*;
  -
  -import org.apache.cocoon.components.language.LanguageException;
  -
  -/**
  - * The Java programming language processor
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:40 $
  - */
  -public class JavaLanguage extends CompiledProgrammingLanguage {
  -  /** The class loader */
  -  ClassLoaderManager classLoaderManager;
  -
  -  /**
  -   * 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
  -   */
  -  protected void setParameters(Parameters params) throws Exception {
  -    super.setParameters(params);
  -
  -    String compilerClass = params.getParameter("class-loader", null);
  -    if (compilerClass != null) {
  -      this.classLoaderManager = (ClassLoaderManager)
  -        
this.getClass().getClassLoader().loadClass(compilerClass).newInstance();
  -    }
  -  }
  -
  -  /**
  -   * 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 setComponentManager(ComponentManager manager) {
  -    super.setComponentManager(manager);
  -
  -    if (this.classLoaderManager == null) {
  -      this.classLoaderManager =
  -        (ClassLoaderManager) this.manager.getComponent("class-loader");
  -    }
  -  }
  -
  -  /**
  -   * 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 Object loadProgram(String name, String baseDirectory)
  -    throws LanguageException
  -  {
  -    try {
  -      this.classLoaderManager.addDirectory(baseDirectory); 
  -      return
  -        this.classLoaderManager.loadClass(name.replace(File.separatorChar, 
'.'));
  -    } catch (Exception e) {
  -      throw new LanguageException(e.getMessage());
  -    }
  -  }
  -
  -  /**
  -   * 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, String baseDirectory, String encoding
  -  ) throws LanguageException {
  -
  -    try {
  -      AbstractJavaCompiler compiler =
  -        (AbstractJavaCompiler) this.compilerClass.newInstance();
  -  
  -      int pos = name.lastIndexOf(File.separatorChar);
  -      String filename = name.substring(pos + 1);
  -      String pathname =
  -        baseDirectory + File.separator +
  -        name.substring(0, pos).replace(File.separatorChar, '/');
  -  
  -      compiler.setFile(
  -        pathname + File.separator +
  -        filename + "." + this.getSourceExtension()
  -      );
  -  
  -      compiler.setSource(pathname);
  -  
  -      compiler.setDestination(baseDirectory);
  -  
  -      compiler.setClasspath(
  -        System.getProperty("java.class.path") + File.pathSeparator +
  -        baseDirectory
  -      );
  -  
  -      if (encoding != null) {
  -        compiler.setEncoding(encoding);
  -      }
  -  
  -      if (!compiler.compile()) {
  -        StringBuffer message =
  -          new StringBuffer("Error compiling " + filename + ":\n");
  -  
  -        Vector errors = compiler.getErrors();
  -        int count = errors.size();
  -        for (int i = 0; i < count; i++) {
  -          CompilerError error = (CompilerError) errors.elementAt(i);
  -          message.append(
  -       "Line " + error.getStartLine() +
  -       ", column " + error.getStartColumn() +
  -       ": " + error.getMessage()
  -          );
  -        }
  -  
  -        throw new LanguageException(message.toString());
  -      }
  -    } catch (Exception e) {
  -e.printStackTrace();
  -      throw new LanguageException(e.getMessage());
  -    }
  -  }
  -
  -  /**
  -   * Create a new instance for the given class
  -   *
  -   * @param program The Java class
  -   * @return A new class instance
  -   * @exception LanguageException If an instantiation error occurs
  -   */
  -  public Object instantiate(Object program) throws LanguageException {
  -    try {
  -      return ((Class) program).newInstance();
  -    } catch (Exception e) {
  -      throw new LanguageException(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;
  -      }
  -    }
  -
  -    return buffer.toString();
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.programming.java;
  +
  +import java.io.File;
  +import java.util.Vector;
  +
  +import org.apache.avalon.utils.Parameters;
  +
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.Component;
  +import org.apache.avalon.ComponentManager;
  +
  +import org.apache.cocoon.components.classloader.ClassLoaderManager;
  +
  +import org.apache.cocoon.components.language.programming.*;
  +
  +import org.apache.cocoon.components.language.LanguageException;
  +
  +/**
  + * The Java programming language processor
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:31 $
  + */
  +public class JavaLanguage extends CompiledProgrammingLanguage {
  +  /** The class loader */
  +  ClassLoaderManager classLoaderManager;
  +
  +  /**
  +   * 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
  +   */
  +  protected void setParameters(Parameters params) throws Exception {
  +    super.setParameters(params);
  +
  +    String compilerClass = params.getParameter("class-loader", null);
  +    if (compilerClass != null) {
  +      this.classLoaderManager = (ClassLoaderManager)
  +        
this.getClass().getClassLoader().loadClass(compilerClass).newInstance();
  +    }
  +  }
  +
  +  /**
  +   * 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 setComponentManager(ComponentManager manager) {
  +    super.setComponentManager(manager);
  +
  +    if (this.classLoaderManager == null) {
  +      this.classLoaderManager =
  +        (ClassLoaderManager) this.manager.getComponent("class-loader");
  +    }
  +  }
  +
  +  /**
  +   * 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 Object loadProgram(String name, String baseDirectory)
  +    throws LanguageException
  +  {
  +    try {
  +      this.classLoaderManager.addDirectory(baseDirectory); 
  +      return
  +        this.classLoaderManager.loadClass(name.replace(File.separatorChar, 
'.'));
  +    } catch (Exception e) {
  +      throw new LanguageException(e.getMessage());
  +    }
  +  }
  +
  +  /**
  +   * 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, String baseDirectory, String encoding
  +  ) throws LanguageException {
  +
  +    try {
  +      AbstractJavaCompiler compiler =
  +        (AbstractJavaCompiler) this.compilerClass.newInstance();
  +  
  +      int pos = name.lastIndexOf(File.separatorChar);
  +      String filename = name.substring(pos + 1);
  +      String pathname =
  +        baseDirectory + File.separator +
  +        name.substring(0, pos).replace(File.separatorChar, '/');
  +  
  +      compiler.setFile(
  +        pathname + File.separator +
  +        filename + "." + this.getSourceExtension()
  +      );
  +  
  +      compiler.setSource(pathname);
  +  
  +      compiler.setDestination(baseDirectory);
  +  
  +      compiler.setClasspath(
  +        System.getProperty("java.class.path") + File.pathSeparator +
  +        baseDirectory
  +      );
  +  
  +      if (encoding != null) {
  +        compiler.setEncoding(encoding);
  +      }
  +  
  +      if (!compiler.compile()) {
  +        StringBuffer message =
  +          new StringBuffer("Error compiling " + filename + ":\n");
  +  
  +        Vector errors = compiler.getErrors();
  +        int count = errors.size();
  +        for (int i = 0; i < count; i++) {
  +          CompilerError error = (CompilerError) errors.elementAt(i);
  +          message.append(
  +       "Line " + error.getStartLine() +
  +       ", column " + error.getStartColumn() +
  +       ": " + error.getMessage()
  +          );
  +        }
  +  
  +        throw new LanguageException(message.toString());
  +      }
  +    } catch (Exception e) {
  +e.printStackTrace();
  +      throw new LanguageException(e.getMessage());
  +    }
  +  }
  +
  +  /**
  +   * Create a new instance for the given class
  +   *
  +   * @param program The Java class
  +   * @return A new class instance
  +   * @exception LanguageException If an instantiation error occurs
  +   */
  +  public Object instantiate(Object program) throws LanguageException {
  +    try {
  +      return ((Class) program).newInstance();
  +    } catch (Exception e) {
  +      throw new LanguageException(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;
  +      }
  +    }
  +
  +    return buffer.toString();
  +  }
  +}
  
  
  
  1.1.2.3   +100 -100  
xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Javac.java
  
  Index: Javac.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Javac.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Javac.java        2000/07/22 20:41:40     1.1.2.2
  +++ Javac.java        2000/07/29 18:30:31     1.1.2.3
  @@ -1,100 +1,100 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.    *
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                             *
  - 
*****************************************************************************/
  -
  -package org.apache.cocoon.components.language.programming.java;
  -
  -import java.io.*;
  -import java.util.*;
  -import org.apache.cocoon.components.language.programming.*;
  -
  -/**
  - * This class wraps the Sun's built-in Java compiler.
  - * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - * @version $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:40 $
  - * @since 2.0
  - */
  -
  -public class Javac extends AbstractJavaCompiler {
  -  /**
  -   * 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
  -   */
  -  public boolean compile() throws IOException {
  -    ByteArrayOutputStream err = new ByteArrayOutputStream();
  -    sun.tools.javac.Main compiler = new sun.tools.javac.Main(err, "javac");
  -    boolean result =
  -      compiler.compile(toStringArray(fillArguments(new Vector(10))));
  -    this.errors = new ByteArrayInputStream(err.toByteArray());
  -    return result;
  -  }
  -  
  -  /**
  -   * 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 Vector parseStream(BufferedReader input) throws IOException {
  -    Vector errors = null;
  -    String line = null;
  -    StringBuffer buffer = new StringBuffer();
  -
  -    while (true) {
  -      // cleanup the buffer
  -      buffer.delete(0, buffer.length());
  -
  -      // each error has 3 lines
  -      for (int i = 0; i < 3 ; i++) {
  -        if ((line = input.readLine()) == null) return errors;
  -        buffer.append(line);
  -        buffer.append('\n');
  -      }
  -
  -      // if error is found create the vector
  -      if (errors == null) errors = new Vector(10);
  -      
  -      // add the error bean
  -      errors.addElement(parseError(buffer.toString()));
  -    }
  -  }
  -  
  -  /**
  -   * Parse an individual compiler error message
  -   *
  -   * @param error The error text
  -   * @return A mssaged <code>CompilerError</code>
  -   */
  -  private CompilerError parseError(String error) {
  -    StringTokenizer tokens = new StringTokenizer(error, ":");
  -    String file = tokens.nextToken();
  -    int line = Integer.parseInt(tokens.nextToken());
  -    
  -    tokens = new StringTokenizer(tokens.nextToken().trim(), "\n");
  -    String message = tokens.nextToken();
  -    String context = tokens.nextToken();
  -    String pointer = tokens.nextToken();
  -    int startcolumn = pointer.indexOf("^");
  -    int endcolumn = context.indexOf(" ", startcolumn);
  -    if (endcolumn == -1) endcolumn = context.length();
  -    
  -    String type = "error";
  -    
  -    return new CompilerError(srcDir + File.separator + file, 
type.equals("error"), line, startcolumn, line, endcolumn, message);
  -  }
  -  
  -  public String getStatus() {
  -    return "Sun Classic JavaC";
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.    *
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                             *
  + 
*****************************************************************************/
  +
  +package org.apache.cocoon.components.language.programming.java;
  +
  +import java.io.*;
  +import java.util.*;
  +import org.apache.cocoon.components.language.programming.*;
  +
  +/**
  + * This class wraps the Sun's built-in Java compiler.
  + * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  + * @version $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:31 $
  + * @since 2.0
  + */
  +
  +public class Javac extends AbstractJavaCompiler {
  +  /**
  +   * 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
  +   */
  +  public boolean compile() throws IOException {
  +    ByteArrayOutputStream err = new ByteArrayOutputStream();
  +    sun.tools.javac.Main compiler = new sun.tools.javac.Main(err, "javac");
  +    boolean result =
  +      compiler.compile(toStringArray(fillArguments(new Vector(10))));
  +    this.errors = new ByteArrayInputStream(err.toByteArray());
  +    return result;
  +  }
  +  
  +  /**
  +   * 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 Vector parseStream(BufferedReader input) throws IOException {
  +    Vector errors = null;
  +    String line = null;
  +    StringBuffer buffer = new StringBuffer();
  +
  +    while (true) {
  +      // cleanup the buffer
  +      buffer.delete(0, buffer.length());
  +
  +      // each error has 3 lines
  +      for (int i = 0; i < 3 ; i++) {
  +        if ((line = input.readLine()) == null) return errors;
  +        buffer.append(line);
  +        buffer.append('\n');
  +      }
  +
  +      // if error is found create the vector
  +      if (errors == null) errors = new Vector(10);
  +      
  +      // add the error bean
  +      errors.addElement(parseError(buffer.toString()));
  +    }
  +  }
  +  
  +  /**
  +   * Parse an individual compiler error message
  +   *
  +   * @param error The error text
  +   * @return A mssaged <code>CompilerError</code>
  +   */
  +  private CompilerError parseError(String error) {
  +    StringTokenizer tokens = new StringTokenizer(error, ":");
  +    String file = tokens.nextToken();
  +    int line = Integer.parseInt(tokens.nextToken());
  +    
  +    tokens = new StringTokenizer(tokens.nextToken().trim(), "\n");
  +    String message = tokens.nextToken();
  +    String context = tokens.nextToken();
  +    String pointer = tokens.nextToken();
  +    int startcolumn = pointer.indexOf("^");
  +    int endcolumn = context.indexOf(" ", startcolumn);
  +    if (endcolumn == -1) endcolumn = context.length();
  +    
  +    String type = "error";
  +    
  +    return new CompilerError(srcDir + File.separator + file, 
type.equals("error"), line, startcolumn, line, endcolumn, message);
  +  }
  +  
  +  public String getStatus() {
  +    return "Sun Classic JavaC";
  +  }
  +}
  
  
  
  1.1.2.3   +111 -111  
xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Jikes.java
  
  Index: Jikes.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Jikes.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Jikes.java        2000/07/22 20:41:40     1.1.2.2
  +++ Jikes.java        2000/07/29 18:30:31     1.1.2.3
  @@ -1,111 +1,111 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.      *
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                      *
  - 
*****************************************************************************/
  - 
  -package org.apache.cocoon.components.language.programming.java;
  -
  -import java.io.*;
  -import java.util.*;
  -import org.apache.cocoon.components.language.programming.*;
  -
  -/**
  - * This class wraps IBM's <i>Jikes</i> Java compiler
  - * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - * @version $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:40 $
  - * @since 2.0
  - */
  -
  -public class Jikes extends AbstractJavaCompiler {
  -  /**
  -  * 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
  -  */
  -   public boolean compile() throws IOException {
  -      Vector args = new Vector(12);
  -      // command line name
  -      args.add("jikes");
  -      // indicate Emacs output mode must be used
  -      args.add("+D");
  -
  -      Process p = 
Runtime.getRuntime().exec(toStringArray(fillArguments(args)));
  -
  -      errors = p.getInputStream();
  -      
  -      try {
  -        p.waitFor();
  -        return (p.exitValue() == 0);
  -      } catch(InterruptedException somethingHappened) {
  -        return false;
  -      }
  -   }
  -   
  -  /**
  -   * 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 Vector parseStream(BufferedReader input) throws IOException {
  -      Vector errors = null;
  -      String line = null;
  -      StringBuffer buffer = new StringBuffer();
  -
  -      while (true) {
  -        // cleanup the buffer
  -        buffer.delete(0, buffer.length());
  -
  -        // first line is not space-starting        
  -        if (line == null) line = input.readLine();
  -        if (line == null) return errors;
  -        buffer.append(line);
  -
  -        // all other space-starting lines are one error
  -        while (true) {        
  -           line = input.readLine();
  -           if ((line == null) || (line.charAt(0) != ' ')) break;
  -           buffer.append(line);
  -           buffer.append('\n');
  -        }
  -        
  -        // if error is found create the vector
  -        if (errors == null) errors = new Vector(10);
  -        
  -        // add the error bean
  -        errors.addElement(parseError(buffer.toString()));
  -      }
  -   }
  -   
  -  /**
  -   * Parse an individual compiler error message
  -   *
  -   * @param error The error text
  -   * @return A mssaged <code>CompilerError</code>
  -   */
  -   private CompilerError parseError(String error) {
  -      StringTokenizer tokens = new StringTokenizer(error, ":");
  -      String file = tokens.nextToken();
  -      int startline = Integer.parseInt(tokens.nextToken());
  -      int startcolumn = Integer.parseInt(tokens.nextToken());
  -      int endline = Integer.parseInt(tokens.nextToken());
  -      int endcolumn = Integer.parseInt(tokens.nextToken());
  -      String type = tokens.nextToken().trim().toLowerCase();
  -      String message = tokens.nextToken().trim();
  -      
  -      return new CompilerError(file, type.equals("error"), startline, 
startcolumn, endline, endcolumn, message);
  -   }
  -   
  -   public String getStatus() {
  -      return "IBM Jikes";
  -   }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.      *
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                      *
  + 
*****************************************************************************/
  + 
  +package org.apache.cocoon.components.language.programming.java;
  +
  +import java.io.*;
  +import java.util.*;
  +import org.apache.cocoon.components.language.programming.*;
  +
  +/**
  + * This class wraps IBM's <i>Jikes</i> Java compiler
  + * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  + * @version $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:31 $
  + * @since 2.0
  + */
  +
  +public class Jikes extends AbstractJavaCompiler {
  +  /**
  +  * 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
  +  */
  +   public boolean compile() throws IOException {
  +      Vector args = new Vector(12);
  +      // command line name
  +      args.add("jikes");
  +      // indicate Emacs output mode must be used
  +      args.add("+D");
  +
  +      Process p = 
Runtime.getRuntime().exec(toStringArray(fillArguments(args)));
  +
  +      errors = p.getInputStream();
  +      
  +      try {
  +        p.waitFor();
  +        return (p.exitValue() == 0);
  +      } catch(InterruptedException somethingHappened) {
  +        return false;
  +      }
  +   }
  +   
  +  /**
  +   * 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 Vector parseStream(BufferedReader input) throws IOException {
  +      Vector errors = null;
  +      String line = null;
  +      StringBuffer buffer = new StringBuffer();
  +
  +      while (true) {
  +        // cleanup the buffer
  +        buffer.delete(0, buffer.length());
  +
  +        // first line is not space-starting        
  +        if (line == null) line = input.readLine();
  +        if (line == null) return errors;
  +        buffer.append(line);
  +
  +        // all other space-starting lines are one error
  +        while (true) {        
  +           line = input.readLine();
  +           if ((line == null) || (line.charAt(0) != ' ')) break;
  +           buffer.append(line);
  +           buffer.append('\n');
  +        }
  +        
  +        // if error is found create the vector
  +        if (errors == null) errors = new Vector(10);
  +        
  +        // add the error bean
  +        errors.addElement(parseError(buffer.toString()));
  +      }
  +   }
  +   
  +  /**
  +   * Parse an individual compiler error message
  +   *
  +   * @param error The error text
  +   * @return A mssaged <code>CompilerError</code>
  +   */
  +   private CompilerError parseError(String error) {
  +      StringTokenizer tokens = new StringTokenizer(error, ":");
  +      String file = tokens.nextToken();
  +      int startline = Integer.parseInt(tokens.nextToken());
  +      int startcolumn = Integer.parseInt(tokens.nextToken());
  +      int endline = Integer.parseInt(tokens.nextToken());
  +      int endcolumn = Integer.parseInt(tokens.nextToken());
  +      String type = tokens.nextToken().trim().toLowerCase();
  +      String message = tokens.nextToken().trim();
  +      
  +      return new CompilerError(file, type.equals("error"), startline, 
startcolumn, endline, endcolumn, message);
  +   }
  +   
  +   public String getStatus() {
  +      return "IBM Jikes";
  +   }
  +}
  
  
  
  1.1.2.3   +103 -103  
xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JstyleFormatter.java
  
  Index: JstyleFormatter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/JstyleFormatter.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- JstyleFormatter.java      2000/07/22 20:41:41     1.1.2.2
  +++ JstyleFormatter.java      2000/07/29 18:30:31     1.1.2.3
  @@ -1,103 +1,103 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.programming.java;
  -
  -import java.io.PrintWriter;
  -import java.io.StringReader;
  -import java.io.BufferedReader;
  -import java.io.ByteArrayOutputStream;
  -import java.io.UnsupportedEncodingException;
  -
  -import jstyle.JSFormatter;
  -import jstyle.JSBeautifier;
  -
  -import org.apache.cocoon.components.language.programming.*;
  -
  -/**
  - * This class implements <code>CodeFormatter</code> based on
  - * Tal Davidson's ([EMAIL PROTECTED]) <i>Jstyle</i> Java
  - * beautifier. This implementation is very improvised...
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:41 $
  - */
  -public class JstyleFormatter implements CodeFormatter {
  -  /**
  -   * The default preferred line length. Should be parametrized!
  -   */
  -  protected static final int PREFERRED_LINE_LENGTH = 72;
  -  /**
  -   * The default line length deviation. Should be parametrized!
  -   */
  -  protected static final int LINE_LENGTH_DEVIATION = 8;
  -
  -  /**
  -   * The default space indentation. Should be parametrized!
  -   */
  -  protected static final int SPACE_INDENTATION = 2;
  -
  -  /**
  -   * Format and beautify a <code>String</code> containing source code.
  -   * This class has 2 pases: one for beautifying and another one for
  -   * indentation. This should be performed in a single step!!!
  -   *
  -   * @param code The input source code
  -   * @param encoding The encoding used for constant strings embedded in the
  -   * source code
  -   * @return The formatted source code
  -   */
  -  public String format(String code, String encoding) {
  -    try {
  -      JSFormatter formatter = new JSFormatter();
  -
  -      formatter.setPreferredLineLength(PREFERRED_LINE_LENGTH);
  -      formatter.setLineLengthDeviation(LINE_LENGTH_DEVIATION);
  -
  -      ByteArrayOutputStream out = new ByteArrayOutputStream(code.length());
  -
  -      formatter.format(
  -        new BufferedReader(new StringReader(code)), new PrintWriter(out, 
true)
  -      );
  -
  -      JSBeautifier beautifier = new JSBeautifier();
  -
  -      code = this.getString(out, encoding);
  -
  -      out = new ByteArrayOutputStream(code.length());
  -
  -      beautifier.setSpaceIndentation(SPACE_INDENTATION);
  -
  -      beautifier.beautifyReader(
  -        new BufferedReader(new StringReader(code)), new PrintWriter(out, 
true)
  -      );
  -
  -      return this.getString(out, encoding);
  -    } catch (Exception e) {
  -      return code;
  -    }
  -  }
  -
  -  /**
  -   * Convert a byte array stream to string according to a given encoding.
  -   * The encoding can be <code>null</code> for the platform's default
  -   * encoding
  -   *
  -   * @param PARAM_NAME Param description
  -   * @return the value
  -   * @exception EXCEPTION_NAME If an error occurs
  -   */
  -  protected String getString(ByteArrayOutputStream out, String encoding)
  -    throws UnsupportedEncodingException
  -  {
  -    if (encoding == null) {
  -      return out.toString();
  -    }
  -
  -    return out.toString(encoding);
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.programming.java;
  +
  +import java.io.PrintWriter;
  +import java.io.StringReader;
  +import java.io.BufferedReader;
  +import java.io.ByteArrayOutputStream;
  +import java.io.UnsupportedEncodingException;
  +
  +import jstyle.JSFormatter;
  +import jstyle.JSBeautifier;
  +
  +import org.apache.cocoon.components.language.programming.*;
  +
  +/**
  + * This class implements <code>CodeFormatter</code> based on
  + * Tal Davidson's ([EMAIL PROTECTED]) <i>Jstyle</i> Java
  + * beautifier. This implementation is very improvised...
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:31 $
  + */
  +public class JstyleFormatter implements CodeFormatter {
  +  /**
  +   * The default preferred line length. Should be parametrized!
  +   */
  +  protected static final int PREFERRED_LINE_LENGTH = 72;
  +  /**
  +   * The default line length deviation. Should be parametrized!
  +   */
  +  protected static final int LINE_LENGTH_DEVIATION = 8;
  +
  +  /**
  +   * The default space indentation. Should be parametrized!
  +   */
  +  protected static final int SPACE_INDENTATION = 2;
  +
  +  /**
  +   * Format and beautify a <code>String</code> containing source code.
  +   * This class has 2 pases: one for beautifying and another one for
  +   * indentation. This should be performed in a single step!!!
  +   *
  +   * @param code The input source code
  +   * @param encoding The encoding used for constant strings embedded in the
  +   * source code
  +   * @return The formatted source code
  +   */
  +  public String format(String code, String encoding) {
  +    try {
  +      JSFormatter formatter = new JSFormatter();
  +
  +      formatter.setPreferredLineLength(PREFERRED_LINE_LENGTH);
  +      formatter.setLineLengthDeviation(LINE_LENGTH_DEVIATION);
  +
  +      ByteArrayOutputStream out = new ByteArrayOutputStream(code.length());
  +
  +      formatter.format(
  +        new BufferedReader(new StringReader(code)), new PrintWriter(out, 
true)
  +      );
  +
  +      JSBeautifier beautifier = new JSBeautifier();
  +
  +      code = this.getString(out, encoding);
  +
  +      out = new ByteArrayOutputStream(code.length());
  +
  +      beautifier.setSpaceIndentation(SPACE_INDENTATION);
  +
  +      beautifier.beautifyReader(
  +        new BufferedReader(new StringReader(code)), new PrintWriter(out, 
true)
  +      );
  +
  +      return this.getString(out, encoding);
  +    } catch (Exception e) {
  +      return code;
  +    }
  +  }
  +
  +  /**
  +   * Convert a byte array stream to string according to a given encoding.
  +   * The encoding can be <code>null</code> for the platform's default
  +   * encoding
  +   *
  +   * @param PARAM_NAME Param description
  +   * @return the value
  +   * @exception EXCEPTION_NAME If an error occurs
  +   */
  +  protected String getString(ByteArrayOutputStream out, String encoding)
  +    throws UnsupportedEncodingException
  +  {
  +    if (encoding == null) {
  +      return out.toString();
  +    }
  +
  +    return out.toString(encoding);
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +82 -82    
xml-cocoon/src/org/apache/cocoon/components/language/programming/javascript/Attic/JavascriptLanguage.java
  
  Index: JavascriptLanguage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/javascript/Attic/JavascriptLanguage.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- JavascriptLanguage.java   2000/07/22 20:41:42     1.1.2.2
  +++ JavascriptLanguage.java   2000/07/29 18:30:32     1.1.2.3
  @@ -1,82 +1,82 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.language.programming.javascript;
  -
  -import java.io.File;
  -
  -import org.mozilla.javascript.*;
  -import org.mozilla.javascript.tools.jsc.Main;
  -
  -import org.apache.cocoon.components.language.programming.java.*;
  -
  -import org.apache.cocoon.components.language.LanguageException;
  -
  -/**
  - * The compiled Javascript (Rhino) programming language processor
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:42 $
  - */
  -public class JavascriptLanguage extends JavaLanguage
  -{
  -  /**
  -   * Return the language name
  -   *
  -   * @return The language name
  -   */
  -  public String getName() {
  -    return "javascript";
  -  }
  -
  -  /**
  -   * Return the language's canonical source file extension.
  -   *
  -   * @return The source file extension
  -   */
  -  public String getSourceExtension() {
  -    return "js";
  -  }
  -
  -  /**
  -   * 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, String baseDirectory, String encoding
  -  ) throws LanguageException {
  -    try {
  -      Main compiler = (Main) this.compilerClass.newInstance();
  -  
  -      int pos = name.lastIndexOf(File.separatorChar);
  -      String filename = name.substring(pos + 1);
  -      String pathname =
  -        baseDirectory + File.separator +
  -        name.substring(0, pos).replace(File.separatorChar, '/');
  -      String packageName =
  -        name.substring(0, pos).replace(File.separatorChar, '.');
  -  
  -      String[] args = {
  -        "-extends",
  -        
"org.apache.cocoon.components.language.markup.xsp.javascript.JSGenerator",
  -        "-nosource",
  -        "-O", "9",
  -        "-package", packageName,
  -        pathname + File.separator + filename + "." + 
this.getSourceExtension()
  -      };
  -  
  -      compiler.main(args);
  -    } catch (Exception e) {
  -      throw new LanguageException(e.getMessage());
  -    }
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.language.programming.javascript;
  +
  +import java.io.File;
  +
  +import org.mozilla.javascript.*;
  +import org.mozilla.javascript.tools.jsc.Main;
  +
  +import org.apache.cocoon.components.language.programming.java.*;
  +
  +import org.apache.cocoon.components.language.LanguageException;
  +
  +/**
  + * The compiled Javascript (Rhino) programming language processor
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:32 $
  + */
  +public class JavascriptLanguage extends JavaLanguage
  +{
  +  /**
  +   * Return the language name
  +   *
  +   * @return The language name
  +   */
  +  public String getName() {
  +    return "javascript";
  +  }
  +
  +  /**
  +   * Return the language's canonical source file extension.
  +   *
  +   * @return The source file extension
  +   */
  +  public String getSourceExtension() {
  +    return "js";
  +  }
  +
  +  /**
  +   * 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, String baseDirectory, String encoding
  +  ) throws LanguageException {
  +    try {
  +      Main compiler = (Main) this.compilerClass.newInstance();
  +  
  +      int pos = name.lastIndexOf(File.separatorChar);
  +      String filename = name.substring(pos + 1);
  +      String pathname =
  +        baseDirectory + File.separator +
  +        name.substring(0, pos).replace(File.separatorChar, '/');
  +      String packageName =
  +        name.substring(0, pos).replace(File.separatorChar, '.');
  +  
  +      String[] args = {
  +        "-extends",
  +        
"org.apache.cocoon.components.language.markup.xsp.javascript.JSGenerator",
  +        "-nosource",
  +        "-O", "9",
  +        "-package", packageName,
  +        pathname + File.separator + filename + "." + 
this.getSourceExtension()
  +      };
  +  
  +      compiler.main(args);
  +    } catch (Exception e) {
  +      throw new LanguageException(e.getMessage());
  +    }
  +  }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.7   +27 -27    
xml-cocoon/src/org/apache/cocoon/components/parser/Attic/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/parser/Attic/Parser.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- Parser.java       2000/07/22 20:41:42     1.1.2.6
  +++ Parser.java       2000/07/29 18:30:32     1.1.2.7
  @@ -1,27 +1,27 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.parser;
  -
  -import java.io.IOException;
  -import org.apache.avalon.Component;
  -import org.apache.cocoon.xml.XMLProducer;
  -import org.apache.cocoon.xml.util.DOMFactory;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/22 20:41:42 $
  - */
  -public interface Parser extends Component, XMLProducer, DOMFactory {
  -    
  -    public void parse(InputSource in) throws SAXException, IOException;
  -    
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.parser;
  +
  +import java.io.IOException;
  +import org.apache.avalon.Component;
  +import org.apache.cocoon.xml.XMLProducer;
  +import org.apache.cocoon.xml.util.DOMFactory;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.7 $ $Date: 2000/07/29 18:30:32 $
  + */
  +public interface Parser extends Component, XMLProducer, DOMFactory {
  +    
  +    public void parse(InputSource in) throws SAXException, IOException;
  +    
  +}
  
  
  
  1.1.2.5   +102 -102  
xml-cocoon/src/org/apache/cocoon/components/parser/Attic/XercesParser.java
  
  Index: XercesParser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/parser/Attic/XercesParser.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- XercesParser.java 2000/07/22 20:41:42     1.1.2.4
  +++ XercesParser.java 2000/07/29 18:30:33     1.1.2.5
  @@ -1,102 +1,102 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.parser;
  -
  -import java.io.IOException;
  -import org.apache.cocoon.xml.AbstractXMLProducer;
  -import org.apache.cocoon.xml.util.DOMFactory;
  -import org.apache.xerces.dom.DocumentImpl;
  -import org.apache.xerces.dom.DocumentTypeImpl;
  -import org.apache.xerces.parsers.SAXParser;
  -import org.xml.sax.ErrorHandler;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.SAXParseException;
  -import org.w3c.dom.Document;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:42 $
  - */
  -public class XercesParser extends AbstractXMLProducer
  -implements Parser, ErrorHandler, DOMFactory {
  -    
  -    public void parse(InputSource in)
  -    throws SAXException, IOException {
  -        SAXParser p=new SAXParser();
  -        p.setFeature("http://xml.org/sax/features/validation",false);
  -        p.setFeature("http://xml.org/sax/features/namespaces",true);
  -        p.setProperty("http://xml.org/sax/properties/lexical-handler";,
  -                      super.lexicalHandler);
  -        p.setErrorHandler(this);
  -        p.setContentHandler(super.contentHandler);
  -        p.parse(in);
  -    }
  -        
  -    /** 
  -     * Create a new Document object.
  -     */
  -    public Document newDocument() {
  -        return(newDocument(null,null,null));
  -    }
  -
  -    /** 
  -     * Create a new Document object with a specified DOCTYPE.
  -     */
  -    public Document newDocument(String name) {
  -        return(newDocument(name,null,null));
  -    }
  -
  -    /** 
  -     * Create a new Document object with a specified DOCTYPE, public ID and 
  -     * system ID.
  -     */
  -    public Document newDocument(String name, String pub, String sys) {
  -        DocumentImpl doc=new DocumentImpl();
  -        if ((pub!=null)||(sys!=null)) {
  -            DocumentTypeImpl dtd=new DocumentTypeImpl(doc,name,pub,sys);
  -            doc.appendChild(dtd);
  -        } else if (name!=null) {
  -            DocumentTypeImpl dtd=new DocumentTypeImpl(doc,name);
  -            doc.appendChild(dtd);
  -        }
  -        return(doc);
  -    }
  -
  -    /**
  -     * Receive notification of a recoverable error.
  -     */
  -    public void error(SAXParseException e)
  -    throws SAXException {
  -        throw new SAXException("Error parsing "+e.getSystemId()+" (line "+
  -                               e.getLineNumber()+" col. 
"+e.getColumnNumber()+
  -                               "): "+e.getMessage(),e);
  -    }
  -
  -    /**
  -     * Receive notification of a fatal error.
  -     */
  -    public void fatalError(SAXParseException e)
  -    throws SAXException {
  -        throw new SAXException("Fatal error parsing "+e.getSystemId()+" 
(line "+
  -                               e.getLineNumber()+" col. 
"+e.getColumnNumber()+
  -                               "): "+e.getMessage(),e);
  -    }
  -
  -    /**
  -     * Receive notification of a warning.
  -     */
  -    public void warning(SAXParseException e)
  -    throws SAXException {
  -        throw new SAXException("Warning parsing "+e.getSystemId()+" (line "+
  -                               e.getLineNumber()+" col. 
"+e.getColumnNumber()+
  -                               "): "+e.getMessage(),e);
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.parser;
  +
  +import java.io.IOException;
  +import org.apache.cocoon.xml.AbstractXMLProducer;
  +import org.apache.cocoon.xml.util.DOMFactory;
  +import org.apache.xerces.dom.DocumentImpl;
  +import org.apache.xerces.dom.DocumentTypeImpl;
  +import org.apache.xerces.parsers.SAXParser;
  +import org.xml.sax.ErrorHandler;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.SAXParseException;
  +import org.w3c.dom.Document;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/29 18:30:33 $
  + */
  +public class XercesParser extends AbstractXMLProducer
  +implements Parser, ErrorHandler, DOMFactory {
  +    
  +    public void parse(InputSource in)
  +    throws SAXException, IOException {
  +        SAXParser p=new SAXParser();
  +        p.setFeature("http://xml.org/sax/features/validation",false);
  +        p.setFeature("http://xml.org/sax/features/namespaces",true);
  +        p.setProperty("http://xml.org/sax/properties/lexical-handler";,
  +                      super.lexicalHandler);
  +        p.setErrorHandler(this);
  +        p.setContentHandler(super.contentHandler);
  +        p.parse(in);
  +    }
  +        
  +    /** 
  +     * Create a new Document object.
  +     */
  +    public Document newDocument() {
  +        return(newDocument(null,null,null));
  +    }
  +
  +    /** 
  +     * Create a new Document object with a specified DOCTYPE.
  +     */
  +    public Document newDocument(String name) {
  +        return(newDocument(name,null,null));
  +    }
  +
  +    /** 
  +     * Create a new Document object with a specified DOCTYPE, public ID and 
  +     * system ID.
  +     */
  +    public Document newDocument(String name, String pub, String sys) {
  +        DocumentImpl doc=new DocumentImpl();
  +        if ((pub!=null)||(sys!=null)) {
  +            DocumentTypeImpl dtd=new DocumentTypeImpl(doc,name,pub,sys);
  +            doc.appendChild(dtd);
  +        } else if (name!=null) {
  +            DocumentTypeImpl dtd=new DocumentTypeImpl(doc,name);
  +            doc.appendChild(dtd);
  +        }
  +        return(doc);
  +    }
  +
  +    /**
  +     * Receive notification of a recoverable error.
  +     */
  +    public void error(SAXParseException e)
  +    throws SAXException {
  +        throw new SAXException("Error parsing "+e.getSystemId()+" (line "+
  +                               e.getLineNumber()+" col. 
"+e.getColumnNumber()+
  +                               "): "+e.getMessage(),e);
  +    }
  +
  +    /**
  +     * Receive notification of a fatal error.
  +     */
  +    public void fatalError(SAXParseException e)
  +    throws SAXException {
  +        throw new SAXException("Fatal error parsing "+e.getSystemId()+" 
(line "+
  +                               e.getLineNumber()+" col. 
"+e.getColumnNumber()+
  +                               "): "+e.getMessage(),e);
  +    }
  +
  +    /**
  +     * Receive notification of a warning.
  +     */
  +    public void warning(SAXParseException e)
  +    throws SAXException {
  +        throw new SAXException("Warning parsing "+e.getSystemId()+" (line "+
  +                               e.getLineNumber()+" col. 
"+e.getColumnNumber()+
  +                               "): "+e.getMessage(),e);
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +196 -196  
xml-cocoon/src/org/apache/cocoon/components/store/Attic/FilesystemStore.java
  
  Index: FilesystemStore.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/store/Attic/FilesystemStore.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- FilesystemStore.java      2000/07/22 20:41:43     1.1.2.2
  +++ FilesystemStore.java      2000/07/29 18:30:33     1.1.2.3
  @@ -1,196 +1,196 @@
  -package org.apache.cocoon.components.store;
  -
  -import java.io.File;
  -import java.util.Enumeration;
  -
  -import org.apache.cocoon.util.IOUtils;
  -
  -import java.io.IOException;
  -
  -public class FilesystemStore implements Store {
  -  /** The directory repository */
  -  protected File directoryFile;
  -  protected volatile String directoryPath;
  -  
  -  /**
  -   * Constructor
  -   */
  -  public FilesystemStore(String directoryName) throws IOException {
  -    this(new File(directoryName));
  -  }
  -
  -  public FilesystemStore(File directoryFile) throws IOException {
  -    this.directoryFile = directoryFile;
  -
  -    /* Save directory path prefix */
  -    this.directoryPath = IOUtils.getFullFilename(this.directoryFile);
  -    this.directoryPath += File.separator;
  -
  -    /* Does directory exist? */
  -    if (!this.directoryFile.exists()) {
  -      /* Create it anew */
  -      if (!this.directoryFile.mkdir()) {
  -        throw new IOException(
  -       "Error creating store directory '" + this.directoryPath + "': "
  -     );
  -      }
  -    }
  -
  -    /* Is given file actually a directory? */
  -    if (!this.directoryFile.isDirectory()) {
  -      throw new IOException("'" + this.directoryPath + "' is not a 
directory");
  -    }
  -
  -    /* Is directory readable and writable? */
  -    if (!(this.directoryFile.canRead() && this.directoryFile.canWrite())) {
  -      throw new IOException(
  -        "Directory '" + this.directoryPath + "' is not readable/writable"
  -      );
  -    }
  -  }
  -
  -  /**
  -   * Returns the repository's full pathname
  -   */
  -  public String getDirectoryPath() {
  -    return this.directoryPath;
  -  }
  -
  -  /**
  -   * Get the file associated with the given unique key name.
  -   */
  -  public Object get(Object key) {
  -    File file = fileFromKey(key);
  -
  -    if (file != null && file.exists()) {
  -      return file;
  -    }
  -
  -    return null;
  -  }
  -  
  -  /**
  -   * Store the given object in a persistent state.
  -   * 1) Null values generate empty directories.
  -   * 2) String values are dumped to text files
  -   * 3) Object values are serialized
  -   */ 
  -  public void store(Object key, Object value) {
  -    try {
  -      File file = fileFromKey(key);
  -
  -      /* Create subdirectories as needed */
  -      File parent = file.getParentFile();
  -      if (parent != null) {
  -        parent.mkdirs();
  -      }
  -
  -      /* Store object as file */
  -      if (value == null) { /* Directory */
  -        if (file.exists()) {
  -          if (!file.delete()) { /* FAILURE */
  -           System.err.println("File cannot be deleted: " + file.toString());
  -           return;
  -          }
  -        }
  -
  -        file.mkdir();
  -      } else if (value instanceof String) { /* Text file */
  -        IOUtils.serializeString(file, (String) value);
  -      } else { /* Serialized Object */
  -        IOUtils.serializeObject(file, value);
  -      }
  -    } catch (Exception e) { /* FAILURE */
  -      e.printStackTrace();
  -    }
  -  }
  -
  -  /**
  -   * Holds the given object in a volatile state.
  -   */ 
  -  public void hold(Object key, Object value) {
  -    this.store(key, value);
  -    File file = (File) this.get(key);
  -    if (file != null) {
  -      file.deleteOnExit();
  -    }
  -  }
  -  
  -  /**
  -   * Remove the object associated to the given key.
  -   */
  -  public void remove(Object key) {
  -    File file = fileFromKey(key);
  -    if (file != null) {
  -      file.delete();
  -    }
  -  }
  -  
  -  /**
  -   * Indicates if the given key is associated to a contained object.
  -   */
  -  public boolean containsKey(Object key) {
  -    File file = fileFromKey(key);
  -    if (file == null) {
  -      return false;
  -    }
  -    return file.exists();
  -  }
  -  
  -  /**
  -   * Returns the list of stored files as an Enumeration of Files
  -   */
  -  public Enumeration keys() {
  -    /* Not yet implemented */
  -    return null;
  -  }
  -
  -  /* Utility Methods*/
  -  protected File fileFromKey(Object key) {
  -    String name = key.toString();
  -
  -    name = IOUtils.getFullFilename(new File(name));
  -
  -    String path = IOUtils.normalizedFilename(IOUtils.pathComponent(name));
  -    String filename = name.substring(name.lastIndexOf(File.separatorChar));
  -
  -    String extension = null;
  -    int extensionPosition = filename.lastIndexOf(".");
  -    if (extensionPosition >= 0) {
  -      extension = filename.substring(extensionPosition + 1);
  -      filename = filename.substring(0, extensionPosition);
  -    }
  -
  -    filename = IOUtils.normalizedFilename(filename);
  -
  -    if (extension != null) {
  -      filename += "." + extension;
  -    }
  -
  -    return new File(this.directoryPath + path + File.separator + filename);
  -  }
  -
  -  public String getString(Object key) throws IOException {
  -    File file = (File) this.get(key);
  -    if (file != null) {
  -      return IOUtils.deserializeString(file);
  -    }
  -
  -    return null;
  -  }
  -
  -  public Object getObject(Object key)
  -    throws IOException, ClassNotFoundException
  -  {
  -    File file = (File) this.get(key);
  -    if (file != null) {
  -      return IOUtils.deserializeObject(file);
  -    }
  -
  -    return null;
  -  }
  -
  -  public String normalizedFilename(String filename) {
  -    return IOUtils.normalizedFilename(filename);
  -  }
  -}
  +package org.apache.cocoon.components.store;
  +
  +import java.io.File;
  +import java.util.Enumeration;
  +
  +import org.apache.cocoon.util.IOUtils;
  +
  +import java.io.IOException;
  +
  +public class FilesystemStore implements Store {
  +  /** The directory repository */
  +  protected File directoryFile;
  +  protected volatile String directoryPath;
  +  
  +  /**
  +   * Constructor
  +   */
  +  public FilesystemStore(String directoryName) throws IOException {
  +    this(new File(directoryName));
  +  }
  +
  +  public FilesystemStore(File directoryFile) throws IOException {
  +    this.directoryFile = directoryFile;
  +
  +    /* Save directory path prefix */
  +    this.directoryPath = IOUtils.getFullFilename(this.directoryFile);
  +    this.directoryPath += File.separator;
  +
  +    /* Does directory exist? */
  +    if (!this.directoryFile.exists()) {
  +      /* Create it anew */
  +      if (!this.directoryFile.mkdir()) {
  +        throw new IOException(
  +       "Error creating store directory '" + this.directoryPath + "': "
  +     );
  +      }
  +    }
  +
  +    /* Is given file actually a directory? */
  +    if (!this.directoryFile.isDirectory()) {
  +      throw new IOException("'" + this.directoryPath + "' is not a 
directory");
  +    }
  +
  +    /* Is directory readable and writable? */
  +    if (!(this.directoryFile.canRead() && this.directoryFile.canWrite())) {
  +      throw new IOException(
  +        "Directory '" + this.directoryPath + "' is not readable/writable"
  +      );
  +    }
  +  }
  +
  +  /**
  +   * Returns the repository's full pathname
  +   */
  +  public String getDirectoryPath() {
  +    return this.directoryPath;
  +  }
  +
  +  /**
  +   * Get the file associated with the given unique key name.
  +   */
  +  public Object get(Object key) {
  +    File file = fileFromKey(key);
  +
  +    if (file != null && file.exists()) {
  +      return file;
  +    }
  +
  +    return null;
  +  }
  +  
  +  /**
  +   * Store the given object in a persistent state.
  +   * 1) Null values generate empty directories.
  +   * 2) String values are dumped to text files
  +   * 3) Object values are serialized
  +   */ 
  +  public void store(Object key, Object value) {
  +    try {
  +      File file = fileFromKey(key);
  +
  +      /* Create subdirectories as needed */
  +      File parent = file.getParentFile();
  +      if (parent != null) {
  +        parent.mkdirs();
  +      }
  +
  +      /* Store object as file */
  +      if (value == null) { /* Directory */
  +        if (file.exists()) {
  +          if (!file.delete()) { /* FAILURE */
  +           System.err.println("File cannot be deleted: " + file.toString());
  +           return;
  +          }
  +        }
  +
  +        file.mkdir();
  +      } else if (value instanceof String) { /* Text file */
  +        IOUtils.serializeString(file, (String) value);
  +      } else { /* Serialized Object */
  +        IOUtils.serializeObject(file, value);
  +      }
  +    } catch (Exception e) { /* FAILURE */
  +      e.printStackTrace();
  +    }
  +  }
  +
  +  /**
  +   * Holds the given object in a volatile state.
  +   */ 
  +  public void hold(Object key, Object value) {
  +    this.store(key, value);
  +    File file = (File) this.get(key);
  +    if (file != null) {
  +      file.deleteOnExit();
  +    }
  +  }
  +  
  +  /**
  +   * Remove the object associated to the given key.
  +   */
  +  public void remove(Object key) {
  +    File file = fileFromKey(key);
  +    if (file != null) {
  +      file.delete();
  +    }
  +  }
  +  
  +  /**
  +   * Indicates if the given key is associated to a contained object.
  +   */
  +  public boolean containsKey(Object key) {
  +    File file = fileFromKey(key);
  +    if (file == null) {
  +      return false;
  +    }
  +    return file.exists();
  +  }
  +  
  +  /**
  +   * Returns the list of stored files as an Enumeration of Files
  +   */
  +  public Enumeration keys() {
  +    /* Not yet implemented */
  +    return null;
  +  }
  +
  +  /* Utility Methods*/
  +  protected File fileFromKey(Object key) {
  +    String name = key.toString();
  +
  +    name = IOUtils.getFullFilename(new File(name));
  +
  +    String path = IOUtils.normalizedFilename(IOUtils.pathComponent(name));
  +    String filename = name.substring(name.lastIndexOf(File.separatorChar));
  +
  +    String extension = null;
  +    int extensionPosition = filename.lastIndexOf(".");
  +    if (extensionPosition >= 0) {
  +      extension = filename.substring(extensionPosition + 1);
  +      filename = filename.substring(0, extensionPosition);
  +    }
  +
  +    filename = IOUtils.normalizedFilename(filename);
  +
  +    if (extension != null) {
  +      filename += "." + extension;
  +    }
  +
  +    return new File(this.directoryPath + path + File.separator + filename);
  +  }
  +
  +  public String getString(Object key) throws IOException {
  +    File file = (File) this.get(key);
  +    if (file != null) {
  +      return IOUtils.deserializeString(file);
  +    }
  +
  +    return null;
  +  }
  +
  +  public Object getObject(Object key)
  +    throws IOException, ClassNotFoundException
  +  {
  +    File file = (File) this.get(key);
  +    if (file != null) {
  +      return IOUtils.deserializeObject(file);
  +    }
  +
  +    return null;
  +  }
  +
  +  public String normalizedFilename(String filename) {
  +    return IOUtils.normalizedFilename(filename);
  +  }
  +}
  
  
  
  1.1.2.4   +77 -77    
xml-cocoon/src/org/apache/cocoon/components/store/Attic/MemoryStore.java
  
  Index: MemoryStore.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/store/Attic/MemoryStore.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- MemoryStore.java  2000/07/22 20:41:43     1.1.2.3
  +++ MemoryStore.java  2000/07/29 18:30:33     1.1.2.4
  @@ -1,78 +1,78 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.store;
  -
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import org.apache.avalon.Component;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
  - *         (Betaversion Productions)
  - * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - *         (Apache Software Foundation)
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:43 $
  - */
  -public class MemoryStore implements Store {
  -    
  -    /** The shared store */
  -    private static Hashtable table=null;
  -    
  -    public MemoryStore() {
  -        if (table==null) table=new Hashtable();
  -    }
  -
  -    /**
  -     * Get the object associated to the given unique key.
  -     */
  -    public Object get(Object key) {
  -        return(table.get(key));
  -    }
  -    
  -    /**
  -     * Store the given object in a persistent state. It is up to the
  -     * caller to ensure that the key has a persistent state across
  -     * different JVM executions.
  -     */ 
  -    public void store(Object key, Object value) {
  -        this.hold(key,value);
  -    }
  -
  -    /**
  -     * Holds the given object in a volatile state. This means
  -     * the object store will discard held objects if the
  -     * virtual machine is restarted or some error happens.
  -     */ 
  -    public void hold(Object key, Object value) {
  -        table.put(key,value);
  -    }
  -    
  -    /**
  -     * Remove the object associated to the given key.
  -     */
  -    public void remove(Object key) {
  -        table.remove(key);
  -    }
  -    
  -    /**
  -     * Indicates if the given key is associated to a contained object.
  -     */
  -    public boolean containsKey(Object key) {
  -        return(table.containsKey(key));
  -    }
  -    
  -    /**
  -     * Returns the list of used keys as an Enumeration of Objects.
  -     */
  -    public Enumeration keys() {
  -        return(table.keys());
  -    }
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.store;
  +
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import org.apache.avalon.Component;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
  + *         (Betaversion Productions)
  + * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  + *         (Apache Software Foundation)
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:33 $
  + */
  +public class MemoryStore implements Store {
  +    
  +    /** The shared store */
  +    private static Hashtable table=null;
  +    
  +    public MemoryStore() {
  +        if (table==null) table=new Hashtable();
  +    }
  +
  +    /**
  +     * Get the object associated to the given unique key.
  +     */
  +    public Object get(Object key) {
  +        return(table.get(key));
  +    }
  +    
  +    /**
  +     * Store the given object in a persistent state. It is up to the
  +     * caller to ensure that the key has a persistent state across
  +     * different JVM executions.
  +     */ 
  +    public void store(Object key, Object value) {
  +        this.hold(key,value);
  +    }
  +
  +    /**
  +     * Holds the given object in a volatile state. This means
  +     * the object store will discard held objects if the
  +     * virtual machine is restarted or some error happens.
  +     */ 
  +    public void hold(Object key, Object value) {
  +        table.put(key,value);
  +    }
  +    
  +    /**
  +     * Remove the object associated to the given key.
  +     */
  +    public void remove(Object key) {
  +        table.remove(key);
  +    }
  +    
  +    /**
  +     * Indicates if the given key is associated to a contained object.
  +     */
  +    public boolean containsKey(Object key) {
  +        return(table.containsKey(key));
  +    }
  +    
  +    /**
  +     * Returns the list of used keys as an Enumeration of Objects.
  +     */
  +    public Enumeration keys() {
  +        return(table.keys());
  +    }
   }
  
  
  
  1.1.2.6   +58 -58    
xml-cocoon/src/org/apache/cocoon/components/store/Attic/Store.java
  
  Index: Store.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/store/Attic/Store.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- Store.java        2000/07/22 20:41:43     1.1.2.5
  +++ Store.java        2000/07/29 18:30:33     1.1.2.6
  @@ -1,59 +1,59 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.components.store;
  -
  -import java.util.Enumeration;
  -import org.apache.avalon.Component;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
  - *         (Betaversion Productions)
  - * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - *         (Apache Software Foundation)
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:43 $
  - */
  -public interface Store extends Component {
  -
  -    /**
  -     * Get the object associated to the given unique key.
  -     */
  -    public Object get(Object key);
  -    
  -    /**
  -     * Store the given object in a persistent state. It is up to the
  -     * caller to ensure that the key has a persistent state across
  -     * different JVM executions.
  -     */ 
  -    public void store(Object key, Object value);
  -
  -    /**
  -     * Holds the given object in a volatile state. This means
  -     * the object store will discard held objects if the
  -     * virtual machine is restarted or some error happens.
  -     */ 
  -    public void hold(Object key, Object value);
  -    
  -    /**
  -     * Remove the object associated to the given key.
  -     */
  -    public void remove(Object key);
  -    
  -    /**
  -     * Indicates if the given key is associated to a contained object.
  -     */
  -    public boolean containsKey(Object key);
  -    
  -    /**
  -     * Returns the list of used keys as an Enumeration of Objects.
  -     */
  -    public Enumeration keys();
  -    
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.components.store;
  +
  +import java.util.Enumeration;
  +import org.apache.avalon.Component;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
  + *         (Betaversion Productions)
  + * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  + *         (Apache Software Foundation)
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/29 18:30:33 $
  + */
  +public interface Store extends Component {
  +
  +    /**
  +     * Get the object associated to the given unique key.
  +     */
  +    public Object get(Object key);
  +    
  +    /**
  +     * Store the given object in a persistent state. It is up to the
  +     * caller to ensure that the key has a persistent state across
  +     * different JVM executions.
  +     */ 
  +    public void store(Object key, Object value);
  +
  +    /**
  +     * Holds the given object in a volatile state. This means
  +     * the object store will discard held objects if the
  +     * virtual machine is restarted or some error happens.
  +     */ 
  +    public void hold(Object key, Object value);
  +    
  +    /**
  +     * Remove the object associated to the given key.
  +     */
  +    public void remove(Object key);
  +    
  +    /**
  +     * Indicates if the given key is associated to a contained object.
  +     */
  +    public boolean containsKey(Object key);
  +    
  +    /**
  +     * Returns the list of used keys as an Enumeration of Objects.
  +     */
  +    public Enumeration keys();
  +    
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +246 -246  
xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpRequest.java
  
  Index: HttpRequest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpRequest.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- HttpRequest.java  2000/07/22 20:41:44     1.1.2.3
  +++ HttpRequest.java  2000/07/29 18:30:34     1.1.2.4
  @@ -1,246 +1,246 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.environment.http;
  -
  -import java.io.BufferedReader;
  -import java.io.IOException;
  -import java.io.UnsupportedEncodingException;
  -import java.util.Enumeration;
  -import java.util.Locale;
  -
  -import javax.servlet.ServletInputStream;
  -import javax.servlet.RequestDispatcher;
  -
  -import javax.servlet.http.Cookie;
  -import javax.servlet.http.HttpServletRequest;
  -import javax.servlet.http.HttpSession;
  -
  -/**
  - *
  - * Implements the [EMAIL PROTECTED] javax.servlet.http.HttpServletRequest} 
interface
  - * to provide request information for HTTP servlets. 
  - */
  -
  -public class HttpRequest implements HttpServletRequest {
  -
  -    /** The real HttpServletRequest object */
  -    private HttpServletRequest req = null;
  -
  -    /** The HttpEnvironment object */
  -    private HttpEnvironment env = null;
  -
  -    /**
  -     * Creates a HttpServletRequest based on a real HttpServletRequest object
  -     */
  -    protected HttpRequest (HttpServletRequest req, HttpEnvironment env) {
  -        super ();
  -        this.req = req;
  -        this.env = env;
  -    }
  -
  -    /* The HttpServletRequest interface methods */
  -
  -    public String getAuthType() {
  -        return this.req.getAuthType();
  -    }
  -
  -    public Cookie[] getCookies() {
  -        return this.req.getCookies();
  -    }    
  -
  -    public long getDateHeader(String name) {
  -        return this.req.getDateHeader(name);
  -    }
  -
  -    public String getHeader(String name) {
  -        return this.req.getHeader(name); 
  -    }
  -
  -    public Enumeration getHeaders(String name) {
  -        return this.req.getHeaders(name); 
  -    }
  -
  -    public Enumeration getHeaderNames() {
  -        return this.req.getHeaderNames();
  -    }
  -
  -    public int getIntHeader(String name) {
  -        return this.req.getIntHeader(name);
  -    }
  -
  -    public String getMethod() {
  -        return this.req.getMethod();
  -    }
  -     
  -    public String getPathInfo() {
  -        return this.req.getPathInfo();
  -    }
  -
  -    public String getPathTranslated() {
  -        return this.req.getPathTranslated();
  -    }
  -
  -    public String getContextPath() {
  -        return this.req.getContextPath();
  -    }
  -
  -    public String getQueryString() {
  -        return this.req.getQueryString();
  -    }
  -
  -    public String getRemoteUser() {
  -        return this.req.getRemoteUser();
  -    }
  -
  -    public boolean isUserInRole(String role) {
  -        return this.req.isUserInRole(role);
  -    }
  -
  -    public java.security.Principal getUserPrincipal() {
  -        return this.req.getUserPrincipal();
  -    }
  -
  -    public String getRequestedSessionId() {
  -        return this.req.getRequestedSessionId();
  -    }
  -
  -    public String getRequestURI() {
  -        return this.env.getUri();
  -    }
  -
  -    public String getServletPath() {
  -        return this.req.getServletPath();
  -    }
  -
  -    public HttpSession getSession(boolean create) {
  -        return this.req.getSession(create);
  -    }
  -
  -    public HttpSession getSession() {
  -        return this.req.getSession();
  -    }
  -
  -    public boolean isRequestedSessionIdValid() {
  -        return this.req.isRequestedSessionIdValid();
  -    }
  -
  -    public boolean isRequestedSessionIdFromCookie()  {
  -        return this.req.isRequestedSessionIdFromCookie();
  -    }
  -    
  -    public boolean isRequestedSessionIdFromURL() {
  -        return this.req.isRequestedSessionIdFromURL();
  -    }
  -
  -    /**
  -     * @deprecated           As of Version 2.1 of the Java Servlet
  -     *                               API, use [EMAIL PROTECTED] 
#isRequestedSessionIdFromURL}
  -     *                               instead.
  -     */
  -    public boolean isRequestedSessionIdFromUrl() {
  -        return this.req.isRequestedSessionIdFromUrl();
  -    }
  -
  -    /* The ServletRequest interface methods */
  -
  -    public Object getAttribute(String name) {
  -        return this.req.getAttribute(name);
  -    }
  -
  -    public Enumeration getAttributeNames() {
  -        return this.req.getAttributeNames();
  -    }
  -
  -    public String getCharacterEncoding() {
  -        return this.req.getCharacterEncoding();
  -    }
  -
  -    public int getContentLength() {
  -        return this.req.getContentLength();
  -    }
  -
  -    public String getContentType() {
  -        return this.req.getContentType();
  -    }
  -
  -    public ServletInputStream getInputStream() throws IOException {
  -        return this.req.getInputStream(); 
  -    }
  -
  -    public String getParameter(String name) {
  -        return this.req.getParameter(name);
  -    }
  -     
  -    public Enumeration getParameterNames() {
  -        return this.req.getParameterNames();
  -    }
  -
  -    public String[] getParameterValues(String name) {
  -        return this.req.getParameterValues(name);
  -    }
  -    
  -    public String getProtocol() {
  -        return this.req.getProtocol();
  -    }
  -
  -    public String getScheme() {
  -        return this.req.getScheme();
  -    }
  -
  -    public String getServerName() {
  -        return this.req.getServerName();
  -    }
  -
  -    public int getServerPort() {
  -        return this.req.getServerPort();
  -    }
  -
  -    public BufferedReader getReader() throws IOException {
  -        return this.req.getReader();
  -    }
  -    
  -    public String getRemoteAddr() {
  -        return this.req.getRemoteAddr();
  -    }
  -
  -    public String getRemoteHost() {
  -        return this.req.getRemoteHost();
  -    }
  -
  -    public void setAttribute(String name, Object o) {
  -        this.req.setAttribute(name, o);
  -    }
  -
  -    public void removeAttribute(String name) {
  -        this.req.removeAttribute(name);
  -    }
  -
  -    public Locale getLocale() {
  -        return this.req.getLocale();
  -    }
  -
  -    public Enumeration getLocales() {
  -        return this.req.getLocales();
  -    }
  -
  -    public boolean isSecure() {
  -        return this.req.isSecure();
  -    }
  -
  -    public RequestDispatcher getRequestDispatcher(String path) {
  -        return this.req.getRequestDispatcher(path);
  -    }
  -
  -    /**
  -     * @deprecated   As of Version 2.1 of the Java Servlet API,
  -     *                       use [EMAIL PROTECTED] 
ServletContext#getRealPath} instead.
  -     */
  -    public String getRealPath(String path) {
  -        return this.req.getRealPath(path);
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.environment.http;
  +
  +import java.io.BufferedReader;
  +import java.io.IOException;
  +import java.io.UnsupportedEncodingException;
  +import java.util.Enumeration;
  +import java.util.Locale;
  +
  +import javax.servlet.ServletInputStream;
  +import javax.servlet.RequestDispatcher;
  +
  +import javax.servlet.http.Cookie;
  +import javax.servlet.http.HttpServletRequest;
  +import javax.servlet.http.HttpSession;
  +
  +/**
  + *
  + * Implements the [EMAIL PROTECTED] javax.servlet.http.HttpServletRequest} 
interface
  + * to provide request information for HTTP servlets. 
  + */
  +
  +public class HttpRequest implements HttpServletRequest {
  +
  +    /** The real HttpServletRequest object */
  +    private HttpServletRequest req = null;
  +
  +    /** The HttpEnvironment object */
  +    private HttpEnvironment env = null;
  +
  +    /**
  +     * Creates a HttpServletRequest based on a real HttpServletRequest object
  +     */
  +    protected HttpRequest (HttpServletRequest req, HttpEnvironment env) {
  +        super ();
  +        this.req = req;
  +        this.env = env;
  +    }
  +
  +    /* The HttpServletRequest interface methods */
  +
  +    public String getAuthType() {
  +        return this.req.getAuthType();
  +    }
  +
  +    public Cookie[] getCookies() {
  +        return this.req.getCookies();
  +    }    
  +
  +    public long getDateHeader(String name) {
  +        return this.req.getDateHeader(name);
  +    }
  +
  +    public String getHeader(String name) {
  +        return this.req.getHeader(name); 
  +    }
  +
  +    public Enumeration getHeaders(String name) {
  +        return this.req.getHeaders(name); 
  +    }
  +
  +    public Enumeration getHeaderNames() {
  +        return this.req.getHeaderNames();
  +    }
  +
  +    public int getIntHeader(String name) {
  +        return this.req.getIntHeader(name);
  +    }
  +
  +    public String getMethod() {
  +        return this.req.getMethod();
  +    }
  +     
  +    public String getPathInfo() {
  +        return this.req.getPathInfo();
  +    }
  +
  +    public String getPathTranslated() {
  +        return this.req.getPathTranslated();
  +    }
  +
  +    public String getContextPath() {
  +        return this.req.getContextPath();
  +    }
  +
  +    public String getQueryString() {
  +        return this.req.getQueryString();
  +    }
  +
  +    public String getRemoteUser() {
  +        return this.req.getRemoteUser();
  +    }
  +
  +    public boolean isUserInRole(String role) {
  +        return this.req.isUserInRole(role);
  +    }
  +
  +    public java.security.Principal getUserPrincipal() {
  +        return this.req.getUserPrincipal();
  +    }
  +
  +    public String getRequestedSessionId() {
  +        return this.req.getRequestedSessionId();
  +    }
  +
  +    public String getRequestURI() {
  +        return this.env.getUri();
  +    }
  +
  +    public String getServletPath() {
  +        return this.req.getServletPath();
  +    }
  +
  +    public HttpSession getSession(boolean create) {
  +        return this.req.getSession(create);
  +    }
  +
  +    public HttpSession getSession() {
  +        return this.req.getSession();
  +    }
  +
  +    public boolean isRequestedSessionIdValid() {
  +        return this.req.isRequestedSessionIdValid();
  +    }
  +
  +    public boolean isRequestedSessionIdFromCookie()  {
  +        return this.req.isRequestedSessionIdFromCookie();
  +    }
  +    
  +    public boolean isRequestedSessionIdFromURL() {
  +        return this.req.isRequestedSessionIdFromURL();
  +    }
  +
  +    /**
  +     * @deprecated           As of Version 2.1 of the Java Servlet
  +     *                               API, use [EMAIL PROTECTED] 
#isRequestedSessionIdFromURL}
  +     *                               instead.
  +     */
  +    public boolean isRequestedSessionIdFromUrl() {
  +        return this.req.isRequestedSessionIdFromUrl();
  +    }
  +
  +    /* The ServletRequest interface methods */
  +
  +    public Object getAttribute(String name) {
  +        return this.req.getAttribute(name);
  +    }
  +
  +    public Enumeration getAttributeNames() {
  +        return this.req.getAttributeNames();
  +    }
  +
  +    public String getCharacterEncoding() {
  +        return this.req.getCharacterEncoding();
  +    }
  +
  +    public int getContentLength() {
  +        return this.req.getContentLength();
  +    }
  +
  +    public String getContentType() {
  +        return this.req.getContentType();
  +    }
  +
  +    public ServletInputStream getInputStream() throws IOException {
  +        return this.req.getInputStream(); 
  +    }
  +
  +    public String getParameter(String name) {
  +        return this.req.getParameter(name);
  +    }
  +     
  +    public Enumeration getParameterNames() {
  +        return this.req.getParameterNames();
  +    }
  +
  +    public String[] getParameterValues(String name) {
  +        return this.req.getParameterValues(name);
  +    }
  +    
  +    public String getProtocol() {
  +        return this.req.getProtocol();
  +    }
  +
  +    public String getScheme() {
  +        return this.req.getScheme();
  +    }
  +
  +    public String getServerName() {
  +        return this.req.getServerName();
  +    }
  +
  +    public int getServerPort() {
  +        return this.req.getServerPort();
  +    }
  +
  +    public BufferedReader getReader() throws IOException {
  +        return this.req.getReader();
  +    }
  +    
  +    public String getRemoteAddr() {
  +        return this.req.getRemoteAddr();
  +    }
  +
  +    public String getRemoteHost() {
  +        return this.req.getRemoteHost();
  +    }
  +
  +    public void setAttribute(String name, Object o) {
  +        this.req.setAttribute(name, o);
  +    }
  +
  +    public void removeAttribute(String name) {
  +        this.req.removeAttribute(name);
  +    }
  +
  +    public Locale getLocale() {
  +        return this.req.getLocale();
  +    }
  +
  +    public Enumeration getLocales() {
  +        return this.req.getLocales();
  +    }
  +
  +    public boolean isSecure() {
  +        return this.req.isSecure();
  +    }
  +
  +    public RequestDispatcher getRequestDispatcher(String path) {
  +        return this.req.getRequestDispatcher(path);
  +    }
  +
  +    /**
  +     * @deprecated   As of Version 2.1 of the Java Servlet API,
  +     *                       use [EMAIL PROTECTED] 
ServletContext#getRealPath} instead.
  +     */
  +    public String getRealPath(String path) {
  +        return this.req.getRealPath(path);
  +    }
  +}
  
  
  
  1.1.2.3   +180 -180  
xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpResponse.java
  
  Index: HttpResponse.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpResponse.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- HttpResponse.java 2000/07/22 20:41:45     1.1.2.2
  +++ HttpResponse.java 2000/07/29 18:30:34     1.1.2.3
  @@ -1,180 +1,180 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.environment.http;
  -
  -import java.io.IOException;
  -import java.io.PrintWriter;
  -import java.io.UnsupportedEncodingException;
  -import java.util.Locale;
  -
  -import javax.servlet.http.HttpServletResponse;
  -import javax.servlet.http.Cookie;
  -import javax.servlet.ServletException;
  -import javax.servlet.ServletOutputStream;
  -
  -/**
  - *
  - * Implements the [EMAIL PROTECTED] HttpServletResponse} interface to 
provide HTTP-specific
  - * functionality in sending a response.  For example, it has methods
  - * to access HTTP headers and cookies.
  - */
  -
  -public class HttpResponse implements HttpServletResponse {
  -
  -    /** The real HttpServletResponse object */
  -    private HttpServletResponse res = null;
  -
  -    /**
  -     * Creates a HttpServletResponse based on a real HttpServletResponse 
object
  -     */
  -    protected HttpResponse (HttpServletResponse res) {
  -        super ();
  -        this.res = res;
  -    }
  -
  -    /* The HttpServletResponse interface methods */
  -
  -    public void addCookie(Cookie cookie) {
  -        this.res.addCookie(cookie);
  -    }
  -
  -    public boolean containsHeader(String name) {
  -        return this.res.containsHeader(name);
  -    }
  -
  -    public String encodeURL(String url) {
  -        return this.res.encodeURL(url);
  -    }
  -
  -    public String encodeRedirectURL(String url) {
  -        return this.res.encodeRedirectURL(url);
  -    }
  -
  -    public void sendError(int sc, String msg) throws IOException {
  -        this.res.sendError(sc, msg);
  -    }
  -
  -    public void sendError(int sc) throws IOException {
  -        this.res.sendError(sc);
  -    }
  -
  -    public void sendRedirect(String location) throws IOException {
  -        this.res.sendRedirect(location);
  -    }
  -
  -    public void setDateHeader(String name, long date) {
  -        this.res.setDateHeader(name, date);
  -    }
  -
  -    public void addDateHeader(String name, long date) {
  -        this.res.addDateHeader(name, date);
  -    }
  -
  -    public void setHeader(String name, String value) {
  -        this.res.setHeader(name, value);
  -    }
  -
  -    public void addHeader(String name, String value) {
  -        this.res.addHeader(name, value);
  -    }
  -
  -    public void setIntHeader(String name, int value) {
  -        this.res.setIntHeader(name, value);
  -    }
  -
  -    public void addIntHeader(String name, int value) {
  -        this.res.addIntHeader(name, value);
  -    }
  -
  -    public void setStatus(int sc) {
  -        this.res.setStatus(sc);
  -    }
  -
  -    /**
  -     * @deprecated   As of version 2.1, use encodeURL(String url) instead
  -     */
  -    public String encodeUrl(String url) {
  -        return this.res.encodeUrl(url);
  -    }
  -
  -    /**
  -     * @deprecated   As of version 2.1, use 
  -     *                       encodeRedirectURL(String url) instead
  -     */
  -    public String encodeRedirectUrl(String url) {
  -        return this.res.encodeRedirectUrl(url);
  -    }
  -
  -    /**
  -     * @deprecated As of version 2.1, due to ambiguous meaning of the 
  -     * message parameter. To set a status code 
  -     * use <code>setStatus(int)</code>, to send an error with a description
  -     * use <code>sendError(int, String)</code>.
  -     */
  -    public void setStatus(int sc, String sm) {
  -        this.res.setStatus(sc, sm);
  -    }
  -
  -    /* The ServletResponse interface methods */
  -  
  -    public String getCharacterEncoding() {
  -        return this.res.getCharacterEncoding();
  -    }
  -
  -    public ServletOutputStream getOutputStream() throws IOException {
  -        //FIXME: How to query if a Serializer/Reader is calleng this ?
  -        if (1==1 /* is the calling object not a serializer/reader ? */) {
  -            throw new IllegalStateException ("you are not a serializer or 
reader");
  -        }
  -        return this.res.getOutputStream();
  -    }
  -
  -    public PrintWriter getWriter() throws IOException {
  -        if (1==1 /* is the calling object not a serializer/reader ? */) {
  -            throw new IllegalStateException ("you are not a serializer or 
reader");
  -        }
  -        return this.res.getWriter();
  -    }
  -
  -    public void setContentLength(int len) {
  -        this.res.setContentLength(len);
  -    }
  -
  -    public void setContentType(String type) {
  -        this.res.setContentType(type);
  -    }
  -
  -    public void setBufferSize(int size) {
  -        this.res.setBufferSize(size);
  -    }
  -
  -    public int getBufferSize() {
  -        return this.res.getBufferSize();
  -    }
  -
  -    public void flushBuffer() throws IOException {
  -        this.res.flushBuffer();
  -    }
  -
  -    public boolean isCommitted() {
  -        return this.res.isCommitted();
  -    }
  -
  -    public void reset() {
  -        this.res.reset();
  -    }
  -
  -    public void setLocale(Locale loc) {
  -        this.res.setLocale(loc);
  -    }
  -
  -    public Locale getLocale() {
  -        return this.res.getLocale();
  -    }
  -}
  -
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.environment.http;
  +
  +import java.io.IOException;
  +import java.io.PrintWriter;
  +import java.io.UnsupportedEncodingException;
  +import java.util.Locale;
  +
  +import javax.servlet.http.HttpServletResponse;
  +import javax.servlet.http.Cookie;
  +import javax.servlet.ServletException;
  +import javax.servlet.ServletOutputStream;
  +
  +/**
  + *
  + * Implements the [EMAIL PROTECTED] HttpServletResponse} interface to 
provide HTTP-specific
  + * functionality in sending a response.  For example, it has methods
  + * to access HTTP headers and cookies.
  + */
  +
  +public class HttpResponse implements HttpServletResponse {
  +
  +    /** The real HttpServletResponse object */
  +    private HttpServletResponse res = null;
  +
  +    /**
  +     * Creates a HttpServletResponse based on a real HttpServletResponse 
object
  +     */
  +    protected HttpResponse (HttpServletResponse res) {
  +        super ();
  +        this.res = res;
  +    }
  +
  +    /* The HttpServletResponse interface methods */
  +
  +    public void addCookie(Cookie cookie) {
  +        this.res.addCookie(cookie);
  +    }
  +
  +    public boolean containsHeader(String name) {
  +        return this.res.containsHeader(name);
  +    }
  +
  +    public String encodeURL(String url) {
  +        return this.res.encodeURL(url);
  +    }
  +
  +    public String encodeRedirectURL(String url) {
  +        return this.res.encodeRedirectURL(url);
  +    }
  +
  +    public void sendError(int sc, String msg) throws IOException {
  +        this.res.sendError(sc, msg);
  +    }
  +
  +    public void sendError(int sc) throws IOException {
  +        this.res.sendError(sc);
  +    }
  +
  +    public void sendRedirect(String location) throws IOException {
  +        this.res.sendRedirect(location);
  +    }
  +
  +    public void setDateHeader(String name, long date) {
  +        this.res.setDateHeader(name, date);
  +    }
  +
  +    public void addDateHeader(String name, long date) {
  +        this.res.addDateHeader(name, date);
  +    }
  +
  +    public void setHeader(String name, String value) {
  +        this.res.setHeader(name, value);
  +    }
  +
  +    public void addHeader(String name, String value) {
  +        this.res.addHeader(name, value);
  +    }
  +
  +    public void setIntHeader(String name, int value) {
  +        this.res.setIntHeader(name, value);
  +    }
  +
  +    public void addIntHeader(String name, int value) {
  +        this.res.addIntHeader(name, value);
  +    }
  +
  +    public void setStatus(int sc) {
  +        this.res.setStatus(sc);
  +    }
  +
  +    /**
  +     * @deprecated   As of version 2.1, use encodeURL(String url) instead
  +     */
  +    public String encodeUrl(String url) {
  +        return this.res.encodeUrl(url);
  +    }
  +
  +    /**
  +     * @deprecated   As of version 2.1, use 
  +     *                       encodeRedirectURL(String url) instead
  +     */
  +    public String encodeRedirectUrl(String url) {
  +        return this.res.encodeRedirectUrl(url);
  +    }
  +
  +    /**
  +     * @deprecated As of version 2.1, due to ambiguous meaning of the 
  +     * message parameter. To set a status code 
  +     * use <code>setStatus(int)</code>, to send an error with a description
  +     * use <code>sendError(int, String)</code>.
  +     */
  +    public void setStatus(int sc, String sm) {
  +        this.res.setStatus(sc, sm);
  +    }
  +
  +    /* The ServletResponse interface methods */
  +  
  +    public String getCharacterEncoding() {
  +        return this.res.getCharacterEncoding();
  +    }
  +
  +    public ServletOutputStream getOutputStream() throws IOException {
  +        //FIXME: How to query if a Serializer/Reader is calleng this ?
  +        if (1==1 /* is the calling object not a serializer/reader ? */) {
  +            throw new IllegalStateException ("you are not a serializer or 
reader");
  +        }
  +        return this.res.getOutputStream();
  +    }
  +
  +    public PrintWriter getWriter() throws IOException {
  +        if (1==1 /* is the calling object not a serializer/reader ? */) {
  +            throw new IllegalStateException ("you are not a serializer or 
reader");
  +        }
  +        return this.res.getWriter();
  +    }
  +
  +    public void setContentLength(int len) {
  +        this.res.setContentLength(len);
  +    }
  +
  +    public void setContentType(String type) {
  +        this.res.setContentType(type);
  +    }
  +
  +    public void setBufferSize(int size) {
  +        this.res.setBufferSize(size);
  +    }
  +
  +    public int getBufferSize() {
  +        return this.res.getBufferSize();
  +    }
  +
  +    public void flushBuffer() throws IOException {
  +        this.res.flushBuffer();
  +    }
  +
  +    public boolean isCommitted() {
  +        return this.res.isCommitted();
  +    }
  +
  +    public void reset() {
  +        this.res.reset();
  +    }
  +
  +    public void setLocale(Locale loc) {
  +        this.res.setLocale(loc);
  +    }
  +
  +    public Locale getLocale() {
  +        return this.res.getLocale();
  +    }
  +}
  +
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +131 -131  
xml-cocoon/src/org/apache/cocoon/generation/Attic/AbstractServerPage.java
  
  Index: AbstractServerPage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/AbstractServerPage.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- AbstractServerPage.java   2000/07/28 16:20:17     1.1.2.3
  +++ AbstractServerPage.java   2000/07/29 18:30:34     1.1.2.4
  @@ -1,133 +1,133 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.generation;
  -
  -import org.apache.avalon.Modifiable;
  -
  -import java.io.File;
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.generation;
  +
  +import org.apache.avalon.Modifiable;
  +
  +import java.io.File;
   //import org.apache.cocoon.Request; 
   import org.apache.cocoon.environment.Environment; 
  -import org.xml.sax.helpers.AttributesImpl;
  -
  -import org.xml.sax.SAXException;
  -
  -/**
  - * Base implementation of <code>ServerPagesGenerator</code>. This class
  - * declares variables that must be explicitly initialized by code generators.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/28 16:20:17 $
  - */
  -public abstract class AbstractServerPage
  -  extends ComposerGenerator
  -  implements Modifiable
  -{
  -  /**
  -   * Code generators should produce a static
  -   * block that initializes the generator's
  -   * creation date and file dependency list.
  -   * Example:
  -   *
  -   *  static {
  -   *    dateCreated = 958058788948L;
  -   *    dependencies = new File[] {
  -   *      new File("source.xml"),
  -   *    };
  -   *  }
  -   *
  -   */
  -
  -  /** The creation date */
  -  protected static long dateCreated = -1L;
  -  /** The dependency file list */
  -  protected static File[] dependencies = null;
  -
  -  /**
  -   * Determines whether this generator's source files have changed
  -   *
  -   * @return Whether any of the files this generator depends on has changed
  -   * since it was created
  -   */
  -  public final boolean modifiedSince(long date) {
  -    if (dateCreated < date) {
  -      return true;
  -    }
  -
  -    for (int i = 0; i < dependencies.length; i++) {
  -      if (dateCreated < dependencies[i].lastModified()) {
  -        return true;
  -      }
  -    }
  -
  -    return false;
  -  }
  -
  -  /**
  -   * Determines whether generated content has changed since
  -   * last invocation. Users may override this method to take
  -   * advantage of SAX event cacheing
  -   *
  -   * @param request The request whose data must be inspected to assert 
whether
  -   * dynamically generated content has changed
  -   * @return Whether content has changes for this request's data
  -   */
  -  public boolean hasContentChanged(Environment environment) {
  -    return true;
  -  }
  -
  -  // FIXME: Add more methods!
  -  /* SAX Utility Methods */
  -  /**
  -   * Add an attribute
  -   *
  -   * @param attr The attribute list to add to
  -   * @param name The attribute name
  -   * @param value The attribute value
  -   */
  -  protected void attribute(AttributesImpl attr, String name, String value) {
  -    attr.addAttribute("", name, name, "CDATA", value);
  -  } 
  -
  -  /**
  -   * Start an element 
  -   *
  -   * @param name The element name
  -   * @param attr The element attributes
  -   */
  -  protected void start(String name, AttributesImpl attr) throws SAXException 
{
  -    this.contentHandler.startElement("", name, name, attr);
  -    attr.clear();
  -  } 
  -
  -  /**
  -   * End an element
  -   * 
  -   * @param name The element name
  -   */
  -  protected void end(String name) throws SAXException {
  -    this.contentHandler.endElement("", name, name);
  -  } 
  -
  -  /**
  -   * Add character data
  -   * 
  -   * @param data The character data
  -   */
  -  protected void characters(String data) throws SAXException {
  -    this.contentHandler.characters(data.toCharArray(), 0, data.length());
  -  } 
  -
  -  /**
  -   * Add a comment
  -   * 
  -   * @param comment The comment data
  -   */
  -  protected void comment(String data) throws SAXException {
  -    this.lexicalHandler.comment(data.toCharArray(), 0, data.length());
  -  } 
  -}
  +import org.xml.sax.helpers.AttributesImpl;
  +
  +import org.xml.sax.SAXException;
  +
  +/**
  + * Base implementation of <code>ServerPagesGenerator</code>. This class
  + * declares variables that must be explicitly initialized by code generators.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:34 $
  + */
  +public abstract class AbstractServerPage
  +  extends ComposerGenerator
  +  implements Modifiable
  +{
  +  /**
  +   * Code generators should produce a static
  +   * block that initializes the generator's
  +   * creation date and file dependency list.
  +   * Example:
  +   *
  +   *  static {
  +   *    dateCreated = 958058788948L;
  +   *    dependencies = new File[] {
  +   *      new File("source.xml"),
  +   *    };
  +   *  }
  +   *
  +   */
  +
  +  /** The creation date */
  +  protected static long dateCreated = -1L;
  +  /** The dependency file list */
  +  protected static File[] dependencies = null;
  +
  +  /**
  +   * Determines whether this generator's source files have changed
  +   *
  +   * @return Whether any of the files this generator depends on has changed
  +   * since it was created
  +   */
  +  public final boolean modifiedSince(long date) {
  +    if (dateCreated < date) {
  +      return true;
  +    }
  +
  +    for (int i = 0; i < dependencies.length; i++) {
  +      if (dateCreated < dependencies[i].lastModified()) {
  +        return true;
  +      }
  +    }
  +
  +    return false;
  +  }
  +
  +  /**
  +   * Determines whether generated content has changed since
  +   * last invocation. Users may override this method to take
  +   * advantage of SAX event cacheing
  +   *
  +   * @param request The request whose data must be inspected to assert 
whether
  +   * dynamically generated content has changed
  +   * @return Whether content has changes for this request's data
  +   */
  +  public boolean hasContentChanged(Environment environment) {
  +    return true;
  +  }
  +
  +  // FIXME: Add more methods!
  +  /* SAX Utility Methods */
  +  /**
  +   * Add an attribute
  +   *
  +   * @param attr The attribute list to add to
  +   * @param name The attribute name
  +   * @param value The attribute value
  +   */
  +  protected void attribute(AttributesImpl attr, String name, String value) {
  +    attr.addAttribute("", name, name, "CDATA", value);
  +  } 
  +
  +  /**
  +   * Start an element 
  +   *
  +   * @param name The element name
  +   * @param attr The element attributes
  +   */
  +  protected void start(String name, AttributesImpl attr) throws SAXException 
{
  +    this.contentHandler.startElement("", name, name, attr);
  +    attr.clear();
  +  } 
  +
  +  /**
  +   * End an element
  +   * 
  +   * @param name The element name
  +   */
  +  protected void end(String name) throws SAXException {
  +    this.contentHandler.endElement("", name, name);
  +  } 
  +
  +  /**
  +   * Add character data
  +   * 
  +   * @param data The character data
  +   */
  +  protected void characters(String data) throws SAXException {
  +    this.contentHandler.characters(data.toCharArray(), 0, data.length());
  +  } 
  +
  +  /**
  +   * Add a comment
  +   * 
  +   * @param comment The comment data
  +   */
  +  protected void comment(String data) throws SAXException {
  +    this.lexicalHandler.comment(data.toCharArray(), 0, data.length());
  +  } 
  +}
  
  
  
  1.1.2.3   +160 -160  
xml-cocoon/src/org/apache/cocoon/generation/Attic/ImageDirectoryGenerator.java
  
  Index: ImageDirectoryGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/ImageDirectoryGenerator.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ImageDirectoryGenerator.java      2000/07/22 20:41:47     1.1.2.2
  +++ ImageDirectoryGenerator.java      2000/07/29 18:30:34     1.1.2.3
  @@ -1,160 +1,160 @@
  -package org.apache.cocoon.generation;
  -
  -import java.io.*;
  -import java.util.*;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * An extension of DirectoryGenerators that adds extra attributes for image
  - * files.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Donald A. Ball Jr.</a>
  - * @version $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:47 $
  - */
  -public class ImageDirectoryGenerator extends DirectoryGenerator {
  -
  -     protected static String IMAGE_WIDTH_ATTR_NAME = "width";
  -     protected static String IMAGE_HEIGHT_ATTR_NAME = "height";
  -
  -     /**
  -      * Extends the <code>setNodeAttributes</code> method from the 
  -      * <code>DirectoryGenerator</code> by adding width and height attributes
  -      * if the path is a GIF or a JPEG file.
  -      */
  -     protected void setNodeAttributes(File path) throws SAXException {
  -             super.setNodeAttributes(path);
  -             if (path.isDirectory()) {
  -                     return;
  -             }
  -             try {
  -                     int dim[] = getSize(path);
  -                     
attributes.addAttribute("",IMAGE_WIDTH_ATTR_NAME,IMAGE_WIDTH_ATTR_NAME,"CDATA",""+dim[0]);
  -                     
attributes.addAttribute("",IMAGE_HEIGHT_ATTR_NAME,IMAGE_HEIGHT_ATTR_NAME,"CDATA",""+dim[1]);
  -             } catch (RuntimeException e) {}
  -             catch (Exception e) {
  -                     throw new SAXException(e);
  -             }
  -     }
  -
  -     // returns width as first element, height as second
  -     public static int[] getSize(File file) throws FileNotFoundException, 
IOException {
  -             String type = getFileType(file);
  -             try {
  -                     if(type.equals("gif")) return getGifSize(file);
  -                     else return getJpegSize(file);
  -             } catch(Exception e) {
  -                     throw new RuntimeException("File is not a valid GIF or 
Jpeg");
  -             }
  -
  -     }
  -
  -     // returns width as first element, height as second
  -     public static int[] getJpegSize(File file) throws 
FileNotFoundException, IOException {
  -             BufferedReader in = null;
  -             try {
  -                     in = new BufferedReader(new FileReader(file));
  -                     // check for "magic" header
  -                     char[] buf = new char[2];
  -                     int count = in.read(buf, 0, 2);
  -                     if(count < 2) throw new RuntimeException("Not a valid 
Jpeg file!");
  -                     if((buf[0]) != 0xFF 
  -                     || (buf[1]) != 0xD8 )
  -                     throw new RuntimeException("Not a valid Jpeg file!");
  -
  -                     int width = 0;
  -                     int height = 0;
  -
  -                     boolean done = false;
  -                     int ch = 0;
  -
  -                     try {
  -                             while(ch != 0xDA && !done) {
  -                                     /* Find next marker (JPEG markers begin 
with 0xFF) */
  -                                     while (ch != 0xFF) { ch = in.read(); }
  -                                     /* JPEG markers can be padded with 
unlimited 0xFF's */
  -                                     while (ch == 0xFF) { ch = in.read(); }
  -                                     /* Now, ch contains the value of the 
marker. */
  -                                     if(ch >= 0xC0 && ch <= 0xC3) {
  -                                             // skip 3 bytes
  -                                             in.read();
  -                                             in.read();
  -                                             in.read();
  -                                             height = 256 * in.read();
  -                                             height += in.read();
  -                                             width = 256 * in.read();
  -                                             width += in.read();
  -                                             done = true;
  -                                     } else {
  -                                             /* We MUST skip variables, 
since FF's within variable names are NOT valid JPEG markers */
  -                                             int length = 256 * in.read();
  -                                             length += in.read();
  -                                             if(length < 2) throw new 
RuntimeException("Erroneous JPEG marker length");
  -                                             for(int foo = 0; foo<length-2; 
foo++)
  -                                                     in.read();
  -                                     }
  -                             }
  -                     } catch(Exception e) {
  -                             throw new RuntimeException("Not a valid Jpeg 
file!");
  -                     }
  -
  -                     int[] dim = { width, height };
  -                     return dim;
  -
  -             } finally {
  -                     if(in != null) try { in.close(); } catch(Exception e) {}
  -             }
  -     }
  -
  -     // returns width as first element, height as second
  -     public static int[] getGifSize(File file) throws FileNotFoundException, 
IOException {
  -             BufferedReader in = null;
  -             try {
  -                     in = new BufferedReader(new FileReader(file));
  -                     char[] buf = new char[10];
  -                     int count = in.read(buf, 0, 10);
  -                     if(count < 10) throw new RuntimeException("Not a valid 
GIF file!");
  -                     if((buf[0]) != 'G' 
  -                     || (buf[1]) != 'I' 
  -                     || (buf[2]) != 'F' )
  -                     throw new RuntimeException("Not a valid GIF file!");
  -
  -                     int w1 = (int)buf[6];
  -                     int w2 = (int)buf[7];
  -                     int h1 = (int)buf[8];
  -                     int h2 = (int)buf[9];
  -
  -                     int width = w1 + (256 * w2);
  -                     int height = h1 + (256 * h2);
  -                     
  -                     int[] dim = { width, height };
  -                     return dim;
  -
  -             } finally {
  -                     if(in != null) try { in.close(); } catch(Exception e) {}
  -             }
  -     }
  -
  -     // returns "gif", "jpeg" or NULL
  -     public static String getFileType(File file) throws 
FileNotFoundException, IOException {
  -             BufferedReader in = null;
  -             try {
  -                     in = new BufferedReader(new FileReader(file));
  -                     char[] buf = new char[3];
  -                     int count = in.read(buf, 0, 3);
  -                     if(count < 3) return null;
  -                     if((buf[0]) == 'G' 
  -                     && (buf[1]) == 'I' 
  -                     && (buf[2]) == 'F' )
  -                     return "gif";
  -
  -                     if((buf[0]) == 0xFF
  -                     && (buf[1]) == 0xD8 )
  -                     return "jpeg";
  -
  -                     return null;
  -
  -             } finally {
  -                     if(in != null) try { in.close(); } catch(Exception e) {}
  -             }
  -     }
  -}
  +package org.apache.cocoon.generation;
  +
  +import java.io.*;
  +import java.util.*;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * An extension of DirectoryGenerators that adds extra attributes for image
  + * files.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Donald A. Ball Jr.</a>
  + * @version $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:34 $
  + */
  +public class ImageDirectoryGenerator extends DirectoryGenerator {
  +
  +     protected static String IMAGE_WIDTH_ATTR_NAME = "width";
  +     protected static String IMAGE_HEIGHT_ATTR_NAME = "height";
  +
  +     /**
  +      * Extends the <code>setNodeAttributes</code> method from the 
  +      * <code>DirectoryGenerator</code> by adding width and height attributes
  +      * if the path is a GIF or a JPEG file.
  +      */
  +     protected void setNodeAttributes(File path) throws SAXException {
  +             super.setNodeAttributes(path);
  +             if (path.isDirectory()) {
  +                     return;
  +             }
  +             try {
  +                     int dim[] = getSize(path);
  +                     
attributes.addAttribute("",IMAGE_WIDTH_ATTR_NAME,IMAGE_WIDTH_ATTR_NAME,"CDATA",""+dim[0]);
  +                     
attributes.addAttribute("",IMAGE_HEIGHT_ATTR_NAME,IMAGE_HEIGHT_ATTR_NAME,"CDATA",""+dim[1]);
  +             } catch (RuntimeException e) {}
  +             catch (Exception e) {
  +                     throw new SAXException(e);
  +             }
  +     }
  +
  +     // returns width as first element, height as second
  +     public static int[] getSize(File file) throws FileNotFoundException, 
IOException {
  +             String type = getFileType(file);
  +             try {
  +                     if(type.equals("gif")) return getGifSize(file);
  +                     else return getJpegSize(file);
  +             } catch(Exception e) {
  +                     throw new RuntimeException("File is not a valid GIF or 
Jpeg");
  +             }
  +
  +     }
  +
  +     // returns width as first element, height as second
  +     public static int[] getJpegSize(File file) throws 
FileNotFoundException, IOException {
  +             BufferedReader in = null;
  +             try {
  +                     in = new BufferedReader(new FileReader(file));
  +                     // check for "magic" header
  +                     char[] buf = new char[2];
  +                     int count = in.read(buf, 0, 2);
  +                     if(count < 2) throw new RuntimeException("Not a valid 
Jpeg file!");
  +                     if((buf[0]) != 0xFF 
  +                     || (buf[1]) != 0xD8 )
  +                     throw new RuntimeException("Not a valid Jpeg file!");
  +
  +                     int width = 0;
  +                     int height = 0;
  +
  +                     boolean done = false;
  +                     int ch = 0;
  +
  +                     try {
  +                             while(ch != 0xDA && !done) {
  +                                     /* Find next marker (JPEG markers begin 
with 0xFF) */
  +                                     while (ch != 0xFF) { ch = in.read(); }
  +                                     /* JPEG markers can be padded with 
unlimited 0xFF's */
  +                                     while (ch == 0xFF) { ch = in.read(); }
  +                                     /* Now, ch contains the value of the 
marker. */
  +                                     if(ch >= 0xC0 && ch <= 0xC3) {
  +                                             // skip 3 bytes
  +                                             in.read();
  +                                             in.read();
  +                                             in.read();
  +                                             height = 256 * in.read();
  +                                             height += in.read();
  +                                             width = 256 * in.read();
  +                                             width += in.read();
  +                                             done = true;
  +                                     } else {
  +                                             /* We MUST skip variables, 
since FF's within variable names are NOT valid JPEG markers */
  +                                             int length = 256 * in.read();
  +                                             length += in.read();
  +                                             if(length < 2) throw new 
RuntimeException("Erroneous JPEG marker length");
  +                                             for(int foo = 0; foo<length-2; 
foo++)
  +                                                     in.read();
  +                                     }
  +                             }
  +                     } catch(Exception e) {
  +                             throw new RuntimeException("Not a valid Jpeg 
file!");
  +                     }
  +
  +                     int[] dim = { width, height };
  +                     return dim;
  +
  +             } finally {
  +                     if(in != null) try { in.close(); } catch(Exception e) {}
  +             }
  +     }
  +
  +     // returns width as first element, height as second
  +     public static int[] getGifSize(File file) throws FileNotFoundException, 
IOException {
  +             BufferedReader in = null;
  +             try {
  +                     in = new BufferedReader(new FileReader(file));
  +                     char[] buf = new char[10];
  +                     int count = in.read(buf, 0, 10);
  +                     if(count < 10) throw new RuntimeException("Not a valid 
GIF file!");
  +                     if((buf[0]) != 'G' 
  +                     || (buf[1]) != 'I' 
  +                     || (buf[2]) != 'F' )
  +                     throw new RuntimeException("Not a valid GIF file!");
  +
  +                     int w1 = (int)buf[6];
  +                     int w2 = (int)buf[7];
  +                     int h1 = (int)buf[8];
  +                     int h2 = (int)buf[9];
  +
  +                     int width = w1 + (256 * w2);
  +                     int height = h1 + (256 * h2);
  +                     
  +                     int[] dim = { width, height };
  +                     return dim;
  +
  +             } finally {
  +                     if(in != null) try { in.close(); } catch(Exception e) {}
  +             }
  +     }
  +
  +     // returns "gif", "jpeg" or NULL
  +     public static String getFileType(File file) throws 
FileNotFoundException, IOException {
  +             BufferedReader in = null;
  +             try {
  +                     in = new BufferedReader(new FileReader(file));
  +                     char[] buf = new char[3];
  +                     int count = in.read(buf, 0, 3);
  +                     if(count < 3) return null;
  +                     if((buf[0]) == 'G' 
  +                     && (buf[1]) == 'I' 
  +                     && (buf[2]) == 'F' )
  +                     return "gif";
  +
  +                     if((buf[0]) == 0xFF
  +                     && (buf[1]) == 0xD8 )
  +                     return "jpeg";
  +
  +                     return null;
  +
  +             } finally {
  +                     if(in != null) try { in.close(); } catch(Exception e) {}
  +             }
  +     }
  +}
  
  
  
  1.1.2.3   +133 -133  
xml-cocoon/src/org/apache/cocoon/generation/Attic/RequestGenerator.java
  
  Index: RequestGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/RequestGenerator.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- RequestGenerator.java     2000/07/22 20:41:47     1.1.2.2
  +++ RequestGenerator.java     2000/07/29 18:30:34     1.1.2.3
  @@ -1,133 +1,133 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.generation;
  -
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.environment.http.HttpEnvironment;
  -
  -import java.util.Enumeration;
  -
  -import org.xml.sax.SAXException;
  -import org.xml.sax.helpers.AttributesImpl;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:47 $
  - */
  -public class RequestGenerator extends AbstractGenerator {
  -
  -    /** The URI of the namespace of this generator. */
  -    private String URI="http://xml.apache.org/cocoon/2.0/RequestGenerator";;
  -
  -    /**
  -     * Generate XML data.
  -     */
  -    public void generate()
  -    throws SAXException {
  -        this.contentHandler.startDocument();
  -        this.contentHandler.startPrefixMapping("",URI);
  -        AttributesImpl attr=new AttributesImpl();
  -        
  -        this.attribute(attr,"target",this.environment.getUri());
  -        this.attribute(attr,"source",this.source);
  -        this.start("request",attr);
  -        this.data("\n");
  -        this.data("\n");
  -
  -        this.data("  ");
  -        this.start("requestHeaders",attr);
  -        this.data("\n");
  -        Enumeration 
headers=((HttpEnvironment)(super.environment)).getRequest().getHeaderNames();
  -        while (headers.hasMoreElements()) {
  -            String header=(String)headers.nextElement();
  -            this.attribute(attr,"name",header);
  -            this.data("    ");
  -            this.start("header",attr);
  -            
this.data(((HttpEnvironment)(super.environment)).getRequest().getHeader(header));
  -            this.end("header");
  -            this.data("\n");
  -        }
  -        this.data("  ");
  -        this.end("requestHeaders");
  -        this.data("\n");
  -        this.data("\n");
  -
  -        this.data("  ");
  -        this.start("requestParameters",attr);
  -        this.data("\n");
  -        Enumeration 
parameters=((HttpEnvironment)(super.environment)).getRequest().getParameterNames();
  -        while (parameters.hasMoreElements()) {
  -            String parameter=(String)parameters.nextElement();
  -            this.attribute(attr,"name",parameter);
  -            this.data("    ");
  -            this.start("parameter",attr);
  -            this.data("\n");
  -            String 
values[]=((HttpEnvironment)(super.environment)).getRequest().getParameterValues(parameter);
  -            if (values!=null) for (int x=0; x<values.length; x++) {
  -                this.data("      ");
  -                this.start("value",attr);
  -                this.data(values[x]);
  -                this.end("value");
  -                this.data("\n");
  -            }
  -            this.data("    ");
  -            this.end("parameter");
  -            this.data("\n");
  -        }
  -        this.data("  ");
  -        this.end("requestParameters");
  -        this.data("\n");
  -        this.data("\n");
  -
  -        this.data("  ");
  -        this.start("configurationParameters",attr);
  -        this.data("\n");
  -        Enumeration confparams=super.parameters.getParameterNames();
  -        while (confparams.hasMoreElements()) {
  -            String parameter=(String)confparams.nextElement();
  -            this.attribute(attr,"name",parameter);
  -            this.data("    ");
  -            this.start("parameter",attr);
  -            this.data(super.parameters.getParameter(parameter,""));
  -            this.end("parameter");
  -            this.data("\n");
  -        }
  -        this.data("  ");
  -        this.end("configurationParameters");
  -        this.data("\n");
  -        this.data("\n");
  -
  -        this.end("request");
  -
  -        // Finish
  -        this.contentHandler.endPrefixMapping("");
  -        this.contentHandler.endDocument();
  -    }
  -    
  -    private void attribute(AttributesImpl attr, String name, String value) {
  -        attr.addAttribute("",name,name,"CDATA",value);
  -    }
  -    
  -    private void start(String name, AttributesImpl attr)
  -    throws SAXException {
  -        super.contentHandler.startElement(URI,name,name,attr);
  -        attr.clear();
  -    }
  -
  -    private void end(String name)
  -    throws SAXException {
  -        super.contentHandler.endElement(URI,name,name);
  -    }
  -    
  -    private void data(String data)
  -    throws SAXException {
  -        super.contentHandler.characters(data.toCharArray(),0,data.length());
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.generation;
  +
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +
  +import java.util.Enumeration;
  +
  +import org.xml.sax.SAXException;
  +import org.xml.sax.helpers.AttributesImpl;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:34 $
  + */
  +public class RequestGenerator extends AbstractGenerator {
  +
  +    /** The URI of the namespace of this generator. */
  +    private String URI="http://xml.apache.org/cocoon/2.0/RequestGenerator";;
  +
  +    /**
  +     * Generate XML data.
  +     */
  +    public void generate()
  +    throws SAXException {
  +        this.contentHandler.startDocument();
  +        this.contentHandler.startPrefixMapping("",URI);
  +        AttributesImpl attr=new AttributesImpl();
  +        
  +        this.attribute(attr,"target",this.environment.getUri());
  +        this.attribute(attr,"source",this.source);
  +        this.start("request",attr);
  +        this.data("\n");
  +        this.data("\n");
  +
  +        this.data("  ");
  +        this.start("requestHeaders",attr);
  +        this.data("\n");
  +        Enumeration 
headers=((HttpEnvironment)(super.environment)).getRequest().getHeaderNames();
  +        while (headers.hasMoreElements()) {
  +            String header=(String)headers.nextElement();
  +            this.attribute(attr,"name",header);
  +            this.data("    ");
  +            this.start("header",attr);
  +            
this.data(((HttpEnvironment)(super.environment)).getRequest().getHeader(header));
  +            this.end("header");
  +            this.data("\n");
  +        }
  +        this.data("  ");
  +        this.end("requestHeaders");
  +        this.data("\n");
  +        this.data("\n");
  +
  +        this.data("  ");
  +        this.start("requestParameters",attr);
  +        this.data("\n");
  +        Enumeration 
parameters=((HttpEnvironment)(super.environment)).getRequest().getParameterNames();
  +        while (parameters.hasMoreElements()) {
  +            String parameter=(String)parameters.nextElement();
  +            this.attribute(attr,"name",parameter);
  +            this.data("    ");
  +            this.start("parameter",attr);
  +            this.data("\n");
  +            String 
values[]=((HttpEnvironment)(super.environment)).getRequest().getParameterValues(parameter);
  +            if (values!=null) for (int x=0; x<values.length; x++) {
  +                this.data("      ");
  +                this.start("value",attr);
  +                this.data(values[x]);
  +                this.end("value");
  +                this.data("\n");
  +            }
  +            this.data("    ");
  +            this.end("parameter");
  +            this.data("\n");
  +        }
  +        this.data("  ");
  +        this.end("requestParameters");
  +        this.data("\n");
  +        this.data("\n");
  +
  +        this.data("  ");
  +        this.start("configurationParameters",attr);
  +        this.data("\n");
  +        Enumeration confparams=super.parameters.getParameterNames();
  +        while (confparams.hasMoreElements()) {
  +            String parameter=(String)confparams.nextElement();
  +            this.attribute(attr,"name",parameter);
  +            this.data("    ");
  +            this.start("parameter",attr);
  +            this.data(super.parameters.getParameter(parameter,""));
  +            this.end("parameter");
  +            this.data("\n");
  +        }
  +        this.data("  ");
  +        this.end("configurationParameters");
  +        this.data("\n");
  +        this.data("\n");
  +
  +        this.end("request");
  +
  +        // Finish
  +        this.contentHandler.endPrefixMapping("");
  +        this.contentHandler.endDocument();
  +    }
  +    
  +    private void attribute(AttributesImpl attr, String name, String value) {
  +        attr.addAttribute("",name,name,"CDATA",value);
  +    }
  +    
  +    private void start(String name, AttributesImpl attr)
  +    throws SAXException {
  +        super.contentHandler.startElement(URI,name,name,attr);
  +        attr.clear();
  +    }
  +
  +    private void end(String name)
  +    throws SAXException {
  +        super.contentHandler.endElement(URI,name,name);
  +    }
  +    
  +    private void data(String data)
  +    throws SAXException {
  +        super.contentHandler.characters(data.toCharArray(),0,data.length());
  +    }
  +}
  
  
  
  1.1.2.3   +189 -189  
xml-cocoon/src/org/apache/cocoon/generation/Attic/StatusGenerator.java
  
  Index: StatusGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/StatusGenerator.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- StatusGenerator.java      2000/07/22 20:41:48     1.1.2.2
  +++ StatusGenerator.java      2000/07/29 18:30:34     1.1.2.3
  @@ -1,189 +1,189 @@
  
-/*****************************************************************************
  -* Copyright (C) The Apache Software Foundation. All rights reserved.        *
  -* ------------------------------------------------------------------------- *
  -* This software is published under the terms of the Apache Software License *
  -* version 1.1, a copy of which has been included  with this distribution in *
  -* the LICENSE file.                                                         *
  
-*****************************************************************************/
  -
  -package org.apache.cocoon.generation;
  -
  -import java.util.Calendar;
  -import java.util.Date;
  -import java.text.DateFormat;
  -import java.net.InetAddress;
  -import java.net.UnknownHostException;
  -
  -import org.xml.sax.SAXException;
  -import org.xml.sax.helpers.AttributesImpl;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.ContentHandler;
  -
  -
  -/** Generates an XML representation of the current status of Cocoon.
  - * Potted DTD:
  - *
  - * <code>
  - * &lt;!ELEMENT statusinfo (group|value)*&gt;
  - *
  - * &lt;!ATTLIST statusinfo
  - *     date CDATA #IMPLIED
  - *     host CDATA #IMPLIED
  - * &gt;
  - *
  - * &lt;!ELEMENT group (group|value)*&gt;
  - * &lt;!ATTLIST group
  - *     name CDATA #IMPLIED
  - * &gt;
  - *
  - * &lt;!ELEMENT value (#PCDATA)&gt;
  - * &lt;!ATTLIST value
  - *     name CDATA #REQUIRED
  - * &gt;
  - * </code>
  - * 
  - * @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a> (Luminas 
Limited)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:48 $
  - */
  -public class StatusGenerator extends ComposerGenerator {
  -
  -     /** The XML namespace for the output document.
  -      */
  -     protected static final String namespace =
  -             "http://apache.org/cocoon/status";;
  -
  -     /** The XML namespace for xlink
  -      */
  -     protected static final String xlinkNamespace =
  -             "http://www.w3.org/1999/xlink";;
  -             
  -     /** Generate the status information in XML format.
  -      * @throws SAXException
  -      *      when there is a problem creating the output SAX events.
  -      */
  -     public void generate() throws SAXException {
  -     
  -             // Start the document and set the namespace.
  -             this.contentHandler.startDocument();
  -             this.contentHandler.startPrefixMapping("", namespace);
  -             this.contentHandler.startPrefixMapping("xlink", xlinkNamespace);
  -
  -             genStatus(this.contentHandler);
  -
  -             // End the document.
  -             this.contentHandler.endPrefixMapping("xlink");
  -             this.contentHandler.endPrefixMapping("");
  -             this.contentHandler.endDocument();
  -     }
  -
  -     /** Generate the main status document.
  -      */
  -     private void genStatus(ContentHandler ch) throws SAXException {
  -             // Root element.
  -
  -             // The current date and time.
  -             String dateTime = DateFormat.getDateTimeInstance().format(new 
Date());
  -
  -             String localHost;
  -
  -             // The local host.
  -             try {
  -                     localHost = InetAddress.getLocalHost().getHostName();
  -             } catch ( UnknownHostException e ) {
  -                     localHost = "";
  -             } catch ( SecurityException e ) {
  -                     localHost = "";
  -             }
  -             
  -             AttributesImpl atts = new AttributesImpl();
  -             atts.addAttribute(namespace, "date", "date", "CDATA", dateTime);
  -             atts.addAttribute(namespace, "host", "host", "CDATA", 
localHost);
  -             ch.startElement(namespace, "statusinfo", "statusinfo", atts);
  -
  -             genVMStatus(ch);
  -
  -             // End root element.
  -             ch.endElement(namespace, "statusinfo", "statusinfo");
  -     }
  -
  -     private void genVMStatus(ContentHandler ch) throws SAXException {
  -             String buf;
  -             AttributesImpl atts = new AttributesImpl();
  -     
  -             startGroup(ch, "vm");
  -             // BEGIN Memory status
  -             startGroup(ch, "memory");
  -             addValue(ch, "total", 
String.valueOf(Runtime.getRuntime().totalMemory()));
  -             addValue(ch, "free", 
String.valueOf(Runtime.getRuntime().freeMemory()));
  -             endGroup(ch);
  -             // END Memory status
  -             
  -             // BEGIN JRE
  -             startGroup(ch, "jre");
  -             addValue(ch, "version", System.getProperty("java.version"));
  -             atts.clear();
  -             atts.addAttribute(xlinkNamespace, "type", "type", "CDATA", 
"simple");
  -             atts.addAttribute(xlinkNamespace, "href", "href", "CDATA",
  -                     System.getProperty("java.vendor.url") );
  -             addValue(ch, "java-vendor", System.getProperty("java.vendor"), 
atts);
  -             endGroup(ch);
  -             // END JRE
  -             
  -             // BEGIN Operating system
  -             startGroup(ch, "operating-system");
  -             addValue(ch, "name", System.getProperty("os.name"));
  -             addValue(ch, "architecture", System.getProperty("os.arch"));
  -             addValue(ch, "version", System.getProperty("os.version"));
  -             endGroup(ch);
  -             // END operating system
  -             
  -             addValue(ch, "classpath", 
System.getProperty("java.class.path"));
  -
  -             // BEGIN OS info
  -             endGroup(ch);
  -     }
  -
  -     /** Utility function to begin a <code>group</code> tag pair. */
  -     private void startGroup(ContentHandler ch, String name) throws 
SAXException {
  -             startGroup(ch, name, null);
  -     }
  -     
  -     /** Utility function to begin a <code>group</code> tag pair with added 
attributes. */
  -     private void startGroup(ContentHandler ch, String name, Attributes 
atts) throws SAXException {
  -             AttributesImpl ai;
  -             if ( atts == null ) {
  -                     ai = new AttributesImpl();
  -             } else {
  -                     ai = new AttributesImpl(atts);
  -             }
  -             ai.addAttribute(namespace, "name", "name", "CDATA", name);
  -             ch.startElement(namespace, "group", "group", ai);
  -     }
  -
  -     /** Utility function to end a <code>group</code> tag pair. */
  -     private void endGroup(ContentHandler ch) throws SAXException {
  -             ch.endElement(namespace, "group", "group");
  -     }
  -
  -     /** Utility function to begin and end a <code>value</code> tag pair. */
  -     private void addValue(ContentHandler ch, String name, String value) 
throws SAXException {
  -             addValue(ch, name, value, null);
  -     }
  -
  -     /** Utility function to begin and end a <code>value</code> tag pair 
with added attributes. */
  -     private void addValue(ContentHandler ch, String name, String value, 
Attributes atts) throws SAXException {
  -             AttributesImpl ai;
  -             if ( atts == null ) {
  -                     ai = new AttributesImpl();
  -             } else {
  -                     ai = new AttributesImpl(atts);
  -             }
  -             ai.addAttribute(namespace, "name", "name", "CDATA", name);
  -             ch.startElement(namespace, "value", "value", ai);
  -             if ( value != null ) {
  -                     ch.characters(value.toCharArray(), 0, value.length());
  -             }
  -             ch.endElement(namespace, "value", "value");
  -     }
  -}
  - 
  
+/*****************************************************************************
  +* Copyright (C) The Apache Software Foundation. All rights reserved.        *
  +* ------------------------------------------------------------------------- *
  +* This software is published under the terms of the Apache Software License *
  +* version 1.1, a copy of which has been included  with this distribution in *
  +* the LICENSE file.                                                         *
  
+*****************************************************************************/
  +
  +package org.apache.cocoon.generation;
  +
  +import java.util.Calendar;
  +import java.util.Date;
  +import java.text.DateFormat;
  +import java.net.InetAddress;
  +import java.net.UnknownHostException;
  +
  +import org.xml.sax.SAXException;
  +import org.xml.sax.helpers.AttributesImpl;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.ContentHandler;
  +
  +
  +/** Generates an XML representation of the current status of Cocoon.
  + * Potted DTD:
  + *
  + * <code>
  + * &lt;!ELEMENT statusinfo (group|value)*&gt;
  + *
  + * &lt;!ATTLIST statusinfo
  + *     date CDATA #IMPLIED
  + *     host CDATA #IMPLIED
  + * &gt;
  + *
  + * &lt;!ELEMENT group (group|value)*&gt;
  + * &lt;!ATTLIST group
  + *     name CDATA #IMPLIED
  + * &gt;
  + *
  + * &lt;!ELEMENT value (#PCDATA)&gt;
  + * &lt;!ATTLIST value
  + *     name CDATA #REQUIRED
  + * &gt;
  + * </code>
  + * 
  + * @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a> (Luminas 
Limited)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:34 $
  + */
  +public class StatusGenerator extends ComposerGenerator {
  +
  +     /** The XML namespace for the output document.
  +      */
  +     protected static final String namespace =
  +             "http://apache.org/cocoon/status";;
  +
  +     /** The XML namespace for xlink
  +      */
  +     protected static final String xlinkNamespace =
  +             "http://www.w3.org/1999/xlink";;
  +             
  +     /** Generate the status information in XML format.
  +      * @throws SAXException
  +      *      when there is a problem creating the output SAX events.
  +      */
  +     public void generate() throws SAXException {
  +     
  +             // Start the document and set the namespace.
  +             this.contentHandler.startDocument();
  +             this.contentHandler.startPrefixMapping("", namespace);
  +             this.contentHandler.startPrefixMapping("xlink", xlinkNamespace);
  +
  +             genStatus(this.contentHandler);
  +
  +             // End the document.
  +             this.contentHandler.endPrefixMapping("xlink");
  +             this.contentHandler.endPrefixMapping("");
  +             this.contentHandler.endDocument();
  +     }
  +
  +     /** Generate the main status document.
  +      */
  +     private void genStatus(ContentHandler ch) throws SAXException {
  +             // Root element.
  +
  +             // The current date and time.
  +             String dateTime = DateFormat.getDateTimeInstance().format(new 
Date());
  +
  +             String localHost;
  +
  +             // The local host.
  +             try {
  +                     localHost = InetAddress.getLocalHost().getHostName();
  +             } catch ( UnknownHostException e ) {
  +                     localHost = "";
  +             } catch ( SecurityException e ) {
  +                     localHost = "";
  +             }
  +             
  +             AttributesImpl atts = new AttributesImpl();
  +             atts.addAttribute(namespace, "date", "date", "CDATA", dateTime);
  +             atts.addAttribute(namespace, "host", "host", "CDATA", 
localHost);
  +             ch.startElement(namespace, "statusinfo", "statusinfo", atts);
  +
  +             genVMStatus(ch);
  +
  +             // End root element.
  +             ch.endElement(namespace, "statusinfo", "statusinfo");
  +     }
  +
  +     private void genVMStatus(ContentHandler ch) throws SAXException {
  +             String buf;
  +             AttributesImpl atts = new AttributesImpl();
  +     
  +             startGroup(ch, "vm");
  +             // BEGIN Memory status
  +             startGroup(ch, "memory");
  +             addValue(ch, "total", 
String.valueOf(Runtime.getRuntime().totalMemory()));
  +             addValue(ch, "free", 
String.valueOf(Runtime.getRuntime().freeMemory()));
  +             endGroup(ch);
  +             // END Memory status
  +             
  +             // BEGIN JRE
  +             startGroup(ch, "jre");
  +             addValue(ch, "version", System.getProperty("java.version"));
  +             atts.clear();
  +             atts.addAttribute(xlinkNamespace, "type", "type", "CDATA", 
"simple");
  +             atts.addAttribute(xlinkNamespace, "href", "href", "CDATA",
  +                     System.getProperty("java.vendor.url") );
  +             addValue(ch, "java-vendor", System.getProperty("java.vendor"), 
atts);
  +             endGroup(ch);
  +             // END JRE
  +             
  +             // BEGIN Operating system
  +             startGroup(ch, "operating-system");
  +             addValue(ch, "name", System.getProperty("os.name"));
  +             addValue(ch, "architecture", System.getProperty("os.arch"));
  +             addValue(ch, "version", System.getProperty("os.version"));
  +             endGroup(ch);
  +             // END operating system
  +             
  +             addValue(ch, "classpath", 
System.getProperty("java.class.path"));
  +
  +             // BEGIN OS info
  +             endGroup(ch);
  +     }
  +
  +     /** Utility function to begin a <code>group</code> tag pair. */
  +     private void startGroup(ContentHandler ch, String name) throws 
SAXException {
  +             startGroup(ch, name, null);
  +     }
  +     
  +     /** Utility function to begin a <code>group</code> tag pair with added 
attributes. */
  +     private void startGroup(ContentHandler ch, String name, Attributes 
atts) throws SAXException {
  +             AttributesImpl ai;
  +             if ( atts == null ) {
  +                     ai = new AttributesImpl();
  +             } else {
  +                     ai = new AttributesImpl(atts);
  +             }
  +             ai.addAttribute(namespace, "name", "name", "CDATA", name);
  +             ch.startElement(namespace, "group", "group", ai);
  +     }
  +
  +     /** Utility function to end a <code>group</code> tag pair. */
  +     private void endGroup(ContentHandler ch) throws SAXException {
  +             ch.endElement(namespace, "group", "group");
  +     }
  +
  +     /** Utility function to begin and end a <code>value</code> tag pair. */
  +     private void addValue(ContentHandler ch, String name, String value) 
throws SAXException {
  +             addValue(ch, name, value, null);
  +     }
  +
  +     /** Utility function to begin and end a <code>value</code> tag pair 
with added attributes. */
  +     private void addValue(ContentHandler ch, String name, String value, 
Attributes atts) throws SAXException {
  +             AttributesImpl ai;
  +             if ( atts == null ) {
  +                     ai = new AttributesImpl();
  +             } else {
  +                     ai = new AttributesImpl(atts);
  +             }
  +             ai.addAttribute(namespace, "name", "name", "CDATA", name);
  +             ch.startElement(namespace, "value", "value", ai);
  +             if ( value != null ) {
  +                     ch.characters(value.toCharArray(), 0, value.length());
  +             }
  +             ch.endElement(namespace, "value", "value");
  +     }
  +}
  + 
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +25 -25    
xml-cocoon/src/org/apache/cocoon/matching/Attic/AuthenticationMatcher.java
  
  Index: AuthenticationMatcher.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/AuthenticationMatcher.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- AuthenticationMatcher.java        2000/07/22 20:41:49     1.1.2.3
  +++ AuthenticationMatcher.java        2000/07/29 18:30:35     1.1.2.4
  @@ -1,25 +1,25 @@
  -package org.apache.cocoon.matching;
  -
  -import java.util.List;
  -import java.util.ArrayList;
  -
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.environment.http.HttpEnvironment;
  -
  -public abstract class AuthenticationMatcher implements Matcher {
  -
  -     protected String username_parameter = "username";
  -     protected String password_parameter = "password";
  -
  -     public List match(String pattern, Environment environment) {
  -             if 
(match(((HttpEnvironment)environment).getRequest().getParameter(username_parameter),
  -                         
((HttpEnvironment)environment).getRequest().getParameter(password_parameter))) {
  -                    return new ArrayList();
  -                } else {
  -                    return null;
  -                }
  -     }
  -
  -     abstract boolean match(String username, String password);
  -
  -}
  +package org.apache.cocoon.matching;
  +
  +import java.util.List;
  +import java.util.ArrayList;
  +
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +
  +public abstract class AuthenticationMatcher implements Matcher {
  +
  +     protected String username_parameter = "username";
  +     protected String password_parameter = "password";
  +
  +     public List match(String pattern, Environment environment) {
  +             if 
(match(((HttpEnvironment)environment).getRequest().getParameter(username_parameter),
  +                         
((HttpEnvironment)environment).getRequest().getParameter(password_parameter))) {
  +                    return new ArrayList();
  +                } else {
  +                    return null;
  +                }
  +     }
  +
  +     abstract boolean match(String username, String password);
  +
  +}
  
  
  
  1.1.2.4   +50 -50    
xml-cocoon/src/org/apache/cocoon/matching/Attic/FileAuthenticationMatcher.java
  
  Index: FileAuthenticationMatcher.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/FileAuthenticationMatcher.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- FileAuthenticationMatcher.java    2000/07/22 20:41:49     1.1.2.3
  +++ FileAuthenticationMatcher.java    2000/07/29 18:30:35     1.1.2.4
  @@ -1,50 +1,50 @@
  -package org.apache.cocoon.matching;
  -
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.List;
  -import java.util.ArrayList;
  -
  -import org.apache.avalon.Configurable;
  -import org.apache.avalon.Configuration;
  -import org.apache.avalon.ConfigurationException;
  -import org.apache.cocoon.environment.Environment; 
  -import org.apache.avalon.utils.Parameters; 
  -
  -public class FileAuthenticationMatcher extends AuthenticationMatcher 
implements Configurable {
  -
  -     private Hashtable users = new Hashtable();
  -
  -     public void setConfiguration(Configuration conf) throws 
ConfigurationException {
  -             Enumeration params = conf.getConfigurations("param");
  -             while (params.hasMoreElements()) {
  -                     Configuration param = 
(Configuration)params.nextElement();
  -                     String name = param.getAttribute("name");
  -                     String value = param.getAttribute("value");
  -                     if (!name.equals("src")) {
  -                             /** load the file indicated by value (relative 
to what?)
  -                                 fill hashtable with users/passwords 
(plaintext for now)
  -                          **/
  -                     }
  -             }
  -     }
  -
  -     public List match(String pattern, Environment environment) {
  -            return new ArrayList();
  -        }
  -     public boolean match(String user, String password) {
  -             if (user == null || password == null) {
  -                     return false;
  -             }
  -             String value = (String)users.get(user);
  -             if (value == null || !value.equals(password)) {
  -                     return false;
  -             } else {
  -                     return true;
  -             }
  -     }
  -
  -   public void setup (Environment environment, String src, Parameters param) 
{
  -   }
  -
  -}
  +package org.apache.cocoon.matching;
  +
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import java.util.List;
  +import java.util.ArrayList;
  +
  +import org.apache.avalon.Configurable;
  +import org.apache.avalon.Configuration;
  +import org.apache.avalon.ConfigurationException;
  +import org.apache.cocoon.environment.Environment; 
  +import org.apache.avalon.utils.Parameters; 
  +
  +public class FileAuthenticationMatcher extends AuthenticationMatcher 
implements Configurable {
  +
  +     private Hashtable users = new Hashtable();
  +
  +     public void setConfiguration(Configuration conf) throws 
ConfigurationException {
  +             Enumeration params = conf.getConfigurations("param");
  +             while (params.hasMoreElements()) {
  +                     Configuration param = 
(Configuration)params.nextElement();
  +                     String name = param.getAttribute("name");
  +                     String value = param.getAttribute("value");
  +                     if (!name.equals("src")) {
  +                             /** load the file indicated by value (relative 
to what?)
  +                                 fill hashtable with users/passwords 
(plaintext for now)
  +                          **/
  +                     }
  +             }
  +     }
  +
  +     public List match(String pattern, Environment environment) {
  +            return new ArrayList();
  +        }
  +     public boolean match(String user, String password) {
  +             if (user == null || password == null) {
  +                     return false;
  +             }
  +             String value = (String)users.get(user);
  +             if (value == null || !value.equals(password)) {
  +                     return false;
  +             } else {
  +                     return true;
  +             }
  +     }
  +
  +   public void setup (Environment environment, String src, Parameters param) 
{
  +   }
  +
  +}
  
  
  
  1.1.2.5   +37 -37    
xml-cocoon/src/org/apache/cocoon/matching/Attic/Matcher.java
  
  Index: Matcher.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/Matcher.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- Matcher.java      2000/07/22 20:41:49     1.1.2.4
  +++ Matcher.java      2000/07/29 18:30:35     1.1.2.5
  @@ -1,37 +1,37 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.matching;
  -
  -import java.util.List;
  -
  -import org.apache.cocoon.sitemap.SitemapComponent;
  -import org.apache.cocoon.environment.Environment;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:41:49 $
  - */
  -public interface Matcher extends SitemapComponent {
  -    /**
  -     * Matches the pattern against some <code>Request</code> values
  -     * and returns a <code>Map</code> object with replacements
  -     * for wildcards contained in the pattern. 
  -     * @param pattern The pattern to match against. Depending on the
  -     *                implementation the pattern can contain wildcards
  -     *                or regular expressions.
  -     * @param request The <code>Request</code> object which can be used
  -     *                to select values this matchers matches against.
  -     * @return Map    The returned <code>Map</code> object with
  -     *                replacements for wildcards/regular-expressions 
  -     *                contained in the pattern.
  -     *                If the return value is null there was no match.
  -     */
  -    public List match (String pattern, Environment environment);
  -}
  -
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.matching;
  +
  +import java.util.List;
  +
  +import org.apache.cocoon.sitemap.SitemapComponent;
  +import org.apache.cocoon.environment.Environment;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/29 18:30:35 $
  + */
  +public interface Matcher extends SitemapComponent {
  +    /**
  +     * Matches the pattern against some <code>Request</code> values
  +     * and returns a <code>Map</code> object with replacements
  +     * for wildcards contained in the pattern. 
  +     * @param pattern The pattern to match against. Depending on the
  +     *                implementation the pattern can contain wildcards
  +     *                or regular expressions.
  +     * @param request The <code>Request</code> object which can be used
  +     *                to select values this matchers matches against.
  +     * @return Map    The returned <code>Map</code> object with
  +     *                replacements for wildcards/regular-expressions 
  +     *                contained in the pattern.
  +     *                If the return value is null there was no match.
  +     */
  +    public List match (String pattern, Environment environment);
  +}
  +
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +205 -205  
xml-cocoon/src/org/apache/cocoon/matching/helpers/Attic/WildcardURIMatcher.java
  
  Index: WildcardURIMatcher.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/matching/helpers/Attic/WildcardURIMatcher.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- WildcardURIMatcher.java   2000/07/22 20:41:51     1.1.2.2
  +++ WildcardURIMatcher.java   2000/07/29 18:30:36     1.1.2.3
  @@ -1,205 +1,205 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.matching.helpers;
  -
  -import java.util.Stack;
  -
  -/**
  - * This class is an utility class that perform wilcard-patterns matching and
  - * isolation.
  - * <br>
  - * 
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:51 $
  - */
  -public class WildcardURIMatcher {
  -
  -    /** The int representing '*' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_FILE=-1;
  -    /** The int representing '**' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_PATH=-2;
  -    /** The int value that terminates the pattern <code>int []</code>. */
  -    protected static final int MATCH_END=-3;
  -
  -    /**
  -     * match a pattern agains a string and isolates wildcard replacement 
into a 
  -     * <code>Stack</code>.
  -     */
  -    public static boolean match (Stack stack, String data, int[] expr) 
  -    throws NullPointerException {
  -        if (stack == null) throw new NullPointerException ("No Stack 
provided");
  -        if (data == null) throw new NullPointerException ("No data 
provided");
  -        if (expr == null) throw new NullPointerException ("No pattern 
expression provided");
  -        
  -        char buff[] = data.toCharArray ();
  -        // Allocate the result buffer
  -        char rslt[]=new char[expr.length+buff.length];
  -        
  -        // The previous and current position of the expression character
  -        // (MATCH_*)
  -        int charpos = 0;
  -        // Search the fist expression character
  -        while (expr[charpos] >= 0) charpos++;
  -        // The expression charater (MATCH_*)
  -        int exprchr = expr[charpos];
  -
  -        // The position in the expression, input, translation and result 
arrays
  -        int exprpos = 0;
  -        int buffpos = 0;
  -        int trnspos = 0;
  -        int rsltpos = 0;
  -        int offset = -1;
  -        
  -        while (true) {
  -            // Check if the data in the expression array before the current
  -            // expression character matches the data in the input buffer
  -            offset = matchArray (expr, exprpos, charpos, buff, buffpos);
  -            if (offset < 0) return(false);
  -
  -            // Copy the data from the translation buffer into the result 
buffer
  -            // up to the next expression character (arriving to the current 
in the
  -            // expression buffer)        
  -            // while (trns[trnspos] >= 0) rslt[rsltpos++] = 
(char)trns[trnspos++];
  -            // trnspos++;
  -                
  -            if (exprchr == MATCH_END) {
  -                if (rsltpos > 0)
  -                    stack.push (new String(rslt, 0, rsltpos));
  -                return (true);
  -            }
  -            
  -            // Search the next expression character
  -            buffpos += (charpos-exprpos);
  -            exprpos = ++charpos;
  -            while (expr[charpos] >= 0) charpos++;
  -            int prevchr = exprchr;
  -            exprchr = expr[charpos];
  -   
  -            offset = matchArray (expr, exprpos, charpos, buff, buffpos);
  -            if (offset < 0) return (false);
  -    
  -            // Copy the data from the source buffer into the result buffer
  -            // to substitute the expression character
  -            if (prevchr == MATCH_PATH) {
  -                while (buffpos < offset) rslt[rsltpos++] = buff[buffpos++];
  -            } else {
  -                // Matching file, don't copy '/'
  -                while (buffpos < offset) {
  -                    if (buff[buffpos] == '/') return (false);
  -                    rslt[rsltpos++] = buff[buffpos++];
  -                }
  -            stack.push (new String (rslt, 0, rsltpos));
  -            rsltpos = 0;
  -            }
  -        }
  -    }
  -
  -    /**
  -     * Get the offset of a part of an int array within a char array.
  -     * <br>
  -     * This method return the index in d of the first occurrence after dpos 
of
  -     * that part of array specified by r, starting at rpos and terminating at
  -     * rend.
  -     *
  -     * @param r The array containing the data that need to be matched in d.
  -     * @param rpos The index of the first character in r to look for.
  -     * @param rend The index of the last character in r to look for plus 1.
  -     * @param d The array of char that should contain a part of r.
  -     * @param dpos The starting offset in d for the matching.
  -     * @return The offset in d of the part of r matched in d or -1 if that 
was
  -     *         not found.
  -     */
  -    protected static int matchArray (int r[], int rpos, int rend, char d[], 
int dpos) {
  -        // Check if pos and len are legal
  -        if (rend < rpos) throw new IllegalArgumentException ("rend < rpos");
  -        // If we need to match a zero length string return current dpos
  -        if (rend == rpos) return (d.length); //?? dpos?
  -        // If we need to match a 1 char length string do it simply
  -        if ((rend - rpos) == 1) {
  -            // Search for the specified character
  -            for (int x = dpos; x < d.length; x++) 
  -                if (r[rpos] == d[x]) return (x);
  -        }
  -        // Main string matching loop. It gets executed if the characters to
  -        // match are less then the characters left in the d buffer
  -        while ((dpos + rend - rpos) <= d.length) {
  -            // Set current startpoint in d
  -            int y = dpos;
  -            // Check every character in d for equity. If the string is 
matched
  -            // return dpos
  -            for (int x = rpos; x <= rend; x++) {
  -                if (x == rend) return (dpos);
  -                if (r[x] == d[y]) y++;
  -                else break;
  -            }
  -            // Increase dpos to search for the same string at next offset
  -            dpos++;
  -        }
  -        // The remaining chars in d buffer were not enough or the string 
  -        // wasn't matched
  -        return (-1);
  -    }
  -
  -    protected static int[] convertPattern(String data)
  -    throws NullPointerException {
  -        // Prepare the arrays
  -        int expr[]=new int[data.length()+1];
  -        char buff[]=data.toCharArray();
  -        // Prepare variables for the translation loop
  -        int y=0;
  -        boolean slash=false;
  -        if(buff[0]=='\\') slash=true;
  -        else if(buff[0]=='*') expr[y++]=MATCH_FILE;
  -        else expr[y++]=buff[0];
  -        // Main translation loop
  -        for (int x=1; x<buff.length; x++) {
  -            // If the previous char was '\' simply copy this char.
  -            if (slash) {
  -                expr[y++]=buff[x];
  -                slash=false;
  -            // If the previous char was not '\' we have to do a bunch of 
checks
  -            } else {
  -                int prev=(y-1);
  -                // If this char is '\' declare that and continue
  -                if(buff[x]=='\\') {
  -                    slash=true;
  -                // If this char is '*' check the previous one
  -                } else if(buff[x]=='*') {
  -                    // If the previous character als was '*' match a path
  -                    if(expr[y-1]<=MATCH_FILE) expr[y-1]=MATCH_PATH;
  -                    else expr[y++]=MATCH_FILE;
  -                } else expr[y++]=buff[x];
  -            }
  -        }
  -        // Declare the end of the array and return it
  -        expr[y]=MATCH_END;
  -        return(expr);
  -    }        
  -    
  -    /** Testing */
  -    public static void main(String argv[]) {
  -        try {
  -            if (argv.length<2) return;
  -            Stack stack = new Stack();
  -            int expr[] = convertPattern (argv[0]);
  -            System.out.println("Matching Expr.    \""+argv[0]+"\"");
  -            System.out.println("Uri String. \""+argv[1]+"\"");
  -            if (WildcardURIMatcher.match (stack, argv[1], expr)) {
  -                System.out.println("Matched");
  -                for (int i = 0; i < stack.size(); i++)
  -                    System.out.println(i+" "+(String)stack.elementAt (i));
  -            } else
  -                System.out.println("Not matched");
  -        } catch (Exception e) {
  -            System.out.println(e.getClass().getName());
  -            System.out.println(e.getMessage());
  -        }
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.matching.helpers;
  +
  +import java.util.Stack;
  +
  +/**
  + * This class is an utility class that perform wilcard-patterns matching and
  + * isolation.
  + * <br>
  + * 
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:36 $
  + */
  +public class WildcardURIMatcher {
  +
  +    /** The int representing '*' in the pattern <code>int []</code>. */
  +    protected static final int MATCH_FILE=-1;
  +    /** The int representing '**' in the pattern <code>int []</code>. */
  +    protected static final int MATCH_PATH=-2;
  +    /** The int value that terminates the pattern <code>int []</code>. */
  +    protected static final int MATCH_END=-3;
  +
  +    /**
  +     * match a pattern agains a string and isolates wildcard replacement 
into a 
  +     * <code>Stack</code>.
  +     */
  +    public static boolean match (Stack stack, String data, int[] expr) 
  +    throws NullPointerException {
  +        if (stack == null) throw new NullPointerException ("No Stack 
provided");
  +        if (data == null) throw new NullPointerException ("No data 
provided");
  +        if (expr == null) throw new NullPointerException ("No pattern 
expression provided");
  +        
  +        char buff[] = data.toCharArray ();
  +        // Allocate the result buffer
  +        char rslt[]=new char[expr.length+buff.length];
  +        
  +        // The previous and current position of the expression character
  +        // (MATCH_*)
  +        int charpos = 0;
  +        // Search the fist expression character
  +        while (expr[charpos] >= 0) charpos++;
  +        // The expression charater (MATCH_*)
  +        int exprchr = expr[charpos];
  +
  +        // The position in the expression, input, translation and result 
arrays
  +        int exprpos = 0;
  +        int buffpos = 0;
  +        int trnspos = 0;
  +        int rsltpos = 0;
  +        int offset = -1;
  +        
  +        while (true) {
  +            // Check if the data in the expression array before the current
  +            // expression character matches the data in the input buffer
  +            offset = matchArray (expr, exprpos, charpos, buff, buffpos);
  +            if (offset < 0) return(false);
  +
  +            // Copy the data from the translation buffer into the result 
buffer
  +            // up to the next expression character (arriving to the current 
in the
  +            // expression buffer)        
  +            // while (trns[trnspos] >= 0) rslt[rsltpos++] = 
(char)trns[trnspos++];
  +            // trnspos++;
  +                
  +            if (exprchr == MATCH_END) {
  +                if (rsltpos > 0)
  +                    stack.push (new String(rslt, 0, rsltpos));
  +                return (true);
  +            }
  +            
  +            // Search the next expression character
  +            buffpos += (charpos-exprpos);
  +            exprpos = ++charpos;
  +            while (expr[charpos] >= 0) charpos++;
  +            int prevchr = exprchr;
  +            exprchr = expr[charpos];
  +   
  +            offset = matchArray (expr, exprpos, charpos, buff, buffpos);
  +            if (offset < 0) return (false);
  +    
  +            // Copy the data from the source buffer into the result buffer
  +            // to substitute the expression character
  +            if (prevchr == MATCH_PATH) {
  +                while (buffpos < offset) rslt[rsltpos++] = buff[buffpos++];
  +            } else {
  +                // Matching file, don't copy '/'
  +                while (buffpos < offset) {
  +                    if (buff[buffpos] == '/') return (false);
  +                    rslt[rsltpos++] = buff[buffpos++];
  +                }
  +            stack.push (new String (rslt, 0, rsltpos));
  +            rsltpos = 0;
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Get the offset of a part of an int array within a char array.
  +     * <br>
  +     * This method return the index in d of the first occurrence after dpos 
of
  +     * that part of array specified by r, starting at rpos and terminating at
  +     * rend.
  +     *
  +     * @param r The array containing the data that need to be matched in d.
  +     * @param rpos The index of the first character in r to look for.
  +     * @param rend The index of the last character in r to look for plus 1.
  +     * @param d The array of char that should contain a part of r.
  +     * @param dpos The starting offset in d for the matching.
  +     * @return The offset in d of the part of r matched in d or -1 if that 
was
  +     *         not found.
  +     */
  +    protected static int matchArray (int r[], int rpos, int rend, char d[], 
int dpos) {
  +        // Check if pos and len are legal
  +        if (rend < rpos) throw new IllegalArgumentException ("rend < rpos");
  +        // If we need to match a zero length string return current dpos
  +        if (rend == rpos) return (d.length); //?? dpos?
  +        // If we need to match a 1 char length string do it simply
  +        if ((rend - rpos) == 1) {
  +            // Search for the specified character
  +            for (int x = dpos; x < d.length; x++) 
  +                if (r[rpos] == d[x]) return (x);
  +        }
  +        // Main string matching loop. It gets executed if the characters to
  +        // match are less then the characters left in the d buffer
  +        while ((dpos + rend - rpos) <= d.length) {
  +            // Set current startpoint in d
  +            int y = dpos;
  +            // Check every character in d for equity. If the string is 
matched
  +            // return dpos
  +            for (int x = rpos; x <= rend; x++) {
  +                if (x == rend) return (dpos);
  +                if (r[x] == d[y]) y++;
  +                else break;
  +            }
  +            // Increase dpos to search for the same string at next offset
  +            dpos++;
  +        }
  +        // The remaining chars in d buffer were not enough or the string 
  +        // wasn't matched
  +        return (-1);
  +    }
  +
  +    protected static int[] convertPattern(String data)
  +    throws NullPointerException {
  +        // Prepare the arrays
  +        int expr[]=new int[data.length()+1];
  +        char buff[]=data.toCharArray();
  +        // Prepare variables for the translation loop
  +        int y=0;
  +        boolean slash=false;
  +        if(buff[0]=='\\') slash=true;
  +        else if(buff[0]=='*') expr[y++]=MATCH_FILE;
  +        else expr[y++]=buff[0];
  +        // Main translation loop
  +        for (int x=1; x<buff.length; x++) {
  +            // If the previous char was '\' simply copy this char.
  +            if (slash) {
  +                expr[y++]=buff[x];
  +                slash=false;
  +            // If the previous char was not '\' we have to do a bunch of 
checks
  +            } else {
  +                int prev=(y-1);
  +                // If this char is '\' declare that and continue
  +                if(buff[x]=='\\') {
  +                    slash=true;
  +                // If this char is '*' check the previous one
  +                } else if(buff[x]=='*') {
  +                    // If the previous character als was '*' match a path
  +                    if(expr[y-1]<=MATCH_FILE) expr[y-1]=MATCH_PATH;
  +                    else expr[y++]=MATCH_FILE;
  +                } else expr[y++]=buff[x];
  +            }
  +        }
  +        // Declare the end of the array and return it
  +        expr[y]=MATCH_END;
  +        return(expr);
  +    }        
  +    
  +    /** Testing */
  +    public static void main(String argv[]) {
  +        try {
  +            if (argv.length<2) return;
  +            Stack stack = new Stack();
  +            int expr[] = convertPattern (argv[0]);
  +            System.out.println("Matching Expr.    \""+argv[0]+"\"");
  +            System.out.println("Uri String. \""+argv[1]+"\"");
  +            if (WildcardURIMatcher.match (stack, argv[1], expr)) {
  +                System.out.println("Matched");
  +                for (int i = 0; i < stack.size(); i++)
  +                    System.out.println(i+" "+(String)stack.elementAt (i));
  +            } else
  +                System.out.println("Not matched");
  +        } catch (Exception e) {
  +            System.out.println(e.getClass().getName());
  +            System.out.println(e.getMessage());
  +        }
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +30 -30    
xml-cocoon/src/org/apache/cocoon/selection/Attic/Selector.java
  
  Index: Selector.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/selection/Attic/Selector.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- Selector.java     2000/07/22 20:41:51     1.1.2.3
  +++ Selector.java     2000/07/29 18:30:36     1.1.2.4
  @@ -1,30 +1,30 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.selection;
  -
  -import org.apache.cocoon.sitemap.SitemapComponent;
  -import org.apache.cocoon.environment.Environment;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:51 $
  - */
  -public interface Selector extends SitemapComponent {
  -    /**
  -     * Selectors test pattern against some <code>Request</code> values
  -     * and signals success with the returned boolean value
  -     * @param expression The expression to test.
  -     * @param request    The <code>Request</code> object which can be used
  -     *                   to select values to test the expression.
  -     * @return boolean   Signals successfull test.
  -     */
  -    public boolean select (String expression, Environment environment);
  -}
  -
  -
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.selection;
  +
  +import org.apache.cocoon.sitemap.SitemapComponent;
  +import org.apache.cocoon.environment.Environment;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:36 $
  + */
  +public interface Selector extends SitemapComponent {
  +    /**
  +     * Selectors test pattern against some <code>Request</code> values
  +     * and signals success with the returned boolean value
  +     * @param expression The expression to test.
  +     * @param request    The <code>Request</code> object which can be used
  +     *                   to select values to test the expression.
  +     * @return boolean   Signals successfull test.
  +     */
  +    public boolean select (String expression, Environment environment);
  +}
  +
  +
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +51 -51    
xml-cocoon/src/org/apache/cocoon/serialization/Attic/AbstractSerializer.java
  
  Index: AbstractSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/AbstractSerializer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- AbstractSerializer.java   2000/07/22 20:41:52     1.1.2.2
  +++ AbstractSerializer.java   2000/07/29 18:30:37     1.1.2.3
  @@ -1,51 +1,51 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.serialization;
  -
  -import java.io.BufferedOutputStream;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.sitemap.SitemapComponent;
  -import org.apache.cocoon.xml.AbstractXMLConsumer;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:52 $
  - */
  -public abstract class AbstractSerializer extends AbstractXMLConsumer 
  -implements Serializer {
  -    /** The current <code>OutputStream</code>. */
  -    protected OutputStream output=null;
  -    /** The current <code>Environment</code>. */
  -    protected Environment environment=null;
  -    /** The current <code>Parameters</code>. */
  -    protected Parameters parameters=null;
  -    /** The source URI associated with the request or <b>null</b>. */
  -    protected String source=null;
  -
  -    /**
  -     * Set the <code>Environment</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Environment environment, String src, Parameters par) {
  -        this.environment=environment;
  -        this.source=src;
  -        this.parameters=par;
  -    }
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        this.output=new BufferedOutputStream(out);
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.serialization;
  +
  +import java.io.BufferedOutputStream;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.sitemap.SitemapComponent;
  +import org.apache.cocoon.xml.AbstractXMLConsumer;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:37 $
  + */
  +public abstract class AbstractSerializer extends AbstractXMLConsumer 
  +implements Serializer {
  +    /** The current <code>OutputStream</code>. */
  +    protected OutputStream output=null;
  +    /** The current <code>Environment</code>. */
  +    protected Environment environment=null;
  +    /** The current <code>Parameters</code>. */
  +    protected Parameters parameters=null;
  +    /** The source URI associated with the request or <b>null</b>. */
  +    protected String source=null;
  +
  +    /**
  +     * Set the <code>Environment</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par) {
  +        this.environment=environment;
  +        this.source=src;
  +        this.parameters=par;
  +    }
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        this.output=new BufferedOutputStream(out);
  +    }
  +}
  
  
  
  1.1.2.4   +80 -80    
xml-cocoon/src/org/apache/cocoon/serialization/Attic/FO2PDFSerializer.java
  
  Index: FO2PDFSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/FO2PDFSerializer.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- FO2PDFSerializer.java     2000/07/22 20:41:52     1.1.2.3
  +++ FO2PDFSerializer.java     2000/07/29 18:30:37     1.1.2.4
  @@ -1,80 +1,80 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.serialization;
  -
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.io.PrintWriter;
  -
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.environment.http.HttpEnvironment;
  -import org.apache.cocoon.xml.util.DocumentHandlerWrapper; 
  -
  -import org.apache.fop.apps.Driver;
  -import org.apache.fop.apps.FOPException;
  -import org.apache.fop.apps.Version;
  -
  -//import org.xml.sax.Attributes;
  -//import org.xml.sax.AttributeList;
  -import org.xml.sax.DocumentHandler;
  -//import org.xml.sax.helpers.AttributeListImpl;
  -//import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - *         (PWR Organisation &amp; Entwicklung)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:52 $
  - *
  - */
  -public class FO2PDFSerializer extends DocumentHandlerWrapper 
  -        implements Serializer {
  -
  -    /**
  -      * The FOP driver 
  -      */
  -    private Driver driver = null;
  -
  -    /**
  -     * Set the <code>Environment</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Environment environment, String src, Parameters par) {
  -        driver = new Driver();
  -        driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", 
Version.getVersion());
  -        driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
  -        driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
  -        
((HttpEnvironment)environment).getResponse().setContentType(par.getParameter("contentType","application/pdf"));
  -        this.setDocumentHandler (driver.getDocumentHandler());
  -    }
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        driver.setWriter(new PrintWriter(out));
  -    }
  - 
  -    /** 
  -     * Receive notification of the end of a document. 
  -     */ 
  -    public void endDocument()  
  -            throws SAXException { 
  -        super.endDocument();
  -        try { 
  -            driver.format(); 
  -            driver.render(); 
  -        } catch (IOException e) { 
  -            throw new SAXException (e); 
  -        } catch (FOPException e) { 
  -            throw new SAXException (e); 
  -        } 
  -    } 
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.serialization;
  +
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.PrintWriter;
  +
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.xml.util.DocumentHandlerWrapper; 
  +
  +import org.apache.fop.apps.Driver;
  +import org.apache.fop.apps.FOPException;
  +import org.apache.fop.apps.Version;
  +
  +//import org.xml.sax.Attributes;
  +//import org.xml.sax.AttributeList;
  +import org.xml.sax.DocumentHandler;
  +//import org.xml.sax.helpers.AttributeListImpl;
  +//import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  + *         (PWR Organisation &amp; Entwicklung)
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:37 $
  + *
  + */
  +public class FO2PDFSerializer extends DocumentHandlerWrapper 
  +        implements Serializer {
  +
  +    /**
  +      * The FOP driver 
  +      */
  +    private Driver driver = null;
  +
  +    /**
  +     * Set the <code>Environment</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par) {
  +        driver = new Driver();
  +        driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", 
Version.getVersion());
  +        driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
  +        driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
  +        
((HttpEnvironment)environment).getResponse().setContentType(par.getParameter("contentType","application/pdf"));
  +        this.setDocumentHandler (driver.getDocumentHandler());
  +    }
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        driver.setWriter(new PrintWriter(out));
  +    }
  + 
  +    /** 
  +     * Receive notification of the end of a document. 
  +     */ 
  +    public void endDocument()  
  +            throws SAXException { 
  +        super.endDocument();
  +        try { 
  +            driver.format(); 
  +            driver.render(); 
  +        } catch (IOException e) { 
  +            throw new SAXException (e); 
  +        } catch (FOPException e) { 
  +            throw new SAXException (e); 
  +        } 
  +    } 
  +}
  
  
  
  1.1.2.3   +371 -371  
xml-cocoon/src/org/apache/cocoon/serialization/Attic/HTMLSerializer.java
  
  Index: HTMLSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/HTMLSerializer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- HTMLSerializer.java       2000/07/22 20:41:52     1.1.2.2
  +++ HTMLSerializer.java       2000/07/29 18:30:37     1.1.2.3
  @@ -1,371 +1,371 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.serialization;
  -
  -import java.io.BufferedOutputStream;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.io.OutputStreamWriter;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.environment.http.HttpEnvironment;
  -import org.apache.cocoon.xml.XMLConsumer;
  -import org.apache.cocoon.xml.util.NamespacesTable;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:52 $
  - */
  -public class HTMLSerializer extends AbstractSerializer implements 
XMLConsumer {
  -    /** The namespaces table */
  -    private NamespacesTable ns=new NamespacesTable();
  -    /** The PrintStream used for output */
  -    private OutputStreamWriter out=null;
  -    /** The current locator */
  -    private Locator loc=null;
  -    /** A flag telling wether we're processing the DTD */
  -    private boolean dtd=false;
  -    /** A flag telling wether we're processing a CDATA section */
  -    private boolean cdata=false;
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        super.setOutputStream(out);
  -        this.out=new OutputStreamWriter(super.output);;
  -    }
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     *
  -     * @param locator An object that can return the location of any SAX
  -     *                document event.
  -     */
  -    public void setDocumentLocator(Locator locator) {
  -        this.loc=locator;
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument()
  -    throws SAXException {
  -        String c=super.parameters.getParameter("contentType","text/html");
  -        
((HttpEnvironment)(super.environment)).getResponse().setContentType(c);
  -    }
  -
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument()
  -    throws SAXException {
  -        try {
  -            this.out.flush();
  -        } catch (IOException e) {
  -            throw new SAXException("IOException flushing stream",e);
  -        }
  -    }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -        this.ns.addDeclaration(prefix,uri);
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -        this.ns.removeDeclaration(prefix);
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes 
a)
  -    throws SAXException {
  -        this.print('<');
  -
  -        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  -        for (int x=0; x<a.getLength(); x++) {
  -            String name=this.ns.resolve(a.getURI(x),a.getQName(x),null,
  -                                        a.getLocalName(x)).getQName();
  -            String value=a.getValue(x);
  -            if ((name.equals("checked"))  || (name.equals("compact"))  ||
  -                (name.equals("declare"))  || (name.equals("defer"))    ||
  -                (name.equals("disabled")) || (name.equals("ismap"))    ||
  -                (name.equals("multiple")) || (name.equals("nohref"))   ||
  -                (name.equals("noresize")) || (name.equals("noshade"))  ||
  -                (name.equals("nowrap"))   || (name.equals("readonly")) ||
  -                (name.equals("selected"))) {
  -                if(name.equals(value)) {
  -                    this.print(' ');
  -                    this.print(name);
  -                } else {
  -                    this.print(' ');
  -                    this.print(name);
  -                    this.print('=');
  -                    this.print('\"');
  -                    this.print(value);
  -                    this.print('\"');
  -                }
  -            } else {
  -                this.print(' ');
  -                this.print(name);
  -                this.print('=');
  -                this.print('\"');
  -                this.print(value);
  -                this.print('\"');
  -            }
  -
  -        }
  -        this.print('>');
  -    }
  -        
  -
  -    /**
  -     * Receive notification of the end of an element.
  -     *
  -     * @param uri The Namespace URI, or the empty string if the element has 
no
  -     *            Namespace URI or if Namespace
  -     *            processing is not being performed.
  -     * @param loc The local name (without prefix), or the empty string if
  -     *            Namespace processing is not being performed.
  -     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
  -     *            raw names are not available.
  -     */
  -    public void endElement (String uri, String loc, String raw)
  -    throws SAXException {
  -        String name=this.ns.resolve(uri,raw,null,loc).getQName();
  -        if ((name.equalsIgnoreCase("AREA"))     || 
(name.equalsIgnoreCase("BASE"))     ||        
  -            (name.equalsIgnoreCase("BASEFONT")) || 
(name.equalsIgnoreCase("BR"))       ||          
  -            (name.equalsIgnoreCase("COL"))      || 
(name.equalsIgnoreCase("FRAME"))    ||       
  -            (name.equalsIgnoreCase("HR"))       || 
(name.equalsIgnoreCase("IMG"))      ||         
  -            (name.equalsIgnoreCase("INPUT"))    || 
(name.equalsIgnoreCase("ISINDEX"))  ||     
  -            (name.equalsIgnoreCase("LINK"))     || 
(name.equalsIgnoreCase("META"))     ||        
  -            (name.equalsIgnoreCase("PARA"))) return;
  -        this.print('<');
  -        this.print('/');
  -        this.print(name);
  -        this.print('>');
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     *
  -     * @param ch The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     */
  -    public void characters (char ch[], int start, int len)
  -    throws SAXException {
  -        if(this.cdata) this.print(ch,start,len);
  -        else this.printSafe(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     *
  -     * @param ch The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     */
  -    public void ignorableWhitespace (char ch[], int start, int len)
  -    throws SAXException {
  -        if(this.cdata) this.print(ch,start,len);
  -        else this.printSafe(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of a processing instruction.
  -     *
  -     * @param target The processing instruction target.
  -     * @param data The processing instruction data, or null if none was
  -     *             supplied.
  -     */
  -    public void processingInstruction (String target, String data)
  -    throws SAXException {
  -        this.print("<?");
  -        this.print(target);
  -        this.print(' ');
  -        this.print(data);
  -        this.print("?>");
  -    }
  -
  -    /**
  -     * Receive notification of a skipped entity.
  -     *
  -     * @param name The name of the skipped entity.  If it is a  parameter
  -     *             entity, the name will begin with '%'.
  -     */
  -    public void skippedEntity (String name)
  -    throws SAXException {
  -        this.print('&');
  -        this.print(name);
  -        this.print(';');
  -    }
  -
  -    /**
  -     * Report the start of DTD declarations, if any.
  -     *
  -     * @param name The document type name.
  -     * @param publicId The declared public identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     * @param systemId The declared system identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     */
  -    public void startDTD (String name, String publicId, String systemId)
  -    throws SAXException {
  -        this.print("<!DOCTYPE ");
  -        this.print(name);
  -        if (publicId!=null) {
  -            this.print(" PUBLIC \"");
  -            this.print(publicId);
  -            this.print('\"');
  -            if (systemId!=null) {
  -                this.print(' ');
  -                this.print('\"');
  -                this.print(systemId);
  -                this.print('\"');
  -            }
  -        } else if (systemId!=null) {
  -            this.print(" SYSTEM \"");
  -            this.print(systemId);
  -            this.print('\"');
  -        }
  -        this.print('>');
  -        this.print('\n');
  -        // Set the DTD flag now, to avoid output
  -        this.dtd=true;
  -    }        
  -    
  -    /**
  -     * Report the end of DTD declarations.
  -     */
  -    public void endDTD ()
  -    throws SAXException {
  -        this.dtd=false;
  -    }
  -
  -    /**
  -     * Report the beginning of an entity.
  -     *
  -     * @param name The name of the entity. If it is a parameter entity, the
  -     *             name will begin with '%'.
  -     */
  -    public void startEntity (String name)
  -    throws SAXException {
  -    }        
  -
  -    /**
  -     * Report the end of an entity.
  -     *
  -     * @param name The name of the entity that is ending.
  -     */
  -    public void endEntity (String name)
  -    throws SAXException {
  -    }        
  -
  -    /**
  -     * Report the start of a CDATA section.
  -     */
  -    public void startCDATA ()
  -    throws SAXException {
  -        this.print("<![CDATA[");
  -        this.cdata=true;
  -    }
  -
  -    /**
  -     * Report the end of a CDATA section.
  -     */
  -    public void endCDATA ()
  -    throws SAXException {
  -        this.cdata=false;
  -        this.print("]]>");
  -    }
  -    
  -
  -    /**
  -     * Report an XML comment anywhere in the document.
  -     *
  -     * @param ch An array holding the characters in the comment.
  -     * @param start The starting position in the array.
  -     * @param len The number of characters to use from the array.
  -     */
  -    public void comment (char ch[], int start, int len)
  -    throws SAXException {
  -        this.print("<!--");
  -        this.print(ch,start,len);
  -        this.print("-->");
  -    }
  -
  -    /** Print a string */
  -    private void print(String s)
  -    throws SAXException {
  -        char data[]=s.toCharArray();
  -        this.print(data,0,data.length);
  -    }
  -    
  -    /** Print data from a character array */
  -    private void print(char data[], int start, int len)
  -    throws SAXException {
  -        try {
  -            if(!this.dtd) this.out.write(data,start,len);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -
  -    /** Print data from a character array */
  -    private void print(char c)
  -    throws SAXException {
  -        try {
  -            if(!this.dtd) this.out.write(c);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -
  -    /** Print a string */
  -    private void printSafe(String s)
  -    throws SAXException {
  -        char data[]=s.toCharArray();
  -        this.printSafe(data,0,data.length);
  -    }
  -    
  -    /** Print data from a character array */
  -    private void printSafe(char data[], int start, int len)
  -    throws SAXException {
  -        int end=start+len;
  -        if(!this.dtd) for(int x=0; x<end; x++) this.printSafe(data[x]);
  -    }
  -
  -    /** Print data from a character array */
  -    private void printSafe(char c)
  -    throws SAXException {
  -        try {
  -            if(this.dtd) return;
  -            if(c=='&') this.print("&amp;");
  -            else if(c=='<') this.print("&lt;");
  -            else if(c=='>') this.print("&gt;");
  -            else this.out.write(c);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.serialization;
  +
  +import java.io.BufferedOutputStream;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.OutputStreamWriter;
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.xml.XMLConsumer;
  +import org.apache.cocoon.xml.util.NamespacesTable;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:37 $
  + */
  +public class HTMLSerializer extends AbstractSerializer implements 
XMLConsumer {
  +    /** The namespaces table */
  +    private NamespacesTable ns=new NamespacesTable();
  +    /** The PrintStream used for output */
  +    private OutputStreamWriter out=null;
  +    /** The current locator */
  +    private Locator loc=null;
  +    /** A flag telling wether we're processing the DTD */
  +    private boolean dtd=false;
  +    /** A flag telling wether we're processing a CDATA section */
  +    private boolean cdata=false;
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        super.setOutputStream(out);
  +        this.out=new OutputStreamWriter(super.output);;
  +    }
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     *
  +     * @param locator An object that can return the location of any SAX
  +     *                document event.
  +     */
  +    public void setDocumentLocator(Locator locator) {
  +        this.loc=locator;
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +    public void startDocument()
  +    throws SAXException {
  +        String c=super.parameters.getParameter("contentType","text/html");
  +        
((HttpEnvironment)(super.environment)).getResponse().setContentType(c);
  +    }
  +
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +    public void endDocument()
  +    throws SAXException {
  +        try {
  +            this.out.flush();
  +        } catch (IOException e) {
  +            throw new SAXException("IOException flushing stream",e);
  +        }
  +    }
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping.
  +     */
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +        this.ns.addDeclaration(prefix,uri);
  +    }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping.
  +     */
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +        this.ns.removeDeclaration(prefix);
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of an element.
  +     */
  +    public void startElement(String uri, String loc, String raw, Attributes 
a)
  +    throws SAXException {
  +        this.print('<');
  +
  +        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  +        for (int x=0; x<a.getLength(); x++) {
  +            String name=this.ns.resolve(a.getURI(x),a.getQName(x),null,
  +                                        a.getLocalName(x)).getQName();
  +            String value=a.getValue(x);
  +            if ((name.equals("checked"))  || (name.equals("compact"))  ||
  +                (name.equals("declare"))  || (name.equals("defer"))    ||
  +                (name.equals("disabled")) || (name.equals("ismap"))    ||
  +                (name.equals("multiple")) || (name.equals("nohref"))   ||
  +                (name.equals("noresize")) || (name.equals("noshade"))  ||
  +                (name.equals("nowrap"))   || (name.equals("readonly")) ||
  +                (name.equals("selected"))) {
  +                if(name.equals(value)) {
  +                    this.print(' ');
  +                    this.print(name);
  +                } else {
  +                    this.print(' ');
  +                    this.print(name);
  +                    this.print('=');
  +                    this.print('\"');
  +                    this.print(value);
  +                    this.print('\"');
  +                }
  +            } else {
  +                this.print(' ');
  +                this.print(name);
  +                this.print('=');
  +                this.print('\"');
  +                this.print(value);
  +                this.print('\"');
  +            }
  +
  +        }
  +        this.print('>');
  +    }
  +        
  +
  +    /**
  +     * Receive notification of the end of an element.
  +     *
  +     * @param uri The Namespace URI, or the empty string if the element has 
no
  +     *            Namespace URI or if Namespace
  +     *            processing is not being performed.
  +     * @param loc The local name (without prefix), or the empty string if
  +     *            Namespace processing is not being performed.
  +     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
  +     *            raw names are not available.
  +     */
  +    public void endElement (String uri, String loc, String raw)
  +    throws SAXException {
  +        String name=this.ns.resolve(uri,raw,null,loc).getQName();
  +        if ((name.equalsIgnoreCase("AREA"))     || 
(name.equalsIgnoreCase("BASE"))     ||        
  +            (name.equalsIgnoreCase("BASEFONT")) || 
(name.equalsIgnoreCase("BR"))       ||          
  +            (name.equalsIgnoreCase("COL"))      || 
(name.equalsIgnoreCase("FRAME"))    ||       
  +            (name.equalsIgnoreCase("HR"))       || 
(name.equalsIgnoreCase("IMG"))      ||         
  +            (name.equalsIgnoreCase("INPUT"))    || 
(name.equalsIgnoreCase("ISINDEX"))  ||     
  +            (name.equalsIgnoreCase("LINK"))     || 
(name.equalsIgnoreCase("META"))     ||        
  +            (name.equalsIgnoreCase("PARA"))) return;
  +        this.print('<');
  +        this.print('/');
  +        this.print(name);
  +        this.print('>');
  +    }
  +
  +    /**
  +     * Receive notification of character data.
  +     *
  +     * @param ch The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     */
  +    public void characters (char ch[], int start, int len)
  +    throws SAXException {
  +        if(this.cdata) this.print(ch,start,len);
  +        else this.printSafe(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     *
  +     * @param ch The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     */
  +    public void ignorableWhitespace (char ch[], int start, int len)
  +    throws SAXException {
  +        if(this.cdata) this.print(ch,start,len);
  +        else this.printSafe(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of a processing instruction.
  +     *
  +     * @param target The processing instruction target.
  +     * @param data The processing instruction data, or null if none was
  +     *             supplied.
  +     */
  +    public void processingInstruction (String target, String data)
  +    throws SAXException {
  +        this.print("<?");
  +        this.print(target);
  +        this.print(' ');
  +        this.print(data);
  +        this.print("?>");
  +    }
  +
  +    /**
  +     * Receive notification of a skipped entity.
  +     *
  +     * @param name The name of the skipped entity.  If it is a  parameter
  +     *             entity, the name will begin with '%'.
  +     */
  +    public void skippedEntity (String name)
  +    throws SAXException {
  +        this.print('&');
  +        this.print(name);
  +        this.print(';');
  +    }
  +
  +    /**
  +     * Report the start of DTD declarations, if any.
  +     *
  +     * @param name The document type name.
  +     * @param publicId The declared public identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     * @param systemId The declared system identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     */
  +    public void startDTD (String name, String publicId, String systemId)
  +    throws SAXException {
  +        this.print("<!DOCTYPE ");
  +        this.print(name);
  +        if (publicId!=null) {
  +            this.print(" PUBLIC \"");
  +            this.print(publicId);
  +            this.print('\"');
  +            if (systemId!=null) {
  +                this.print(' ');
  +                this.print('\"');
  +                this.print(systemId);
  +                this.print('\"');
  +            }
  +        } else if (systemId!=null) {
  +            this.print(" SYSTEM \"");
  +            this.print(systemId);
  +            this.print('\"');
  +        }
  +        this.print('>');
  +        this.print('\n');
  +        // Set the DTD flag now, to avoid output
  +        this.dtd=true;
  +    }        
  +    
  +    /**
  +     * Report the end of DTD declarations.
  +     */
  +    public void endDTD ()
  +    throws SAXException {
  +        this.dtd=false;
  +    }
  +
  +    /**
  +     * Report the beginning of an entity.
  +     *
  +     * @param name The name of the entity. If it is a parameter entity, the
  +     *             name will begin with '%'.
  +     */
  +    public void startEntity (String name)
  +    throws SAXException {
  +    }        
  +
  +    /**
  +     * Report the end of an entity.
  +     *
  +     * @param name The name of the entity that is ending.
  +     */
  +    public void endEntity (String name)
  +    throws SAXException {
  +    }        
  +
  +    /**
  +     * Report the start of a CDATA section.
  +     */
  +    public void startCDATA ()
  +    throws SAXException {
  +        this.print("<![CDATA[");
  +        this.cdata=true;
  +    }
  +
  +    /**
  +     * Report the end of a CDATA section.
  +     */
  +    public void endCDATA ()
  +    throws SAXException {
  +        this.cdata=false;
  +        this.print("]]>");
  +    }
  +    
  +
  +    /**
  +     * Report an XML comment anywhere in the document.
  +     *
  +     * @param ch An array holding the characters in the comment.
  +     * @param start The starting position in the array.
  +     * @param len The number of characters to use from the array.
  +     */
  +    public void comment (char ch[], int start, int len)
  +    throws SAXException {
  +        this.print("<!--");
  +        this.print(ch,start,len);
  +        this.print("-->");
  +    }
  +
  +    /** Print a string */
  +    private void print(String s)
  +    throws SAXException {
  +        char data[]=s.toCharArray();
  +        this.print(data,0,data.length);
  +    }
  +    
  +    /** Print data from a character array */
  +    private void print(char data[], int start, int len)
  +    throws SAXException {
  +        try {
  +            if(!this.dtd) this.out.write(data,start,len);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +
  +    /** Print data from a character array */
  +    private void print(char c)
  +    throws SAXException {
  +        try {
  +            if(!this.dtd) this.out.write(c);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +
  +    /** Print a string */
  +    private void printSafe(String s)
  +    throws SAXException {
  +        char data[]=s.toCharArray();
  +        this.printSafe(data,0,data.length);
  +    }
  +    
  +    /** Print data from a character array */
  +    private void printSafe(char data[], int start, int len)
  +    throws SAXException {
  +        int end=start+len;
  +        if(!this.dtd) for(int x=0; x<end; x++) this.printSafe(data[x]);
  +    }
  +
  +    /** Print data from a character array */
  +    private void printSafe(char c)
  +    throws SAXException {
  +        try {
  +            if(this.dtd) return;
  +            if(c=='&') this.print("&amp;");
  +            else if(c=='<') this.print("&lt;");
  +            else if(c=='>') this.print("&gt;");
  +            else this.out.write(c);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +}
  
  
  
  1.1.2.3   +365 -365  
xml-cocoon/src/org/apache/cocoon/serialization/Attic/ImageSerializer.java
  
  Index: ImageSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/ImageSerializer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ImageSerializer.java      2000/07/22 20:41:52     1.1.2.2
  +++ ImageSerializer.java      2000/07/29 18:30:37     1.1.2.3
  @@ -1,365 +1,365 @@
  
-/*****************************************************************************
  - * Copyright (C) 1999 The Apache Software Foundation.   All rights reserved. 
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1,  a copy of wich has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.serialization;
  -
  -import org.apache.avalon.*;
  -import org.apache.avalon.utils.*;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.environment.http.HttpEnvironment;
  -import org.apache.cocoon.*;
  -import org.apache.cocoon.components.parser.Parser;
  -import org.apache.cocoon.xml.*;
  -import org.apache.cocoon.xml.util.*;
  -import com.sun.image.codec.jpeg.*;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.io.PrintStream;
  -import java.io.*;
  -import java.net.URL;
  -import java.awt.*;
  -import java.awt.geom.AffineTransform;
  -import java.awt.image.*;
  -import java.util.*;
  -import javax.swing.*;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.ext.*;
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.CDATASection;
  -import org.w3c.dom.Comment;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.DocumentFragment;
  -import org.w3c.dom.DocumentType;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Entity;
  -import org.w3c.dom.EntityReference;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.Notation;
  -import org.w3c.dom.ProcessingInstruction;
  -import org.w3c.dom.Text;
  -
  -/**
  - * The ImagePrinter Printer writes images.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - * @author Copyright 1999 &copy; <a href="http://www.apache.org";>The Apache
  - *         Software Foundation</a>. All rights reserved.
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:52 $
  - */
  -public class ImageSerializer extends DOMBuilder implements Serializer, 
Composer {
  -   
  -    int R=0;
  -    int G=1;
  -    int B=2;
  -    int A=3;
  -
  -    /** The <code>ContentHandler</code> receiving SAX events. */
  -    private ContentHandler contentHandler=null;
  -    /** The <code>LexicalHandler</code> receiving SAX events. */
  -    private LexicalHandler lexicalHandler=null;
  -    /** The component manager instance */
  -    private ComponentManager manager=null;
  -    /** The current <code>Environment</code>. */
  -    private Environment environment=null;
  -    /** The current <code>Parameters</code>. */
  -    private Parameters parameters=null;
  -    /** The source URI associated with the request or <b>null</b>. */
  -    private String source=null;
  -    /** The current <code>OutputStream</code>. */
  -    private OutputStream output=null;
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        this.output=new BufferedOutputStream(out);
  -    }
  -
  -    /**
  -     * Set the <code>Environment</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Environment environment, String src, Parameters par) {
  -        this.environment=environment;
  -        this.source=src;
  -        this.parameters=par;
  -        super.factory=(Parser)this.manager.getComponent("parser");
  -    }
  -
  -    /**
  -     * Set the <code>XMLConsumer</code> that will receive XML data.
  -     * <br>
  -     * This method will simply call <code>setContentHandler(consumer)</code>
  -     * and <code>setLexicalHandler(consumer)</code>.
  -     */
  -    public void setConsumer(XMLConsumer consumer) {
  -        this.contentHandler=consumer;
  -        this.lexicalHandler=consumer;
  -    }
  -
  -    /**
  -     * Set the current <code>ComponentManager</code> instance used by this
  -     * <code>Composer</code>.
  -     */
  -    public void setComponentManager(ComponentManager manager) {
  -        this.manager=manager;
  -    }
  -
  -    /**
  -     * Set the <code>ContentHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>ContentHandler</code> instance
  -     * accessing the protected <code>super.contentHandler</code> field.
  -     */
  -    public void setContentHandler(ContentHandler content) {
  -        this.contentHandler=content;
  -    }
  -
  -    /**
  -     * Set the <code>LexicalHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  -     * accessing the protected <code>super.lexicalHandler</code> field.
  -     *
  -     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  -     *                                  the <code>XMLConsumer</code> were
  -     *                                  already set.
  -     */
  -    public void setLexicalHandler(LexicalHandler lexical) {
  -        this.lexicalHandler=lexical;
  -    }
  -
  -    /**
  -     * Receive notification of a successfully completed DOM tree generation.
  -     */
  -    public void notify(Document doc)
  -    throws SAXException {
  -        
((HttpEnvironment)(this.environment)).getResponse().setContentType("image/jpeg");
  -        try {
  -            this.print(doc,this.output);
  -        } catch(IOException e) {
  -            throw new SAXException("IOException writing image ",e);
  -        }
  -    }
  -
  -    public void print(Document doc, OutputStream out)
  -    throws SAXException, IOException {
  -        // Check for proper root element
  -        Element element=doc.getDocumentElement();
  -        if (!element.getTagName().equals("image")) {
  -            throw new SAXException("Invalid document supplied");
  -        }
  -        // Check wether we have a source image
  -        String source=element.getAttribute("source");
  -        BufferedImage img=null;
  -        Graphics2D gr=null;
  -        // If we have a source image, this is taken as our source.
  -        if (source.length()>0) {
  -            ImageIcon ico=null;
  -            if (source.indexOf(":/")>=0) {
  -                ico=new ImageIcon(new URL(source).openConnection().getURL());
  -            } else ico=new ImageIcon(source);
  -
  -            if ((ico.getIconWidth()<1) | (ico.getIconHeight()<1)) {
  -                throw new SAXException("Cannot load image 
\""+System.getProperty("user.dir")+"/"+source+"\"");
  -            }
  -            img=new BufferedImage(ico.getIconWidth(), ico.getIconHeight(),
  -                                  BufferedImage.TYPE_INT_RGB);
  -            gr=img.createGraphics();
  -            gr.drawImage(ico.getImage(),0,0,ico.getImageObserver());
  -        } else {
  -            // We don't have a source image. Build up a new getting height 
and
  -            // width from attributes
  -            int w=0;
  -            int h=0;
  -            try {
  -                String width=element.getAttribute("width");
  -                String height=element.getAttribute("height");
  -                w=Integer.parseInt(width);
  -                h=Integer.parseInt(height);
  -            } catch (NumberFormatException e) {
  -                throw new SAXException("Image witdth or height error");
  -            }
  -            if ((w<1) | (h<1)) {
  -                throw new SAXException("Image witdth or height unspecified");
  -            }
  -            img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
  -            gr=img.createGraphics();
  -            // Now process the bgcolor attribute for background colorization
  -            int bg=0;
  -            try {
  -                String bgcolor=element.getAttribute("bgcolor");
  -                bg=Integer.parseInt(bgcolor,16);
  -            } catch (NumberFormatException e) {
  -                throw new SAXException("Background color error");
  -            }
  -            Color c=new Color(bg);
  -            gr.setBackground(c);
  -            gr.clearRect(0,0,w,h);
  -            // Check if we have a background to tile
  -            String background=element.getAttribute("background");
  -            if (background.length()>0) {
  -                // We have a background image. Load it.
  -                ImageIcon ico=new ImageIcon(background);
  -                if ((ico.getIconWidth()<1) | (ico.getIconHeight()<1)) {
  -                    throw new SAXException("Cannot load background 
\""+source+"\"");
  -                }
  -                // Tile the image.
  -                int x=0;
  -                int y=0;
  -                while (true) {
  -                    gr.drawImage(ico.getImage(),x,y,ico.getImageObserver());
  -                    x+=ico.getIconWidth();
  -                    if (x>w) {
  -                        x=0;
  -                        y+=ico.getIconHeight();
  -                    }
  -                    if (y>h) break;
  -                }
  -            }
  -        }
  -
  -        // Process child elements
  -        NodeList l=element.getChildNodes();
  -        for (int x=0;x<l.getLength();x++) {
  -            if (l.item(x).getNodeType()==Node.ELEMENT_NODE) {
  -                processElement((Element)l.item(x),img);
  -            }
  -        }
  -
  -        // Write out image (highest quality for jpeg data)
  -        JPEGEncodeParam jpar=JPEGCodec.getDefaultJPEGEncodeParam(img);
  -        jpar.setQuality(1,true);
  -        JPEGImageEncoder jenc=JPEGCodec.createJPEGEncoder(out,jpar);
  -        jenc.encode(img);
  -        out.flush();
  -    }
  -
  -    void processElement(Element e, BufferedImage i)
  -    throws SAXException {
  -        if (e==null) return;
  -        int R=0; int G=1; int B=2; int A=3;
  -        // Create new alpha image
  -        int w=i.getWidth();
  -        int h=i.getHeight();
  -        BufferedImage n=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
  -        // Clear new alpha image
  -        int np[]=new int[]{0,0,0,0};
  -        WritableRaster nr=n.getRaster();
  -        for (int x=0;x<nr.getWidth();x++) for (int 
y=10;y<nr.getHeight();y++) {
  -            nr.setPixel(x,y,np);
  -        }
  -        // Check wich element is being processed.
  -        boolean ret=false;
  -        if (e.getTagName().equals("text")) ret=placeText(e,n);
  -        if(!ret) return;
  -        // Apply new image over existing
  -        WritableRaster ir=i.getRaster();
  -        int ip[]=new int[]{0,0,0,0};
  -        double ia=0;
  -        double na=1;
  -        for (int x=0;x<ir.getWidth();x++) for (int y=0;y<ir.getHeight();y++) 
{
  -            ir.getPixel(x,y,ip);
  -            nr.getPixel(x,y,np);
  -            if (np[A]>0) {
  -                na=((double)np[A]/255);
  -                ia=(1-na);
  -                ip[R]=(int)(((double)ip[R]*ia) + ((double)np[R]*na));
  -                ip[G]=(int)(((double)ip[G]*ia) + ((double)np[G]*na));;
  -                ip[B]=(int)(((double)ip[B]*ia) + ((double)np[B]*na));;
  -            }
  -            ir.setPixel(x,y,ip);
  -        }
  -    }
  -
  -    private boolean placeText(Element e, BufferedImage i)
  -    throws SAXException {
  -        String text=e.getAttribute("text");
  -        String font=e.getAttribute("font");
  -        String ssize=e.getAttribute("size");
  -        String sstyle=e.getAttribute("style");
  -        String scolor=e.getAttribute("color");
  -        String sx=e.getAttribute("x");
  -        String sy=e.getAttribute("y");
  -        String halign=e.getAttribute("halign");
  -        String valign=e.getAttribute("valign");
  -        // Check proper text
  -        if (text.length()<1) return(false);
  -        // Check size, x and y parameters
  -        int color,size,insx,insy;
  -        try {
  -            size=Integer.parseInt(ssize);
  -            insx=Integer.parseInt(sx);
  -            insy=Integer.parseInt(sy);
  -            color=Integer.parseInt(scolor,16);
  -        } catch (NumberFormatException ex) {
  -            throw new SAXException("Attribute size, x, y or color error");
  -        }
  -        // Get style
  -        int style=Font.PLAIN;
  -        if (sstyle.equals("bold")) style=Font.BOLD;
  -        else if (sstyle.equals("italic")) style=Font.ITALIC;
  -        else if (sstyle.equals("bolditalic")) style=Font.BOLD+Font.ITALIC;
  -        Font f=new Font(font,style,size);
  -        FontMetrics m=i.createGraphics().getFontMetrics(f);
  -        // Create temporary image
  -        int w=m.stringWidth(text)*2;
  -        int h=m.getHeight()*2;
  -        BufferedImage n=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
  -        // Write out some text
  -        Graphics2D gr=n.createGraphics();
  -        gr.setColor(new Color(0x0ff000000,true));
  -        gr.setFont(f);
  -        gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
  -                            RenderingHints.VALUE_ANTIALIAS_ON);
  -        gr.drawString(text,5,h-(h/4));
  -        // Resize image
  -        int minx=w;
  -        int miny=h;
  -        int maxx=0;
  -        int maxy=0;
  -        WritableRaster nr=n.getRaster();
  -        int np[]=new int[]{0,0,0,0};
  -        for (int x=0;x<nr.getWidth();x++) for (int 
y=10;y<nr.getHeight();y++) {
  -            nr.getPixel(x,y,np);
  -            if (np[A]>0) {
  -                if(x<minx) minx=x;
  -                if(x>maxx) maxx=x;
  -                if(y<miny) miny=y;
  -                if(y>maxy) maxy=y;
  -            }
  -        }
  -        if (halign.equals("right")) insx=insx-((maxx-minx)+1);
  -        if (halign.equals("center")) insx=insx-(((maxx-minx)+1)/2);
  -        if (valign.equals("bottom")) insy=insy-((maxy-miny)+1);
  -        if (valign.equals("center")) insy=insy-(((maxy-miny)+1)/2);
  -        WritableRaster ir=i.getRaster();
  -        int newx,newy;
  -        newy=insy;
  -        for (int y=miny;y<=maxy;y++) {
  -            newx=insx;
  -            if(newy>=0) {
  -                for (int x=minx;x<=maxx;x++) {
  -                    nr.getPixel(x,y,np);
  -                    np[R]=(color >> 16) & 0x0ff;
  -                    np[G]=(color >> 8) & 0x0ff;
  -                    np[B]=(color & 0x0ff);
  -                    if(newx>=0) ir.setPixel(newx,newy,np);
  -                    newx++;
  -                    if(newx>=i.getWidth()) break;
  -                }
  -            }
  -            newy++;
  -            if(newy>=i.getHeight()) break;
  -        }
  -        return(true);
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) 1999 The Apache Software Foundation.   All rights reserved. 
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1,  a copy of wich has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.serialization;
  +
  +import org.apache.avalon.*;
  +import org.apache.avalon.utils.*;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.*;
  +import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.xml.*;
  +import org.apache.cocoon.xml.util.*;
  +import com.sun.image.codec.jpeg.*;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.PrintStream;
  +import java.io.*;
  +import java.net.URL;
  +import java.awt.*;
  +import java.awt.geom.AffineTransform;
  +import java.awt.image.*;
  +import java.util.*;
  +import javax.swing.*;
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.ext.*;
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.CDATASection;
  +import org.w3c.dom.Comment;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.DocumentFragment;
  +import org.w3c.dom.DocumentType;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.Entity;
  +import org.w3c.dom.EntityReference;
  +import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.Notation;
  +import org.w3c.dom.ProcessingInstruction;
  +import org.w3c.dom.Text;
  +
  +/**
  + * The ImagePrinter Printer writes images.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + * @author Copyright 1999 &copy; <a href="http://www.apache.org";>The Apache
  + *         Software Foundation</a>. All rights reserved.
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:37 $
  + */
  +public class ImageSerializer extends DOMBuilder implements Serializer, 
Composer {
  +   
  +    int R=0;
  +    int G=1;
  +    int B=2;
  +    int A=3;
  +
  +    /** The <code>ContentHandler</code> receiving SAX events. */
  +    private ContentHandler contentHandler=null;
  +    /** The <code>LexicalHandler</code> receiving SAX events. */
  +    private LexicalHandler lexicalHandler=null;
  +    /** The component manager instance */
  +    private ComponentManager manager=null;
  +    /** The current <code>Environment</code>. */
  +    private Environment environment=null;
  +    /** The current <code>Parameters</code>. */
  +    private Parameters parameters=null;
  +    /** The source URI associated with the request or <b>null</b>. */
  +    private String source=null;
  +    /** The current <code>OutputStream</code>. */
  +    private OutputStream output=null;
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        this.output=new BufferedOutputStream(out);
  +    }
  +
  +    /**
  +     * Set the <code>Environment</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par) {
  +        this.environment=environment;
  +        this.source=src;
  +        this.parameters=par;
  +        super.factory=(Parser)this.manager.getComponent("parser");
  +    }
  +
  +    /**
  +     * Set the <code>XMLConsumer</code> that will receive XML data.
  +     * <br>
  +     * This method will simply call <code>setContentHandler(consumer)</code>
  +     * and <code>setLexicalHandler(consumer)</code>.
  +     */
  +    public void setConsumer(XMLConsumer consumer) {
  +        this.contentHandler=consumer;
  +        this.lexicalHandler=consumer;
  +    }
  +
  +    /**
  +     * Set the current <code>ComponentManager</code> instance used by this
  +     * <code>Composer</code>.
  +     */
  +    public void setComponentManager(ComponentManager manager) {
  +        this.manager=manager;
  +    }
  +
  +    /**
  +     * Set the <code>ContentHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>ContentHandler</code> instance
  +     * accessing the protected <code>super.contentHandler</code> field.
  +     */
  +    public void setContentHandler(ContentHandler content) {
  +        this.contentHandler=content;
  +    }
  +
  +    /**
  +     * Set the <code>LexicalHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  +     * accessing the protected <code>super.lexicalHandler</code> field.
  +     *
  +     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  +     *                                  the <code>XMLConsumer</code> were
  +     *                                  already set.
  +     */
  +    public void setLexicalHandler(LexicalHandler lexical) {
  +        this.lexicalHandler=lexical;
  +    }
  +
  +    /**
  +     * Receive notification of a successfully completed DOM tree generation.
  +     */
  +    public void notify(Document doc)
  +    throws SAXException {
  +        
((HttpEnvironment)(this.environment)).getResponse().setContentType("image/jpeg");
  +        try {
  +            this.print(doc,this.output);
  +        } catch(IOException e) {
  +            throw new SAXException("IOException writing image ",e);
  +        }
  +    }
  +
  +    public void print(Document doc, OutputStream out)
  +    throws SAXException, IOException {
  +        // Check for proper root element
  +        Element element=doc.getDocumentElement();
  +        if (!element.getTagName().equals("image")) {
  +            throw new SAXException("Invalid document supplied");
  +        }
  +        // Check wether we have a source image
  +        String source=element.getAttribute("source");
  +        BufferedImage img=null;
  +        Graphics2D gr=null;
  +        // If we have a source image, this is taken as our source.
  +        if (source.length()>0) {
  +            ImageIcon ico=null;
  +            if (source.indexOf(":/")>=0) {
  +                ico=new ImageIcon(new URL(source).openConnection().getURL());
  +            } else ico=new ImageIcon(source);
  +
  +            if ((ico.getIconWidth()<1) | (ico.getIconHeight()<1)) {
  +                throw new SAXException("Cannot load image 
\""+System.getProperty("user.dir")+"/"+source+"\"");
  +            }
  +            img=new BufferedImage(ico.getIconWidth(), ico.getIconHeight(),
  +                                  BufferedImage.TYPE_INT_RGB);
  +            gr=img.createGraphics();
  +            gr.drawImage(ico.getImage(),0,0,ico.getImageObserver());
  +        } else {
  +            // We don't have a source image. Build up a new getting height 
and
  +            // width from attributes
  +            int w=0;
  +            int h=0;
  +            try {
  +                String width=element.getAttribute("width");
  +                String height=element.getAttribute("height");
  +                w=Integer.parseInt(width);
  +                h=Integer.parseInt(height);
  +            } catch (NumberFormatException e) {
  +                throw new SAXException("Image witdth or height error");
  +            }
  +            if ((w<1) | (h<1)) {
  +                throw new SAXException("Image witdth or height unspecified");
  +            }
  +            img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
  +            gr=img.createGraphics();
  +            // Now process the bgcolor attribute for background colorization
  +            int bg=0;
  +            try {
  +                String bgcolor=element.getAttribute("bgcolor");
  +                bg=Integer.parseInt(bgcolor,16);
  +            } catch (NumberFormatException e) {
  +                throw new SAXException("Background color error");
  +            }
  +            Color c=new Color(bg);
  +            gr.setBackground(c);
  +            gr.clearRect(0,0,w,h);
  +            // Check if we have a background to tile
  +            String background=element.getAttribute("background");
  +            if (background.length()>0) {
  +                // We have a background image. Load it.
  +                ImageIcon ico=new ImageIcon(background);
  +                if ((ico.getIconWidth()<1) | (ico.getIconHeight()<1)) {
  +                    throw new SAXException("Cannot load background 
\""+source+"\"");
  +                }
  +                // Tile the image.
  +                int x=0;
  +                int y=0;
  +                while (true) {
  +                    gr.drawImage(ico.getImage(),x,y,ico.getImageObserver());
  +                    x+=ico.getIconWidth();
  +                    if (x>w) {
  +                        x=0;
  +                        y+=ico.getIconHeight();
  +                    }
  +                    if (y>h) break;
  +                }
  +            }
  +        }
  +
  +        // Process child elements
  +        NodeList l=element.getChildNodes();
  +        for (int x=0;x<l.getLength();x++) {
  +            if (l.item(x).getNodeType()==Node.ELEMENT_NODE) {
  +                processElement((Element)l.item(x),img);
  +            }
  +        }
  +
  +        // Write out image (highest quality for jpeg data)
  +        JPEGEncodeParam jpar=JPEGCodec.getDefaultJPEGEncodeParam(img);
  +        jpar.setQuality(1,true);
  +        JPEGImageEncoder jenc=JPEGCodec.createJPEGEncoder(out,jpar);
  +        jenc.encode(img);
  +        out.flush();
  +    }
  +
  +    void processElement(Element e, BufferedImage i)
  +    throws SAXException {
  +        if (e==null) return;
  +        int R=0; int G=1; int B=2; int A=3;
  +        // Create new alpha image
  +        int w=i.getWidth();
  +        int h=i.getHeight();
  +        BufferedImage n=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
  +        // Clear new alpha image
  +        int np[]=new int[]{0,0,0,0};
  +        WritableRaster nr=n.getRaster();
  +        for (int x=0;x<nr.getWidth();x++) for (int 
y=10;y<nr.getHeight();y++) {
  +            nr.setPixel(x,y,np);
  +        }
  +        // Check wich element is being processed.
  +        boolean ret=false;
  +        if (e.getTagName().equals("text")) ret=placeText(e,n);
  +        if(!ret) return;
  +        // Apply new image over existing
  +        WritableRaster ir=i.getRaster();
  +        int ip[]=new int[]{0,0,0,0};
  +        double ia=0;
  +        double na=1;
  +        for (int x=0;x<ir.getWidth();x++) for (int y=0;y<ir.getHeight();y++) 
{
  +            ir.getPixel(x,y,ip);
  +            nr.getPixel(x,y,np);
  +            if (np[A]>0) {
  +                na=((double)np[A]/255);
  +                ia=(1-na);
  +                ip[R]=(int)(((double)ip[R]*ia) + ((double)np[R]*na));
  +                ip[G]=(int)(((double)ip[G]*ia) + ((double)np[G]*na));;
  +                ip[B]=(int)(((double)ip[B]*ia) + ((double)np[B]*na));;
  +            }
  +            ir.setPixel(x,y,ip);
  +        }
  +    }
  +
  +    private boolean placeText(Element e, BufferedImage i)
  +    throws SAXException {
  +        String text=e.getAttribute("text");
  +        String font=e.getAttribute("font");
  +        String ssize=e.getAttribute("size");
  +        String sstyle=e.getAttribute("style");
  +        String scolor=e.getAttribute("color");
  +        String sx=e.getAttribute("x");
  +        String sy=e.getAttribute("y");
  +        String halign=e.getAttribute("halign");
  +        String valign=e.getAttribute("valign");
  +        // Check proper text
  +        if (text.length()<1) return(false);
  +        // Check size, x and y parameters
  +        int color,size,insx,insy;
  +        try {
  +            size=Integer.parseInt(ssize);
  +            insx=Integer.parseInt(sx);
  +            insy=Integer.parseInt(sy);
  +            color=Integer.parseInt(scolor,16);
  +        } catch (NumberFormatException ex) {
  +            throw new SAXException("Attribute size, x, y or color error");
  +        }
  +        // Get style
  +        int style=Font.PLAIN;
  +        if (sstyle.equals("bold")) style=Font.BOLD;
  +        else if (sstyle.equals("italic")) style=Font.ITALIC;
  +        else if (sstyle.equals("bolditalic")) style=Font.BOLD+Font.ITALIC;
  +        Font f=new Font(font,style,size);
  +        FontMetrics m=i.createGraphics().getFontMetrics(f);
  +        // Create temporary image
  +        int w=m.stringWidth(text)*2;
  +        int h=m.getHeight()*2;
  +        BufferedImage n=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
  +        // Write out some text
  +        Graphics2D gr=n.createGraphics();
  +        gr.setColor(new Color(0x0ff000000,true));
  +        gr.setFont(f);
  +        gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
  +                            RenderingHints.VALUE_ANTIALIAS_ON);
  +        gr.drawString(text,5,h-(h/4));
  +        // Resize image
  +        int minx=w;
  +        int miny=h;
  +        int maxx=0;
  +        int maxy=0;
  +        WritableRaster nr=n.getRaster();
  +        int np[]=new int[]{0,0,0,0};
  +        for (int x=0;x<nr.getWidth();x++) for (int 
y=10;y<nr.getHeight();y++) {
  +            nr.getPixel(x,y,np);
  +            if (np[A]>0) {
  +                if(x<minx) minx=x;
  +                if(x>maxx) maxx=x;
  +                if(y<miny) miny=y;
  +                if(y>maxy) maxy=y;
  +            }
  +        }
  +        if (halign.equals("right")) insx=insx-((maxx-minx)+1);
  +        if (halign.equals("center")) insx=insx-(((maxx-minx)+1)/2);
  +        if (valign.equals("bottom")) insy=insy-((maxy-miny)+1);
  +        if (valign.equals("center")) insy=insy-(((maxy-miny)+1)/2);
  +        WritableRaster ir=i.getRaster();
  +        int newx,newy;
  +        newy=insy;
  +        for (int y=miny;y<=maxy;y++) {
  +            newx=insx;
  +            if(newy>=0) {
  +                for (int x=minx;x<=maxx;x++) {
  +                    nr.getPixel(x,y,np);
  +                    np[R]=(color >> 16) & 0x0ff;
  +                    np[G]=(color >> 8) & 0x0ff;
  +                    np[B]=(color & 0x0ff);
  +                    if(newx>=0) ir.setPixel(newx,newy,np);
  +                    newx++;
  +                    if(newx>=i.getWidth()) break;
  +                }
  +            }
  +            newy++;
  +            if(newy>=i.getHeight()) break;
  +        }
  +        return(true);
  +    }
  +}
  
  
  
  1.1.2.3   +161 -161  
xml-cocoon/src/org/apache/cocoon/serialization/Attic/SVGSerializer.java
  
  Index: SVGSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/SVGSerializer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- SVGSerializer.java        2000/07/22 20:41:52     1.1.2.2
  +++ SVGSerializer.java        2000/07/29 18:30:37     1.1.2.3
  @@ -1,161 +1,161 @@
  
-/*****************************************************************************
  - * Copyright (C) 1999 The Apache Software Foundation.   All rights reserved. 
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1,  a copy of wich has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.serialization;
  -
  -import org.apache.avalon.*;
  -import org.apache.avalon.utils.*;
  -import org.apache.cocoon.*;
  -import org.apache.cocoon.environment.http.HttpEnvironment;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.components.parser.Parser;
  -import org.apache.cocoon.xml.*;
  -import org.apache.cocoon.xml.util.*;
  -import com.sun.image.codec.jpeg.*;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.io.PrintStream;
  -import java.io.*;
  -import java.net.URL;
  -import java.awt.*;
  -import java.awt.geom.AffineTransform;
  -import java.awt.image.*;
  -import java.util.*;
  -import javax.swing.*;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.ext.*;
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.CDATASection;
  -import org.w3c.dom.Comment;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.DocumentFragment;
  -import org.w3c.dom.DocumentType;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Entity;
  -import org.w3c.dom.EntityReference;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.Notation;
  -import org.w3c.dom.ProcessingInstruction;
  -import org.w3c.dom.Text;
  -import org.csiro.svgv.display.*;
  -
  -/**
  - * The ImagePrinter Printer writes images.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - * @author Copyright 1999 &copy; <a href="http://www.apache.org";>The Apache
  - *         Software Foundation</a>. All rights reserved.
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:52 $
  - */
  -public class SVGSerializer extends DOMBuilder implements Serializer, 
Composer {
  -   
  -    int R=0;
  -    int G=1;
  -    int B=2;
  -    int A=3;
  -
  -    /** The <code>ContentHandler</code> receiving SAX events. */
  -    private ContentHandler contentHandler=null;
  -    /** The <code>LexicalHandler</code> receiving SAX events. */
  -    private LexicalHandler lexicalHandler=null;
  -    /** The component manager instance */
  -    private ComponentManager manager=null;
  -    /** The current <code>Environment</code>. */
  -    private Environment environment=null;
  -    /** The current <code>Parameters</code>. */
  -    private Parameters parameters=null;
  -    /** The source URI associated with the request or <b>null</b>. */
  -    private String source=null;
  -    /** The current <code>OutputStream</code>. */
  -    private OutputStream output=null;
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        this.output=new BufferedOutputStream(out);
  -    }
  -
  -    /**
  -     * Set the <code>Environment</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Environment environment, String src, Parameters par) {
  -        this.environment=environment;
  -        this.source=src;
  -        this.parameters=par;
  -        super.factory=(Parser)this.manager.getComponent("parser");
  -    }
  -
  -    /**
  -     * Set the <code>XMLConsumer</code> that will receive XML data.
  -     * <br>
  -     * This method will simply call <code>setContentHandler(consumer)</code>
  -     * and <code>setLexicalHandler(consumer)</code>.
  -     */
  -    public void setConsumer(XMLConsumer consumer) {
  -        this.contentHandler=consumer;
  -        this.lexicalHandler=consumer;
  -    }
  -
  -    /**
  -     * Set the current <code>ComponentManager</code> instance used by this
  -     * <code>Composer</code>.
  -     */
  -    public void setComponentManager(ComponentManager manager) {
  -        this.manager=manager;
  -    }
  -
  -    /**
  -     * Set the <code>ContentHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>ContentHandler</code> instance
  -     * accessing the protected <code>super.contentHandler</code> field.
  -     */
  -    public void setContentHandler(ContentHandler content) {
  -        this.contentHandler=content;
  -    }
  -
  -    /**
  -     * Set the <code>LexicalHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  -     * accessing the protected <code>super.lexicalHandler</code> field.
  -     *
  -     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  -     *                                  the <code>XMLConsumer</code> were
  -     *                                  already set.
  -     */
  -    public void setLexicalHandler(LexicalHandler lexical) {
  -        this.lexicalHandler=lexical;
  -    }
  -
  -    /**
  -     * Receive notification of a successfully completed DOM tree generation.
  -     */
  -    public void notify(Document doc)
  -    throws SAXException {
  -        
((HttpEnvironment)(this.environment)).getResponse().setContentType("image/jpeg");
  -        try {
  -            BufferedImage img=SvgToAwtConverter.convert(doc,this.source);
  -            OutputStream out=this.output;
  -            // Write out image (highest quality for jpeg data)
  -            JPEGEncodeParam jpar=JPEGCodec.getDefaultJPEGEncodeParam(img);
  -            jpar.setQuality(1,true);
  -            JPEGImageEncoder jenc=JPEGCodec.createJPEGEncoder(out,jpar);
  -            jenc.encode(img);
  -            out.flush();
  -
  -        } catch(IOException e) {
  -            throw new SAXException("IOException writing image ",e);
  -        }
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) 1999 The Apache Software Foundation.   All rights reserved. 
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1,  a copy of wich has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.serialization;
  +
  +import org.apache.avalon.*;
  +import org.apache.avalon.utils.*;
  +import org.apache.cocoon.*;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.xml.*;
  +import org.apache.cocoon.xml.util.*;
  +import com.sun.image.codec.jpeg.*;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.PrintStream;
  +import java.io.*;
  +import java.net.URL;
  +import java.awt.*;
  +import java.awt.geom.AffineTransform;
  +import java.awt.image.*;
  +import java.util.*;
  +import javax.swing.*;
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.ext.*;
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.CDATASection;
  +import org.w3c.dom.Comment;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.DocumentFragment;
  +import org.w3c.dom.DocumentType;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.Entity;
  +import org.w3c.dom.EntityReference;
  +import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.Notation;
  +import org.w3c.dom.ProcessingInstruction;
  +import org.w3c.dom.Text;
  +import org.csiro.svgv.display.*;
  +
  +/**
  + * The ImagePrinter Printer writes images.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + * @author Copyright 1999 &copy; <a href="http://www.apache.org";>The Apache
  + *         Software Foundation</a>. All rights reserved.
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:37 $
  + */
  +public class SVGSerializer extends DOMBuilder implements Serializer, 
Composer {
  +   
  +    int R=0;
  +    int G=1;
  +    int B=2;
  +    int A=3;
  +
  +    /** The <code>ContentHandler</code> receiving SAX events. */
  +    private ContentHandler contentHandler=null;
  +    /** The <code>LexicalHandler</code> receiving SAX events. */
  +    private LexicalHandler lexicalHandler=null;
  +    /** The component manager instance */
  +    private ComponentManager manager=null;
  +    /** The current <code>Environment</code>. */
  +    private Environment environment=null;
  +    /** The current <code>Parameters</code>. */
  +    private Parameters parameters=null;
  +    /** The source URI associated with the request or <b>null</b>. */
  +    private String source=null;
  +    /** The current <code>OutputStream</code>. */
  +    private OutputStream output=null;
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        this.output=new BufferedOutputStream(out);
  +    }
  +
  +    /**
  +     * Set the <code>Environment</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par) {
  +        this.environment=environment;
  +        this.source=src;
  +        this.parameters=par;
  +        super.factory=(Parser)this.manager.getComponent("parser");
  +    }
  +
  +    /**
  +     * Set the <code>XMLConsumer</code> that will receive XML data.
  +     * <br>
  +     * This method will simply call <code>setContentHandler(consumer)</code>
  +     * and <code>setLexicalHandler(consumer)</code>.
  +     */
  +    public void setConsumer(XMLConsumer consumer) {
  +        this.contentHandler=consumer;
  +        this.lexicalHandler=consumer;
  +    }
  +
  +    /**
  +     * Set the current <code>ComponentManager</code> instance used by this
  +     * <code>Composer</code>.
  +     */
  +    public void setComponentManager(ComponentManager manager) {
  +        this.manager=manager;
  +    }
  +
  +    /**
  +     * Set the <code>ContentHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>ContentHandler</code> instance
  +     * accessing the protected <code>super.contentHandler</code> field.
  +     */
  +    public void setContentHandler(ContentHandler content) {
  +        this.contentHandler=content;
  +    }
  +
  +    /**
  +     * Set the <code>LexicalHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  +     * accessing the protected <code>super.lexicalHandler</code> field.
  +     *
  +     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  +     *                                  the <code>XMLConsumer</code> were
  +     *                                  already set.
  +     */
  +    public void setLexicalHandler(LexicalHandler lexical) {
  +        this.lexicalHandler=lexical;
  +    }
  +
  +    /**
  +     * Receive notification of a successfully completed DOM tree generation.
  +     */
  +    public void notify(Document doc)
  +    throws SAXException {
  +        
((HttpEnvironment)(this.environment)).getResponse().setContentType("image/jpeg");
  +        try {
  +            BufferedImage img=SvgToAwtConverter.convert(doc,this.source);
  +            OutputStream out=this.output;
  +            // Write out image (highest quality for jpeg data)
  +            JPEGEncodeParam jpar=JPEGCodec.getDefaultJPEGEncodeParam(img);
  +            jpar.setQuality(1,true);
  +            JPEGImageEncoder jenc=JPEGCodec.createJPEGEncoder(out,jpar);
  +            jenc.encode(img);
  +            out.flush();
  +
  +        } catch(IOException e) {
  +            throw new SAXException("IOException writing image ",e);
  +        }
  +    }
  +}
  
  
  
  1.1.2.3   +27 -27    
xml-cocoon/src/org/apache/cocoon/serialization/Attic/Serializer.java
  
  Index: Serializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/Serializer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Serializer.java   2000/07/22 20:41:53     1.1.2.2
  +++ Serializer.java   2000/07/29 18:30:37     1.1.2.3
  @@ -1,27 +1,27 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.serialization;
  -
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import org.apache.cocoon.sitemap.SitemapComponent;
  -import org.apache.cocoon.xml.XMLConsumer;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:53 $
  - */
  -public interface Serializer extends XMLConsumer, SitemapComponent {
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out);
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.serialization;
  +
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import org.apache.cocoon.sitemap.SitemapComponent;
  +import org.apache.cocoon.xml.XMLConsumer;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:37 $
  + */
  +public interface Serializer extends XMLConsumer, SitemapComponent {
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out);
  +}
  
  
  
  1.1.2.3   +388 -388  
xml-cocoon/src/org/apache/cocoon/serialization/Attic/XMLSerializer.java
  
  Index: XMLSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/XMLSerializer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- XMLSerializer.java        2000/07/22 20:41:53     1.1.2.2
  +++ XMLSerializer.java        2000/07/29 18:30:37     1.1.2.3
  @@ -1,388 +1,388 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.serialization;
  -
  -import java.io.BufferedOutputStream;
  -import java.io.IOException;
  -import java.io.OutputStream;
  -import java.io.OutputStreamWriter;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import org.apache.cocoon.environment.http.HttpEnvironment;
  -import org.apache.cocoon.xml.XMLConsumer;
  -import org.apache.cocoon.xml.util.NamespacesTable;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:41:53 $
  - */
  -public class XMLSerializer extends AbstractSerializer implements XMLConsumer 
{
  -    /** The namespaces table */
  -    private NamespacesTable ns=new NamespacesTable();
  -    /** The PrintStream used for output */
  -    private OutputStreamWriter out=null;
  -    /** The current locator */
  -    private Locator loc=null;
  -    /** A flag representing an open element (for "/>" or ">") */
  -    private boolean openElement=false;
  -    /** A flag telling wether we're processing the DTD */
  -    private boolean dtd=false;
  -    /** A flag telling wether we're processing a CDATA section */
  -    private boolean cdata=false;
  -    /** The table of the namespaces to declare */
  -    private Hashtable nstd=new Hashtable();
  -
  -    /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  -     */
  -    public void setOutputStream(OutputStream out) {
  -        super.setOutputStream(out);
  -        this.out=new OutputStreamWriter(super.output);;
  -    }
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     *
  -     * @param locator An object that can return the location of any SAX
  -     *                document event.
  -     */
  -    public void setDocumentLocator(Locator locator) {
  -        this.loc=locator;
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument()
  -    throws SAXException {
  -        String c=super.parameters.getParameter("contentType","text/xml");
  -        
((HttpEnvironment)(super.environment)).getResponse().setContentType(c);
  -        this.print("<?xml version=\"1.0\"?>\n");
  -    }
  -
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument()
  -    throws SAXException {
  -        this.closeElement();
  -        try {
  -            this.out.flush();
  -        } catch (IOException e) {
  -            throw new SAXException("IOException flushing stream",e);
  -        }
  -    }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -        this.ns.addDeclaration(prefix,uri);
  -        this.nstd.put(prefix,uri);
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -        this.ns.removeDeclaration(prefix);
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes 
a)
  -    throws SAXException {
  -        this.closeElement();
  -        this.print('<');
  -
  -        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  -        for (int x=0; x<a.getLength(); x++) {
  -            this.print(' ');
  -            this.print(this.ns.resolve(a.getURI(x),a.getQName(x),null,
  -                                       a.getLocalName(x)).getQName());
  -            this.print('=');
  -            this.print('\"');
  -            this.printSafe(a.getValue(x));
  -            this.print('\"');
  -        }
  -
  -        Enumeration e=this.nstd.keys();
  -        while (e.hasMoreElements()) {
  -            this.print(' ');
  -            String nsname=(String)e.nextElement();
  -            String nsuri=(String)this.nstd.get(nsname);
  -            if (nsname.length()>0) {
  -                this.print("xmlns:");
  -                this.print(nsname);
  -            } else this.print("xmlns");
  -            this.print('=');
  -            this.print('\"');
  -            this.printSafe(nsuri);
  -            this.print('\"');
  -        }
  -        this.nstd.clear();
  -
  -        this.openElement=true;
  -    }
  -        
  -
  -    /**
  -     * Receive notification of the end of an element.
  -     *
  -     * @param uri The Namespace URI, or the empty string if the element has 
no
  -     *            Namespace URI or if Namespace
  -     *            processing is not being performed.
  -     * @param loc The local name (without prefix), or the empty string if
  -     *            Namespace processing is not being performed.
  -     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
  -     *            raw names are not available.
  -     */
  -    public void endElement (String uri, String loc, String raw)
  -    throws SAXException {
  -        if (this.openElement) {
  -            this.print('/');
  -            this.closeElement();
  -            return;
  -        }
  -        this.print('<');
  -        this.print('/');
  -        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  -        this.print('>');
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     *
  -     * @param ch The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     */
  -    public void characters (char ch[], int start, int len)
  -    throws SAXException {
  -        this.closeElement();
  -        if(this.cdata) this.print(ch,start,len);
  -        else this.printSafe(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     *
  -     * @param ch The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     */
  -    public void ignorableWhitespace (char ch[], int start, int len)
  -    throws SAXException {
  -        this.closeElement();
  -        if(this.cdata) this.print(ch,start,len);
  -        else this.printSafe(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of a processing instruction.
  -     *
  -     * @param target The processing instruction target.
  -     * @param data The processing instruction data, or null if none was
  -     *             supplied.
  -     */
  -    public void processingInstruction (String target, String data)
  -    throws SAXException {
  -        this.closeElement();
  -        this.print("<?");
  -        this.print(target);
  -        this.print(' ');
  -        this.print(data);
  -        this.print("?>");
  -    }
  -
  -    /**
  -     * Receive notification of a skipped entity.
  -     *
  -     * @param name The name of the skipped entity.  If it is a  parameter
  -     *             entity, the name will begin with '%'.
  -     */
  -    public void skippedEntity (String name)
  -    throws SAXException {
  -        this.closeElement();
  -        this.print('&');
  -        this.print(name);
  -        this.print(';');
  -    }
  -
  -    /**
  -     * Report the start of DTD declarations, if any.
  -     *
  -     * @param name The document type name.
  -     * @param publicId The declared public identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     * @param systemId The declared system identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     */
  -    public void startDTD (String name, String publicId, String systemId)
  -    throws SAXException {
  -        this.print("<!DOCTYPE ");
  -        this.print(name);
  -        if (publicId!=null) {
  -            this.print(" PUBLIC \"");
  -            this.print(publicId);
  -            this.print('\"');
  -            if (systemId!=null) {
  -                this.print(' ');
  -                this.print('\"');
  -                this.print(systemId);
  -                this.print('\"');
  -            }
  -        } else if (systemId!=null) {
  -            this.print(" SYSTEM \"");
  -            this.print(systemId);
  -            this.print('\"');
  -        }
  -        this.print('>');
  -        this.print('\n');
  -        // Set the DTD flag now, to avoid output
  -        this.dtd=true;
  -    }        
  -    
  -    /**
  -     * Report the end of DTD declarations.
  -     */
  -    public void endDTD ()
  -    throws SAXException {
  -        this.dtd=false;
  -    }
  -
  -    /**
  -     * Report the beginning of an entity.
  -     *
  -     * @param name The name of the entity. If it is a parameter entity, the
  -     *             name will begin with '%'.
  -     */
  -    public void startEntity (String name)
  -    throws SAXException {
  -        this.closeElement();
  -    }        
  -
  -    /**
  -     * Report the end of an entity.
  -     *
  -     * @param name The name of the entity that is ending.
  -     */
  -    public void endEntity (String name)
  -    throws SAXException {
  -        this.closeElement();
  -    }        
  -
  -    /**
  -     * Report the start of a CDATA section.
  -     */
  -    public void startCDATA ()
  -    throws SAXException {
  -        this.closeElement();
  -        this.print("<![CDATA[");
  -        this.cdata=true;
  -    }
  -
  -    /**
  -     * Report the end of a CDATA section.
  -     */
  -    public void endCDATA ()
  -    throws SAXException {
  -        this.cdata=false;
  -        this.closeElement();
  -        this.print("]]>");
  -    }
  -    
  -
  -    /**
  -     * Report an XML comment anywhere in the document.
  -     *
  -     * @param ch An array holding the characters in the comment.
  -     * @param start The starting position in the array.
  -     * @param len The number of characters to use from the array.
  -     */
  -    public void comment (char ch[], int start, int len)
  -    throws SAXException {
  -        this.closeElement();
  -        this.print("<!--");
  -        this.print(ch,start,len);
  -        this.print("-->");
  -    }
  -
  -    /** Print a string */
  -    private void print(String s)
  -    throws SAXException {
  -        if(s==null) return;
  -        char data[]=s.toCharArray();
  -        this.print(data,0,data.length);
  -    }
  -    
  -    /** Print data from a character array */
  -    private void print(char data[], int start, int len)
  -    throws SAXException {
  -        try {
  -            if(!this.dtd) this.out.write(data,start,len);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -
  -    /** Print data from a character array */
  -    private void print(char c)
  -    throws SAXException {
  -        try {
  -            if(!this.dtd) this.out.write(c);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -
  -    /** Print a string */
  -    private void printSafe(String s)
  -    throws SAXException {
  -        if(s==null) return;
  -        char data[]=s.toCharArray();
  -        this.printSafe(data,0,data.length);
  -    }
  -    
  -    /** Print data from a character array */
  -    private void printSafe(char data[], int start, int len)
  -    throws SAXException {
  -        int end=start+len;
  -        if(!this.dtd) for(int x=start; x<end; x++) this.printSafe(data[x]);
  -    }
  -
  -    /** Print data from a character array */
  -    private void printSafe(char c)
  -    throws SAXException {
  -        try {
  -            if(this.dtd) return;
  -            if(c=='&') this.print("&amp;");
  -            else if(c=='<') this.print("&lt;");
  -            else if(c=='>') this.print("&gt;");
  -            else this.out.write(c);
  -        } catch (IOException e) {
  -            throw new SAXException("IOException printing data",e);
  -        }
  -    }
  -
  -    /** Close an element, if required */
  -    private void closeElement()
  -    throws SAXException {
  -        if(!this.openElement) return;
  -        this.print('>');
  -        this.openElement=false;
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.serialization;
  +
  +import java.io.BufferedOutputStream;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.OutputStreamWriter;
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.xml.XMLConsumer;
  +import org.apache.cocoon.xml.util.NamespacesTable;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:37 $
  + */
  +public class XMLSerializer extends AbstractSerializer implements XMLConsumer 
{
  +    /** The namespaces table */
  +    private NamespacesTable ns=new NamespacesTable();
  +    /** The PrintStream used for output */
  +    private OutputStreamWriter out=null;
  +    /** The current locator */
  +    private Locator loc=null;
  +    /** A flag representing an open element (for "/>" or ">") */
  +    private boolean openElement=false;
  +    /** A flag telling wether we're processing the DTD */
  +    private boolean dtd=false;
  +    /** A flag telling wether we're processing a CDATA section */
  +    private boolean cdata=false;
  +    /** The table of the namespaces to declare */
  +    private Hashtable nstd=new Hashtable();
  +
  +    /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        super.setOutputStream(out);
  +        this.out=new OutputStreamWriter(super.output);;
  +    }
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     *
  +     * @param locator An object that can return the location of any SAX
  +     *                document event.
  +     */
  +    public void setDocumentLocator(Locator locator) {
  +        this.loc=locator;
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +    public void startDocument()
  +    throws SAXException {
  +        String c=super.parameters.getParameter("contentType","text/xml");
  +        
((HttpEnvironment)(super.environment)).getResponse().setContentType(c);
  +        this.print("<?xml version=\"1.0\"?>\n");
  +    }
  +
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +    public void endDocument()
  +    throws SAXException {
  +        this.closeElement();
  +        try {
  +            this.out.flush();
  +        } catch (IOException e) {
  +            throw new SAXException("IOException flushing stream",e);
  +        }
  +    }
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping.
  +     */
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +        this.ns.addDeclaration(prefix,uri);
  +        this.nstd.put(prefix,uri);
  +    }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping.
  +     */
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +        this.ns.removeDeclaration(prefix);
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of an element.
  +     */
  +    public void startElement(String uri, String loc, String raw, Attributes 
a)
  +    throws SAXException {
  +        this.closeElement();
  +        this.print('<');
  +
  +        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  +        for (int x=0; x<a.getLength(); x++) {
  +            this.print(' ');
  +            this.print(this.ns.resolve(a.getURI(x),a.getQName(x),null,
  +                                       a.getLocalName(x)).getQName());
  +            this.print('=');
  +            this.print('\"');
  +            this.printSafe(a.getValue(x));
  +            this.print('\"');
  +        }
  +
  +        Enumeration e=this.nstd.keys();
  +        while (e.hasMoreElements()) {
  +            this.print(' ');
  +            String nsname=(String)e.nextElement();
  +            String nsuri=(String)this.nstd.get(nsname);
  +            if (nsname.length()>0) {
  +                this.print("xmlns:");
  +                this.print(nsname);
  +            } else this.print("xmlns");
  +            this.print('=');
  +            this.print('\"');
  +            this.printSafe(nsuri);
  +            this.print('\"');
  +        }
  +        this.nstd.clear();
  +
  +        this.openElement=true;
  +    }
  +        
  +
  +    /**
  +     * Receive notification of the end of an element.
  +     *
  +     * @param uri The Namespace URI, or the empty string if the element has 
no
  +     *            Namespace URI or if Namespace
  +     *            processing is not being performed.
  +     * @param loc The local name (without prefix), or the empty string if
  +     *            Namespace processing is not being performed.
  +     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
  +     *            raw names are not available.
  +     */
  +    public void endElement (String uri, String loc, String raw)
  +    throws SAXException {
  +        if (this.openElement) {
  +            this.print('/');
  +            this.closeElement();
  +            return;
  +        }
  +        this.print('<');
  +        this.print('/');
  +        this.print(this.ns.resolve(uri,raw,null,loc).getQName());
  +        this.print('>');
  +    }
  +
  +    /**
  +     * Receive notification of character data.
  +     *
  +     * @param ch The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     */
  +    public void characters (char ch[], int start, int len)
  +    throws SAXException {
  +        this.closeElement();
  +        if(this.cdata) this.print(ch,start,len);
  +        else this.printSafe(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     *
  +     * @param ch The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     */
  +    public void ignorableWhitespace (char ch[], int start, int len)
  +    throws SAXException {
  +        this.closeElement();
  +        if(this.cdata) this.print(ch,start,len);
  +        else this.printSafe(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of a processing instruction.
  +     *
  +     * @param target The processing instruction target.
  +     * @param data The processing instruction data, or null if none was
  +     *             supplied.
  +     */
  +    public void processingInstruction (String target, String data)
  +    throws SAXException {
  +        this.closeElement();
  +        this.print("<?");
  +        this.print(target);
  +        this.print(' ');
  +        this.print(data);
  +        this.print("?>");
  +    }
  +
  +    /**
  +     * Receive notification of a skipped entity.
  +     *
  +     * @param name The name of the skipped entity.  If it is a  parameter
  +     *             entity, the name will begin with '%'.
  +     */
  +    public void skippedEntity (String name)
  +    throws SAXException {
  +        this.closeElement();
  +        this.print('&');
  +        this.print(name);
  +        this.print(';');
  +    }
  +
  +    /**
  +     * Report the start of DTD declarations, if any.
  +     *
  +     * @param name The document type name.
  +     * @param publicId The declared public identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     * @param systemId The declared system identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     */
  +    public void startDTD (String name, String publicId, String systemId)
  +    throws SAXException {
  +        this.print("<!DOCTYPE ");
  +        this.print(name);
  +        if (publicId!=null) {
  +            this.print(" PUBLIC \"");
  +            this.print(publicId);
  +            this.print('\"');
  +            if (systemId!=null) {
  +                this.print(' ');
  +                this.print('\"');
  +                this.print(systemId);
  +                this.print('\"');
  +            }
  +        } else if (systemId!=null) {
  +            this.print(" SYSTEM \"");
  +            this.print(systemId);
  +            this.print('\"');
  +        }
  +        this.print('>');
  +        this.print('\n');
  +        // Set the DTD flag now, to avoid output
  +        this.dtd=true;
  +    }        
  +    
  +    /**
  +     * Report the end of DTD declarations.
  +     */
  +    public void endDTD ()
  +    throws SAXException {
  +        this.dtd=false;
  +    }
  +
  +    /**
  +     * Report the beginning of an entity.
  +     *
  +     * @param name The name of the entity. If it is a parameter entity, the
  +     *             name will begin with '%'.
  +     */
  +    public void startEntity (String name)
  +    throws SAXException {
  +        this.closeElement();
  +    }        
  +
  +    /**
  +     * Report the end of an entity.
  +     *
  +     * @param name The name of the entity that is ending.
  +     */
  +    public void endEntity (String name)
  +    throws SAXException {
  +        this.closeElement();
  +    }        
  +
  +    /**
  +     * Report the start of a CDATA section.
  +     */
  +    public void startCDATA ()
  +    throws SAXException {
  +        this.closeElement();
  +        this.print("<![CDATA[");
  +        this.cdata=true;
  +    }
  +
  +    /**
  +     * Report the end of a CDATA section.
  +     */
  +    public void endCDATA ()
  +    throws SAXException {
  +        this.cdata=false;
  +        this.closeElement();
  +        this.print("]]>");
  +    }
  +    
  +
  +    /**
  +     * Report an XML comment anywhere in the document.
  +     *
  +     * @param ch An array holding the characters in the comment.
  +     * @param start The starting position in the array.
  +     * @param len The number of characters to use from the array.
  +     */
  +    public void comment (char ch[], int start, int len)
  +    throws SAXException {
  +        this.closeElement();
  +        this.print("<!--");
  +        this.print(ch,start,len);
  +        this.print("-->");
  +    }
  +
  +    /** Print a string */
  +    private void print(String s)
  +    throws SAXException {
  +        if(s==null) return;
  +        char data[]=s.toCharArray();
  +        this.print(data,0,data.length);
  +    }
  +    
  +    /** Print data from a character array */
  +    private void print(char data[], int start, int len)
  +    throws SAXException {
  +        try {
  +            if(!this.dtd) this.out.write(data,start,len);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +
  +    /** Print data from a character array */
  +    private void print(char c)
  +    throws SAXException {
  +        try {
  +            if(!this.dtd) this.out.write(c);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +
  +    /** Print a string */
  +    private void printSafe(String s)
  +    throws SAXException {
  +        if(s==null) return;
  +        char data[]=s.toCharArray();
  +        this.printSafe(data,0,data.length);
  +    }
  +    
  +    /** Print data from a character array */
  +    private void printSafe(char data[], int start, int len)
  +    throws SAXException {
  +        int end=start+len;
  +        if(!this.dtd) for(int x=start; x<end; x++) this.printSafe(data[x]);
  +    }
  +
  +    /** Print data from a character array */
  +    private void printSafe(char c)
  +    throws SAXException {
  +        try {
  +            if(this.dtd) return;
  +            if(c=='&') this.print("&amp;");
  +            else if(c=='<') this.print("&lt;");
  +            else if(c=='>') this.print("&gt;");
  +            else this.out.write(c);
  +        } catch (IOException e) {
  +            throw new SAXException("IOException printing data",e);
  +        }
  +    }
  +
  +    /** Close an element, if required */
  +    private void closeElement()
  +    throws SAXException {
  +        if(!this.openElement) return;
  +        this.print('>');
  +        this.openElement=false;
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.15  +255 -255  
xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java,v
  retrieving revision 1.1.4.14
  retrieving revision 1.1.4.15
  diff -u -r1.1.4.14 -r1.1.4.15
  --- CocoonServlet.java        2000/07/25 18:48:36     1.1.4.14
  +++ CocoonServlet.java        2000/07/29 18:30:38     1.1.4.15
  @@ -1,255 +1,255 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -
  -package org.apache.cocoon.servlet;
  -
  -import java.util.Date;
  -import java.io.IOException;
  -import java.io.PrintWriter;
  -import java.util.Enumeration;
  -
  -import javax.servlet.ServletConfig;
  -import javax.servlet.ServletContext;
  -import javax.servlet.ServletException;
  -import javax.servlet.ServletOutputStream;
  -import javax.servlet.http.HttpServlet;
  -import javax.servlet.http.HttpServletRequest;
  -import javax.servlet.http.HttpServletResponse;
  -
  -import org.apache.avalon.ConfigurationException;
  -import org.apache.avalon.ComponentNotAccessibleException;
  -
  -import org.apache.cocoon.Cocoon;
  -import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.environment.http.HttpEnvironment;
  -
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.14 $ $Date: 2000/07/25 18:48:36 $
  - */
  -public class CocoonServlet extends HttpServlet {
  -    private Cocoon cocoon=null;
  -    private long creationTime=0;
  -    private String configurationFile=null;
  -    private Exception exception=null;
  -    private ServletContext context=null;
  -
  -    /**
  -     * Initialize this <code>CocoonServlet</code> instance.
  -     */
  -    public void init(ServletConfig conf)
  -    throws ServletException {
  -        super.init(conf);
  -        this.context=conf.getServletContext();
  -        String configFile=conf.getInitParameter("configurations");
  -        this.context.log ("this.configurationFile: "+this.configurationFile);
  -        if (configFile==null) {
  -            throw new ServletException("Servlet initialization argument "+
  -                                       "'configurations' not specified");
  -        }
  -        try {
  -            
this.configurationFile=this.context.getResource(configFile).getFile();
  -            this.context.log ("this.configurationFile: 
"+this.configurationFile);
  -        } catch (java.net.MalformedURLException mue) {
  -            throw new ServletException("Servlet initialization argument "+
  -                                       "'configurations' not found at 
"+this.configurationFile);
  -        }
  -        this.cocoon=this.create();
  -    }
  -
  -    /**
  -     * Process the specified <code>HttpServletRequest</code> producing output
  -     * on the specified <code>HttpServletResponse</code>.
  -     */
  -    public void service(HttpServletRequest req, HttpServletResponse res)
  -    throws ServletException, IOException {
  -        long start = new Date().getTime();
  -        long end = 0;
  -        // Reload cocoon if configuration changed or we are reloading
  -        boolean reloaded=false;
  -        synchronized (this) {
  -            if (this.cocoon!=null) {
  -                if (this.cocoon.modifiedSince(this.creationTime)) {
  -                    this.context.log("Configuration changed reload attempt");
  -                    this.cocoon=this.create();
  -                    reloaded=true;
  -                } else if ((req.getPathInfo()==null) &&
  -                           (req.getParameter("reload")!=null)) {
  -                    this.context.log("Forced reload attempt");
  -                    this.cocoon=this.create();
  -                    reloaded=true;
  -                }
  -            } else if ((req.getPathInfo()==null) &&
  -                       (req.getParameter("reload")!=null)) {
  -                this.context.log("Invalid configurations reload");
  -                this.cocoon=this.create();
  -                reloaded=true;
  -            }
  -        }
  -
  -        ServletOutputStream out=res.getOutputStream();
  -
  -        // Check if cocoon was initialized
  -        if (this.cocoon==null) {
  -            res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  -            res.setContentType("text/html");
  -            out.println("<html><head>");
  -            out.println("<title>Cocoon Version 2.0: Not 
initialized</title>");
  -            out.println("<body>");
  -            out.println("<center><h1>Cocoon 2.0: Not 
initialized</h1></center>");
  -            out.println("<hr>");
  -            out.print("Try to <a href=\"");
  -            out.print(req.getScheme()+"://"+req.getServerName()+":");
  -            out.print(req.getServerPort()+req.getServletPath());
  -            out.print("?reload=true\">Reload</a>");
  -            out.println("<!-- PATH_INFO=\""+req.getPathInfo()+"\" -->");
  -            out.println("<hr>");
  -            this.printException(out,this.exception);
  -            if (exception instanceof SAXException) {
  -                Exception 
nested=((SAXException)this.exception).getException();
  -                out.println("<hr>");
  -                this.printException(out,nested);
  -            } else if (exception instanceof ComponentNotAccessibleException) 
{
  -                out.println("Component not accessible<br>");
  -                Exception nested=this.exception;
  -                
nested=((ComponentNotAccessibleException)nested).getException();
  -                out.println("<hr>");
  -                this.printException(out,nested);
  -            }
  -            out.println("<hr></body></html>");
  -            out.flush();
  -            return;
  -        }
  -        // We got it... Process the request
  -        // We should use getRequestURI(), minus the Context path otherwise
  -        // we break compatability with Tomcat and other Servlet 2.2 engines
  -        // (like Gefion LWS and Orion)
  -        String 
uri=req.getRequestURI().substring(req.getContextPath().length());
  -        if (!uri.equals("")) {
  -            try {
  -                if (uri.charAt(0)=='/') uri=uri.substring(1);
  -                HttpEnvironment env = new HttpEnvironment (uri, req, res, 
context);
  -                if (!this.cocoon.process(env,out)) {
  -                    res.setStatus(res.SC_NOT_FOUND);
  -                    res.setContentType("text/html");
  -                    out.println("<html><head>");
  -                    out.println("<title>Cocoon Version 2.0: Not 
Found</title>");
  -                    out.println("<body>");
  -                    out.println("<center><h1>Cocoon 2.0: Not 
Found</h1></center>");
  -                    out.println("<hr>");
  -                    out.print("The requested URI \""+req.getRequestURI());
  -                    out.print("\" was not found.");
  -                    out.println("<!-- PATH_INFO=\""+uri+"\" -->");
  -                    out.println("<hr></body></html>");
  -                }
  -            } catch (Exception e) {
  -                //res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  -                res.setContentType("text/html");
  -                out.println("<html><head>");
  -                out.println("<title>Cocoon Version 2.0: Exception</title>");
  -                out.println("<body>");
  -                out.println("<center><h1>Cocoon 2.0: 
Exception</h1></center>");
  -                out.println("<hr>");
  -                this.printException(out,e);
  -                if (e instanceof SAXException) {
  -                    out.println("<hr>");
  -                    out.println("SAX processing exception<br>");
  -                    Exception nested=((SAXException)e).getException();
  -                    this.printException(out,nested);
  -                } else if (e instanceof ComponentNotAccessibleException) {
  -                    out.println("<hr>");
  -                    out.println("Component not accessible<br>");
  -                    Exception nested=e;
  -                    
nested=((ComponentNotAccessibleException)nested).getException();
  -                    this.printException(out,nested);
  -                }
  -
  -                out.println("<hr></body></html>");
  -            }
  -        } else {
  -            res.setContentType("text/html");
  -            out.println("<html><head>");
  -            out.println("<title>Cocoon Version 2.0</title>");
  -            out.println("<body>");
  -            out.println("<center><h1>Cocoon 2.0: Version 2.0</h1></center>");
  -            out.println("<hr>");
  -            if (reloaded) out.println("Configurations reloaded.<br>");
  -            out.println("Ready to process requests...");
  -            out.println("<!-- PATH_INFO=\""+uri+"\" -->");
  -            out.println("<hr></body></html>");
  -        }
  -
  -        end = new Date().getTime();
  -        String showTime = req.getParameter("showtime");
  -        if ((showTime != null) && !showTime.equalsIgnoreCase("no")) {
  -            float time = (float) (end - start);
  -            float second = (float) 1000;
  -            float minute = (float) 60 * second;
  -            float hour = (float) 60 * minute;
  -
  -            if (showTime.equalsIgnoreCase("hide")) {
  -                out.print("<!--");
  -            } else {
  -                out.print("<p>");
  -            }
  -            out.print("Processed by Cocoon in ");
  -
  -            if (time > hour) {
  -                out.print(time / hour);
  -                out.print(" hours.");
  -            } else if (time > minute) {
  -                out.print(time / minute);
  -                out.print(" minutes.");
  -            } else if (time > second) {
  -                out.print(time / second);
  -                out.print(" seconds.");
  -            } else {
  -                out.print(time);
  -                out.print(" milliseconds.");
  -            }
  -
  -            if (showTime == "hide") {
  -                out.print("-->");
  -            } else {
  -                out.print("</p>");
  -            }
  -        }
  -
  -        out.flush();
  -    }
  -
  -    /** Create a new <code>Cocoon</code> object. */
  -    private Cocoon create() {
  -        try {
  -            this.context.log("Reloading from: "+this.configurationFile);
  -            Cocoon c=new Cocoon(this.configurationFile);
  -            this.creationTime=System.currentTimeMillis();
  -            return(c);
  -        } catch (Exception e) {
  -            this.context.log("Exception reloading: "+e.getMessage());
  -            this.exception=e;
  -        }
  -        return(null);
  -    }
  -
  -    /** Dump an exception to the specified <code>ServletOutputStream</code> 
*/
  -    private void printException(ServletOutputStream o, Exception e) {
  -        PrintWriter out=new PrintWriter(o);
  -        out.println("Class: <b>"+e.getClass().getName()+"</b><br>");
  -        out.println("Message: <i>"+e.getMessage()+"</i><br>");
  -        out.println("<pre>");
  -        e.printStackTrace(out);
  -        out.println("</pre>");
  -        out.flush();
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +
  +package org.apache.cocoon.servlet;
  +
  +import java.util.Date;
  +import java.io.IOException;
  +import java.io.PrintWriter;
  +import java.util.Enumeration;
  +
  +import javax.servlet.ServletConfig;
  +import javax.servlet.ServletContext;
  +import javax.servlet.ServletException;
  +import javax.servlet.ServletOutputStream;
  +import javax.servlet.http.HttpServlet;
  +import javax.servlet.http.HttpServletRequest;
  +import javax.servlet.http.HttpServletResponse;
  +
  +import org.apache.avalon.ConfigurationException;
  +import org.apache.avalon.ComponentNotAccessibleException;
  +
  +import org.apache.cocoon.Cocoon;
  +import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.4.15 $ $Date: 2000/07/29 18:30:38 $
  + */
  +public class CocoonServlet extends HttpServlet {
  +    private Cocoon cocoon=null;
  +    private long creationTime=0;
  +    private String configurationFile=null;
  +    private Exception exception=null;
  +    private ServletContext context=null;
  +
  +    /**
  +     * Initialize this <code>CocoonServlet</code> instance.
  +     */
  +    public void init(ServletConfig conf)
  +    throws ServletException {
  +        super.init(conf);
  +        this.context=conf.getServletContext();
  +        String configFile=conf.getInitParameter("configurations");
  +        this.context.log ("this.configurationFile: "+this.configurationFile);
  +        if (configFile==null) {
  +            throw new ServletException("Servlet initialization argument "+
  +                                       "'configurations' not specified");
  +        }
  +        try {
  +            
this.configurationFile=this.context.getResource(configFile).getFile();
  +            this.context.log ("this.configurationFile: 
"+this.configurationFile);
  +        } catch (java.net.MalformedURLException mue) {
  +            throw new ServletException("Servlet initialization argument "+
  +                                       "'configurations' not found at 
"+this.configurationFile);
  +        }
  +        this.cocoon=this.create();
  +    }
  +
  +    /**
  +     * Process the specified <code>HttpServletRequest</code> producing output
  +     * on the specified <code>HttpServletResponse</code>.
  +     */
  +    public void service(HttpServletRequest req, HttpServletResponse res)
  +    throws ServletException, IOException {
  +        long start = new Date().getTime();
  +        long end = 0;
  +        // Reload cocoon if configuration changed or we are reloading
  +        boolean reloaded=false;
  +        synchronized (this) {
  +            if (this.cocoon!=null) {
  +                if (this.cocoon.modifiedSince(this.creationTime)) {
  +                    this.context.log("Configuration changed reload attempt");
  +                    this.cocoon=this.create();
  +                    reloaded=true;
  +                } else if ((req.getPathInfo()==null) &&
  +                           (req.getParameter("reload")!=null)) {
  +                    this.context.log("Forced reload attempt");
  +                    this.cocoon=this.create();
  +                    reloaded=true;
  +                }
  +            } else if ((req.getPathInfo()==null) &&
  +                       (req.getParameter("reload")!=null)) {
  +                this.context.log("Invalid configurations reload");
  +                this.cocoon=this.create();
  +                reloaded=true;
  +            }
  +        }
  +
  +        ServletOutputStream out=res.getOutputStream();
  +
  +        // Check if cocoon was initialized
  +        if (this.cocoon==null) {
  +            res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  +            res.setContentType("text/html");
  +            out.println("<html><head>");
  +            out.println("<title>Cocoon Version 2.0: Not 
initialized</title>");
  +            out.println("<body>");
  +            out.println("<center><h1>Cocoon 2.0: Not 
initialized</h1></center>");
  +            out.println("<hr>");
  +            out.print("Try to <a href=\"");
  +            out.print(req.getScheme()+"://"+req.getServerName()+":");
  +            out.print(req.getServerPort()+req.getServletPath());
  +            out.print("?reload=true\">Reload</a>");
  +            out.println("<!-- PATH_INFO=\""+req.getPathInfo()+"\" -->");
  +            out.println("<hr>");
  +            this.printException(out,this.exception);
  +            if (exception instanceof SAXException) {
  +                Exception 
nested=((SAXException)this.exception).getException();
  +                out.println("<hr>");
  +                this.printException(out,nested);
  +            } else if (exception instanceof ComponentNotAccessibleException) 
{
  +                out.println("Component not accessible<br>");
  +                Exception nested=this.exception;
  +                
nested=((ComponentNotAccessibleException)nested).getException();
  +                out.println("<hr>");
  +                this.printException(out,nested);
  +            }
  +            out.println("<hr></body></html>");
  +            out.flush();
  +            return;
  +        }
  +        // We got it... Process the request
  +        // We should use getRequestURI(), minus the Context path otherwise
  +        // we break compatability with Tomcat and other Servlet 2.2 engines
  +        // (like Gefion LWS and Orion)
  +        String 
uri=req.getRequestURI().substring(req.getContextPath().length());
  +        if (!uri.equals("")) {
  +            try {
  +                if (uri.charAt(0)=='/') uri=uri.substring(1);
  +                HttpEnvironment env = new HttpEnvironment (uri, req, res, 
context);
  +                if (!this.cocoon.process(env,out)) {
  +                    res.setStatus(res.SC_NOT_FOUND);
  +                    res.setContentType("text/html");
  +                    out.println("<html><head>");
  +                    out.println("<title>Cocoon Version 2.0: Not 
Found</title>");
  +                    out.println("<body>");
  +                    out.println("<center><h1>Cocoon 2.0: Not 
Found</h1></center>");
  +                    out.println("<hr>");
  +                    out.print("The requested URI \""+req.getRequestURI());
  +                    out.print("\" was not found.");
  +                    out.println("<!-- PATH_INFO=\""+uri+"\" -->");
  +                    out.println("<hr></body></html>");
  +                }
  +            } catch (Exception e) {
  +                //res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
  +                res.setContentType("text/html");
  +                out.println("<html><head>");
  +                out.println("<title>Cocoon Version 2.0: Exception</title>");
  +                out.println("<body>");
  +                out.println("<center><h1>Cocoon 2.0: 
Exception</h1></center>");
  +                out.println("<hr>");
  +                this.printException(out,e);
  +                if (e instanceof SAXException) {
  +                    out.println("<hr>");
  +                    out.println("SAX processing exception<br>");
  +                    Exception nested=((SAXException)e).getException();
  +                    this.printException(out,nested);
  +                } else if (e instanceof ComponentNotAccessibleException) {
  +                    out.println("<hr>");
  +                    out.println("Component not accessible<br>");
  +                    Exception nested=e;
  +                    
nested=((ComponentNotAccessibleException)nested).getException();
  +                    this.printException(out,nested);
  +                }
  +
  +                out.println("<hr></body></html>");
  +            }
  +        } else {
  +            res.setContentType("text/html");
  +            out.println("<html><head>");
  +            out.println("<title>Cocoon Version 2.0</title>");
  +            out.println("<body>");
  +            out.println("<center><h1>Cocoon 2.0: Version 2.0</h1></center>");
  +            out.println("<hr>");
  +            if (reloaded) out.println("Configurations reloaded.<br>");
  +            out.println("Ready to process requests...");
  +            out.println("<!-- PATH_INFO=\""+uri+"\" -->");
  +            out.println("<hr></body></html>");
  +        }
  +
  +        end = new Date().getTime();
  +        String showTime = req.getParameter("showtime");
  +        if ((showTime != null) && !showTime.equalsIgnoreCase("no")) {
  +            float time = (float) (end - start);
  +            float second = (float) 1000;
  +            float minute = (float) 60 * second;
  +            float hour = (float) 60 * minute;
  +
  +            if (showTime.equalsIgnoreCase("hide")) {
  +                out.print("<!--");
  +            } else {
  +                out.print("<p>");
  +            }
  +            out.print("Processed by Cocoon in ");
  +
  +            if (time > hour) {
  +                out.print(time / hour);
  +                out.print(" hours.");
  +            } else if (time > minute) {
  +                out.print(time / minute);
  +                out.print(" minutes.");
  +            } else if (time > second) {
  +                out.print(time / second);
  +                out.print(" seconds.");
  +            } else {
  +                out.print(time);
  +                out.print(" milliseconds.");
  +            }
  +
  +            if (showTime == "hide") {
  +                out.print("-->");
  +            } else {
  +                out.print("</p>");
  +            }
  +        }
  +
  +        out.flush();
  +    }
  +
  +    /** Create a new <code>Cocoon</code> object. */
  +    private Cocoon create() {
  +        try {
  +            this.context.log("Reloading from: "+this.configurationFile);
  +            Cocoon c=new Cocoon(this.configurationFile);
  +            this.creationTime=System.currentTimeMillis();
  +            return(c);
  +        } catch (Exception e) {
  +            this.context.log("Exception reloading: "+e.getMessage());
  +            this.exception=e;
  +        }
  +        return(null);
  +    }
  +
  +    /** Dump an exception to the specified <code>ServletOutputStream</code> 
*/
  +    private void printException(ServletOutputStream o, Exception e) {
  +        PrintWriter out=new PrintWriter(o);
  +        out.println("Class: <b>"+e.getClass().getName()+"</b><br>");
  +        out.println("Message: <i>"+e.getMessage()+"</i><br>");
  +        out.println("<pre>");
  +        e.printStackTrace(out);
  +        out.println("</pre>");
  +        out.flush();
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +31 -31    
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapComponent.java
  
  Index: SitemapComponent.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapComponent.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- SitemapComponent.java     2000/07/22 20:41:57     1.1.2.5
  +++ SitemapComponent.java     2000/07/29 18:30:39     1.1.2.6
  @@ -1,31 +1,31 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.sitemap;
  -
  -import java.io.IOException;
  -import org.apache.avalon.Component;
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.ProcessingException;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:41:57 $
  - */
  -public interface SitemapComponent extends Component {
  -
  -    /**
  -     * Set the <code>Request</code>, <code>Response</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Environment environment, String src, Parameters par)
  -    throws ProcessingException, SAXException, IOException;
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.sitemap;
  +
  +import java.io.IOException;
  +import org.apache.avalon.Component;
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.ProcessingException;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/29 18:30:39 $
  + */
  +public interface SitemapComponent extends Component {
  +
  +    /**
  +     * Set the <code>Request</code>, <code>Response</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par)
  +    throws ProcessingException, SAXException, IOException;
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +27 -27    
xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternException.java
  
  Index: PatternException.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternException.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- PatternException.java     2000/07/22 20:41:59     1.1.2.3
  +++ PatternException.java     2000/07/29 18:30:39     1.1.2.4
  @@ -1,27 +1,27 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.sitemap.patterns;
  -
  -/**
  - * This exception is thrown by a <code>URIMatcher</code> or by a
  - * <code>URITranslator</code> when there's something wrong with the matching 
or
  - * translation patterns.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:41:59 $
  - */
  -public class PatternException extends Exception {
  -
  -    /**
  -     * Construct a new <code>PatternException</code> instance.
  -     */
  -    public PatternException(String message) {
  -        super(message);
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.sitemap.patterns;
  +
  +/**
  + * This exception is thrown by a <code>URIMatcher</code> or by a
  + * <code>URITranslator</code> when there's something wrong with the matching 
or
  + * translation patterns.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:39 $
  + */
  +public class PatternException extends Exception {
  +
  +    /**
  +     * Construct a new <code>PatternException</code> instance.
  +     */
  +    public PatternException(String message) {
  +        super(message);
  +    }
  +}
  
  
  
  1.1.2.7   +255 -255  
xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternMatcher.java
  
  Index: PatternMatcher.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternMatcher.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- PatternMatcher.java       2000/07/22 20:41:59     1.1.2.6
  +++ PatternMatcher.java       2000/07/29 18:30:39     1.1.2.7
  @@ -1,255 +1,255 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.sitemap.patterns;
  -
  -/**
  - * This class is an utility class that perform wilcard-patterns matching.
  - * <br>
  - * The pattern is made up with the following wildcards:
  - * <ul>
  - *   <li>The '*' character means that zero or more characters (excluding the
  - *       path separator '/') are to be matched.</li>
  - *   <li>The '**' sequence means that zero or more characters (including the
  - *       path separator '/') are to be matched.</li>
  - *   <li>The '\' character is used as an escape sequence ('\*' is translated 
in
  - *       '*', it does not represent a matching pattern). If an exact '\'
  - *       character needs to be matched the source string must contain a '\\'
  - *       sequence.</li>
  - * </ul>
  - * 
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/22 20:41:59 $
  - */
  -public class PatternMatcher {
  -
  -    /** The int representing '*' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_FILE=-1;
  -    /** The int representing '**' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_PATH=-2;
  -    /** The int value that terminates the pattern <code>int []</code>. */
  -    protected static final int MATCH_END=-3;
  -
  -    /** The <code>int []</code> identifying the pattern to match. */
  -    protected int[] sourcePattern=null;
  -
  -    /**
  -     * Construct a new <code>PatternMatcher</code> instance.
  -     */
  -    public PatternMatcher() {
  -        super();
  -    }
  -
  -    /**
  -     * Construct a new <code>PatternMatcher</code> instance.
  -     */
  -    public PatternMatcher(String pattern)
  -    throws PatternException {
  -        this();
  -        this.setPattern(pattern);
  -    }
  -
  -    /**
  -     * Match the specified <code>String</code> against the configured 
pattern.
  -     */
  -    public boolean match(String data) {
  -        if (data==null) throw new NullPointerException("Null data");
  -        if (this.sourcePattern==null)
  -            throw new IllegalStateException("Null internals");
  -        return(this.matchPattern(data.toCharArray(),this.sourcePattern));
  -    }
  -
  -    /**
  -     * Set the pattern for matching.
  -     */
  -    public void setPattern(String pattern)
  -    throws PatternException {
  -        if (pattern==null) throw new PatternException("Null pattern");
  -        this.sourcePattern=this.convertPattern(pattern);
  -    }
  -
  -    /**
  -     * Translate the given <code>String</code> into a <code>int []</code>
  -     * representing the pattern matchable by this class.
  -     * <br>
  -     * This function translates a <code>String</code> into an int array
  -     * converting the special '*' and '\' characters.
  -     * <br>
  -     * Here is how the conversion algorithm works:
  -     * <ul>
  -     *   <li>The '*' character is converted to MATCH_FILE, meaning that zero
  -     *        or more characters (excluding the path separator '/') are to
  -     *        be matched.</li>
  -     *   <li>The '**' sequence is converted to MATCH_PATH, meaning that zero
  -     *       or more characters (including the path separator '/') are to
  -     *        be matched.</li>
  -     *   <li>The '\' character is used as an escape sequence ('\*' is
  -     *       translated in '*', not in MATCH_FILE). If an exact '\' character
  -     *       is to be matched the source string must contain a '\\'.
  -     *       sequence.</li>
  -     * </ul>
  -     * When more than two '*' characters, not separated by another character,
  -     * are found their value is considered as '**' (MATCH_PATH).
  -     * <br>
  -     * The array is always terminated by a special value (MATCH_END).
  -     * <br>
  -     * All MATCH* values are less than zero, while normal characters are 
equal
  -     * or greater.
  -     *
  -     * @parameter data The string to translate.
  -     * @return The encoded string as an int array, terminated by the 
MATCH_END
  -     *         value (don't consider the array length).
  -     * @exception NullPointerException If data is null.
  -     */
  -    protected int[] convertPattern(String data)
  -    throws NullPointerException {
  -        // Prepare the arrays
  -        int expr[]=new int[data.length()+1];
  -        char buff[]=data.toCharArray();
  -        // Prepare variables for the translation loop
  -        int y=0;
  -        boolean slash=false;
  -        if(buff[0]=='\\') slash=true;
  -        else if(buff[0]=='*') expr[y++]=MATCH_FILE;
  -        else expr[y++]=buff[0];
  -        // Main translation loop
  -        for (int x=1; x<buff.length; x++) {
  -            // If the previous char was '\' simply copy this char.
  -            if (slash) {
  -                expr[y++]=buff[x];
  -                slash=false;
  -            // If the previous char was not '\' we have to do a bunch of 
checks
  -            } else {
  -                int prev=(y-1);
  -                // If this char is '\' declare that and continue
  -                if(buff[x]=='\\') {
  -                    slash=true;
  -                // If this char is '*' check the previous one
  -                } else if(buff[x]=='*') {
  -                    // If the previous character als was '*' match a path
  -                    if(expr[y-1]<=MATCH_FILE) expr[y-1]=MATCH_PATH;
  -                    else expr[y++]=MATCH_FILE;
  -                } else expr[y++]=buff[x];
  -            }
  -        }
  -        // Declare the end of the array and return it
  -        expr[y]=MATCH_END;
  -        return(expr);
  -    }        
  -
  -    /**
  -     * Matches the specified <code>char []</code> against the given pattern
  -     * formatted as an <code>int []</code>.
  -     * <br>
  -     * This method returns <b>true</b> if the specified <code>char []</code>
  -     * can be matched by the pattern created by 
<code>convertPattern(...)</code>
  -     * be represented as an <code>int []</code>, <b>false</b> otherwise.
  -     * <br>
  -     * <b>FIXME: This routine doesn't match when the pattern ends with a
  -     *    wildcard. Need to fix together with 
<code>translatePattern()</code>,
  -     *    in <code>PatternTranslator</code> otherwise it won't work.</b>
  -     * <br>
  -     * <i>Seems ok now</i>
  -     *
  -     * @param buff The <code>char []</code> of the path to be matched.
  -     * @param expr The <code>int []</code> representing the pattern, as
  -     *             returned by <code>convertPattern(...)</code>.
  -     * @exception NullPointerException If a parameter is <b>null</b>.
  -     */
  -    protected boolean matchPattern(char buff[], int expr[])
  -    throws NullPointerException {
  -                
  -        // The previous and current position of the expression character
  -        // (MATCH_*)
  -        int charpos=0;
  -        // Search the fist expression character
  -        while (expr[charpos]>=0) charpos++;
  -        // The expression charater (MATCH_*)
  -        int exprchr=expr[charpos];
  -
  -        // The position in the expression, input, translation and result 
arrays
  -        int exprpos=0;
  -        int buffpos=0;
  -        int offset=-1;
  -        
  -        while (true) {
  -            // Check if the data in the expression array before the current
  -            // expression character matches the data in the input buffer
  -            offset=this.matchArray(expr,exprpos,charpos,buff,buffpos);
  -            if (offset<0) return(false);
  -
  -            if (exprchr==MATCH_END) return(true);
  -            
  -            // Search the next expression character
  -            buffpos+=(charpos-exprpos);
  -            exprpos=++charpos;
  -            while (expr[charpos]>=0) charpos++;
  -            int prevchr=exprchr;
  -            exprchr=expr[charpos];
  -   
  -            offset=this.matchArray(expr,exprpos,charpos,buff,buffpos);
  -            if (offset<0) return(false);
  -    
  -            // Copy the data from the source buffer into the result buffer
  -            // to substitute the expression character
  -            if (prevchr==MATCH_PATH) {
  -                while (buffpos<offset) buffpos++;
  -            } else {
  -                // Matching file, don't copy '/'
  -                while (buffpos<offset) {
  -                    if (buff[buffpos++]=='/') return(false);
  -                }
  -            }
  -        }
  -    }
  -
  -    /**
  -     * Get the offset of a part of an int array within a char array.
  -     * <br>
  -     * This method return the index in d of the first occurrence after dpos 
of
  -     * that part of array specified by r, starting at rpos and terminating at
  -     * rend.
  -     *
  -     * @param r The array containing the data that need to be matched in d.
  -     * @param rpos The index of the first character in r to look for.
  -     * @param rend The index of the last character in r to look for plus 1.
  -     * @param d The array of char that should contain a part of r.
  -     * @param dpos The starting offset in d for the matching.
  -     * @return The offset in d of the part of r matched in d or -1 if that 
was
  -     *         not found.
  -     */
  -    protected int matchArray(int r[], int rpos, int rend, char d[], int 
dpos) {
  -        // Check if pos and len are legal
  -        if(rend<rpos) throw new IllegalArgumentException("rend<rpos");
  -        // If we need to match a zero length string return current dpos
  -        if(rend==rpos) return(d.length);
  -        // If we need to match a 1 char length string do it simply
  -        if(rend-rpos==1) {
  -            // Search for the specified character
  -            for(int x=dpos; x<d.length; x++) if (r[rpos]==d[x]) return(x);
  -        }
  -        // Main string matching loop. It gets executed if the characters to
  -        // match are less then the characters left in the d buffer
  -        while(dpos+rend-rpos<=d.length) {
  -            // Set current startpoint in d
  -            int y=dpos;
  -            // Check every character in d for equity. If the string is 
matched
  -            // return dpos
  -            for(int x=rpos; x<=rend; x++) {
  -                if(x==rend) return(dpos);
  -                if(r[x]==d[y]) y++;
  -                else break;
  -            }
  -            // Increase dpos to search for the same string at next offset
  -            dpos++;
  -        }
  -        // The remaining chars in d buffer were not enough or the string 
  -        // wasn't matched
  -        return(-1);
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.sitemap.patterns;
  +
  +/**
  + * This class is an utility class that perform wilcard-patterns matching.
  + * <br>
  + * The pattern is made up with the following wildcards:
  + * <ul>
  + *   <li>The '*' character means that zero or more characters (excluding the
  + *       path separator '/') are to be matched.</li>
  + *   <li>The '**' sequence means that zero or more characters (including the
  + *       path separator '/') are to be matched.</li>
  + *   <li>The '\' character is used as an escape sequence ('\*' is translated 
in
  + *       '*', it does not represent a matching pattern). If an exact '\'
  + *       character needs to be matched the source string must contain a '\\'
  + *       sequence.</li>
  + * </ul>
  + * 
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.7 $ $Date: 2000/07/29 18:30:39 $
  + */
  +public class PatternMatcher {
  +
  +    /** The int representing '*' in the pattern <code>int []</code>. */
  +    protected static final int MATCH_FILE=-1;
  +    /** The int representing '**' in the pattern <code>int []</code>. */
  +    protected static final int MATCH_PATH=-2;
  +    /** The int value that terminates the pattern <code>int []</code>. */
  +    protected static final int MATCH_END=-3;
  +
  +    /** The <code>int []</code> identifying the pattern to match. */
  +    protected int[] sourcePattern=null;
  +
  +    /**
  +     * Construct a new <code>PatternMatcher</code> instance.
  +     */
  +    public PatternMatcher() {
  +        super();
  +    }
  +
  +    /**
  +     * Construct a new <code>PatternMatcher</code> instance.
  +     */
  +    public PatternMatcher(String pattern)
  +    throws PatternException {
  +        this();
  +        this.setPattern(pattern);
  +    }
  +
  +    /**
  +     * Match the specified <code>String</code> against the configured 
pattern.
  +     */
  +    public boolean match(String data) {
  +        if (data==null) throw new NullPointerException("Null data");
  +        if (this.sourcePattern==null)
  +            throw new IllegalStateException("Null internals");
  +        return(this.matchPattern(data.toCharArray(),this.sourcePattern));
  +    }
  +
  +    /**
  +     * Set the pattern for matching.
  +     */
  +    public void setPattern(String pattern)
  +    throws PatternException {
  +        if (pattern==null) throw new PatternException("Null pattern");
  +        this.sourcePattern=this.convertPattern(pattern);
  +    }
  +
  +    /**
  +     * Translate the given <code>String</code> into a <code>int []</code>
  +     * representing the pattern matchable by this class.
  +     * <br>
  +     * This function translates a <code>String</code> into an int array
  +     * converting the special '*' and '\' characters.
  +     * <br>
  +     * Here is how the conversion algorithm works:
  +     * <ul>
  +     *   <li>The '*' character is converted to MATCH_FILE, meaning that zero
  +     *        or more characters (excluding the path separator '/') are to
  +     *        be matched.</li>
  +     *   <li>The '**' sequence is converted to MATCH_PATH, meaning that zero
  +     *       or more characters (including the path separator '/') are to
  +     *        be matched.</li>
  +     *   <li>The '\' character is used as an escape sequence ('\*' is
  +     *       translated in '*', not in MATCH_FILE). If an exact '\' character
  +     *       is to be matched the source string must contain a '\\'.
  +     *       sequence.</li>
  +     * </ul>
  +     * When more than two '*' characters, not separated by another character,
  +     * are found their value is considered as '**' (MATCH_PATH).
  +     * <br>
  +     * The array is always terminated by a special value (MATCH_END).
  +     * <br>
  +     * All MATCH* values are less than zero, while normal characters are 
equal
  +     * or greater.
  +     *
  +     * @parameter data The string to translate.
  +     * @return The encoded string as an int array, terminated by the 
MATCH_END
  +     *         value (don't consider the array length).
  +     * @exception NullPointerException If data is null.
  +     */
  +    protected int[] convertPattern(String data)
  +    throws NullPointerException {
  +        // Prepare the arrays
  +        int expr[]=new int[data.length()+1];
  +        char buff[]=data.toCharArray();
  +        // Prepare variables for the translation loop
  +        int y=0;
  +        boolean slash=false;
  +        if(buff[0]=='\\') slash=true;
  +        else if(buff[0]=='*') expr[y++]=MATCH_FILE;
  +        else expr[y++]=buff[0];
  +        // Main translation loop
  +        for (int x=1; x<buff.length; x++) {
  +            // If the previous char was '\' simply copy this char.
  +            if (slash) {
  +                expr[y++]=buff[x];
  +                slash=false;
  +            // If the previous char was not '\' we have to do a bunch of 
checks
  +            } else {
  +                int prev=(y-1);
  +                // If this char is '\' declare that and continue
  +                if(buff[x]=='\\') {
  +                    slash=true;
  +                // If this char is '*' check the previous one
  +                } else if(buff[x]=='*') {
  +                    // If the previous character als was '*' match a path
  +                    if(expr[y-1]<=MATCH_FILE) expr[y-1]=MATCH_PATH;
  +                    else expr[y++]=MATCH_FILE;
  +                } else expr[y++]=buff[x];
  +            }
  +        }
  +        // Declare the end of the array and return it
  +        expr[y]=MATCH_END;
  +        return(expr);
  +    }        
  +
  +    /**
  +     * Matches the specified <code>char []</code> against the given pattern
  +     * formatted as an <code>int []</code>.
  +     * <br>
  +     * This method returns <b>true</b> if the specified <code>char []</code>
  +     * can be matched by the pattern created by 
<code>convertPattern(...)</code>
  +     * be represented as an <code>int []</code>, <b>false</b> otherwise.
  +     * <br>
  +     * <b>FIXME: This routine doesn't match when the pattern ends with a
  +     *    wildcard. Need to fix together with 
<code>translatePattern()</code>,
  +     *    in <code>PatternTranslator</code> otherwise it won't work.</b>
  +     * <br>
  +     * <i>Seems ok now</i>
  +     *
  +     * @param buff The <code>char []</code> of the path to be matched.
  +     * @param expr The <code>int []</code> representing the pattern, as
  +     *             returned by <code>convertPattern(...)</code>.
  +     * @exception NullPointerException If a parameter is <b>null</b>.
  +     */
  +    protected boolean matchPattern(char buff[], int expr[])
  +    throws NullPointerException {
  +                
  +        // The previous and current position of the expression character
  +        // (MATCH_*)
  +        int charpos=0;
  +        // Search the fist expression character
  +        while (expr[charpos]>=0) charpos++;
  +        // The expression charater (MATCH_*)
  +        int exprchr=expr[charpos];
  +
  +        // The position in the expression, input, translation and result 
arrays
  +        int exprpos=0;
  +        int buffpos=0;
  +        int offset=-1;
  +        
  +        while (true) {
  +            // Check if the data in the expression array before the current
  +            // expression character matches the data in the input buffer
  +            offset=this.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(false);
  +
  +            if (exprchr==MATCH_END) return(true);
  +            
  +            // Search the next expression character
  +            buffpos+=(charpos-exprpos);
  +            exprpos=++charpos;
  +            while (expr[charpos]>=0) charpos++;
  +            int prevchr=exprchr;
  +            exprchr=expr[charpos];
  +   
  +            offset=this.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(false);
  +    
  +            // Copy the data from the source buffer into the result buffer
  +            // to substitute the expression character
  +            if (prevchr==MATCH_PATH) {
  +                while (buffpos<offset) buffpos++;
  +            } else {
  +                // Matching file, don't copy '/'
  +                while (buffpos<offset) {
  +                    if (buff[buffpos++]=='/') return(false);
  +                }
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Get the offset of a part of an int array within a char array.
  +     * <br>
  +     * This method return the index in d of the first occurrence after dpos 
of
  +     * that part of array specified by r, starting at rpos and terminating at
  +     * rend.
  +     *
  +     * @param r The array containing the data that need to be matched in d.
  +     * @param rpos The index of the first character in r to look for.
  +     * @param rend The index of the last character in r to look for plus 1.
  +     * @param d The array of char that should contain a part of r.
  +     * @param dpos The starting offset in d for the matching.
  +     * @return The offset in d of the part of r matched in d or -1 if that 
was
  +     *         not found.
  +     */
  +    protected int matchArray(int r[], int rpos, int rend, char d[], int 
dpos) {
  +        // Check if pos and len are legal
  +        if(rend<rpos) throw new IllegalArgumentException("rend<rpos");
  +        // If we need to match a zero length string return current dpos
  +        if(rend==rpos) return(d.length);
  +        // If we need to match a 1 char length string do it simply
  +        if(rend-rpos==1) {
  +            // Search for the specified character
  +            for(int x=dpos; x<d.length; x++) if (r[rpos]==d[x]) return(x);
  +        }
  +        // Main string matching loop. It gets executed if the characters to
  +        // match are less then the characters left in the d buffer
  +        while(dpos+rend-rpos<=d.length) {
  +            // Set current startpoint in d
  +            int y=dpos;
  +            // Check every character in d for equity. If the string is 
matched
  +            // return dpos
  +            for(int x=rpos; x<=rend; x++) {
  +                if(x==rend) return(dpos);
  +                if(r[x]==d[y]) y++;
  +                else break;
  +            }
  +            // Increase dpos to search for the same string at next offset
  +            dpos++;
  +        }
  +        // The remaining chars in d buffer were not enough or the string 
  +        // wasn't matched
  +        return(-1);
  +    }
  +}
  
  
  
  1.1.2.8   +201 -201  
xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternTranslator.java
  
  Index: PatternTranslator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternTranslator.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- PatternTranslator.java    2000/07/22 20:42:00     1.1.2.7
  +++ PatternTranslator.java    2000/07/29 18:30:39     1.1.2.8
  @@ -1,201 +1,201 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.sitemap.patterns;
  -
  -/**
  - * This class is an utility class that perform wilcard-patterns matching and
  - * translation.
  - * <br>
  - * The pattern rules follow the one defined by <code>PatternMatcher</code> 
and
  - * the translation is done in the following way (in example):
  - * if the source pattern is &quot;test/*.xml&quot; and the target pattern is
  - * &quot;sources/data/*&quot;, the <code>String</code> 
&quot;test/my.xml&quot;
  - * will be translated into &quot;sources/data/my&quot;
  - * 
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.7 $ $Date: 2000/07/22 20:42:00 $
  - */
  -public class PatternTranslator extends PatternMatcher {
  -
  -    /** Wether the source and the target patterns are equal. */
  -    private boolean identityTranslation=false;
  -    /** The int array identifying the pattern to match. */
  -    protected int[] targetPattern=null;
  -
  -
  -    /**
  -     * Construct a new <code>PatternTranslator</code> instance.
  -     */
  -    public PatternTranslator() {
  -        super();
  -    }
  -
  -    /**
  -     * Construct a new <code>PatternTranslator</code> instance.
  -     */
  -    public PatternTranslator(String pattern)
  -    throws PatternException {
  -        this();
  -        this.setPattern(pattern);
  -    }
  -
  -    /**
  -     * Construct a new <code>PatternTranslator</code> instance.
  -     */
  -    public PatternTranslator(String source, String target)
  -    throws PatternException {
  -        this();
  -        this.setPattern(source,target);
  -    }
  -
  -    /**
  -     * Translate the specified <code>String</code> according to the rules
  -     * specified by the source and target patterns.
  -     * <br>
  -     * If the specified <code>String</code> is not matched by the source
  -     * pattern <b>null</b> is returned.
  -     * <br>
  -     * If the source and the target patterns are qual the same
  -     * <code>String</code> is returned.
  -     */
  -    public String translate(String data) {
  -        if (data==null) throw new NullPointerException("Null data");
  -        if (this.identityTranslation) return(data);
  -        if ((this.targetPattern==null) || (super.sourcePattern==null))
  -            throw new IllegalStateException("Null internals");
  -        if (!super.match(data)) return(null);
  -        
  -        char x[]=data.toCharArray();
  -        
return(this.translatePattern(x,super.sourcePattern,this.targetPattern));
  -    }
  -
  -    /**
  -     * Set the source and target patterns as two identical patterns.
  -     * <br>
  -     * No translation will be performed, as this specifies the identity
  -     * transformation.
  -     */
  -    public void setPattern(String pattern)
  -    throws PatternException {
  -        if (pattern==null) throw new PatternException("Null pattern");
  -        this.setPattern(pattern,pattern);
  -    }
  -
  -    /**
  -     * Set the source and target patterns.
  -     * <br>
  -     * If the source pattern is equal to the target one, no translation will
  -     * be performed as same patterns specify an identity transformation.
  -     */
  -    public void setPattern(String source, String target)
  -    throws PatternException {
  -        if (source==null) throw new PatternException("Null source pattern");
  -        if (target==null) throw new PatternException("Null target pattern");
  -        if (source.equals(target)) {
  -            this.targetPattern=super.convertPattern(target);
  -            super.sourcePattern=this.targetPattern;
  -            this.identityTranslation=true;
  -            return;
  -        }
  -        int t[]=super.convertPattern(target);
  -        int s[]=super.convertPattern(source);
  -        int y=0;
  -        for(int x=0; x<t.length; x++) if(t[x]<0) {
  -            while(s[y]>=0) y++;
  -            if(t[x]!=s[y]) throw new PatternException("Unbalanced 
expression");
  -            else y++;
  -            if(t[x]==MATCH_END) break;
  -        }
  -        this.targetPattern=t;
  -        super.sourcePattern=s;
  -    }
  -
  -    /** 
  -     * Internal routines for translation
  -     * <br>
  -     * <b>FIXME: This routine doesn't match when the pattern ends with a
  -     *    wildcard. Need to fix together with <code>matchPattern()</code>,
  -     *    in <code>PatternMatcher</code> otherwise it won't work.</b>
  -     * <br>
  -     * <i>Seems ok now</i>
  -     */
  -    protected String translatePattern(char buff[], int expr[], int trns[])
  -    throws NullPointerException {
  -        // Allocate the result buffer
  -        char rslt[]=new char[expr.length+trns.length+buff.length];
  -        
  -        // The previous and current position of the expression character
  -        // (MATCH_*)
  -        int charpos=0;
  -        // Search the fist expression character
  -        while (expr[charpos]>=0) charpos++;
  -        // The expression charater (MATCH_*)
  -        int exprchr=expr[charpos];
  -
  -        // The position in the expression, input, translation and result 
arrays
  -        int exprpos=0;
  -        int buffpos=0;
  -        int trnspos=0;
  -        int rsltpos=0;
  -        int offset=-1;
  -        
  -        while (true) {
  -            // Check if the data in the expression array before the current
  -            // expression character matches the data in the input buffer
  -            offset=super.matchArray(expr,exprpos,charpos,buff,buffpos);
  -            if (offset<0) return(null);
  -
  -            // Copy the data from the translation buffer into the result 
buffer
  -            // up to the next expression character (arriving to the current 
in the
  -            // expression buffer)        
  -            while (trns[trnspos]>=0) rslt[rsltpos++]=(char)trns[trnspos++];
  -            trnspos++;
  -                
  -            if (exprchr==MATCH_END) return(new String(rslt,0,rsltpos));
  -            
  -            // Search the next expression character
  -            buffpos+=(charpos-exprpos);
  -            exprpos=++charpos;
  -            while (expr[charpos]>=0) charpos++;
  -            int prevchr=exprchr;
  -            exprchr=expr[charpos];
  -   
  -            offset=super.matchArray(expr,exprpos,charpos,buff,buffpos);
  -            if (offset<0) return(null);
  -    
  -            // Copy the data from the source buffer into the result buffer
  -            // to substitute the expression character
  -            if (prevchr==MATCH_PATH) {
  -                while (buffpos<offset) rslt[rsltpos++]=buff[buffpos++];
  -            } else {
  -                // Matching file, don't copy '/'
  -                while (buffpos<offset) {
  -                    if (buff[buffpos]=='/') return(null);
  -                    rslt[rsltpos++]=buff[buffpos++];
  -                }
  -            }
  -        }
  -    }
  -    
  -    /** Testing */
  -    public static void main(String argv[]) {
  -        try {
  -            if (argv.length<3) return;
  -            PatternTranslator t=new PatternTranslator(argv[0],argv[1]);
  -            System.out.println("Matching Expr.    \""+argv[0]+"\"");
  -            System.out.println("Translation Expr. \""+argv[1]+"\"");
  -            System.out.println("Source Data       \""+argv[2]+"\"");
  -            System.out.println(" - Math returned \""+t.match(argv[2])+"\"");
  -            System.out.println(" - Translation   
\""+t.translate(argv[2])+"\"");
  -        } catch (Exception e) {
  -            System.out.println(e.getClass().getName());
  -            System.out.println(e.getMessage());
  -        }
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.sitemap.patterns;
  +
  +/**
  + * This class is an utility class that perform wilcard-patterns matching and
  + * translation.
  + * <br>
  + * The pattern rules follow the one defined by <code>PatternMatcher</code> 
and
  + * the translation is done in the following way (in example):
  + * if the source pattern is &quot;test/*.xml&quot; and the target pattern is
  + * &quot;sources/data/*&quot;, the <code>String</code> 
&quot;test/my.xml&quot;
  + * will be translated into &quot;sources/data/my&quot;
  + * 
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.8 $ $Date: 2000/07/29 18:30:39 $
  + */
  +public class PatternTranslator extends PatternMatcher {
  +
  +    /** Wether the source and the target patterns are equal. */
  +    private boolean identityTranslation=false;
  +    /** The int array identifying the pattern to match. */
  +    protected int[] targetPattern=null;
  +
  +
  +    /**
  +     * Construct a new <code>PatternTranslator</code> instance.
  +     */
  +    public PatternTranslator() {
  +        super();
  +    }
  +
  +    /**
  +     * Construct a new <code>PatternTranslator</code> instance.
  +     */
  +    public PatternTranslator(String pattern)
  +    throws PatternException {
  +        this();
  +        this.setPattern(pattern);
  +    }
  +
  +    /**
  +     * Construct a new <code>PatternTranslator</code> instance.
  +     */
  +    public PatternTranslator(String source, String target)
  +    throws PatternException {
  +        this();
  +        this.setPattern(source,target);
  +    }
  +
  +    /**
  +     * Translate the specified <code>String</code> according to the rules
  +     * specified by the source and target patterns.
  +     * <br>
  +     * If the specified <code>String</code> is not matched by the source
  +     * pattern <b>null</b> is returned.
  +     * <br>
  +     * If the source and the target patterns are qual the same
  +     * <code>String</code> is returned.
  +     */
  +    public String translate(String data) {
  +        if (data==null) throw new NullPointerException("Null data");
  +        if (this.identityTranslation) return(data);
  +        if ((this.targetPattern==null) || (super.sourcePattern==null))
  +            throw new IllegalStateException("Null internals");
  +        if (!super.match(data)) return(null);
  +        
  +        char x[]=data.toCharArray();
  +        
return(this.translatePattern(x,super.sourcePattern,this.targetPattern));
  +    }
  +
  +    /**
  +     * Set the source and target patterns as two identical patterns.
  +     * <br>
  +     * No translation will be performed, as this specifies the identity
  +     * transformation.
  +     */
  +    public void setPattern(String pattern)
  +    throws PatternException {
  +        if (pattern==null) throw new PatternException("Null pattern");
  +        this.setPattern(pattern,pattern);
  +    }
  +
  +    /**
  +     * Set the source and target patterns.
  +     * <br>
  +     * If the source pattern is equal to the target one, no translation will
  +     * be performed as same patterns specify an identity transformation.
  +     */
  +    public void setPattern(String source, String target)
  +    throws PatternException {
  +        if (source==null) throw new PatternException("Null source pattern");
  +        if (target==null) throw new PatternException("Null target pattern");
  +        if (source.equals(target)) {
  +            this.targetPattern=super.convertPattern(target);
  +            super.sourcePattern=this.targetPattern;
  +            this.identityTranslation=true;
  +            return;
  +        }
  +        int t[]=super.convertPattern(target);
  +        int s[]=super.convertPattern(source);
  +        int y=0;
  +        for(int x=0; x<t.length; x++) if(t[x]<0) {
  +            while(s[y]>=0) y++;
  +            if(t[x]!=s[y]) throw new PatternException("Unbalanced 
expression");
  +            else y++;
  +            if(t[x]==MATCH_END) break;
  +        }
  +        this.targetPattern=t;
  +        super.sourcePattern=s;
  +    }
  +
  +    /** 
  +     * Internal routines for translation
  +     * <br>
  +     * <b>FIXME: This routine doesn't match when the pattern ends with a
  +     *    wildcard. Need to fix together with <code>matchPattern()</code>,
  +     *    in <code>PatternMatcher</code> otherwise it won't work.</b>
  +     * <br>
  +     * <i>Seems ok now</i>
  +     */
  +    protected String translatePattern(char buff[], int expr[], int trns[])
  +    throws NullPointerException {
  +        // Allocate the result buffer
  +        char rslt[]=new char[expr.length+trns.length+buff.length];
  +        
  +        // The previous and current position of the expression character
  +        // (MATCH_*)
  +        int charpos=0;
  +        // Search the fist expression character
  +        while (expr[charpos]>=0) charpos++;
  +        // The expression charater (MATCH_*)
  +        int exprchr=expr[charpos];
  +
  +        // The position in the expression, input, translation and result 
arrays
  +        int exprpos=0;
  +        int buffpos=0;
  +        int trnspos=0;
  +        int rsltpos=0;
  +        int offset=-1;
  +        
  +        while (true) {
  +            // Check if the data in the expression array before the current
  +            // expression character matches the data in the input buffer
  +            offset=super.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(null);
  +
  +            // Copy the data from the translation buffer into the result 
buffer
  +            // up to the next expression character (arriving to the current 
in the
  +            // expression buffer)        
  +            while (trns[trnspos]>=0) rslt[rsltpos++]=(char)trns[trnspos++];
  +            trnspos++;
  +                
  +            if (exprchr==MATCH_END) return(new String(rslt,0,rsltpos));
  +            
  +            // Search the next expression character
  +            buffpos+=(charpos-exprpos);
  +            exprpos=++charpos;
  +            while (expr[charpos]>=0) charpos++;
  +            int prevchr=exprchr;
  +            exprchr=expr[charpos];
  +   
  +            offset=super.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(null);
  +    
  +            // Copy the data from the source buffer into the result buffer
  +            // to substitute the expression character
  +            if (prevchr==MATCH_PATH) {
  +                while (buffpos<offset) rslt[rsltpos++]=buff[buffpos++];
  +            } else {
  +                // Matching file, don't copy '/'
  +                while (buffpos<offset) {
  +                    if (buff[buffpos]=='/') return(null);
  +                    rslt[rsltpos++]=buff[buffpos++];
  +                }
  +            }
  +        }
  +    }
  +    
  +    /** Testing */
  +    public static void main(String argv[]) {
  +        try {
  +            if (argv.length<3) return;
  +            PatternTranslator t=new PatternTranslator(argv[0],argv[1]);
  +            System.out.println("Matching Expr.    \""+argv[0]+"\"");
  +            System.out.println("Translation Expr. \""+argv[1]+"\"");
  +            System.out.println("Source Data       \""+argv[2]+"\"");
  +            System.out.println(" - Math returned \""+t.match(argv[2])+"\"");
  +            System.out.println(" - Translation   
\""+t.translate(argv[2])+"\"");
  +        } catch (Exception e) {
  +            System.out.println(e.getClass().getName());
  +            System.out.println(e.getMessage());
  +        }
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +189 -189  
xml-cocoon/src/org/apache/cocoon/transformation/Attic/AbstractTransformer.java
  
  Index: AbstractTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/AbstractTransformer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- AbstractTransformer.java  2000/07/22 20:42:00     1.1.2.2
  +++ AbstractTransformer.java  2000/07/29 18:30:40     1.1.2.3
  @@ -1,189 +1,189 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.transformation;
  -
  -import org.apache.cocoon.xml.AbstractXMLProducer;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:42:00 $
  - */
  -public abstract class AbstractTransformer extends AbstractXMLProducer
  -implements Transformer {
  -
  -    /** Wether we are forwarding XML data or not. */
  -    private boolean canReset=true;
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     */
  -    public void setDocumentLocator(Locator locator) {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.setDocumentLocator(locator);
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument()
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startDocument();
  -        this.canReset=false;
  -    }
  -
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument()
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.endDocument();
  -        this.canReset=true;
  -    }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startPrefixMapping(prefix,uri);
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes 
a)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startElement(uri,loc,raw,a);
  -    }
  -
  -
  -    /**
  -     * Receive notification of the end of an element.
  -     */
  -    public void endElement(String uri, String loc, String raw)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.endElement(uri,loc,raw);
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     */
  -    public void characters(char ch[], int start, int len)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.characters(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     */
  -    public void ignorableWhitespace(char ch[], int start, int len)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.ignorableWhitespace(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of a processing instruction.
  -     */
  -    public void processingInstruction(String target, String data)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.processingInstruction(target,data);
  -    }
  -
  -    /**
  -     * Receive notification of a skipped entity.
  -     */
  -    public void skippedEntity(String name)
  -    throws SAXException {
  -        if (super.contentHandler!=null)
  -            super.contentHandler.skippedEntity(name);
  -    }
  -
  -    /**
  -     * Report the start of DTD declarations, if any.
  -     */
  -    public void startDTD(String name, String publicId, String systemId)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startDTD(name,publicId,systemId);
  -    }
  -
  -    /**
  -     * Report the end of DTD declarations.
  -     */
  -    public void endDTD()
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endDTD();
  -    }
  -
  -    /**
  -     * Report the beginning of an entity.
  -     */
  -    public void startEntity(String name)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startEntity(name);
  -    }
  -
  -    /**
  -     * Report the end of an entity.
  -     */
  -    public void endEntity(String name)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endEntity(name);
  -    }
  -
  -    /**
  -     * Report the start of a CDATA section.
  -     */
  -    public void startCDATA()
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startCDATA();
  -    }
  -
  -    /**
  -     * Report the end of a CDATA section.
  -     */
  -    public void endCDATA()
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endCDATA();
  -    }
  -
  -
  -    /**
  -     * Report an XML comment anywhere in the document.
  -     */
  -    public void comment(char ch[], int start, int len)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.comment(ch,start,len);
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.transformation;
  +
  +import org.apache.cocoon.xml.AbstractXMLProducer;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:40 $
  + */
  +public abstract class AbstractTransformer extends AbstractXMLProducer
  +implements Transformer {
  +
  +    /** Wether we are forwarding XML data or not. */
  +    private boolean canReset=true;
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     */
  +    public void setDocumentLocator(Locator locator) {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.setDocumentLocator(locator);
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +    public void startDocument()
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.startDocument();
  +        this.canReset=false;
  +    }
  +
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +    public void endDocument()
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.endDocument();
  +        this.canReset=true;
  +    }
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping.
  +     */
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.startPrefixMapping(prefix,uri);
  +    }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping.
  +     */
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of an element.
  +     */
  +    public void startElement(String uri, String loc, String raw, Attributes 
a)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.startElement(uri,loc,raw,a);
  +    }
  +
  +
  +    /**
  +     * Receive notification of the end of an element.
  +     */
  +    public void endElement(String uri, String loc, String raw)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.endElement(uri,loc,raw);
  +    }
  +
  +    /**
  +     * Receive notification of character data.
  +     */
  +    public void characters(char ch[], int start, int len)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.characters(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     */
  +    public void ignorableWhitespace(char ch[], int start, int len)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.ignorableWhitespace(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of a processing instruction.
  +     */
  +    public void processingInstruction(String target, String data)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.processingInstruction(target,data);
  +    }
  +
  +    /**
  +     * Receive notification of a skipped entity.
  +     */
  +    public void skippedEntity(String name)
  +    throws SAXException {
  +        if (super.contentHandler!=null)
  +            super.contentHandler.skippedEntity(name);
  +    }
  +
  +    /**
  +     * Report the start of DTD declarations, if any.
  +     */
  +    public void startDTD(String name, String publicId, String systemId)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startDTD(name,publicId,systemId);
  +    }
  +
  +    /**
  +     * Report the end of DTD declarations.
  +     */
  +    public void endDTD()
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endDTD();
  +    }
  +
  +    /**
  +     * Report the beginning of an entity.
  +     */
  +    public void startEntity(String name)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startEntity(name);
  +    }
  +
  +    /**
  +     * Report the end of an entity.
  +     */
  +    public void endEntity(String name)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endEntity(name);
  +    }
  +
  +    /**
  +     * Report the start of a CDATA section.
  +     */
  +    public void startCDATA()
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startCDATA();
  +    }
  +
  +    /**
  +     * Report the end of a CDATA section.
  +     */
  +    public void endCDATA()
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endCDATA();
  +    }
  +
  +
  +    /**
  +     * Report an XML comment anywhere in the document.
  +     */
  +    public void comment(char ch[], int start, int len)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.comment(ch,start,len);
  +    }
  +}
  
  
  
  1.1.2.3   +312 -312  
xml-cocoon/src/org/apache/cocoon/transformation/Attic/LogTransformer.java
  
  Index: LogTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/LogTransformer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- LogTransformer.java       2000/07/22 20:42:01     1.1.2.2
  +++ LogTransformer.java       2000/07/29 18:30:40     1.1.2.3
  @@ -1,312 +1,312 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.transformation;
  -
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.xml.AbstractXMLProducer;
  -
  -import org.xml.sax.Attributes;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -
  -import java.io.FileWriter;
  -import java.io.IOException;
  -import java.util.Date;
  -
  -/**
  - *
  - * The <code>LogTransformer</code> is a class that can be plugged into a 
pipeline
  - * to print the SAX events which passes thru this transformer in a readable 
form 
  - * to a file. 
  - * <br>
  - * The file will be specified in a parameter tag to the transformer as 
follows:
  - * <p>
  - * <code>
  - * &lt;transformer name="log"&gt;<br>
  - * &nbsp;&nbsp;&lt;parameter name="logfile" value="logfile.log"/&gt;<br>
  - * &nbsp;&nbsp;&lt;parameter name="append" value="no"/&gt;<br>
  - * &lt;/transformer&gt;<br>
  - * </code>
  - * </p>
  - *
  - * Because the log file will be hardcoded into the sitemap this 
LOGTransformer will 
  - * not be thread save!!
  - * <br>
  - * This transformations main purpose is debugging.
  - * 
  - * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - *         (PWR Organisation &amp; Entwicklung)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:42:01 $
  - *
  - */
  -public class LogTransformer extends AbstractTransformer {
  -
  -    /** Wether we are forwarding XML data or not. */
  -    private boolean canReset=true;
  -
  -    private String lf = System.getProperty("line.separator", "\n");
  -    
  -    /** true if filename is valid and writeable */
  -    private boolean isValid = true;
  -    /** filename for log file        */
  -    private String logfilename = null;
  -    /** log file     */
  -    private FileWriter logfile = null;
  -    /** should we append content to the log file */
  -    private boolean append = false;
  -
  -    /** BEGIN SitemapComponent methods **/
  -
  -    public void setup(Environment environment, 
  -                      String source, Parameters parameters) 
  -            throws ProcessingException, SAXException, IOException {
  -        if (logfile == null) {
  -            String appends = parameters.getParameter("append", null);
  -            logfilename = parameters.getParameter("logfile", null);
  -            if (appends != null && appends.equals ("yes")) {
  -                append = true;
  -            } else {
  -                append = false;
  -            }
  -            try {
  -                logfile = new FileWriter(logfilename, append );
  -            } catch (IOException e) {
  -                isValid = false;
  -                throw e;
  -            }
  -        }
  -        Date date = new Date();
  -        StringBuffer logEntry = new StringBuffer();
  -        logEntry.append ( "---------------------------- [" );
  -        logEntry.append ( date.toString() ); 
  -        logEntry.append ( "] ----------------------------" );
  -        log("setup", logEntry.toString());
  -    }
  -
  -    /** END SitemapComponent methods **/
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     */
  -    public void setDocumentLocator(Locator locator) {
  -        log("setDocumentLocator","");
  -        if (super.contentHandler!=null)
  -            super.contentHandler.setDocumentLocator(locator);
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument()
  -    throws SAXException {
  -        log("startDocument", "");
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startDocument();
  -        this.canReset=false;
  -    }
  -
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument()
  -    throws SAXException {
  -        log ("endDocument", "");
  -        if (super.contentHandler!=null)
  -            super.contentHandler.endDocument();
  -        this.canReset=true;
  -    }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -        log ("startPrefixMapping", "prefix="+prefix+",uri="+uri);
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startPrefixMapping(prefix,uri);
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -        log ("endPrefixMapping", "prefix="+prefix);
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes 
a)
  -    throws SAXException {
  -        log ("startElement", "uri="+uri+",local="+loc+",raw="+raw);
  -        for (int i = 0; i < a.getLength(); i++) {
  -            log ("            ", new Integer(i+1).toString()
  -                 +". uri="+a.getURI(i)
  -                 +",local="+a.getLocalName(i)
  -                 +",qname="+a.getQName(i)
  -                 +",type="+a.getType(i)
  -                 +",value="+a.getValue(i));
  -        }
  -        if (super.contentHandler!=null)
  -            super.contentHandler.startElement(uri,loc,raw,a);
  -    }
  -
  -
  -    /**
  -     * Receive notification of the end of an element.
  -     */
  -    public void endElement(String uri, String loc, String qname)
  -    throws SAXException {
  -        log ("endElement", "uri="+uri+",local="+loc+",qname="+qname);
  -        if (super.contentHandler!=null)
  -            super.contentHandler.endElement(uri,loc,qname);
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     */
  -    public void characters(char ch[], int start, int len)
  -    throws SAXException {
  -        log ("characters", new String(ch).substring(start, len));
  -        if (super.contentHandler!=null)
  -            super.contentHandler.characters(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     */
  -    public void ignorableWhitespace(char ch[], int start, int len)
  -    throws SAXException {
  -        log ("ignorableWhitespace", new String(ch).substring(start, len));
  -        if (super.contentHandler!=null)
  -            super.contentHandler.ignorableWhitespace(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of a processing instruction.
  -     */
  -    public void processingInstruction(String target, String data)
  -    throws SAXException {
  -        log ("processingInstruction", "target="+target+",data="+data);
  -        if (super.contentHandler!=null)
  -            super.contentHandler.processingInstruction(target,data);
  -    }
  -
  -    /**
  -     * Receive notification of a skipped entity.
  -     */
  -    public void skippedEntity(String name)
  -    throws SAXException {
  -        log ("skippedEntity", "name="+name);
  -        if (super.contentHandler!=null)
  -            super.contentHandler.skippedEntity(name);
  -    }
  -
  -    /**
  -     * Report the start of DTD declarations, if any.
  -     */
  -    public void startDTD(String name, String publicId, String systemId)
  -    throws SAXException {
  -        log ("startDTD", 
"name="+name+",publicId="+publicId+",systemId="+systemId);
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startDTD(name,publicId,systemId);
  -    }
  -
  -    /**
  -     * Report the end of DTD declarations.
  -     */
  -    public void endDTD()
  -    throws SAXException {
  -        log ("endDTD", "");
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endDTD();
  -    }
  -
  -    /**
  -     * Report the beginning of an entity.
  -     */
  -    public void startEntity(String name)
  -    throws SAXException {
  -        log ("startEntity", "name="+name);
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startEntity(name);
  -    }
  -
  -    /**
  -     * Report the end of an entity.
  -     */
  -    public void endEntity(String name)
  -    throws SAXException {
  -        log ("endEntity", "name="+name);
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endEntity(name);
  -    }
  -
  -    /**
  -     * Report the start of a CDATA section.
  -     */
  -    public void startCDATA()
  -    throws SAXException {
  -        log ("startCDATA", "");
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.startCDATA();
  -    }
  -
  -    /**
  -     * Report the end of a CDATA section.
  -     */
  -    public void endCDATA()
  -    throws SAXException {
  -        log ("endCDATA", "");
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.endCDATA();
  -    }
  -
  -    /**
  -     * Report an XML comment anywhere in the document.
  -     */
  -    public void comment(char ch[], int start, int len)
  -    throws SAXException {
  -        log ("comment", new String(ch).substring(start, len));
  -        if (super.lexicalHandler!=null)
  -            super.lexicalHandler.comment(ch,start,len);
  -    }
  -
  -    /**
  -     * Report to logfile.
  -     */
  -    private void log (String location, String description) {
  -        if (isValid) {    
  -            StringBuffer logEntry = new StringBuffer();
  -            logEntry.append ( "[" );
  -            logEntry.append ( location ); 
  -            logEntry.append ( "] " );
  -            logEntry.append ( description );
  -            logEntry.append ( lf );
  -            synchronized (logfile) {
  -                try {
  -                    logfile.write( logEntry.toString(), 0, 
logEntry.length());
  -                    logfile.flush();
  -                }
  -                catch(IOException ioe) { }
  -            }
  -        }
  -    }
  -    
  -    /**
  -     *  Attempt to close the log file when the class is GC'd
  -     */
  -    public void destroy() {
  -        try {
  -            logfile.close();
  -        } catch (Exception e) {}
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.transformation;
  +
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.xml.AbstractXMLProducer;
  +
  +import org.xml.sax.Attributes;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +
  +import java.io.FileWriter;
  +import java.io.IOException;
  +import java.util.Date;
  +
  +/**
  + *
  + * The <code>LogTransformer</code> is a class that can be plugged into a 
pipeline
  + * to print the SAX events which passes thru this transformer in a readable 
form 
  + * to a file. 
  + * <br>
  + * The file will be specified in a parameter tag to the transformer as 
follows:
  + * <p>
  + * <code>
  + * &lt;transformer name="log"&gt;<br>
  + * &nbsp;&nbsp;&lt;parameter name="logfile" value="logfile.log"/&gt;<br>
  + * &nbsp;&nbsp;&lt;parameter name="append" value="no"/&gt;<br>
  + * &lt;/transformer&gt;<br>
  + * </code>
  + * </p>
  + *
  + * Because the log file will be hardcoded into the sitemap this 
LOGTransformer will 
  + * not be thread save!!
  + * <br>
  + * This transformations main purpose is debugging.
  + * 
  + * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  + *         (PWR Organisation &amp; Entwicklung)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:40 $
  + *
  + */
  +public class LogTransformer extends AbstractTransformer {
  +
  +    /** Wether we are forwarding XML data or not. */
  +    private boolean canReset=true;
  +
  +    private String lf = System.getProperty("line.separator", "\n");
  +    
  +    /** true if filename is valid and writeable */
  +    private boolean isValid = true;
  +    /** filename for log file        */
  +    private String logfilename = null;
  +    /** log file     */
  +    private FileWriter logfile = null;
  +    /** should we append content to the log file */
  +    private boolean append = false;
  +
  +    /** BEGIN SitemapComponent methods **/
  +
  +    public void setup(Environment environment, 
  +                      String source, Parameters parameters) 
  +            throws ProcessingException, SAXException, IOException {
  +        if (logfile == null) {
  +            String appends = parameters.getParameter("append", null);
  +            logfilename = parameters.getParameter("logfile", null);
  +            if (appends != null && appends.equals ("yes")) {
  +                append = true;
  +            } else {
  +                append = false;
  +            }
  +            try {
  +                logfile = new FileWriter(logfilename, append );
  +            } catch (IOException e) {
  +                isValid = false;
  +                throw e;
  +            }
  +        }
  +        Date date = new Date();
  +        StringBuffer logEntry = new StringBuffer();
  +        logEntry.append ( "---------------------------- [" );
  +        logEntry.append ( date.toString() ); 
  +        logEntry.append ( "] ----------------------------" );
  +        log("setup", logEntry.toString());
  +    }
  +
  +    /** END SitemapComponent methods **/
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     */
  +    public void setDocumentLocator(Locator locator) {
  +        log("setDocumentLocator","");
  +        if (super.contentHandler!=null)
  +            super.contentHandler.setDocumentLocator(locator);
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +    public void startDocument()
  +    throws SAXException {
  +        log("startDocument", "");
  +        if (super.contentHandler!=null)
  +            super.contentHandler.startDocument();
  +        this.canReset=false;
  +    }
  +
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +    public void endDocument()
  +    throws SAXException {
  +        log ("endDocument", "");
  +        if (super.contentHandler!=null)
  +            super.contentHandler.endDocument();
  +        this.canReset=true;
  +    }
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping.
  +     */
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +        log ("startPrefixMapping", "prefix="+prefix+",uri="+uri);
  +        if (super.contentHandler!=null)
  +            super.contentHandler.startPrefixMapping(prefix,uri);
  +    }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping.
  +     */
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +        log ("endPrefixMapping", "prefix="+prefix);
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of an element.
  +     */
  +    public void startElement(String uri, String loc, String raw, Attributes 
a)
  +    throws SAXException {
  +        log ("startElement", "uri="+uri+",local="+loc+",raw="+raw);
  +        for (int i = 0; i < a.getLength(); i++) {
  +            log ("            ", new Integer(i+1).toString()
  +                 +". uri="+a.getURI(i)
  +                 +",local="+a.getLocalName(i)
  +                 +",qname="+a.getQName(i)
  +                 +",type="+a.getType(i)
  +                 +",value="+a.getValue(i));
  +        }
  +        if (super.contentHandler!=null)
  +            super.contentHandler.startElement(uri,loc,raw,a);
  +    }
  +
  +
  +    /**
  +     * Receive notification of the end of an element.
  +     */
  +    public void endElement(String uri, String loc, String qname)
  +    throws SAXException {
  +        log ("endElement", "uri="+uri+",local="+loc+",qname="+qname);
  +        if (super.contentHandler!=null)
  +            super.contentHandler.endElement(uri,loc,qname);
  +    }
  +
  +    /**
  +     * Receive notification of character data.
  +     */
  +    public void characters(char ch[], int start, int len)
  +    throws SAXException {
  +        log ("characters", new String(ch).substring(start, len));
  +        if (super.contentHandler!=null)
  +            super.contentHandler.characters(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     */
  +    public void ignorableWhitespace(char ch[], int start, int len)
  +    throws SAXException {
  +        log ("ignorableWhitespace", new String(ch).substring(start, len));
  +        if (super.contentHandler!=null)
  +            super.contentHandler.ignorableWhitespace(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of a processing instruction.
  +     */
  +    public void processingInstruction(String target, String data)
  +    throws SAXException {
  +        log ("processingInstruction", "target="+target+",data="+data);
  +        if (super.contentHandler!=null)
  +            super.contentHandler.processingInstruction(target,data);
  +    }
  +
  +    /**
  +     * Receive notification of a skipped entity.
  +     */
  +    public void skippedEntity(String name)
  +    throws SAXException {
  +        log ("skippedEntity", "name="+name);
  +        if (super.contentHandler!=null)
  +            super.contentHandler.skippedEntity(name);
  +    }
  +
  +    /**
  +     * Report the start of DTD declarations, if any.
  +     */
  +    public void startDTD(String name, String publicId, String systemId)
  +    throws SAXException {
  +        log ("startDTD", 
"name="+name+",publicId="+publicId+",systemId="+systemId);
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startDTD(name,publicId,systemId);
  +    }
  +
  +    /**
  +     * Report the end of DTD declarations.
  +     */
  +    public void endDTD()
  +    throws SAXException {
  +        log ("endDTD", "");
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endDTD();
  +    }
  +
  +    /**
  +     * Report the beginning of an entity.
  +     */
  +    public void startEntity(String name)
  +    throws SAXException {
  +        log ("startEntity", "name="+name);
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startEntity(name);
  +    }
  +
  +    /**
  +     * Report the end of an entity.
  +     */
  +    public void endEntity(String name)
  +    throws SAXException {
  +        log ("endEntity", "name="+name);
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endEntity(name);
  +    }
  +
  +    /**
  +     * Report the start of a CDATA section.
  +     */
  +    public void startCDATA()
  +    throws SAXException {
  +        log ("startCDATA", "");
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.startCDATA();
  +    }
  +
  +    /**
  +     * Report the end of a CDATA section.
  +     */
  +    public void endCDATA()
  +    throws SAXException {
  +        log ("endCDATA", "");
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.endCDATA();
  +    }
  +
  +    /**
  +     * Report an XML comment anywhere in the document.
  +     */
  +    public void comment(char ch[], int start, int len)
  +    throws SAXException {
  +        log ("comment", new String(ch).substring(start, len));
  +        if (super.lexicalHandler!=null)
  +            super.lexicalHandler.comment(ch,start,len);
  +    }
  +
  +    /**
  +     * Report to logfile.
  +     */
  +    private void log (String location, String description) {
  +        if (isValid) {    
  +            StringBuffer logEntry = new StringBuffer();
  +            logEntry.append ( "[" );
  +            logEntry.append ( location ); 
  +            logEntry.append ( "] " );
  +            logEntry.append ( description );
  +            logEntry.append ( lf );
  +            synchronized (logfile) {
  +                try {
  +                    logfile.write( logEntry.toString(), 0, 
logEntry.length());
  +                    logfile.flush();
  +                }
  +                catch(IOException ioe) { }
  +            }
  +        }
  +    }
  +    
  +    /**
  +     *  Attempt to close the log file when the class is GC'd
  +     */
  +    public void destroy() {
  +        try {
  +            logfile.close();
  +        } catch (Exception e) {}
  +    }
  +}
  
  
  
  1.1.2.3   +522 -522  
xml-cocoon/src/org/apache/cocoon/transformation/Attic/SQLTransformer.java
  
  Index: SQLTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/SQLTransformer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- SQLTransformer.java       2000/07/22 20:42:01     1.1.2.2
  +++ SQLTransformer.java       2000/07/29 18:30:40     1.1.2.3
  @@ -1,522 +1,522 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.transformation;
  -
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.xml.XMLConsumer;
  -import org.apache.cocoon.xml.XMLProducer;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.helpers.AttributesImpl;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.Locator;
  -import org.xml.sax.ext.LexicalHandler;
  -import java.sql.Connection;
  -import java.sql.DriverManager;
  -import java.sql.Statement;
  -import java.sql.ResultSet;
  -import java.sql.ResultSetMetaData;
  -import java.sql.SQLException;
  -import java.io.IOException;
  -import java.util.Properties;
  -import java.util.Vector;
  -import java.util.Enumeration;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Donald Ball</a>
  - * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - *         (PWR Organisation & Entwicklung)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:42:01 $ $Author: 
giacomo $
  - */
  -
  -public class SQLTransformer extends AbstractTransformer {
  -
  -     protected boolean debug = true;
  -
  -    /** The SQL namespace **/
  -    public static final String my_uri = "http://xml.apache.org/cocoon/SQL";;
  -    public static final String my_name = "SQLTransformer";
  -
  -    /** The SQL namespace element names **/
  -    public static final String MAGIC_EXECUTE_QUERY = "execute-query";
  -    public static final String MAGIC_DRIVER = "driver";
  -    public static final String MAGIC_DBURL = "dburl";
  -    public static final String MAGIC_USERNAME = "username";
  -    public static final String MAGIC_PASSWORD = "password";
  -    public static final String MAGIC_QUERY = "query";
  -     public static final String MAGIC_ANCESTOR_VALUE = "ancestor-value";
  -     public static final String MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE = 
"level";
  -     public static final String MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE = "name";
  -
  -    /** The states we are allowed to be in **/
  -    public static final int STATE_OUTSIDE = 0;
  -    public static final int STATE_INSIDE_EXECUTE_QUERY_ELEMENT = 1;
  -    public static final int STATE_INSIDE_VALUE_ELEMENT = 2;
  -     public static final int STATE_INSIDE_QUERY_ELEMENT = 3;
  -     public static final int STATE_INSIDE_ANCESTOR_VALUE_ELEMENT = 4;
  -
  -     /** Default parameters that might apply to all queries **/
  -     protected Properties default_properties = new Properties();
  -
  -     /** The list of queries that we're currently working on **/
  -     protected Vector queries = new Vector();
  -
  -     /** The offset of the current query in the queries list **/
  -     protected int current_query_index = -1;
  -
  -     /** The name of the value element we're currently receiving **/
  -     protected String current_name;
  -
  -     /** The current state of the event receiving FSM **/
  -     protected int current_state;
  -
  -     /** The value of the value element we're currently receiving **/
  -     protected StringBuffer current_value = new StringBuffer();
  -
  -    /** SAX producing state information **/
  -    protected XMLConsumer xml_consumer;
  -    protected LexicalHandler lexical_handler;
  -
  -    /** BEGIN SitemapComponent methods **/
  -
  -    public void setup(Environment environment, 
  -                      String source, Parameters parameters) 
  -            throws ProcessingException, SAXException, IOException {
  -        current_state = STATE_OUTSIDE;
  -
  -        // Check the driver
  -             String parameter = parameters.getParameter("driver",null);
  -             if (parameter != null) {
  -                     default_properties.setProperty("driver",parameter);
  -             }
  -
  -        // Check the dburl
  -             parameter = parameters.getParameter("dburl",null);
  -             if (parameter != null) {
  -                     default_properties.setProperty("dburl",parameter);
  -             }
  -
  -        // Check the username
  -             parameter = parameters.getParameter("username",null);
  -             if (parameter != null) {
  -                     default_properties.setProperty("username",parameter);
  -             }
  -
  -        // Check the password
  -             parameter = parameters.getParameter("password",null);
  -             if (parameter != null) {
  -                     default_properties.setProperty("password",parameter);
  -             }
  -
  -    }
  -
  -    /** END SitemapComponent methods **/
  -
  -    /** BEGIN my very own methods **/
  -
  -    /**
  -     * This will be the meat of SQLTransformer, where the query is run.
  -     */
  -    protected void executeQuery(int index) throws SAXException {
  -        this.contentHandler.startPrefixMapping("",my_uri);
  -        AttributesImpl attr = new AttributesImpl();
  -             Query query = (Query)queries.elementAt(index);
  -             try {
  -                     query.execute();
  -             } catch (SQLException e) {
  -                     throw new SAXException(e);
  -             }
  -             this.start(query.rowset_name,attr);
  -             try {
  -                     while (query.next()) {
  -                             this.start(query.row_name,attr);
  -                             query.serializeRow();
  -                             if (index+1 < queries.size()) {
  -                                     executeQuery(index+1);
  -                             }
  -                             this.end(query.row_name);
  -                     }
  -             } catch (SQLException e) {
  -                     throw new SAXException(e);
  -             }
  -             this.end(query.rowset_name);
  -        this.contentHandler.endPrefixMapping("");
  -    }
  -
  -    protected static void throwIllegalStateException(String message) {
  -        throw new IllegalStateException(my_name+": "+message);
  -    }
  -
  -     protected void startExecuteQueryElement() {
  -             switch(current_state) {
  -                     case STATE_OUTSIDE:
  -                     case STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  -                             current_query_index = queries.size();
  -                             Query query = new 
Query(this,current_query_index);
  -                             queries.addElement(query);
  -                             current_state = 
STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
  -                             break;
  -                     default:
  -                             throwIllegalStateException("Not expecting a 
start execute query element");
  -             }
  -     }
  -
  -     protected void startValueElement(String name) {
  -             switch(current_state) {
  -                     case STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  -                             current_name = name;
  -                             current_value.setLength(0);
  -                             current_state = STATE_INSIDE_VALUE_ELEMENT;
  -                             break;
  -                     default:
  -                             throwIllegalStateException("Not expecting a 
start value element: "+name);
  -             }
  -     }
  -
  -     protected void startQueryElement() {
  -             switch(current_state) {
  -                     case STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  -                             current_value.setLength(0);
  -                             current_state = STATE_INSIDE_QUERY_ELEMENT;
  -                             break;
  -                     default:
  -                             throwIllegalStateException("Not expecting a 
start query element");
  -             }
  -     }
  -
  -     protected void endQueryElement() {
  -             switch(current_state) {
  -                     case STATE_INSIDE_QUERY_ELEMENT:
  -                             if (current_value.length() > 0) {
  -                                     
getCurrentQuery().addQueryPart(current_value.toString());
  -                                     current_value.setLength(0);
  -                             }
  -                             current_state = 
STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
  -                             break;
  -                     default:
  -                             throwIllegalStateException("Not expecting a 
stop query element");
  -             }
  -     }
  -
  -     protected void endValueElement() {
  -             switch(current_state) {
  -                     case STATE_INSIDE_VALUE_ELEMENT:
  -                             
getCurrentQuery().setParameter(current_name,current_value.toString());
  -                             if (debug) { System.err.println("SETTING VALUE 
ELEMENT name {"+current_name+"} value {"+current_value.toString()+"}"); }
  -                             current_state = 
STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
  -                             break;
  -                     default:
  -                             throwIllegalStateException("Not expecting an 
end value element");
  -             }
  -     }
  -
  -     protected void endExecuteQueryElement() throws SAXException {
  -             switch(current_state) {
  -                     case STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  -                             if (current_query_index == 0) {
  -                                     executeQuery(0);
  -                                     queries.removeAllElements();
  -                                     current_state = STATE_OUTSIDE;
  -                             } else {
  -                                     current_query_index--;
  -                                     current_state = 
STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
  -                             }
  -                             break;
  -                     default:
  -                             throwIllegalStateException("Not expecting an 
end execute query element");
  -             }
  -     }
  -
  -     protected void startAncestorValueElement(Attributes attributes) {
  -             switch(current_state) {
  -                     case STATE_INSIDE_QUERY_ELEMENT:
  -                             int level = 0;
  -                             try {
  -                                     level = 
Integer.parseInt(attributes.getValue(my_uri,MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE));
  -                             } catch (Exception e) {
  -                                     throwIllegalStateException("Ancestor 
value elements must have a "+MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE+" attribute");
  -                             }
  -                             String name = 
attributes.getValue(my_uri,MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE);
  -                             if (name == null) {
  -                                     throwIllegalStateException("Ancestor 
value elements must have a "+MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE+" attribute");
  -                             }
  -                             AncestorValue av = new 
AncestorValue(level,name);
  -                             if (current_value.length() > 0) {
  -                                     
getCurrentQuery().addQueryPart(current_value.toString());
  -                                     current_value.setLength(0);
  -                             }
  -                             getCurrentQuery().addQueryPart(av);
  -                             current_state = 
STATE_INSIDE_ANCESTOR_VALUE_ELEMENT;
  -                             break;
  -                     default:
  -                             throwIllegalStateException("Not expecting a 
start ancestor value element");
  -             }
  -     }
  -
  -     protected void endAncestorValueElement() {
  -             current_state = STATE_INSIDE_QUERY_ELEMENT;
  -     }
  -
  -     protected Query getCurrentQuery() {
  -             return (Query)queries.elementAt(current_query_index);
  -     }
  -
  -     protected Query getQuery(int i) {
  -             return (Query)queries.elementAt(i);
  -     }
  -
  -     /** END my very own methods **/
  -
  -    /** BEGIN SAX ContentHandler handlers **/
  -
  -    public void setDocumentLocator(Locator locator) {
  -             System.err.println("PUBLIC ID"+locator.getPublicId());
  -             System.err.println("SYSTEM ID"+locator.getSystemId());
  -        if (super.contentHandler!=null)
  -            super.contentHandler.setDocumentLocator(locator);
  -    }
  -
  -    public void startElement(String uri, String name, String raw, Attributes 
attributes) 
  -            throws SAXException {
  -        if (!uri.equals(my_uri)) {
  -            super.startElement(uri,name,raw,attributes);
  -            return;
  -        }
  -             if (debug) { System.err.println("RECEIVED START ELEMENT 
"+name); }
  -        if (name.equals(MAGIC_EXECUTE_QUERY)) {
  -                     startExecuteQueryElement();
  -             } else if (name.equals(MAGIC_QUERY)) {
  -                     startQueryElement();
  -             } else if (name.equals(MAGIC_ANCESTOR_VALUE)) {
  -                     startAncestorValueElement(attributes);
  -             } else {
  -                     startValueElement(name);
  -             }
  -     }
  -
  -    public void endElement(String uri, String name, String raw) 
  -            throws SAXException {
  -        if (!uri.equals(my_uri)) {
  -            super.endElement(uri,name,raw);
  -            return;
  -        }
  -             if (debug) { System.err.println("RECEIVED END ELEMENT "+name); }
  -        if (name.equals(MAGIC_EXECUTE_QUERY)) {
  -                     endExecuteQueryElement();
  -        } else if (name.equals(MAGIC_QUERY)) {
  -                     endQueryElement();
  -             } else if (name.equals(MAGIC_ANCESTOR_VALUE)) {
  -                     endAncestorValueElement();
  -             } else {
  -                     endValueElement();
  -             }
  -    }
  -
  -    public void characters(char ary[], int start, int length) 
  -            throws SAXException {
  -        if (current_state != STATE_INSIDE_VALUE_ELEMENT) {
  -            super.characters(ary,start,length);
  -        }
  -             if (debug) { System.err.println("RECEIVED CHARACTERS: "+new 
String(ary,start,length)); }
  -        current_value.append(ary,start,length);
  -    }
  -
  -    private void attribute(AttributesImpl attr, String name, String value) {
  -        attr.addAttribute("",name,name,"CDATA",value);
  -    }
  -
  -    private void start(String name, AttributesImpl attr)
  -    throws SAXException {
  -        super.contentHandler.startElement(my_uri,name,name,attr);
  -        attr.clear();
  -    }
  -
  -    private void end(String name)
  -    throws SAXException {
  -        super.contentHandler.endElement(my_uri,name,name);
  -    }
  -
  -    private void data(String data)
  -    throws SAXException {
  -        if (data != null)
  -            
super.contentHandler.characters(data.toCharArray(),0,data.length());
  -    }
  -
  -     protected static String getStringValue(Object object) {
  -             if (object instanceof byte[]) {
  -                     return new String((byte[])object);
  -             } else if (object instanceof char[]) {
  -                     return new String((char[])object);
  -             } else if (object != null) {
  -                     return object.toString();
  -             } else {
  -                     return "";
  -             }
  -     }
  -
  -class Query {
  -
  -     /** Who's your daddy? **/
  -     protected SQLTransformer transformer;
  -
  -     /** What index are you in daddy's queries list **/
  -     protected int query_index;
  -
  -    /** SQL configuration information **/
  -     protected Properties properties;
  -
  -    /** Dummy static variables for the moment **/
  -    protected final String rowset_name = "ROWSET";
  -    protected final String row_name = "ROW";
  -
  -     /** The connection, once opened **/
  -     protected Connection conn;
  -
  -     /** And the statement **/
  -     protected Statement st;
  -
  -     /** The results, of course **/
  -     protected ResultSet rs;
  -
  -     /** And the results' metadata **/
  -     protected ResultSetMetaData md;
  -
  -     /** The parts of the query **/
  -     protected Vector query_parts = new Vector();
  -
  -     protected Query(SQLTransformer transformer, int query_index) {
  -             this.transformer = transformer;
  -             this.query_index = query_index;
  -             this.properties = new 
Properties(transformer.default_properties);
  -     }
  -
  -     protected void setParameter(String name, String value) {
  -             properties.setProperty(name,value);
  -     }
  -
  -     protected void execute() throws SQLException {
  -             String driver = 
properties.getProperty(transformer.MAGIC_DRIVER);
  -             try {
  -                     Class.forName(driver).newInstance();
  -             } catch (ClassNotFoundException e) {}
  -             catch (IllegalAccessException e) {}
  -             catch (InstantiationException e) {}
  -             String dburl = properties.getProperty(transformer.MAGIC_DBURL);
  -             String username = 
properties.getProperty(transformer.MAGIC_USERNAME);
  -             String password = 
properties.getProperty(transformer.MAGIC_PASSWORD);
  -             Enumeration enum = query_parts.elements();
  -             StringBuffer sb = new StringBuffer();
  -             while (enum.hasMoreElements()) {
  -                     Object object = enum.nextElement();
  -                     if (object instanceof String) {
  -                             sb.append((String)object);
  -                     } else if (object instanceof AncestorValue) {
  -                             /** Do a lookup into the ancestors' result's 
values **/
  -                             AncestorValue av = (AncestorValue)object;
  -                             Query query = 
transformer.getQuery(query_index-av.level);
  -                             try {
  -                                     
sb.append(query.getColumnValue(av.name));
  -                             } catch (SQLException e) {
  -                                     close();
  -                                     throw e;
  -                             }
  -                     }
  -             }
  -             String query = sb.toString();
  -             try {
  -                     if (username == null || password == null) {
  -                             conn = DriverManager.getConnection(dburl);
  -                     } else {
  -                             conn = 
DriverManager.getConnection(dburl,username,password);
  -                     }
  -                     st = conn.createStatement();
  -                     rs = st.executeQuery(query);
  -                     md = rs.getMetaData();
  -             } catch (SQLException e) {
  -                     e.printStackTrace();
  -                     conn.close();
  -                     throw e;
  -             }
  -     }
  -
  -     protected String getColumnValue(int i) throws SQLException {
  -             try {
  -                     return transformer.getStringValue(rs.getObject(i));
  -             } catch (SQLException e) {
  -                     close();
  -                     throw e;
  -             }
  -     }
  -
  -     protected String getColumnValue(String name) throws SQLException {
  -             try {
  -                     return transformer.getStringValue(rs.getObject(name));
  -             } catch (SQLException e) {
  -                     close();
  -                     throw e;
  -             }
  -     }
  -
  -     protected boolean next() throws SQLException {
  -             try {
  -                     if (!rs.next()) {
  -                             close();
  -                             return false;
  -                     }
  -                     return true;
  -             } catch (SQLException e) {
  -                     close();
  -                     throw e;
  -             }
  -     }
  -
  -     protected void close() throws SQLException {
  -             try {
  -                     rs.close();
  -                     st.close();
  -             } finally {
  -                     conn.close();
  -             }
  -     }
  -
  -     protected void addQueryPart(Object object) {
  -             query_parts.addElement(object);
  -     }
  -
  -     protected void serializeRow() throws SQLException,SAXException {
  -        AttributesImpl attr = new AttributesImpl();
  -             for (int i=1; i <= md.getColumnCount(); i++) {
  -                     
transformer.start(md.getColumnName(i).toLowerCase(),attr);
  -                     try {
  -                             transformer.data(getColumnValue(i));
  -                     } catch (SQLException e) {
  -                             close();
  -                             throw e;
  -                     }
  -                     transformer.end(md.getColumnName(i).toLowerCase());
  -             }
  -     }
  -
  -}
  -
  -class AncestorValue {
  -     
  -     protected int level;
  -     protected String name;
  -
  -     protected AncestorValue(int level, String name) {
  -             this.level = level;
  -             this.name = name;
  -     }
  -
  -}
  -
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.transformation;
  +
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.xml.XMLConsumer;
  +import org.apache.cocoon.xml.XMLProducer;
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.helpers.AttributesImpl;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.Locator;
  +import org.xml.sax.ext.LexicalHandler;
  +import java.sql.Connection;
  +import java.sql.DriverManager;
  +import java.sql.Statement;
  +import java.sql.ResultSet;
  +import java.sql.ResultSetMetaData;
  +import java.sql.SQLException;
  +import java.io.IOException;
  +import java.util.Properties;
  +import java.util.Vector;
  +import java.util.Enumeration;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Donald Ball</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  + *         (PWR Organisation & Entwicklung)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:40 $ $Author: 
rubys $
  + */
  +
  +public class SQLTransformer extends AbstractTransformer {
  +
  +     protected boolean debug = true;
  +
  +    /** The SQL namespace **/
  +    public static final String my_uri = "http://xml.apache.org/cocoon/SQL";;
  +    public static final String my_name = "SQLTransformer";
  +
  +    /** The SQL namespace element names **/
  +    public static final String MAGIC_EXECUTE_QUERY = "execute-query";
  +    public static final String MAGIC_DRIVER = "driver";
  +    public static final String MAGIC_DBURL = "dburl";
  +    public static final String MAGIC_USERNAME = "username";
  +    public static final String MAGIC_PASSWORD = "password";
  +    public static final String MAGIC_QUERY = "query";
  +     public static final String MAGIC_ANCESTOR_VALUE = "ancestor-value";
  +     public static final String MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE = 
"level";
  +     public static final String MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE = "name";
  +
  +    /** The states we are allowed to be in **/
  +    public static final int STATE_OUTSIDE = 0;
  +    public static final int STATE_INSIDE_EXECUTE_QUERY_ELEMENT = 1;
  +    public static final int STATE_INSIDE_VALUE_ELEMENT = 2;
  +     public static final int STATE_INSIDE_QUERY_ELEMENT = 3;
  +     public static final int STATE_INSIDE_ANCESTOR_VALUE_ELEMENT = 4;
  +
  +     /** Default parameters that might apply to all queries **/
  +     protected Properties default_properties = new Properties();
  +
  +     /** The list of queries that we're currently working on **/
  +     protected Vector queries = new Vector();
  +
  +     /** The offset of the current query in the queries list **/
  +     protected int current_query_index = -1;
  +
  +     /** The name of the value element we're currently receiving **/
  +     protected String current_name;
  +
  +     /** The current state of the event receiving FSM **/
  +     protected int current_state;
  +
  +     /** The value of the value element we're currently receiving **/
  +     protected StringBuffer current_value = new StringBuffer();
  +
  +    /** SAX producing state information **/
  +    protected XMLConsumer xml_consumer;
  +    protected LexicalHandler lexical_handler;
  +
  +    /** BEGIN SitemapComponent methods **/
  +
  +    public void setup(Environment environment, 
  +                      String source, Parameters parameters) 
  +            throws ProcessingException, SAXException, IOException {
  +        current_state = STATE_OUTSIDE;
  +
  +        // Check the driver
  +             String parameter = parameters.getParameter("driver",null);
  +             if (parameter != null) {
  +                     default_properties.setProperty("driver",parameter);
  +             }
  +
  +        // Check the dburl
  +             parameter = parameters.getParameter("dburl",null);
  +             if (parameter != null) {
  +                     default_properties.setProperty("dburl",parameter);
  +             }
  +
  +        // Check the username
  +             parameter = parameters.getParameter("username",null);
  +             if (parameter != null) {
  +                     default_properties.setProperty("username",parameter);
  +             }
  +
  +        // Check the password
  +             parameter = parameters.getParameter("password",null);
  +             if (parameter != null) {
  +                     default_properties.setProperty("password",parameter);
  +             }
  +
  +    }
  +
  +    /** END SitemapComponent methods **/
  +
  +    /** BEGIN my very own methods **/
  +
  +    /**
  +     * This will be the meat of SQLTransformer, where the query is run.
  +     */
  +    protected void executeQuery(int index) throws SAXException {
  +        this.contentHandler.startPrefixMapping("",my_uri);
  +        AttributesImpl attr = new AttributesImpl();
  +             Query query = (Query)queries.elementAt(index);
  +             try {
  +                     query.execute();
  +             } catch (SQLException e) {
  +                     throw new SAXException(e);
  +             }
  +             this.start(query.rowset_name,attr);
  +             try {
  +                     while (query.next()) {
  +                             this.start(query.row_name,attr);
  +                             query.serializeRow();
  +                             if (index+1 < queries.size()) {
  +                                     executeQuery(index+1);
  +                             }
  +                             this.end(query.row_name);
  +                     }
  +             } catch (SQLException e) {
  +                     throw new SAXException(e);
  +             }
  +             this.end(query.rowset_name);
  +        this.contentHandler.endPrefixMapping("");
  +    }
  +
  +    protected static void throwIllegalStateException(String message) {
  +        throw new IllegalStateException(my_name+": "+message);
  +    }
  +
  +     protected void startExecuteQueryElement() {
  +             switch(current_state) {
  +                     case STATE_OUTSIDE:
  +                     case STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  +                             current_query_index = queries.size();
  +                             Query query = new 
Query(this,current_query_index);
  +                             queries.addElement(query);
  +                             current_state = 
STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
  +                             break;
  +                     default:
  +                             throwIllegalStateException("Not expecting a 
start execute query element");
  +             }
  +     }
  +
  +     protected void startValueElement(String name) {
  +             switch(current_state) {
  +                     case STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  +                             current_name = name;
  +                             current_value.setLength(0);
  +                             current_state = STATE_INSIDE_VALUE_ELEMENT;
  +                             break;
  +                     default:
  +                             throwIllegalStateException("Not expecting a 
start value element: "+name);
  +             }
  +     }
  +
  +     protected void startQueryElement() {
  +             switch(current_state) {
  +                     case STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  +                             current_value.setLength(0);
  +                             current_state = STATE_INSIDE_QUERY_ELEMENT;
  +                             break;
  +                     default:
  +                             throwIllegalStateException("Not expecting a 
start query element");
  +             }
  +     }
  +
  +     protected void endQueryElement() {
  +             switch(current_state) {
  +                     case STATE_INSIDE_QUERY_ELEMENT:
  +                             if (current_value.length() > 0) {
  +                                     
getCurrentQuery().addQueryPart(current_value.toString());
  +                                     current_value.setLength(0);
  +                             }
  +                             current_state = 
STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
  +                             break;
  +                     default:
  +                             throwIllegalStateException("Not expecting a 
stop query element");
  +             }
  +     }
  +
  +     protected void endValueElement() {
  +             switch(current_state) {
  +                     case STATE_INSIDE_VALUE_ELEMENT:
  +                             
getCurrentQuery().setParameter(current_name,current_value.toString());
  +                             if (debug) { System.err.println("SETTING VALUE 
ELEMENT name {"+current_name+"} value {"+current_value.toString()+"}"); }
  +                             current_state = 
STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
  +                             break;
  +                     default:
  +                             throwIllegalStateException("Not expecting an 
end value element");
  +             }
  +     }
  +
  +     protected void endExecuteQueryElement() throws SAXException {
  +             switch(current_state) {
  +                     case STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  +                             if (current_query_index == 0) {
  +                                     executeQuery(0);
  +                                     queries.removeAllElements();
  +                                     current_state = STATE_OUTSIDE;
  +                             } else {
  +                                     current_query_index--;
  +                                     current_state = 
STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
  +                             }
  +                             break;
  +                     default:
  +                             throwIllegalStateException("Not expecting an 
end execute query element");
  +             }
  +     }
  +
  +     protected void startAncestorValueElement(Attributes attributes) {
  +             switch(current_state) {
  +                     case STATE_INSIDE_QUERY_ELEMENT:
  +                             int level = 0;
  +                             try {
  +                                     level = 
Integer.parseInt(attributes.getValue(my_uri,MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE));
  +                             } catch (Exception e) {
  +                                     throwIllegalStateException("Ancestor 
value elements must have a "+MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE+" attribute");
  +                             }
  +                             String name = 
attributes.getValue(my_uri,MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE);
  +                             if (name == null) {
  +                                     throwIllegalStateException("Ancestor 
value elements must have a "+MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE+" attribute");
  +                             }
  +                             AncestorValue av = new 
AncestorValue(level,name);
  +                             if (current_value.length() > 0) {
  +                                     
getCurrentQuery().addQueryPart(current_value.toString());
  +                                     current_value.setLength(0);
  +                             }
  +                             getCurrentQuery().addQueryPart(av);
  +                             current_state = 
STATE_INSIDE_ANCESTOR_VALUE_ELEMENT;
  +                             break;
  +                     default:
  +                             throwIllegalStateException("Not expecting a 
start ancestor value element");
  +             }
  +     }
  +
  +     protected void endAncestorValueElement() {
  +             current_state = STATE_INSIDE_QUERY_ELEMENT;
  +     }
  +
  +     protected Query getCurrentQuery() {
  +             return (Query)queries.elementAt(current_query_index);
  +     }
  +
  +     protected Query getQuery(int i) {
  +             return (Query)queries.elementAt(i);
  +     }
  +
  +     /** END my very own methods **/
  +
  +    /** BEGIN SAX ContentHandler handlers **/
  +
  +    public void setDocumentLocator(Locator locator) {
  +             System.err.println("PUBLIC ID"+locator.getPublicId());
  +             System.err.println("SYSTEM ID"+locator.getSystemId());
  +        if (super.contentHandler!=null)
  +            super.contentHandler.setDocumentLocator(locator);
  +    }
  +
  +    public void startElement(String uri, String name, String raw, Attributes 
attributes) 
  +            throws SAXException {
  +        if (!uri.equals(my_uri)) {
  +            super.startElement(uri,name,raw,attributes);
  +            return;
  +        }
  +             if (debug) { System.err.println("RECEIVED START ELEMENT 
"+name); }
  +        if (name.equals(MAGIC_EXECUTE_QUERY)) {
  +                     startExecuteQueryElement();
  +             } else if (name.equals(MAGIC_QUERY)) {
  +                     startQueryElement();
  +             } else if (name.equals(MAGIC_ANCESTOR_VALUE)) {
  +                     startAncestorValueElement(attributes);
  +             } else {
  +                     startValueElement(name);
  +             }
  +     }
  +
  +    public void endElement(String uri, String name, String raw) 
  +            throws SAXException {
  +        if (!uri.equals(my_uri)) {
  +            super.endElement(uri,name,raw);
  +            return;
  +        }
  +             if (debug) { System.err.println("RECEIVED END ELEMENT "+name); }
  +        if (name.equals(MAGIC_EXECUTE_QUERY)) {
  +                     endExecuteQueryElement();
  +        } else if (name.equals(MAGIC_QUERY)) {
  +                     endQueryElement();
  +             } else if (name.equals(MAGIC_ANCESTOR_VALUE)) {
  +                     endAncestorValueElement();
  +             } else {
  +                     endValueElement();
  +             }
  +    }
  +
  +    public void characters(char ary[], int start, int length) 
  +            throws SAXException {
  +        if (current_state != STATE_INSIDE_VALUE_ELEMENT) {
  +            super.characters(ary,start,length);
  +        }
  +             if (debug) { System.err.println("RECEIVED CHARACTERS: "+new 
String(ary,start,length)); }
  +        current_value.append(ary,start,length);
  +    }
  +
  +    private void attribute(AttributesImpl attr, String name, String value) {
  +        attr.addAttribute("",name,name,"CDATA",value);
  +    }
  +
  +    private void start(String name, AttributesImpl attr)
  +    throws SAXException {
  +        super.contentHandler.startElement(my_uri,name,name,attr);
  +        attr.clear();
  +    }
  +
  +    private void end(String name)
  +    throws SAXException {
  +        super.contentHandler.endElement(my_uri,name,name);
  +    }
  +
  +    private void data(String data)
  +    throws SAXException {
  +        if (data != null)
  +            
super.contentHandler.characters(data.toCharArray(),0,data.length());
  +    }
  +
  +     protected static String getStringValue(Object object) {
  +             if (object instanceof byte[]) {
  +                     return new String((byte[])object);
  +             } else if (object instanceof char[]) {
  +                     return new String((char[])object);
  +             } else if (object != null) {
  +                     return object.toString();
  +             } else {
  +                     return "";
  +             }
  +     }
  +
  +class Query {
  +
  +     /** Who's your daddy? **/
  +     protected SQLTransformer transformer;
  +
  +     /** What index are you in daddy's queries list **/
  +     protected int query_index;
  +
  +    /** SQL configuration information **/
  +     protected Properties properties;
  +
  +    /** Dummy static variables for the moment **/
  +    protected final String rowset_name = "ROWSET";
  +    protected final String row_name = "ROW";
  +
  +     /** The connection, once opened **/
  +     protected Connection conn;
  +
  +     /** And the statement **/
  +     protected Statement st;
  +
  +     /** The results, of course **/
  +     protected ResultSet rs;
  +
  +     /** And the results' metadata **/
  +     protected ResultSetMetaData md;
  +
  +     /** The parts of the query **/
  +     protected Vector query_parts = new Vector();
  +
  +     protected Query(SQLTransformer transformer, int query_index) {
  +             this.transformer = transformer;
  +             this.query_index = query_index;
  +             this.properties = new 
Properties(transformer.default_properties);
  +     }
  +
  +     protected void setParameter(String name, String value) {
  +             properties.setProperty(name,value);
  +     }
  +
  +     protected void execute() throws SQLException {
  +             String driver = 
properties.getProperty(transformer.MAGIC_DRIVER);
  +             try {
  +                     Class.forName(driver).newInstance();
  +             } catch (ClassNotFoundException e) {}
  +             catch (IllegalAccessException e) {}
  +             catch (InstantiationException e) {}
  +             String dburl = properties.getProperty(transformer.MAGIC_DBURL);
  +             String username = 
properties.getProperty(transformer.MAGIC_USERNAME);
  +             String password = 
properties.getProperty(transformer.MAGIC_PASSWORD);
  +             Enumeration enum = query_parts.elements();
  +             StringBuffer sb = new StringBuffer();
  +             while (enum.hasMoreElements()) {
  +                     Object object = enum.nextElement();
  +                     if (object instanceof String) {
  +                             sb.append((String)object);
  +                     } else if (object instanceof AncestorValue) {
  +                             /** Do a lookup into the ancestors' result's 
values **/
  +                             AncestorValue av = (AncestorValue)object;
  +                             Query query = 
transformer.getQuery(query_index-av.level);
  +                             try {
  +                                     
sb.append(query.getColumnValue(av.name));
  +                             } catch (SQLException e) {
  +                                     close();
  +                                     throw e;
  +                             }
  +                     }
  +             }
  +             String query = sb.toString();
  +             try {
  +                     if (username == null || password == null) {
  +                             conn = DriverManager.getConnection(dburl);
  +                     } else {
  +                             conn = 
DriverManager.getConnection(dburl,username,password);
  +                     }
  +                     st = conn.createStatement();
  +                     rs = st.executeQuery(query);
  +                     md = rs.getMetaData();
  +             } catch (SQLException e) {
  +                     e.printStackTrace();
  +                     conn.close();
  +                     throw e;
  +             }
  +     }
  +
  +     protected String getColumnValue(int i) throws SQLException {
  +             try {
  +                     return transformer.getStringValue(rs.getObject(i));
  +             } catch (SQLException e) {
  +                     close();
  +                     throw e;
  +             }
  +     }
  +
  +     protected String getColumnValue(String name) throws SQLException {
  +             try {
  +                     return transformer.getStringValue(rs.getObject(name));
  +             } catch (SQLException e) {
  +                     close();
  +                     throw e;
  +             }
  +     }
  +
  +     protected boolean next() throws SQLException {
  +             try {
  +                     if (!rs.next()) {
  +                             close();
  +                             return false;
  +                     }
  +                     return true;
  +             } catch (SQLException e) {
  +                     close();
  +                     throw e;
  +             }
  +     }
  +
  +     protected void close() throws SQLException {
  +             try {
  +                     rs.close();
  +                     st.close();
  +             } finally {
  +                     conn.close();
  +             }
  +     }
  +
  +     protected void addQueryPart(Object object) {
  +             query_parts.addElement(object);
  +     }
  +
  +     protected void serializeRow() throws SQLException,SAXException {
  +        AttributesImpl attr = new AttributesImpl();
  +             for (int i=1; i <= md.getColumnCount(); i++) {
  +                     
transformer.start(md.getColumnName(i).toLowerCase(),attr);
  +                     try {
  +                             transformer.data(getColumnValue(i));
  +                     } catch (SQLException e) {
  +                             close();
  +                             throw e;
  +                     }
  +                     transformer.end(md.getColumnName(i).toLowerCase());
  +             }
  +     }
  +
  +}
  +
  +class AncestorValue {
  +     
  +     protected int level;
  +     protected String name;
  +
  +     protected AncestorValue(int level, String name) {
  +             this.level = level;
  +             this.name = name;
  +     }
  +
  +}
  +
  +}
  
  
  
  1.1.2.3   +21 -21    
xml-cocoon/src/org/apache/cocoon/transformation/Attic/Transformer.java
  
  Index: Transformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/Transformer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Transformer.java  2000/07/22 20:42:01     1.1.2.2
  +++ Transformer.java  2000/07/29 18:30:40     1.1.2.3
  @@ -1,21 +1,21 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.transformation;
  -
  -import org.apache.cocoon.sitemap.SitemapComponent;
  -import org.apache.cocoon.xml.XMLConsumer;
  -import org.apache.cocoon.xml.XMLProducer;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:42:01 $
  - */
  -public interface Transformer extends XMLProducer, XMLConsumer, 
SitemapComponent {
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.transformation;
  +
  +import org.apache.cocoon.sitemap.SitemapComponent;
  +import org.apache.cocoon.xml.XMLConsumer;
  +import org.apache.cocoon.xml.XMLProducer;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:40 $
  + */
  +public interface Transformer extends XMLProducer, XMLConsumer, 
SitemapComponent {
  +}
  
  
  
  1.1.2.3   +345 -345  
xml-cocoon/src/org/apache/cocoon/transformation/Attic/XIncludeTransformer.java
  
  Index: XIncludeTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/XIncludeTransformer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- XIncludeTransformer.java  2000/07/22 20:42:01     1.1.2.2
  +++ XIncludeTransformer.java  2000/07/29 18:30:40     1.1.2.3
  @@ -1,345 +1,345 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.transformation;
  -
  -import java.net.URL;
  -import java.net.MalformedURLException;
  -import java.io.IOException;
  -import java.io.Reader;
  -import java.io.InputStream;
  -import java.io.InputStreamReader;
  -import java.util.Stack;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.ext.LexicalHandler;
  -import org.xml.sax.ContentHandler;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.Document;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.avalon.utils.Parameters;
  -import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.components.parser.Parser;
  -import org.apache.avalon.ComponentManager;
  -import org.apache.avalon.Composer;
  -import org.apache.cocoon.xml.util.DOMBuilder;
  -import org.apache.cocoon.xml.util.DOMStreamer;
  -import org.apache.cocoon.xml.util.XPathAPI;
  -
  -/**
  - * My first pass at an XInclude transformation. Currently it should set the 
base URI 
  - * from the SAX Locator's system id but allow it to be overridden by xml:base
  - * elements as the XInclude spec mandates. It's also got some untested code
  - * that should handle inclusion of text includes, but that method isn't 
called
  - * by the SAX event FSM yet.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Donald Ball</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:42:01 $ $Author: 
giacomo $
  - */
  -public class XIncludeTransformer extends AbstractTransformer implements 
Composer {
  -
  -     protected boolean debug = true;
  -
  -     protected ComponentManager manager = null;
  -
  -     public static final String XMLBASE_NAMESPACE_URI = 
"http://www.w3.org/XML/1998/namespace";;
  -     public static final String XMLBASE_ATTRIBUTE = "base";
  -
  -     public static final String XINCLUDE_NAMESPACE_URI = 
"http://www.w3.org/1999/XML/xinclude";;
  -     public static final String XINCLUDE_INCLUDE_ELEMENT = "include";
  -     public static final String XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE = 
"href";
  -     public static final String XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE = 
"parse";
  -
  -     protected URL base_xmlbase_uri = null;
  -     
  -     /** The current XMLBase URI. We start with an empty "dummy" URL. **/
  -     protected URL current_xmlbase_uri = null;
  -
  -     /** This is a stack of xml:base attributes which belong to our 
ancestors **/
  -     protected Stack xmlbase_stack = new Stack();
  -
  -     /** namespace uri of the last element which had an xml:base attribute 
**/
  -     protected String last_xmlbase_element_uri = "";
  -
  -     protected Stack xmlbase_element_uri_stack = new Stack();
  -
  -     /** name of the last element which had an xml:base attribute **/
  -     protected String last_xmlbase_element_name = "";
  -
  -     protected Stack xmlbase_element_name_stack = new Stack();
  -
  -    public void setup(Environment environment, 
  -                      String source, Parameters parameters) 
  -            throws ProcessingException, SAXException, IOException {}
  -     /*
  -             try {
  -                     System.err.println("SOURCE: "+source);
  -                     base_xmlbase_uri = new URL(source);
  -                     System.err.println("SOURCE URI: 
"+base_xmlbase_uri.toString());
  -             } catch (MalformedURLException e) {
  -                     throw new ProcessingException(e.getMessage());
  -             }
  -     }
  -     */
  -
  -     public void setComponentManager(ComponentManager manager) {
  -             this.manager = manager;
  -     }
  -
  -     public void startElement(String uri, String name, String raw, 
Attributes attr) throws SAXException {
  -             String value;
  -             if ((value = 
attr.getValue(XMLBASE_NAMESPACE_URI,XMLBASE_ATTRIBUTE)) != null) {
  -                     try {
  -                             startXMLBaseAttribute(uri,name,value);
  -                     } catch (MalformedURLException e) {
  -                             throw new SAXException(e);
  -                     }
  -             }
  -             if (uri.equals(XINCLUDE_NAMESPACE_URI) && 
name.equals(XINCLUDE_INCLUDE_ELEMENT)) {
  -                     String href = 
attr.getValue("",XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE);
  -                     String parse = 
attr.getValue("",XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE);
  -                     try {
  -                             processXIncludeElement(href, parse);
  -                     } catch (MalformedURLException e) {
  -                             throw new SAXException(e);
  -                     } catch (IOException e) {
  -                             throw new SAXException(e);
  -                     }
  -                     return;
  -             }
  -             if (super.contentHandler!= null) {
  -                     super.contentHandler.startElement(uri,name,raw,attr);
  -             }
  -     }
  -
  -     public void endElement(String uri, String name, String raw) throws 
SAXException {
  -             if (last_xmlbase_element_uri.equals(uri) && 
last_xmlbase_element_name.equals(name)) {
  -                     endXMLBaseAttribute();
  -             }
  -             if (uri.equals(XINCLUDE_NAMESPACE_URI) && 
name.equals(XINCLUDE_INCLUDE_ELEMENT)) {
  -                     return;
  -             }
  -             if (super.contentHandler!= null) {
  -                     super.contentHandler.endElement(uri,name,raw);
  -             }
  -     }
  -
  -    public void setDocumentLocator(Locator locator) {
  -             try {
  -                     base_xmlbase_uri = new URL(locator.getSystemId());
  -                     if (current_xmlbase_uri == null) {
  -                             current_xmlbase_uri = base_xmlbase_uri;
  -                     }
  -             } catch (MalformedURLException e) {}
  -        if (super.contentHandler!=null) {
  -            super.contentHandler.setDocumentLocator(locator);
  -             }
  -    }
  -
  -     protected void startXMLBaseAttribute(String uri, String name, String 
value) throws MalformedURLException {
  -             if (current_xmlbase_uri != null) {
  -                     xmlbase_stack.push(current_xmlbase_uri);
  -             }
  -             current_xmlbase_uri = new URL(value);
  -
  -             xmlbase_element_uri_stack.push(last_xmlbase_element_uri);
  -             last_xmlbase_element_uri = uri;
  -
  -             xmlbase_element_name_stack.push(last_xmlbase_element_name);
  -             last_xmlbase_element_name = name;
  -     }
  -
  -     protected void endXMLBaseAttribute() {
  -             if (xmlbase_stack.size() > 0) {
  -                     current_xmlbase_uri = (URL)xmlbase_stack.pop();
  -             } else {
  -                     current_xmlbase_uri = base_xmlbase_uri;
  -             }
  -             last_xmlbase_element_uri = 
(String)xmlbase_element_uri_stack.pop();
  -             last_xmlbase_element_name = 
(String)xmlbase_element_name_stack.pop();
  -     }
  -
  -     protected void processXIncludeElement(String href, String parse) throws 
SAXException,MalformedURLException,IOException {
  -             if (debug) { System.err.println("Processing XInclude element: 
href="+href+", parse="+parse); }
  -             URL url;
  -             String suffix;
  -             int index = href.indexOf('#');
  -             if (index < 0) {
  -                     url = new URL(current_xmlbase_uri,href);
  -                     suffix = "";
  -             } else {
  -                     url = new 
URL(current_xmlbase_uri,href.substring(0,index));
  -                     suffix = href.substring(index+1);
  -             }
  -             if (debug) { System.err.println("URL: "+url+"\nSuffix: 
"+suffix); }
  -             Object object = url.getContent();
  -             if (debug) { System.err.println("Object: "+object); }
  -             if (parse.equals("text")) {
  -                     if (debug) { System.err.println("Parse type is text"); }
  -                     if (object instanceof Reader) {
  -                             Reader reader = (Reader)object;
  -                             int read;
  -                             char ary[] = new char[1024];
  -                             if (reader != null) {
  -                                     while ((read = reader.read(ary)) != -1) 
{
  -                                             if (super.contentHandler != 
null) {
  -                                                     
super.contentHandler.characters(ary,0,read);
  -                                             }
  -                                     }
  -                                     reader.close();
  -                             }
  -                     } else if (object instanceof InputStream) {
  -                             InputStream input = (InputStream)object;
  -                             InputStreamReader reader = new 
InputStreamReader(input);
  -                             int read;
  -                             char ary[] = new char[1024];
  -                             if (reader != null) {
  -                                     while ((read = reader.read(ary)) != -1) 
{
  -                                             if (super.contentHandler != 
null) {
  -                                                     
super.contentHandler.characters(ary,0,read);
  -                                             }
  -                                     }
  -                                     reader.close();
  -                             }
  -                     }
  -             } else if (parse.equals("xml")) {
  -                     if (debug) { System.err.println("Parse type is XML"); }
  -                     Parser parser = (Parser)manager.getComponent("parser");
  -                     InputSource input;
  -                     if (object instanceof Reader) {
  -                             input = new InputSource((Reader)object);
  -                     } else if (object instanceof InputStream) {
  -                             input = new InputSource((InputStream)object);
  -                     } else {
  -                             throw new SAXException("Unknown object type: 
"+object);
  -                     }
  -                     if (suffix.startsWith("xpointer(") && 
suffix.endsWith(")")) {
  -                             String xpath = 
suffix.substring(9,suffix.length()-1);
  -                             if (debug) { System.err.println("XPath is 
"+xpath); }
  -                             DOMBuilder builder = new DOMBuilder(parser);
  -                             parser.setContentHandler(builder);
  -                             parser.setLexicalHandler(builder);
  -                             parser.parse(input);
  -                             Document document = builder.getDocument();
  -                             NodeList list = 
XPathAPI.selectNodeList(document,xpath);
  -                             DOMStreamer streamer = new 
DOMStreamer(super.contentHandler,super.lexicalHandler);
  -                             int length = list.getLength();
  -                             for (int i=0; i<length; i++) {
  -                                     streamer.stream(list.item(i));
  -                             }
  -                     } else {
  -                             XIncludeContentHandler xinclude_handler = new 
XIncludeContentHandler(super.contentHandler,super.lexicalHandler);
  -                             xinclude_handler.debug = debug;
  -                             parser.setContentHandler(xinclude_handler);
  -                             parser.setLexicalHandler(xinclude_handler);
  -                             parser.parse(input);
  -                     }
  -             }
  -     }
  -
  -     class XIncludeContentHandler implements ContentHandler,LexicalHandler {
  -
  -             ContentHandler content_handler;
  -             LexicalHandler lexical_handler;
  -             boolean debug;
  -
  -             XIncludeContentHandler(ContentHandler content_handler, 
LexicalHandler lexical_handler) {
  -                     this.content_handler = content_handler;
  -                     this.lexical_handler = lexical_handler;
  -             }
  -
  -             public void setDocumentLocator(Locator locator) {
  -                     content_handler.setDocumentLocator(locator);
  -             }
  -
  -             public void startDocument() {
  -                     if (debug) { System.err.println("Internal start 
document received"); }
  -                     /** We don't pass start document on to the "real" 
handler **/
  -             }
  -
  -             public void endDocument() {
  -                     if (debug) { System.err.println("Internal end document 
received"); }
  -                     /** We don't pass end document on to the "real" handler 
**/
  -             }
  -
  -             public void startPrefixMapping(String prefix, String uri) 
  -                     throws SAXException {
  -                     content_handler.startPrefixMapping(prefix,uri);
  -             }
  -
  -             public void endPrefixMapping(String prefix) 
  -                     throws SAXException {
  -                     content_handler.endPrefixMapping(prefix);
  -             }
  -
  -             public void startElement(String namespace, String name, String 
raw, 
  -                     Attributes attr) throws SAXException {
  -                     if (debug) { System.err.println("Internal element 
received: "+name); }
  -                     content_handler.startElement(namespace,name,raw,attr);
  -             }
  -
  -             public void endElement(String namespace, String name, String 
raw)
  -                     throws SAXException {
  -                     content_handler.endElement(namespace,name,raw);
  -             }
  -
  -             public void characters(char ary[], int start, int length) 
  -                     throws SAXException {
  -                     content_handler.characters(ary,start,length);
  -             }
  -
  -             public void ignorableWhitespace(char ary[], int start, int 
length)
  -                     throws SAXException {
  -                     content_handler.ignorableWhitespace(ary,start,length);
  -             }
  -
  -             public void processingInstruction(String target, String data)
  -                     throws SAXException {
  -                     content_handler.processingInstruction(target,data);
  -             }
  -
  -             public void skippedEntity(String name)
  -                     throws SAXException {
  -                     content_handler.skippedEntity(name);
  -             }
  -
  -             public void startDTD(String name, String public_id, String 
system_id)
  -                     throws SAXException {
  -                     lexical_handler.startDTD(name,public_id,system_id);
  -             }
  -
  -             public void endDTD() throws SAXException {
  -                     lexical_handler.endDTD();
  -             }
  -
  -             public void startEntity(String name) throws SAXException {
  -                     lexical_handler.startEntity(name);
  -             }
  -
  -             public void endEntity(String name) throws SAXException {
  -                     lexical_handler.endEntity(name);
  -             }
  -
  -             public void startCDATA() throws SAXException {
  -                     lexical_handler.startCDATA();
  -             }
  -
  -             public void endCDATA() throws SAXException {
  -                     lexical_handler.endCDATA();
  -             }
  -
  -             public void comment(char ary[], int start, int length)
  -                     throws SAXException {
  -                     lexical_handler.comment(ary,start,length);
  -             }
  -
  -     }
  -
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.transformation;
  +
  +import java.net.URL;
  +import java.net.MalformedURLException;
  +import java.io.IOException;
  +import java.io.Reader;
  +import java.io.InputStream;
  +import java.io.InputStreamReader;
  +import java.util.Stack;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.ext.LexicalHandler;
  +import org.xml.sax.ContentHandler;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.Document;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.avalon.utils.Parameters;
  +import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.components.parser.Parser;
  +import org.apache.avalon.ComponentManager;
  +import org.apache.avalon.Composer;
  +import org.apache.cocoon.xml.util.DOMBuilder;
  +import org.apache.cocoon.xml.util.DOMStreamer;
  +import org.apache.cocoon.xml.util.XPathAPI;
  +
  +/**
  + * My first pass at an XInclude transformation. Currently it should set the 
base URI 
  + * from the SAX Locator's system id but allow it to be overridden by xml:base
  + * elements as the XInclude spec mandates. It's also got some untested code
  + * that should handle inclusion of text includes, but that method isn't 
called
  + * by the SAX event FSM yet.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Donald Ball</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:40 $ $Author: 
rubys $
  + */
  +public class XIncludeTransformer extends AbstractTransformer implements 
Composer {
  +
  +     protected boolean debug = true;
  +
  +     protected ComponentManager manager = null;
  +
  +     public static final String XMLBASE_NAMESPACE_URI = 
"http://www.w3.org/XML/1998/namespace";;
  +     public static final String XMLBASE_ATTRIBUTE = "base";
  +
  +     public static final String XINCLUDE_NAMESPACE_URI = 
"http://www.w3.org/1999/XML/xinclude";;
  +     public static final String XINCLUDE_INCLUDE_ELEMENT = "include";
  +     public static final String XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE = 
"href";
  +     public static final String XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE = 
"parse";
  +
  +     protected URL base_xmlbase_uri = null;
  +     
  +     /** The current XMLBase URI. We start with an empty "dummy" URL. **/
  +     protected URL current_xmlbase_uri = null;
  +
  +     /** This is a stack of xml:base attributes which belong to our 
ancestors **/
  +     protected Stack xmlbase_stack = new Stack();
  +
  +     /** namespace uri of the last element which had an xml:base attribute 
**/
  +     protected String last_xmlbase_element_uri = "";
  +
  +     protected Stack xmlbase_element_uri_stack = new Stack();
  +
  +     /** name of the last element which had an xml:base attribute **/
  +     protected String last_xmlbase_element_name = "";
  +
  +     protected Stack xmlbase_element_name_stack = new Stack();
  +
  +    public void setup(Environment environment, 
  +                      String source, Parameters parameters) 
  +            throws ProcessingException, SAXException, IOException {}
  +     /*
  +             try {
  +                     System.err.println("SOURCE: "+source);
  +                     base_xmlbase_uri = new URL(source);
  +                     System.err.println("SOURCE URI: 
"+base_xmlbase_uri.toString());
  +             } catch (MalformedURLException e) {
  +                     throw new ProcessingException(e.getMessage());
  +             }
  +     }
  +     */
  +
  +     public void setComponentManager(ComponentManager manager) {
  +             this.manager = manager;
  +     }
  +
  +     public void startElement(String uri, String name, String raw, 
Attributes attr) throws SAXException {
  +             String value;
  +             if ((value = 
attr.getValue(XMLBASE_NAMESPACE_URI,XMLBASE_ATTRIBUTE)) != null) {
  +                     try {
  +                             startXMLBaseAttribute(uri,name,value);
  +                     } catch (MalformedURLException e) {
  +                             throw new SAXException(e);
  +                     }
  +             }
  +             if (uri.equals(XINCLUDE_NAMESPACE_URI) && 
name.equals(XINCLUDE_INCLUDE_ELEMENT)) {
  +                     String href = 
attr.getValue("",XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE);
  +                     String parse = 
attr.getValue("",XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE);
  +                     try {
  +                             processXIncludeElement(href, parse);
  +                     } catch (MalformedURLException e) {
  +                             throw new SAXException(e);
  +                     } catch (IOException e) {
  +                             throw new SAXException(e);
  +                     }
  +                     return;
  +             }
  +             if (super.contentHandler!= null) {
  +                     super.contentHandler.startElement(uri,name,raw,attr);
  +             }
  +     }
  +
  +     public void endElement(String uri, String name, String raw) throws 
SAXException {
  +             if (last_xmlbase_element_uri.equals(uri) && 
last_xmlbase_element_name.equals(name)) {
  +                     endXMLBaseAttribute();
  +             }
  +             if (uri.equals(XINCLUDE_NAMESPACE_URI) && 
name.equals(XINCLUDE_INCLUDE_ELEMENT)) {
  +                     return;
  +             }
  +             if (super.contentHandler!= null) {
  +                     super.contentHandler.endElement(uri,name,raw);
  +             }
  +     }
  +
  +    public void setDocumentLocator(Locator locator) {
  +             try {
  +                     base_xmlbase_uri = new URL(locator.getSystemId());
  +                     if (current_xmlbase_uri == null) {
  +                             current_xmlbase_uri = base_xmlbase_uri;
  +                     }
  +             } catch (MalformedURLException e) {}
  +        if (super.contentHandler!=null) {
  +            super.contentHandler.setDocumentLocator(locator);
  +             }
  +    }
  +
  +     protected void startXMLBaseAttribute(String uri, String name, String 
value) throws MalformedURLException {
  +             if (current_xmlbase_uri != null) {
  +                     xmlbase_stack.push(current_xmlbase_uri);
  +             }
  +             current_xmlbase_uri = new URL(value);
  +
  +             xmlbase_element_uri_stack.push(last_xmlbase_element_uri);
  +             last_xmlbase_element_uri = uri;
  +
  +             xmlbase_element_name_stack.push(last_xmlbase_element_name);
  +             last_xmlbase_element_name = name;
  +     }
  +
  +     protected void endXMLBaseAttribute() {
  +             if (xmlbase_stack.size() > 0) {
  +                     current_xmlbase_uri = (URL)xmlbase_stack.pop();
  +             } else {
  +                     current_xmlbase_uri = base_xmlbase_uri;
  +             }
  +             last_xmlbase_element_uri = 
(String)xmlbase_element_uri_stack.pop();
  +             last_xmlbase_element_name = 
(String)xmlbase_element_name_stack.pop();
  +     }
  +
  +     protected void processXIncludeElement(String href, String parse) throws 
SAXException,MalformedURLException,IOException {
  +             if (debug) { System.err.println("Processing XInclude element: 
href="+href+", parse="+parse); }
  +             URL url;
  +             String suffix;
  +             int index = href.indexOf('#');
  +             if (index < 0) {
  +                     url = new URL(current_xmlbase_uri,href);
  +                     suffix = "";
  +             } else {
  +                     url = new 
URL(current_xmlbase_uri,href.substring(0,index));
  +                     suffix = href.substring(index+1);
  +             }
  +             if (debug) { System.err.println("URL: "+url+"\nSuffix: 
"+suffix); }
  +             Object object = url.getContent();
  +             if (debug) { System.err.println("Object: "+object); }
  +             if (parse.equals("text")) {
  +                     if (debug) { System.err.println("Parse type is text"); }
  +                     if (object instanceof Reader) {
  +                             Reader reader = (Reader)object;
  +                             int read;
  +                             char ary[] = new char[1024];
  +                             if (reader != null) {
  +                                     while ((read = reader.read(ary)) != -1) 
{
  +                                             if (super.contentHandler != 
null) {
  +                                                     
super.contentHandler.characters(ary,0,read);
  +                                             }
  +                                     }
  +                                     reader.close();
  +                             }
  +                     } else if (object instanceof InputStream) {
  +                             InputStream input = (InputStream)object;
  +                             InputStreamReader reader = new 
InputStreamReader(input);
  +                             int read;
  +                             char ary[] = new char[1024];
  +                             if (reader != null) {
  +                                     while ((read = reader.read(ary)) != -1) 
{
  +                                             if (super.contentHandler != 
null) {
  +                                                     
super.contentHandler.characters(ary,0,read);
  +                                             }
  +                                     }
  +                                     reader.close();
  +                             }
  +                     }
  +             } else if (parse.equals("xml")) {
  +                     if (debug) { System.err.println("Parse type is XML"); }
  +                     Parser parser = (Parser)manager.getComponent("parser");
  +                     InputSource input;
  +                     if (object instanceof Reader) {
  +                             input = new InputSource((Reader)object);
  +                     } else if (object instanceof InputStream) {
  +                             input = new InputSource((InputStream)object);
  +                     } else {
  +                             throw new SAXException("Unknown object type: 
"+object);
  +                     }
  +                     if (suffix.startsWith("xpointer(") && 
suffix.endsWith(")")) {
  +                             String xpath = 
suffix.substring(9,suffix.length()-1);
  +                             if (debug) { System.err.println("XPath is 
"+xpath); }
  +                             DOMBuilder builder = new DOMBuilder(parser);
  +                             parser.setContentHandler(builder);
  +                             parser.setLexicalHandler(builder);
  +                             parser.parse(input);
  +                             Document document = builder.getDocument();
  +                             NodeList list = 
XPathAPI.selectNodeList(document,xpath);
  +                             DOMStreamer streamer = new 
DOMStreamer(super.contentHandler,super.lexicalHandler);
  +                             int length = list.getLength();
  +                             for (int i=0; i<length; i++) {
  +                                     streamer.stream(list.item(i));
  +                             }
  +                     } else {
  +                             XIncludeContentHandler xinclude_handler = new 
XIncludeContentHandler(super.contentHandler,super.lexicalHandler);
  +                             xinclude_handler.debug = debug;
  +                             parser.setContentHandler(xinclude_handler);
  +                             parser.setLexicalHandler(xinclude_handler);
  +                             parser.parse(input);
  +                     }
  +             }
  +     }
  +
  +     class XIncludeContentHandler implements ContentHandler,LexicalHandler {
  +
  +             ContentHandler content_handler;
  +             LexicalHandler lexical_handler;
  +             boolean debug;
  +
  +             XIncludeContentHandler(ContentHandler content_handler, 
LexicalHandler lexical_handler) {
  +                     this.content_handler = content_handler;
  +                     this.lexical_handler = lexical_handler;
  +             }
  +
  +             public void setDocumentLocator(Locator locator) {
  +                     content_handler.setDocumentLocator(locator);
  +             }
  +
  +             public void startDocument() {
  +                     if (debug) { System.err.println("Internal start 
document received"); }
  +                     /** We don't pass start document on to the "real" 
handler **/
  +             }
  +
  +             public void endDocument() {
  +                     if (debug) { System.err.println("Internal end document 
received"); }
  +                     /** We don't pass end document on to the "real" handler 
**/
  +             }
  +
  +             public void startPrefixMapping(String prefix, String uri) 
  +                     throws SAXException {
  +                     content_handler.startPrefixMapping(prefix,uri);
  +             }
  +
  +             public void endPrefixMapping(String prefix) 
  +                     throws SAXException {
  +                     content_handler.endPrefixMapping(prefix);
  +             }
  +
  +             public void startElement(String namespace, String name, String 
raw, 
  +                     Attributes attr) throws SAXException {
  +                     if (debug) { System.err.println("Internal element 
received: "+name); }
  +                     content_handler.startElement(namespace,name,raw,attr);
  +             }
  +
  +             public void endElement(String namespace, String name, String 
raw)
  +                     throws SAXException {
  +                     content_handler.endElement(namespace,name,raw);
  +             }
  +
  +             public void characters(char ary[], int start, int length) 
  +                     throws SAXException {
  +                     content_handler.characters(ary,start,length);
  +             }
  +
  +             public void ignorableWhitespace(char ary[], int start, int 
length)
  +                     throws SAXException {
  +                     content_handler.ignorableWhitespace(ary,start,length);
  +             }
  +
  +             public void processingInstruction(String target, String data)
  +                     throws SAXException {
  +                     content_handler.processingInstruction(target,data);
  +             }
  +
  +             public void skippedEntity(String name)
  +                     throws SAXException {
  +                     content_handler.skippedEntity(name);
  +             }
  +
  +             public void startDTD(String name, String public_id, String 
system_id)
  +                     throws SAXException {
  +                     lexical_handler.startDTD(name,public_id,system_id);
  +             }
  +
  +             public void endDTD() throws SAXException {
  +                     lexical_handler.endDTD();
  +             }
  +
  +             public void startEntity(String name) throws SAXException {
  +                     lexical_handler.startEntity(name);
  +             }
  +
  +             public void endEntity(String name) throws SAXException {
  +                     lexical_handler.endEntity(name);
  +             }
  +
  +             public void startCDATA() throws SAXException {
  +                     lexical_handler.startCDATA();
  +             }
  +
  +             public void endCDATA() throws SAXException {
  +                     lexical_handler.endCDATA();
  +             }
  +
  +             public void comment(char ary[], int start, int length)
  +                     throws SAXException {
  +                     lexical_handler.comment(ary,start,length);
  +             }
  +
  +     }
  +
  +}
  
  
  
  1.1.2.5   +149 -149  
xml-cocoon/src/org/apache/cocoon/transformation/Attic/XalanTransformer.java
  
  Index: XalanTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/XalanTransformer.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- XalanTransformer.java     2000/07/28 16:20:49     1.1.2.4
  +++ XalanTransformer.java     2000/07/29 18:30:40     1.1.2.5
  @@ -1,152 +1,152 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.transformation;
  -
  -import java.io.IOException;
  -import java.util.Enumeration;
  -import java.text.StringCharacterIterator;
  -
  -import org.apache.avalon.Component;
  -import org.apache.avalon.ComponentManager;
  -import org.apache.avalon.Composer;
  -import org.apache.avalon.utils.Parameters;
  -
  -import org.apache.cocoon.Cocoon;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.environment.http.HttpEnvironment;
  -import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.components.parser.Parser;
  -import org.apache.cocoon.xml.XMLConsumer;
  -import org.apache.cocoon.xml.util.DocumentHandlerAdapter;
  -import org.apache.cocoon.xml.util.DocumentHandlerWrapper;
  -
  -import org.apache.xalan.xslt.StylesheetRoot;
  -import org.apache.xalan.xslt.XSLTInputSource;
  -import org.apache.xalan.xslt.XSLTProcessor;
  -import org.apache.xalan.xslt.XSLTProcessorFactory;
  -
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.ext.LexicalHandler;
  -
  -/**
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/28 16:20:49 $
  - */
  -public class XalanTransformer extends DocumentHandlerWrapper
  -implements Transformer, Composer {
  -    
  -    /** The component manager instance */
  -    private ComponentManager manager=null;
  -    /** The XALAN XSLTProcessor */
  -    private XSLTProcessor processor=null;
  -
  -    /**
  -     * Set the <code>Environment</code> and sitemap
  -     * <code>Parameters</code> used to process the request.
  -     */
  -    public void setup(Environment environment, String src, Parameters par)
  -    throws SAXException, ProcessingException, IOException {
  -
  -
  -        // Check the stylesheet uri
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.transformation;
  +
  +import java.io.IOException;
  +import java.util.Enumeration;
  +import java.text.StringCharacterIterator;
  +
  +import org.apache.avalon.Component;
  +import org.apache.avalon.ComponentManager;
  +import org.apache.avalon.Composer;
  +import org.apache.avalon.utils.Parameters;
  +
  +import org.apache.cocoon.Cocoon;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.xml.XMLConsumer;
  +import org.apache.cocoon.xml.util.DocumentHandlerAdapter;
  +import org.apache.cocoon.xml.util.DocumentHandlerWrapper;
  +
  +import org.apache.xalan.xslt.StylesheetRoot;
  +import org.apache.xalan.xslt.XSLTInputSource;
  +import org.apache.xalan.xslt.XSLTProcessor;
  +import org.apache.xalan.xslt.XSLTProcessorFactory;
  +
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.ext.LexicalHandler;
  +
  +/**
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/29 18:30:40 $
  + */
  +public class XalanTransformer extends DocumentHandlerWrapper
  +implements Transformer, Composer {
  +    
  +    /** The component manager instance */
  +    private ComponentManager manager=null;
  +    /** The XALAN XSLTProcessor */
  +    private XSLTProcessor processor=null;
  +
  +    /**
  +     * Set the <code>Environment</code> and sitemap
  +     * <code>Parameters</code> used to process the request.
  +     */
  +    public void setup(Environment environment, String src, Parameters par)
  +    throws SAXException, ProcessingException, IOException {
  +
  +
  +        // Check the stylesheet uri
           // String xsluri=par.getParameter("stylesheet",null); 
           String xsluri=src; 
  -        if (xsluri==null) throw new ProcessingException("No stylesheet");
  -
  -        // Load the stylesheet (we should cache it in the STORE!)
  -        //Cocoon cocoon=(Cocoon)this.manager.getComponent("cocoon");
  -        StylesheetRoot stylesheet=null;
  -        if (true) {
  -            XSLTProcessor 
loaderprocessor=XSLTProcessorFactory.getProcessor();
  +        if (xsluri==null) throw new ProcessingException("No stylesheet");
  +
  +        // Load the stylesheet (we should cache it in the STORE!)
  +        //Cocoon cocoon=(Cocoon)this.manager.getComponent("cocoon");
  +        StylesheetRoot stylesheet=null;
  +        if (true) {
  +            XSLTProcessor 
loaderprocessor=XSLTProcessorFactory.getProcessor();
               InputSource xslsrc=environment.resolveEntity(null,xsluri);
  -            XSLTInputSource style=new XSLTInputSource(xslsrc);
  -            stylesheet=loaderprocessor.processStylesheet(style);
  -        }
  -
  -        // Create the processor and set it as this documenthandler
  -        this.processor=XSLTProcessorFactory.getProcessor();
  -        this.processor.setStylesheet(stylesheet);
  -             Enumeration enum = 
((HttpEnvironment)environment).getRequest().getParameterNames();
  -             while (enum.hasMoreElements()) {
  -                     String name = (String)enum.nextElement();
  -                     if (isValidXSLTParameterName(name)) {
  -                             String value = 
((HttpEnvironment)environment).getRequest().getParameter(name);
  -                             
processor.setStylesheetParam(name,this.processor.createXString(value));
  -                     }
  -             }
  -        this.setDocumentHandler(this.processor);
  -
  -    }
  -
  -    /**
  -     * Set the current <code>ComponentManager</code> instance used by this
  -     * <code>Composer</code>.
  -     */
  -    public void setComponentManager(ComponentManager manager) {
  -        this.manager=manager;
  -    }
  -
  -    /**
  -     * Set the <code>XMLConsumer</code> that will receive XML data.
  -     * <br>
  -     * This method will simply call <code>setContentHandler(consumer)</code>
  -     * and <code>setLexicalHandler(consumer)</code>.
  -     */
  -    public void setConsumer(XMLConsumer consumer) {
  -        this.setContentHandler(consumer);
  -    }
  -
  -    /**
  -     * Set the <code>ContentHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>ContentHandler</code> instance
  -     * accessing the protected <code>super.contentHandler</code> field.
  -     */
  -    public void setContentHandler(ContentHandler content) {
  -        this.processor.setDocumentHandler(new 
DocumentHandlerAdapter(content));
  -    }
  -
  -    /**
  -     * Set the <code>LexicalHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  -     * accessing the protected <code>super.lexicalHandler</code> field.
  -     *
  -     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  -     *                                  the <code>XMLConsumer</code> were
  -     *                                  already set.
  -     */
  -    public void setLexicalHandler(LexicalHandler lexical) {
  -    }
  -
  -     public static boolean isValidXSLTParameterName(String name) {
  -             StringCharacterIterator iter = new 
StringCharacterIterator(name);
  -             char c = iter.first();
  -             if (!(Character.isLetter(c) || c == '_')) {
  -                     return false;
  -             } else {
  -                     c = iter.next();
  -             }
  -             while (c != iter.DONE) {
  -                     if (!(Character.isLetterOrDigit(c) ||
  -                             c == '-' ||
  -                             c == '_' ||
  -                             c == '.')) {
  -                             return false;
  -                     } else {
  -                             c = iter.next();
  -                     }
  -             }
  -             return true;
  -     }
  -
  -}
  +            XSLTInputSource style=new XSLTInputSource(xslsrc);
  +            stylesheet=loaderprocessor.processStylesheet(style);
  +        }
  +
  +        // Create the processor and set it as this documenthandler
  +        this.processor=XSLTProcessorFactory.getProcessor();
  +        this.processor.setStylesheet(stylesheet);
  +             Enumeration enum = 
((HttpEnvironment)environment).getRequest().getParameterNames();
  +             while (enum.hasMoreElements()) {
  +                     String name = (String)enum.nextElement();
  +                     if (isValidXSLTParameterName(name)) {
  +                             String value = 
((HttpEnvironment)environment).getRequest().getParameter(name);
  +                             
processor.setStylesheetParam(name,this.processor.createXString(value));
  +                     }
  +             }
  +        this.setDocumentHandler(this.processor);
  +
  +    }
  +
  +    /**
  +     * Set the current <code>ComponentManager</code> instance used by this
  +     * <code>Composer</code>.
  +     */
  +    public void setComponentManager(ComponentManager manager) {
  +        this.manager=manager;
  +    }
  +
  +    /**
  +     * Set the <code>XMLConsumer</code> that will receive XML data.
  +     * <br>
  +     * This method will simply call <code>setContentHandler(consumer)</code>
  +     * and <code>setLexicalHandler(consumer)</code>.
  +     */
  +    public void setConsumer(XMLConsumer consumer) {
  +        this.setContentHandler(consumer);
  +    }
  +
  +    /**
  +     * Set the <code>ContentHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>ContentHandler</code> instance
  +     * accessing the protected <code>super.contentHandler</code> field.
  +     */
  +    public void setContentHandler(ContentHandler content) {
  +        this.processor.setDocumentHandler(new 
DocumentHandlerAdapter(content));
  +    }
  +
  +    /**
  +     * Set the <code>LexicalHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  +     * accessing the protected <code>super.lexicalHandler</code> field.
  +     *
  +     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  +     *                                  the <code>XMLConsumer</code> were
  +     *                                  already set.
  +     */
  +    public void setLexicalHandler(LexicalHandler lexical) {
  +    }
  +
  +     public static boolean isValidXSLTParameterName(String name) {
  +             StringCharacterIterator iter = new 
StringCharacterIterator(name);
  +             char c = iter.first();
  +             if (!(Character.isLetter(c) || c == '_')) {
  +                     return false;
  +             } else {
  +                     c = iter.next();
  +             }
  +             while (c != iter.DONE) {
  +                     if (!(Character.isLetterOrDigit(c) ||
  +                             c == '-' ||
  +                             c == '_' ||
  +                             c == '.')) {
  +                             return false;
  +                     } else {
  +                             c = iter.next();
  +                     }
  +             }
  +             return true;
  +     }
  +
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +84 -84    
xml-cocoon/src/org/apache/cocoon/util/Attic/ClassUtils.java
  
  Index: ClassUtils.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/util/Attic/ClassUtils.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ClassUtils.java   2000/07/22 20:42:02     1.1.2.2
  +++ ClassUtils.java   2000/07/29 18:30:42     1.1.2.3
  @@ -1,84 +1,84 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.util;
  -
  -import java.io.File;
  -import java.net.URL;
  -
  -import java.io.IOException;
  -
  -/**
  - * A collection of class management utility methods.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:42:02 $
  - */
  -public class ClassUtils {
  -  /**
  -   * Create a new instance given a class name
  -   *
  -   * @param className A class name
  -   * @return A new instance
  -   * @exception Exception If an instantiation error occurs
  -   */
  -  public static Object newInstance(String className) throws Exception {
  -    return getClass(className).newInstance();
  -  }
  -
  -  /**
  -   * Load a class given its name
  -   *
  -   * @param className A class name
  -   * @return The class pointed to by <code>className</code>
  -   * @exception Exception If a loading error occurs
  -   */
  -  public static Class getClass(String className) throws Exception {
  -    return ClassUtils.class.getClassLoader().loadClass(className);
  -  }
  -
  -  /**
  -   * Determine the last modification date for this
  -   * class file or its enclosing library
  -   *
  -   * @param aClass A class whose last modification date is queried
  -   * @return The time the given class was last modified
  -   * @exception IOException IOError
  -   * @exception IllegalArgumentException The class was not loaded from a file
  -   * or directory
  -   */
  -  public static long lastModified(Class aClass)
  -    throws IOException, IllegalArgumentException
  -  {
  -    URL url =
  -      aClass.
  -      getProtectionDomain().
  -      getCodeSource().
  -      getLocation();
  -
  -    if (!url.getProtocol().equals("file")) {
  -      throw new IllegalArgumentException("Class was not loaded from a file 
url");
  -    }
  -
  -    File directory = new File(url.getFile());
  -    if (!directory.isDirectory()) {
  -      throw new IllegalArgumentException("Class was not loaded from a 
directory");
  -    }
  -
  -    String className = aClass.getName();
  -    String basename = className.substring(className.lastIndexOf(".") + 1);
  -
  -    File file = new File(
  -      directory.getCanonicalPath() +
  -      File.separator +
  -      basename +
  -      ".class"
  -    );
  -
  -    return file.lastModified();
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.util;
  +
  +import java.io.File;
  +import java.net.URL;
  +
  +import java.io.IOException;
  +
  +/**
  + * A collection of class management utility methods.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:42 $
  + */
  +public class ClassUtils {
  +  /**
  +   * Create a new instance given a class name
  +   *
  +   * @param className A class name
  +   * @return A new instance
  +   * @exception Exception If an instantiation error occurs
  +   */
  +  public static Object newInstance(String className) throws Exception {
  +    return getClass(className).newInstance();
  +  }
  +
  +  /**
  +   * Load a class given its name
  +   *
  +   * @param className A class name
  +   * @return The class pointed to by <code>className</code>
  +   * @exception Exception If a loading error occurs
  +   */
  +  public static Class getClass(String className) throws Exception {
  +    return ClassUtils.class.getClassLoader().loadClass(className);
  +  }
  +
  +  /**
  +   * Determine the last modification date for this
  +   * class file or its enclosing library
  +   *
  +   * @param aClass A class whose last modification date is queried
  +   * @return The time the given class was last modified
  +   * @exception IOException IOError
  +   * @exception IllegalArgumentException The class was not loaded from a file
  +   * or directory
  +   */
  +  public static long lastModified(Class aClass)
  +    throws IOException, IllegalArgumentException
  +  {
  +    URL url =
  +      aClass.
  +      getProtectionDomain().
  +      getCodeSource().
  +      getLocation();
  +
  +    if (!url.getProtocol().equals("file")) {
  +      throw new IllegalArgumentException("Class was not loaded from a file 
url");
  +    }
  +
  +    File directory = new File(url.getFile());
  +    if (!directory.isDirectory()) {
  +      throw new IllegalArgumentException("Class was not loaded from a 
directory");
  +    }
  +
  +    String className = aClass.getName();
  +    String basename = className.substring(className.lastIndexOf(".") + 1);
  +
  +    File file = new File(
  +      directory.getCanonicalPath() +
  +      File.separator +
  +      basename +
  +      ".class"
  +    );
  +
  +    return file.lastModified();
  +  }
  +}
  
  
  
  1.1.2.3   +304 -304  xml-cocoon/src/org/apache/cocoon/util/Attic/DOMUtils.java
  
  Index: DOMUtils.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/util/Attic/DOMUtils.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DOMUtils.java     2000/07/22 20:42:02     1.1.2.2
  +++ DOMUtils.java     2000/07/29 18:30:42     1.1.2.3
  @@ -1,304 +1,304 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.util;
  -
  -import java.util.Vector;
  -import java.util.Hashtable;
  -
  -import org.w3c.dom.Node;
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.ProcessingInstruction;
  -
  -import org.xml.sax.InputSource;
  -
  -import java.io.IOException;
  -import org.xml.sax.SAXException;
  -import java.net.MalformedURLException;
  -import java.util.NoSuchElementException;
  -
  -/* Start Xalan/Xerces kludge */
  -import org.w3c.dom.*;
  -import org.apache.xerces.dom.DocumentImpl;
  -import org.apache.xerces.parsers.DOMParser;
  -import org.apache.xalan.xslt.XSLTProcessor;
  -import org.apache.xalan.xslt.XSLTInputSource;
  -import org.apache.xalan.xslt.XSLTResultTarget;
  -import org.apache.xalan.xslt.XSLTProcessorFactory;
  -import org.apache.xalan.xpath.xml.XMLParserLiaisonDefault;
  -/* End Xalan/Xerces kludge */
  -
  -/**
  - * Collection of utility methods for DOM manipulation.
  - * This class contains ugly dependencies on Xerces and Xalan
  - * classes. These should be removed as the Cocoon2 core interfaces
  - * add (needed!) DOM support.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:42:02 $
  - */
  -public class DOMUtils {
  -  // *** Start Xalan/Xerces kludge ***
  -
  -  /**
  -   * Static stylesheet processor with an augmented default liaison capable
  -   * of creating empty documents
  -   */
  -  private static XSLTProcessor xsltProcessor =
  -      XSLTProcessorFactory.getProcessor(
  -        new XMLParserLiaisonDefault() {
  -          public Document createDocument() {
  -            return new DocumentImpl();
  -          }
  -     }
  -      );
  -
  -  /**
  -   * Parse an input source returning a DOM. <code>Document</code>
  -   *
  -   * @param inputSource The input source
  -   * @return A DOM <code>Document</code>
  -   * @exception IOException IO Error
  -   * @exception SAXException Parse Error
  -   */
  -  public static Document DOMParse(InputSource inputSource)
  -    throws IOException, SAXException
  -  {
  -    DOMParser parser = new DOMParser();
  -    parser.parse(inputSource);
  -
  -    return parser.getDocument();
  -  }
  -
  -  /**
  -   * Apply a stylesheet to a given document
  -   *
  -   * @param input The input document
  -   * @param stylehseet The stylesheet document
  -   * @return The transformed document
  -   * @exception SAXException SAX Error
  -   */
  -  public static Document transformDocument(Document input, Document 
stylesheet)
  -    throws SAXException
  -  {
  -    Document output = new DocumentImpl();
  -
  -    xsltProcessor.process(
  -      new XSLTInputSource(input),
  -      new XSLTInputSource(stylesheet),
  -      new XSLTResultTarget(output)
  -    );
  -
  -    return output;
  -  }
  -
  -  // *** End Xalan/Xerces kludge ***
  -
  -  /**
  -   * This method returns an hashtable of pseudo attributes found in the first
  -   * occurrence of the PI with the given name in the given document.
  -   * No validation is performed on the PI pseudo syntax
  -   *
  -   * @param pi The processing instruction
  -   * @return A hashtable containing key/value pairs in the pi 
pseudo-attributes
  -   */
  -  public static Hashtable getPIPseudoAttributes(ProcessingInstruction pi)
  -  {
  -    Hashtable attributes = new Hashtable();
  -    addPIPseudoAttributes(pi, attributes);
  -    return attributes;
  -  }
  -
  -  /**
  -   * This method adds pseudo attributes from a pi to an existing attribute 
list.
  -   * All attributes are all put in the same hashtable.
  -   * If there are collisions, the last attribute is inserted.
  -   * No validation is performed on the PI pseudo syntax.
  -   *
  -   * @param pi The processing instruction
  -   * @param attributes The receiving hashtable
  -   */
  -  public static void addPIPseudoAttributes(
  -    ProcessingInstruction pi, Hashtable attributes
  -  )
  -  {
  -    String data = pi.getData();
  -
  -    Tokenizer st = new Tokenizer(data, "\" \t\r\n");
  -    try {
  -      while (st.hasMoreTokens()) {
  -        String key   = st.nextToken();   // attribute name and '='
  -        String token = st.nextToken();   // exact attribute value
  -        key = key.replace('=',' ').trim(); // remove whitespace and '='
  -        attributes.put(key, token);  
  -      }
  -    } catch (NoSuchElementException nsee) {
  -      // ignore white-space at the end of pseudo-list
  -    }
  -  }
  -
  -
  -  /**
  -   * Return a list of all namespace-declaring attributes in the element.
  -   * This method returns both prefix-mapped namespaces and the optional
  -   * "unnamed" uri.
  -   *
  -   * @param element An element containing namespace declarations
  -   * @return A (possibly empty) vector containing all namespace declarations
  -   *         as a <code>String</code> array of 2 elements (attribue name, 
uri)
  -   */
  -  public static Vector namespaces(Element element) {
  -   Vector vector = new Vector();
  -   NamedNodeMap map = element.getAttributes();
  -   int attrCount = map.getLength();
  -   for (int i = 0; i < attrCount; i++) {
  -     Attr attr = (Attr) map.item(i);
  -     String attrName = attr.getName();
  -     if (
  -       !attrName.equals("xmlns:xsl") &&
  -          (attrName.equals("xmlns") || attrName.startsWith("xmlns:"))
  -     ) {
  -       String[] pair = new String[2];
  -       pair[0] = attrName;
  -       pair[1] = attr.getValue();
  -       vector.addElement(pair);
  -     }
  -   } 
  -
  -   return vector;
  -  }
  -
  -  /**
  -   * Escape reserved markup characters as their corresponding entity
  -   * representation.
  -   *
  -   * @param string The string to be encoded
  -   * @return A markup-encoded string
  -   */
  -  public static String encodeMarkup(String string) {
  -    char[] array = string.toCharArray();
  -    StringBuffer buffer = new StringBuffer();
  -
  -    for (int i = 0; i < array.length; i++) {
  -      switch (array[i]) {
  -        case '<':
  -          buffer.append("&lt;");
  -          break;
  -        case'>':
  -          buffer.append("&gt;");
  -          break;
  -        case '&':
  -          buffer.append("&amp;");
  -          break;
  -        default:
  -          buffer.append(array[i]);
  -          break;
  -      }
  -    }
  -
  -    return buffer.toString();
  -  }
  -
  -  /**
  -   * Return the string representation of a DOM node
  -   *
  -   * @param node The node to be represented as a <code>String</code>
  -   * @return The string representation of the node
  -   */
  -  public static String toMarkup(Node node) {
  -    StringBuffer buffer = new StringBuffer();
  -    doMarkup(node, buffer);
  -    return buffer.toString();
  -  }
  -
  -  /**
  -   * Actually perform the (recursive) <code>Node</code> to
  -   * <code>String</code> conversion
  -   *
  -   * @param node The <code>Node</code> to be converted
  -   * @param buffer The <code>StringBuffer</code> to append to
  -   */
  -  protected static void doMarkup(Node node, StringBuffer buffer) {
  -    switch (node.getNodeType()) {
  -      case Node.CDATA_SECTION_NODE:
  -        buffer.append("<![CDATA[\n");
  -        buffer.append(node.getNodeValue());
  -        buffer.append("]]>\n");
  -        break;
  -      case Node.DOCUMENT_NODE:
  -      case Node.DOCUMENT_FRAGMENT_NODE: {
  -        NodeList nodeList = node.getChildNodes();
  -        int childCount = nodeList.getLength();
  -
  -        for (int i = 0; i < childCount; i++) {
  -          doMarkup(nodeList.item(i), buffer);
  -        }
  -
  -        break;
  -      }
  -      case Node.ELEMENT_NODE: {
  -        Element element = (Element) node;
  -
  -        buffer.append("<" + element.getTagName());
  -
  -        NamedNodeMap attributes = element.getAttributes();
  -        int attributeCount = attributes.getLength();
  -
  -        for (int i = 0; i < attributeCount; i++) {
  -          Attr attribute = (Attr) attributes.item(i);
  -
  -          buffer.append(" ");
  -          buffer.append(attribute.getName());
  -          buffer.append("=\"");
  -          buffer.append(attribute.getValue());
  -          buffer.append("\"");
  -        }
  -
  -        NodeList nodeList = element.getChildNodes();
  -        int childCount = nodeList.getLength();
  -
  -        if (childCount == 0) {
  -          buffer.append("/>\n");
  -        } else {
  -          buffer.append(">");
  -          for (int i = 0; i < childCount; i++) {
  -            doMarkup(nodeList.item(i), buffer);
  -          }
  -
  -          buffer.append("</");
  -          buffer.append(element.getTagName());
  -          buffer.append(">");
  -        }
  -
  -        break;
  -      }
  -      case Node.COMMENT_NODE:
  -        buffer.append("<!-- ");
  -        buffer.append(node.getNodeValue());
  -        buffer.append(" -->\n");
  -        break;
  -      case Node.PROCESSING_INSTRUCTION_NODE:
  -        ProcessingInstruction pi = (ProcessingInstruction) node;
  -
  -        buffer.append("<?");
  -        buffer.append(pi.getTarget());
  -        buffer.append(" ");
  -        buffer.append(pi.getData());
  -        buffer.append("?>\n");
  -        break;
  -      case Node.TEXT_NODE:
  -        buffer.append(encodeMarkup(node.getNodeValue()));
  -        // buffer.append("\n");
  -        break;
  -      default:
  -        break;
  -    }
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.util;
  +
  +import java.util.Vector;
  +import java.util.Hashtable;
  +
  +import org.w3c.dom.Node;
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.ProcessingInstruction;
  +
  +import org.xml.sax.InputSource;
  +
  +import java.io.IOException;
  +import org.xml.sax.SAXException;
  +import java.net.MalformedURLException;
  +import java.util.NoSuchElementException;
  +
  +/* Start Xalan/Xerces kludge */
  +import org.w3c.dom.*;
  +import org.apache.xerces.dom.DocumentImpl;
  +import org.apache.xerces.parsers.DOMParser;
  +import org.apache.xalan.xslt.XSLTProcessor;
  +import org.apache.xalan.xslt.XSLTInputSource;
  +import org.apache.xalan.xslt.XSLTResultTarget;
  +import org.apache.xalan.xslt.XSLTProcessorFactory;
  +import org.apache.xalan.xpath.xml.XMLParserLiaisonDefault;
  +/* End Xalan/Xerces kludge */
  +
  +/**
  + * Collection of utility methods for DOM manipulation.
  + * This class contains ugly dependencies on Xerces and Xalan
  + * classes. These should be removed as the Cocoon2 core interfaces
  + * add (needed!) DOM support.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:42 $
  + */
  +public class DOMUtils {
  +  // *** Start Xalan/Xerces kludge ***
  +
  +  /**
  +   * Static stylesheet processor with an augmented default liaison capable
  +   * of creating empty documents
  +   */
  +  private static XSLTProcessor xsltProcessor =
  +      XSLTProcessorFactory.getProcessor(
  +        new XMLParserLiaisonDefault() {
  +          public Document createDocument() {
  +            return new DocumentImpl();
  +          }
  +     }
  +      );
  +
  +  /**
  +   * Parse an input source returning a DOM. <code>Document</code>
  +   *
  +   * @param inputSource The input source
  +   * @return A DOM <code>Document</code>
  +   * @exception IOException IO Error
  +   * @exception SAXException Parse Error
  +   */
  +  public static Document DOMParse(InputSource inputSource)
  +    throws IOException, SAXException
  +  {
  +    DOMParser parser = new DOMParser();
  +    parser.parse(inputSource);
  +
  +    return parser.getDocument();
  +  }
  +
  +  /**
  +   * Apply a stylesheet to a given document
  +   *
  +   * @param input The input document
  +   * @param stylehseet The stylesheet document
  +   * @return The transformed document
  +   * @exception SAXException SAX Error
  +   */
  +  public static Document transformDocument(Document input, Document 
stylesheet)
  +    throws SAXException
  +  {
  +    Document output = new DocumentImpl();
  +
  +    xsltProcessor.process(
  +      new XSLTInputSource(input),
  +      new XSLTInputSource(stylesheet),
  +      new XSLTResultTarget(output)
  +    );
  +
  +    return output;
  +  }
  +
  +  // *** End Xalan/Xerces kludge ***
  +
  +  /**
  +   * This method returns an hashtable of pseudo attributes found in the first
  +   * occurrence of the PI with the given name in the given document.
  +   * No validation is performed on the PI pseudo syntax
  +   *
  +   * @param pi The processing instruction
  +   * @return A hashtable containing key/value pairs in the pi 
pseudo-attributes
  +   */
  +  public static Hashtable getPIPseudoAttributes(ProcessingInstruction pi)
  +  {
  +    Hashtable attributes = new Hashtable();
  +    addPIPseudoAttributes(pi, attributes);
  +    return attributes;
  +  }
  +
  +  /**
  +   * This method adds pseudo attributes from a pi to an existing attribute 
list.
  +   * All attributes are all put in the same hashtable.
  +   * If there are collisions, the last attribute is inserted.
  +   * No validation is performed on the PI pseudo syntax.
  +   *
  +   * @param pi The processing instruction
  +   * @param attributes The receiving hashtable
  +   */
  +  public static void addPIPseudoAttributes(
  +    ProcessingInstruction pi, Hashtable attributes
  +  )
  +  {
  +    String data = pi.getData();
  +
  +    Tokenizer st = new Tokenizer(data, "\" \t\r\n");
  +    try {
  +      while (st.hasMoreTokens()) {
  +        String key   = st.nextToken();   // attribute name and '='
  +        String token = st.nextToken();   // exact attribute value
  +        key = key.replace('=',' ').trim(); // remove whitespace and '='
  +        attributes.put(key, token);  
  +      }
  +    } catch (NoSuchElementException nsee) {
  +      // ignore white-space at the end of pseudo-list
  +    }
  +  }
  +
  +
  +  /**
  +   * Return a list of all namespace-declaring attributes in the element.
  +   * This method returns both prefix-mapped namespaces and the optional
  +   * "unnamed" uri.
  +   *
  +   * @param element An element containing namespace declarations
  +   * @return A (possibly empty) vector containing all namespace declarations
  +   *         as a <code>String</code> array of 2 elements (attribue name, 
uri)
  +   */
  +  public static Vector namespaces(Element element) {
  +   Vector vector = new Vector();
  +   NamedNodeMap map = element.getAttributes();
  +   int attrCount = map.getLength();
  +   for (int i = 0; i < attrCount; i++) {
  +     Attr attr = (Attr) map.item(i);
  +     String attrName = attr.getName();
  +     if (
  +       !attrName.equals("xmlns:xsl") &&
  +          (attrName.equals("xmlns") || attrName.startsWith("xmlns:"))
  +     ) {
  +       String[] pair = new String[2];
  +       pair[0] = attrName;
  +       pair[1] = attr.getValue();
  +       vector.addElement(pair);
  +     }
  +   } 
  +
  +   return vector;
  +  }
  +
  +  /**
  +   * Escape reserved markup characters as their corresponding entity
  +   * representation.
  +   *
  +   * @param string The string to be encoded
  +   * @return A markup-encoded string
  +   */
  +  public static String encodeMarkup(String string) {
  +    char[] array = string.toCharArray();
  +    StringBuffer buffer = new StringBuffer();
  +
  +    for (int i = 0; i < array.length; i++) {
  +      switch (array[i]) {
  +        case '<':
  +          buffer.append("&lt;");
  +          break;
  +        case'>':
  +          buffer.append("&gt;");
  +          break;
  +        case '&':
  +          buffer.append("&amp;");
  +          break;
  +        default:
  +          buffer.append(array[i]);
  +          break;
  +      }
  +    }
  +
  +    return buffer.toString();
  +  }
  +
  +  /**
  +   * Return the string representation of a DOM node
  +   *
  +   * @param node The node to be represented as a <code>String</code>
  +   * @return The string representation of the node
  +   */
  +  public static String toMarkup(Node node) {
  +    StringBuffer buffer = new StringBuffer();
  +    doMarkup(node, buffer);
  +    return buffer.toString();
  +  }
  +
  +  /**
  +   * Actually perform the (recursive) <code>Node</code> to
  +   * <code>String</code> conversion
  +   *
  +   * @param node The <code>Node</code> to be converted
  +   * @param buffer The <code>StringBuffer</code> to append to
  +   */
  +  protected static void doMarkup(Node node, StringBuffer buffer) {
  +    switch (node.getNodeType()) {
  +      case Node.CDATA_SECTION_NODE:
  +        buffer.append("<![CDATA[\n");
  +        buffer.append(node.getNodeValue());
  +        buffer.append("]]>\n");
  +        break;
  +      case Node.DOCUMENT_NODE:
  +      case Node.DOCUMENT_FRAGMENT_NODE: {
  +        NodeList nodeList = node.getChildNodes();
  +        int childCount = nodeList.getLength();
  +
  +        for (int i = 0; i < childCount; i++) {
  +          doMarkup(nodeList.item(i), buffer);
  +        }
  +
  +        break;
  +      }
  +      case Node.ELEMENT_NODE: {
  +        Element element = (Element) node;
  +
  +        buffer.append("<" + element.getTagName());
  +
  +        NamedNodeMap attributes = element.getAttributes();
  +        int attributeCount = attributes.getLength();
  +
  +        for (int i = 0; i < attributeCount; i++) {
  +          Attr attribute = (Attr) attributes.item(i);
  +
  +          buffer.append(" ");
  +          buffer.append(attribute.getName());
  +          buffer.append("=\"");
  +          buffer.append(attribute.getValue());
  +          buffer.append("\"");
  +        }
  +
  +        NodeList nodeList = element.getChildNodes();
  +        int childCount = nodeList.getLength();
  +
  +        if (childCount == 0) {
  +          buffer.append("/>\n");
  +        } else {
  +          buffer.append(">");
  +          for (int i = 0; i < childCount; i++) {
  +            doMarkup(nodeList.item(i), buffer);
  +          }
  +
  +          buffer.append("</");
  +          buffer.append(element.getTagName());
  +          buffer.append(">");
  +        }
  +
  +        break;
  +      }
  +      case Node.COMMENT_NODE:
  +        buffer.append("<!-- ");
  +        buffer.append(node.getNodeValue());
  +        buffer.append(" -->\n");
  +        break;
  +      case Node.PROCESSING_INSTRUCTION_NODE:
  +        ProcessingInstruction pi = (ProcessingInstruction) node;
  +
  +        buffer.append("<?");
  +        buffer.append(pi.getTarget());
  +        buffer.append(" ");
  +        buffer.append(pi.getData());
  +        buffer.append("?>\n");
  +        break;
  +      case Node.TEXT_NODE:
  +        buffer.append(encodeMarkup(node.getNodeValue()));
  +        // buffer.append("\n");
  +        break;
  +      default:
  +        break;
  +    }
  +  }
  +}
  
  
  
  1.1.2.3   +236 -236  xml-cocoon/src/org/apache/cocoon/util/Attic/IOUtils.java
  
  Index: IOUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/util/Attic/IOUtils.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- IOUtils.java      2000/07/22 20:42:02     1.1.2.2
  +++ IOUtils.java      2000/07/29 18:30:42     1.1.2.3
  @@ -1,236 +1,236 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.util;
  -
  -import java.net.URL;
  -
  -import java.io.File;
  -import java.io.FileWriter;
  -import java.io.FileReader;
  -import java.io.FileOutputStream;
  -import java.io.ObjectOutputStream;
  -import java.io.FileInputStream;
  -import java.io.ObjectInputStream;
  -
  -import java.io.IOException;
  -import java.net.MalformedURLException;
  -
  -/**
  - * A collection of <code>File</code>, <code>URL</code> and filename
  - * utility methods
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:42:02 $
  - */
  -public class IOUtils {
  -  /**
  -   * Create a URL from a location. This method supports the
  -   * <i>resource://</i> pseudo-protocol for loading resources
  -   * accessible to this same class' <code>ClassLoader</code>
  -   *
  -   * @param location The location
  -   * @return The URL pointed to by the location
  -   * @exception MalformedURLException If the location is malformed
  -   */
  -  public static URL getURL(String location)
  -    throws MalformedURLException
  -  {
  -    if (location.indexOf("://") < 0) {
  -      // Absolute file location
  -      File file = new File(location);
  -
  -      return new URL(
  -        "file://" +
  -     getFullFilename(file).replace(File.separatorChar, '/')
  -      );
  -    } else if (location.startsWith("resource://")) {
  -      return IOUtils.class.getClassLoader().getSystemResource(
  -        location.substring("resource://".length())
  -      );
  -    } else {
  -      return new URL(location);
  -    }
  -  }
  -
  -  /**
  -   * Dump a <code>String</code> to a text file.
  -   *
  -   * @param file The output file
  -   * @param string The string to be dumped
  -   * @exception IOException IO Error
  -   */
  -  public static void serializeString(File file, String string)
  -    throws IOException
  -  {
  -    FileWriter fw = new FileWriter(file);
  -    fw.write(string);
  -    fw.flush();
  -    fw.close();
  -  }
  -
  -  /**
  -   * Load a text file contents as a <code>String<code>.
  -   * This method does not perform enconding conversions
  -   *
  -   * @param file The input file
  -   * @return The file contents as a <code>String</code>
  -   * @exception IOException IO Error
  -   */
  -  public static String deserializeString(File file)
  -    throws IOException
  -  {
  -    int len;
  -    char[] chr = new char[4096];
  -    FileReader reader = new FileReader(file);
  -    StringBuffer buffer = new StringBuffer();
  -
  -    while ((len = reader.read(chr)) > 0) {
  -      buffer.append(chr, 0, len);
  -    }
  -
  -    return buffer.toString();
  -  }
  -
  -  /**
  -   * This method serializes an object to an output stream.
  -   *
  -   * @param file The output file
  -   * @param object The object to be serialized
  -   * @exception IOException IOError
  -   */
  -  public static void serializeObject(File file, Object object)
  -    throws IOException
  -  {
  -    FileOutputStream fos = new FileOutputStream(file);
  -    ObjectOutputStream oos = new ObjectOutputStream(fos);
  -    oos.writeObject(object);
  -    oos.flush();
  -    fos.close();
  -  }
  -
  -  /**
  -   * This method deserializes an object from an input stream.
  -   *
  -   * @param file The input file
  -   * @return The deserialized object
  -   * @exception IOException IOError
  -   */
  -  public static Object deserializeObject(File file)
  -   throws IOException, ClassNotFoundException
  -  {
  -    FileInputStream fis = new FileInputStream(file);
  -    ObjectInputStream ois = new ObjectInputStream(fis);
  -    Object object = ois.readObject();
  -    fis.close();
  -    return object;
  -  }
  -
  -  // **********************
  -  // Filename Methods
  -  // **********************
  -
  -  /**
  -   * Return a modified filename suitable for replicating directory
  -   * structures below the store's base directory. The following
  -   * conversions are performed:
  -   * <ul>
  -   * <li>Path separators are converted to regular directory names</li>
  -   * <li>File path components are transliterated to make them valid (?)
  -   *     programming language identifiers. This transformation may well
  -   *     generate collisions for unusual filenames.</li>
  -   * </ul>
  -   * @return The transformed filename
  -   */
  -  public static String normalizedFilename(String filename) {
  -    String[] path = StringUtils.split(filename, File.separator);
  -    int start = (path[0].length() == 0) ? 1 : 0;
  -
  -    StringBuffer buffer = new StringBuffer();
  -    for (int i = start; i < path.length; i++) {
  -      if (i > start) {
  -        buffer.append(File.separator);
  -      }
  -
  -      buffer.append('_');
  -      char[] chars = path[i].toCharArray();
  -
  -      for (int j = 0; j < chars.length; j++) {
  -        if (StringUtils.isAlphaNumeric(chars[j])) {
  -          buffer.append(chars[j]);
  -        } else {
  -          buffer.append('_');
  -        }
  -      }
  -    }
  -
  -    return buffer.toString();
  -  }
  -
  -  /**
  -   * Remove file information from a filename returning only its path
  -   * component
  -   *
  -   * @param filename The filename
  -   * @return The path information
  -   */
  -  public static String pathComponent(String filename) {
  -    int i = filename.lastIndexOf(File.separator);
  -    return (i >= 0) ? filename.substring(0, i) : filename;
  -  }
  -
  -  /**
  -   * Remove path information from a filename returning only its file
  -   * component
  -   *
  -   * @param filename The filename
  -   * @return The filename sans path information
  -   */
  -  public static String fileComponent(String filename) {
  -    int i = filename.lastIndexOf(File.separator);
  -    return (i >= 0) ? filename.substring(i + 1) : filename;
  -  }
  -
  -  /**
  -   * Strip a filename of its <i>last</i> extension (the portion
  -   * immediately following the last dot character, if any)
  -   *
  -   * @param filename The filename
  -   * @return The filename sans extension
  -   */
  -  public static String baseName(String filename) {
  -    return baseName(filename, ".");
  -  }
  -
  -  public static String baseName(String filename, String suffix) {
  -    int lastDot = filename.lastIndexOf(suffix);
  -
  -    if (lastDot >= 0) {
  -      filename = filename.substring(0, lastDot);
  -    }
  -
  -    return filename;
  -  }
  -
  -  /**
  -   * Get the complete filename corresponding to a (typically relative)
  -   * <code>File</code.
  -   * This method accounts for the possibility of an error in getting
  -   * the filename's <i>canonical</i> path, returning the io/error-safe
  -   * <i>absolute</i> form instead
  -   *
  -   * @param file The file
  -   * @return The file's absolute filename
  -   */
  -  public static String getFullFilename(File file) {
  -    try {
  -      return file.getCanonicalPath();
  -    } catch (IOException e) {
  -      return file.getAbsolutePath();
  -    }
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.util;
  +
  +import java.net.URL;
  +
  +import java.io.File;
  +import java.io.FileWriter;
  +import java.io.FileReader;
  +import java.io.FileOutputStream;
  +import java.io.ObjectOutputStream;
  +import java.io.FileInputStream;
  +import java.io.ObjectInputStream;
  +
  +import java.io.IOException;
  +import java.net.MalformedURLException;
  +
  +/**
  + * A collection of <code>File</code>, <code>URL</code> and filename
  + * utility methods
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:42 $
  + */
  +public class IOUtils {
  +  /**
  +   * Create a URL from a location. This method supports the
  +   * <i>resource://</i> pseudo-protocol for loading resources
  +   * accessible to this same class' <code>ClassLoader</code>
  +   *
  +   * @param location The location
  +   * @return The URL pointed to by the location
  +   * @exception MalformedURLException If the location is malformed
  +   */
  +  public static URL getURL(String location)
  +    throws MalformedURLException
  +  {
  +    if (location.indexOf("://") < 0) {
  +      // Absolute file location
  +      File file = new File(location);
  +
  +      return new URL(
  +        "file://" +
  +     getFullFilename(file).replace(File.separatorChar, '/')
  +      );
  +    } else if (location.startsWith("resource://")) {
  +      return IOUtils.class.getClassLoader().getSystemResource(
  +        location.substring("resource://".length())
  +      );
  +    } else {
  +      return new URL(location);
  +    }
  +  }
  +
  +  /**
  +   * Dump a <code>String</code> to a text file.
  +   *
  +   * @param file The output file
  +   * @param string The string to be dumped
  +   * @exception IOException IO Error
  +   */
  +  public static void serializeString(File file, String string)
  +    throws IOException
  +  {
  +    FileWriter fw = new FileWriter(file);
  +    fw.write(string);
  +    fw.flush();
  +    fw.close();
  +  }
  +
  +  /**
  +   * Load a text file contents as a <code>String<code>.
  +   * This method does not perform enconding conversions
  +   *
  +   * @param file The input file
  +   * @return The file contents as a <code>String</code>
  +   * @exception IOException IO Error
  +   */
  +  public static String deserializeString(File file)
  +    throws IOException
  +  {
  +    int len;
  +    char[] chr = new char[4096];
  +    FileReader reader = new FileReader(file);
  +    StringBuffer buffer = new StringBuffer();
  +
  +    while ((len = reader.read(chr)) > 0) {
  +      buffer.append(chr, 0, len);
  +    }
  +
  +    return buffer.toString();
  +  }
  +
  +  /**
  +   * This method serializes an object to an output stream.
  +   *
  +   * @param file The output file
  +   * @param object The object to be serialized
  +   * @exception IOException IOError
  +   */
  +  public static void serializeObject(File file, Object object)
  +    throws IOException
  +  {
  +    FileOutputStream fos = new FileOutputStream(file);
  +    ObjectOutputStream oos = new ObjectOutputStream(fos);
  +    oos.writeObject(object);
  +    oos.flush();
  +    fos.close();
  +  }
  +
  +  /**
  +   * This method deserializes an object from an input stream.
  +   *
  +   * @param file The input file
  +   * @return The deserialized object
  +   * @exception IOException IOError
  +   */
  +  public static Object deserializeObject(File file)
  +   throws IOException, ClassNotFoundException
  +  {
  +    FileInputStream fis = new FileInputStream(file);
  +    ObjectInputStream ois = new ObjectInputStream(fis);
  +    Object object = ois.readObject();
  +    fis.close();
  +    return object;
  +  }
  +
  +  // **********************
  +  // Filename Methods
  +  // **********************
  +
  +  /**
  +   * Return a modified filename suitable for replicating directory
  +   * structures below the store's base directory. The following
  +   * conversions are performed:
  +   * <ul>
  +   * <li>Path separators are converted to regular directory names</li>
  +   * <li>File path components are transliterated to make them valid (?)
  +   *     programming language identifiers. This transformation may well
  +   *     generate collisions for unusual filenames.</li>
  +   * </ul>
  +   * @return The transformed filename
  +   */
  +  public static String normalizedFilename(String filename) {
  +    String[] path = StringUtils.split(filename, File.separator);
  +    int start = (path[0].length() == 0) ? 1 : 0;
  +
  +    StringBuffer buffer = new StringBuffer();
  +    for (int i = start; i < path.length; i++) {
  +      if (i > start) {
  +        buffer.append(File.separator);
  +      }
  +
  +      buffer.append('_');
  +      char[] chars = path[i].toCharArray();
  +
  +      for (int j = 0; j < chars.length; j++) {
  +        if (StringUtils.isAlphaNumeric(chars[j])) {
  +          buffer.append(chars[j]);
  +        } else {
  +          buffer.append('_');
  +        }
  +      }
  +    }
  +
  +    return buffer.toString();
  +  }
  +
  +  /**
  +   * Remove file information from a filename returning only its path
  +   * component
  +   *
  +   * @param filename The filename
  +   * @return The path information
  +   */
  +  public static String pathComponent(String filename) {
  +    int i = filename.lastIndexOf(File.separator);
  +    return (i >= 0) ? filename.substring(0, i) : filename;
  +  }
  +
  +  /**
  +   * Remove path information from a filename returning only its file
  +   * component
  +   *
  +   * @param filename The filename
  +   * @return The filename sans path information
  +   */
  +  public static String fileComponent(String filename) {
  +    int i = filename.lastIndexOf(File.separator);
  +    return (i >= 0) ? filename.substring(i + 1) : filename;
  +  }
  +
  +  /**
  +   * Strip a filename of its <i>last</i> extension (the portion
  +   * immediately following the last dot character, if any)
  +   *
  +   * @param filename The filename
  +   * @return The filename sans extension
  +   */
  +  public static String baseName(String filename) {
  +    return baseName(filename, ".");
  +  }
  +
  +  public static String baseName(String filename, String suffix) {
  +    int lastDot = filename.lastIndexOf(suffix);
  +
  +    if (lastDot >= 0) {
  +      filename = filename.substring(0, lastDot);
  +    }
  +
  +    return filename;
  +  }
  +
  +  /**
  +   * Get the complete filename corresponding to a (typically relative)
  +   * <code>File</code.
  +   * This method accounts for the possibility of an error in getting
  +   * the filename's <i>canonical</i> path, returning the io/error-safe
  +   * <i>absolute</i> form instead
  +   *
  +   * @param file The file
  +   * @return The file's absolute filename
  +   */
  +  public static String getFullFilename(File file) {
  +    try {
  +      return file.getCanonicalPath();
  +    } catch (IOException e) {
  +      return file.getAbsolutePath();
  +    }
  +  }
  +}
  
  
  
  1.1.2.3   +61 -61    
xml-cocoon/src/org/apache/cocoon/util/Attic/StringUtils.java
  
  Index: StringUtils.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/util/Attic/StringUtils.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- StringUtils.java  2000/07/22 20:42:02     1.1.2.2
  +++ StringUtils.java  2000/07/29 18:30:42     1.1.2.3
  @@ -1,61 +1,61 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.util;
  -
  -import java.util.StringTokenizer;
  -
  -/**
  - * A collection of <code>String</code> handling utility methods.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/07/22 20:42:02 $
  - */
  -public class StringUtils {
  -  /**
  -   * Split a string as an array using whitespace as separator
  -   *
  -   * @param line The string to be split
  -   * @return An array of whitespace-separated tokens
  -   */
  -  public static String[] split(String line) {
  -    return split(line, " \t\n\r");
  -  }
  -
  -  /**
  -   * Split a string as an array using a given set of separators
  -   *
  -   * @param line The string to be split
  -   * @param delimiter A string containing token separators
  -   * @return An array of token
  -   */
  -  public static String[] split(String line, String delimiter) {
  -    Tokenizer tokenizer = new Tokenizer(line, delimiter);
  -    int tokenCount = tokenizer.countTokens();
  -    String[] result = new String[tokenCount];
  -
  -    for (int i = 0; i < tokenCount; i++) {
  -      result[i] = tokenizer.nextToken();
  -    }
  -
  -    return result;
  -  }
  -
  -  /**
  -   * Tests whether a given character is alphabetic, numeric or
  -   * underscore
  -   *
  -   * @param c The character to be tested
  -   * @return whether the given character is alphameric or not
  -   */
  -  public static boolean isAlphaNumeric(char c) {
  -    return c == '_' ||
  -           (c >= 'a' && c <= 'z') ||
  -           (c >= 'A' && c <= 'Z') ||
  -           (c >= '0' && c <= '9');
  -  }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.util;
  +
  +import java.util.StringTokenizer;
  +
  +/**
  + * A collection of <code>String</code> handling utility methods.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/29 18:30:42 $
  + */
  +public class StringUtils {
  +  /**
  +   * Split a string as an array using whitespace as separator
  +   *
  +   * @param line The string to be split
  +   * @return An array of whitespace-separated tokens
  +   */
  +  public static String[] split(String line) {
  +    return split(line, " \t\n\r");
  +  }
  +
  +  /**
  +   * Split a string as an array using a given set of separators
  +   *
  +   * @param line The string to be split
  +   * @param delimiter A string containing token separators
  +   * @return An array of token
  +   */
  +  public static String[] split(String line, String delimiter) {
  +    Tokenizer tokenizer = new Tokenizer(line, delimiter);
  +    int tokenCount = tokenizer.countTokens();
  +    String[] result = new String[tokenCount];
  +
  +    for (int i = 0; i < tokenCount; i++) {
  +      result[i] = tokenizer.nextToken();
  +    }
  +
  +    return result;
  +  }
  +
  +  /**
  +   * Tests whether a given character is alphabetic, numeric or
  +   * underscore
  +   *
  +   * @param c The character to be tested
  +   * @return whether the given character is alphameric or not
  +   */
  +  public static boolean isAlphaNumeric(char c) {
  +    return c == '_' ||
  +           (c >= 'a' && c <= 'z') ||
  +           (c >= 'A' && c <= 'Z') ||
  +           (c >= '0' && c <= '9');
  +  }
  +}
  
  
  
  1.1.2.3   +279 -279  
xml-cocoon/src/org/apache/cocoon/util/Attic/Tokenizer.java
  
  Index: Tokenizer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/util/Attic/Tokenizer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Tokenizer.java    2000/07/22 20:42:02     1.1.2.2
  +++ Tokenizer.java    2000/07/29 18:30:42     1.1.2.3
  @@ -1,279 +1,279 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.util;
  -
  -import java.util.Enumeration;
  -import java.util.NoSuchElementException;
  -
  -/**
  - * Replacement for StringTokenizer in java.util, beacuse of bug in the
  - * Sun's implementation.
  - *
  - * @author <A HREF="mailto:[EMAIL PROTECTED]">Peter Moravek</A>
  - */
  -public class Tokenizer implements Enumeration {
  -
  -  /**
  -   * Constructs a string tokenizer for the specified string. All characters
  -   * in the delim argument are the delimiters for separating tokens.
  -   * If the returnTokens flag is true, then the delimiter characters are
  -   * also returned as tokens. Each delimiter is returned as a string of
  -   * length one. If the flag is false, the delimiter characters are skipped
  -   * and only serve as separators between tokens.
  -   *
  -   * @param str           a string to be parsed
  -   * @param delim         the delimiters
  -   * @param returnTokens  flag indicating whether to return the delimiters
  -   *                      as tokens
  -   */
  -  public Tokenizer(String str, String delim, boolean returnTokens) {
  -    this.str = str;
  -    this.delim = delim;
  -    this.returnTokens = returnTokens;
  -
  -    max = str.length();
  -  }
  -
  -  /**
  -   * Constructs a string tokenizer for the specified string. The characters
  -   * in the delim argument are the delimiters for separating tokens.
  -   * Delimiter characters themselves will not be treated as tokens.
  -   *
  -   * @param str          a string to be parsed
  -   * @param delim        the delimiters
  -   */
  -  public Tokenizer(String str, String delim) {
  -    this(str, delim, false);
  -  }
  -
  -  /**
  -   * Constructs a string tokenizer for the specified string. The character
  -   * in the delim argument is the delimiter for separating tokens.
  -   * Delimiter character themselves will not be treated as token.
  -   *
  -   * @param str          a string to be parsed
  -   * @param delim        the delimiter
  -   */
  -  public Tokenizer(String str, char delim) {
  -    this(str, String.valueOf(delim), false);
  -  }
  -
  -  /**
  -   * Constructs a string tokenizer for the specified string. The tokenizer
  -   * uses the default delimiter set, which is " \t\n\r\f": the space
  -   * character, the tab character, the newline character, the carriage-return
  -   * character, and the form-feed character. Delimiter characters themselves
  -   * will not be treated as tokens.
  -   *
  -   * @param str          a string to be parsed
  -   */
  -  public Tokenizer(String str) {
  -    this(str, DEFAULT_DELIMITERS, false);
  -  }
  -
  -  /**
  -   * Tests if there are more tokens available from this tokenizer's string.
  -   * If this method returns true, then a subsequent call to nextToken with
  -   * no argument will successfully return a token.
  -   *
  -   * @return true if and only if there is at least one token in the string
  -   * after the current position; false otherwise.
  -   */
  -  public boolean hasMoreTokens() {
  -    return ((current < max) ? (true) : 
  -      (((current == max) && (max == 0 
  -        || (returnTokens && delim.indexOf(str.charAt(previous)) >= 0)))));
  -  }
  -  
  -  /**
  -   * Returns the next token from this string tokenizer.
  -   *
  -   * @return the next token from this string tokenizer
  -   *
  -   * @exception NoSuchElementException  if there are no more tokens in this
  -   *                                    tokenizer's string
  -   */
  -  public String nextToken() throws NoSuchElementException {
  -    if (current == max
  -      && (max == 0
  -      || (returnTokens && delim.indexOf(str.charAt(previous)) >= 0))) {
  -
  -      current++;
  -      return new String();
  -    }
  -
  -    if (current >= max)
  -      throw new NoSuchElementException();
  -
  -    int start = current;
  -    String result = null;
  -
  -    if (delim.indexOf(str.charAt(start)) >= 0) {
  -      if (previous == -1 || (returnTokens && previous != current
  -        && delim.indexOf(str.charAt(previous)) >= 0)) {
  -
  -        result = new String();
  -      }
  -      else if (returnTokens)
  -        result = str.substring(start, ++current);
  -
  -      if (!returnTokens)
  -        current++;
  -    }
  -
  -    previous = start;
  -    start = current;
  -
  -    if (result == null)
  -      while (current < max && delim.indexOf(str.charAt(current)) < 0)
  -        current++;
  -
  -    return result == null ? str.substring(start, current) : result;
  -  }
  -
  -  /**
  -   * Returns the next token in this string tokenizer's string. First, the
  -   * set of characters considered to be delimiters by this Tokenizer
  -   * object is changed to be the characters in the string delim.
  -   * Then the next token in the string after the current position is
  -   * returned. The current position is advanced beyond the recognized token.
  -   * The new delimiter set remains the default after this call.
  -   *
  -   * @param delim the new delimiters
  -   *
  -   * @return the next token, after switching to the new delimiter set
  -   *
  -   * @exception NoSuchElementException  if there are no more tokens in this
  -   *                                    tokenizer's string.
  -   */
  -  public String nextToken(String delim) throws NoSuchElementException {
  -    this.delim = delim;
  -    return nextToken();
  -  }
  -
  -  /**
  -   * Returns the same value as the hasMoreTokens method. It exists so that
  -   * this class can implement the Enumeration interface.
  -   *
  -   * @return true if there are more tokens; false otherwise.
  -   */
  -  public boolean hasMoreElements() {
  -    return hasMoreTokens();
  -  }
  -
  -  /**
  -   * Returns the same value as the nextToken method, except that its
  -   * declared return value is Object rather than String. It exists so that
  -   * this class can implement the Enumeration interface.
  -   *
  -   * @return the next token in the string
  -   *
  -   * @exception NoSuchElementException  if there are no more tokens in this
  -   *                                    tokenizer's string
  -   */
  -  public Object nextElement() {
  -    return nextToken();
  -  }
  -
  -  /**
  -   * Calculates the number of times that this tokenizer's nextToken method
  -   * can be called before it generates an exception. The current position
  -   * is not advanced.
  -   *
  -   * @return  the number of tokens remaining in the string using the
  -   *          current delimiter set
  -   */
  -  public int countTokens() {
  -    int curr = current;
  -    int count = 0;
  -
  -    for (int i = curr; i < max; i++) {
  -      if (delim.indexOf(str.charAt(i)) >= 0)
  -        count++;
  -
  -      curr++;
  -    }
  -
  -    return count + (returnTokens ? count : 0) + 1;
  -  }
  -
  -  /**
  -   * Resets this tokenizer's state so the tokenizing starts from the begin.
  -   */
  -  public void reset() {
  -    previous = -1;
  -    current = 0;
  -  }
  -
  -  /**
  -   * Constructs a string tokenizer for the specified string. All characters
  -   * in the delim argument are the delimiters for separating tokens.
  -   * If the returnTokens flag is true, then the delimiter characters are
  -   * also returned as tokens. Each delimiter is returned as a string of
  -   * length one. If the flag is false, the delimiter characters are skipped
  -   * and only serve as separators between tokens. Then tokenizes the str
  -   * and return an String[] array with tokens.
  -   *
  -   * @param str           a string to be parsed
  -   * @param delim         the delimiters
  -   * @param returnTokens  flag indicating whether to return the delimiters
  -   *                      as tokens
  -   *
  -   * @return array with tokens
  -   */
  -  public static String[] tokenize(String str, String delim,
  -    boolean returnTokens) {
  -
  -    Tokenizer tokenizer = new Tokenizer(str, delim, returnTokens);
  -    String[] tokens = new String[tokenizer.countTokens()];
  -
  -    for (int i = 0; i < tokens.length; i++)
  -      tokens[i] = tokenizer.nextToken();
  -
  -    return tokens;
  -  }
  -
  -  /**
  -   * Default delimiters "\t\n\r\f":
  -   * the space character, the tab character, the newline character,
  -   * the carriage-return character, and the form-feed character.
  -   */
  -  public static final String DEFAULT_DELIMITERS = " \t\n\r\f";
  -
  -  /**
  -   * String to tokenize.
  -   */
  -  private String str = null;
  -
  -  /**
  -   * Delimiters.
  -   */
  -  private String delim = null;
  -
  -  /**
  -   * Flag indicating whether to return the delimiters as tokens.
  -   */
  -  private boolean returnTokens = false;
  -
  -  /**
  -   * Previous token start.
  -   */
  -  private int previous = -1;
  -
  -  /**
  -   * Current position in str string.
  -   */
  -  private int current = 0;
  -
  -  /**
  -   * Maximal position in str string.
  -   */
  -  private int max = 0;
  -}
  -
  -
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.util;
  +
  +import java.util.Enumeration;
  +import java.util.NoSuchElementException;
  +
  +/**
  + * Replacement for StringTokenizer in java.util, beacuse of bug in the
  + * Sun's implementation.
  + *
  + * @author <A HREF="mailto:[EMAIL PROTECTED]">Peter Moravek</A>
  + */
  +public class Tokenizer implements Enumeration {
  +
  +  /**
  +   * Constructs a string tokenizer for the specified string. All characters
  +   * in the delim argument are the delimiters for separating tokens.
  +   * If the returnTokens flag is true, then the delimiter characters are
  +   * also returned as tokens. Each delimiter is returned as a string of
  +   * length one. If the flag is false, the delimiter characters are skipped
  +   * and only serve as separators between tokens.
  +   *
  +   * @param str           a string to be parsed
  +   * @param delim         the delimiters
  +   * @param returnTokens  flag indicating whether to return the delimiters
  +   *                      as tokens
  +   */
  +  public Tokenizer(String str, String delim, boolean returnTokens) {
  +    this.str = str;
  +    this.delim = delim;
  +    this.returnTokens = returnTokens;
  +
  +    max = str.length();
  +  }
  +
  +  /**
  +   * Constructs a string tokenizer for the specified string. The characters
  +   * in the delim argument are the delimiters for separating tokens.
  +   * Delimiter characters themselves will not be treated as tokens.
  +   *
  +   * @param str          a string to be parsed
  +   * @param delim        the delimiters
  +   */
  +  public Tokenizer(String str, String delim) {
  +    this(str, delim, false);
  +  }
  +
  +  /**
  +   * Constructs a string tokenizer for the specified string. The character
  +   * in the delim argument is the delimiter for separating tokens.
  +   * Delimiter character themselves will not be treated as token.
  +   *
  +   * @param str          a string to be parsed
  +   * @param delim        the delimiter
  +   */
  +  public Tokenizer(String str, char delim) {
  +    this(str, String.valueOf(delim), false);
  +  }
  +
  +  /**
  +   * Constructs a string tokenizer for the specified string. The tokenizer
  +   * uses the default delimiter set, which is " \t\n\r\f": the space
  +   * character, the tab character, the newline character, the carriage-return
  +   * character, and the form-feed character. Delimiter characters themselves
  +   * will not be treated as tokens.
  +   *
  +   * @param str          a string to be parsed
  +   */
  +  public Tokenizer(String str) {
  +    this(str, DEFAULT_DELIMITERS, false);
  +  }
  +
  +  /**
  +   * Tests if there are more tokens available from this tokenizer's string.
  +   * If this method returns true, then a subsequent call to nextToken with
  +   * no argument will successfully return a token.
  +   *
  +   * @return true if and only if there is at least one token in the string
  +   * after the current position; false otherwise.
  +   */
  +  public boolean hasMoreTokens() {
  +    return ((current < max) ? (true) : 
  +      (((current == max) && (max == 0 
  +        || (returnTokens && delim.indexOf(str.charAt(previous)) >= 0)))));
  +  }
  +  
  +  /**
  +   * Returns the next token from this string tokenizer.
  +   *
  +   * @return the next token from this string tokenizer
  +   *
  +   * @exception NoSuchElementException  if there are no more tokens in this
  +   *                                    tokenizer's string
  +   */
  +  public String nextToken() throws NoSuchElementException {
  +    if (current == max
  +      && (max == 0
  +      || (returnTokens && delim.indexOf(str.charAt(previous)) >= 0))) {
  +
  +      current++;
  +      return new String();
  +    }
  +
  +    if (current >= max)
  +      throw new NoSuchElementException();
  +
  +    int start = current;
  +    String result = null;
  +
  +    if (delim.indexOf(str.charAt(start)) >= 0) {
  +      if (previous == -1 || (returnTokens && previous != current
  +        && delim.indexOf(str.charAt(previous)) >= 0)) {
  +
  +        result = new String();
  +      }
  +      else if (returnTokens)
  +        result = str.substring(start, ++current);
  +
  +      if (!returnTokens)
  +        current++;
  +    }
  +
  +    previous = start;
  +    start = current;
  +
  +    if (result == null)
  +      while (current < max && delim.indexOf(str.charAt(current)) < 0)
  +        current++;
  +
  +    return result == null ? str.substring(start, current) : result;
  +  }
  +
  +  /**
  +   * Returns the next token in this string tokenizer's string. First, the
  +   * set of characters considered to be delimiters by this Tokenizer
  +   * object is changed to be the characters in the string delim.
  +   * Then the next token in the string after the current position is
  +   * returned. The current position is advanced beyond the recognized token.
  +   * The new delimiter set remains the default after this call.
  +   *
  +   * @param delim the new delimiters
  +   *
  +   * @return the next token, after switching to the new delimiter set
  +   *
  +   * @exception NoSuchElementException  if there are no more tokens in this
  +   *                                    tokenizer's string.
  +   */
  +  public String nextToken(String delim) throws NoSuchElementException {
  +    this.delim = delim;
  +    return nextToken();
  +  }
  +
  +  /**
  +   * Returns the same value as the hasMoreTokens method. It exists so that
  +   * this class can implement the Enumeration interface.
  +   *
  +   * @return true if there are more tokens; false otherwise.
  +   */
  +  public boolean hasMoreElements() {
  +    return hasMoreTokens();
  +  }
  +
  +  /**
  +   * Returns the same value as the nextToken method, except that its
  +   * declared return value is Object rather than String. It exists so that
  +   * this class can implement the Enumeration interface.
  +   *
  +   * @return the next token in the string
  +   *
  +   * @exception NoSuchElementException  if there are no more tokens in this
  +   *                                    tokenizer's string
  +   */
  +  public Object nextElement() {
  +    return nextToken();
  +  }
  +
  +  /**
  +   * Calculates the number of times that this tokenizer's nextToken method
  +   * can be called before it generates an exception. The current position
  +   * is not advanced.
  +   *
  +   * @return  the number of tokens remaining in the string using the
  +   *          current delimiter set
  +   */
  +  public int countTokens() {
  +    int curr = current;
  +    int count = 0;
  +
  +    for (int i = curr; i < max; i++) {
  +      if (delim.indexOf(str.charAt(i)) >= 0)
  +        count++;
  +
  +      curr++;
  +    }
  +
  +    return count + (returnTokens ? count : 0) + 1;
  +  }
  +
  +  /**
  +   * Resets this tokenizer's state so the tokenizing starts from the begin.
  +   */
  +  public void reset() {
  +    previous = -1;
  +    current = 0;
  +  }
  +
  +  /**
  +   * Constructs a string tokenizer for the specified string. All characters
  +   * in the delim argument are the delimiters for separating tokens.
  +   * If the returnTokens flag is true, then the delimiter characters are
  +   * also returned as tokens. Each delimiter is returned as a string of
  +   * length one. If the flag is false, the delimiter characters are skipped
  +   * and only serve as separators between tokens. Then tokenizes the str
  +   * and return an String[] array with tokens.
  +   *
  +   * @param str           a string to be parsed
  +   * @param delim         the delimiters
  +   * @param returnTokens  flag indicating whether to return the delimiters
  +   *                      as tokens
  +   *
  +   * @return array with tokens
  +   */
  +  public static String[] tokenize(String str, String delim,
  +    boolean returnTokens) {
  +
  +    Tokenizer tokenizer = new Tokenizer(str, delim, returnTokens);
  +    String[] tokens = new String[tokenizer.countTokens()];
  +
  +    for (int i = 0; i < tokens.length; i++)
  +      tokens[i] = tokenizer.nextToken();
  +
  +    return tokens;
  +  }
  +
  +  /**
  +   * Default delimiters "\t\n\r\f":
  +   * the space character, the tab character, the newline character,
  +   * the carriage-return character, and the form-feed character.
  +   */
  +  public static final String DEFAULT_DELIMITERS = " \t\n\r\f";
  +
  +  /**
  +   * String to tokenize.
  +   */
  +  private String str = null;
  +
  +  /**
  +   * Delimiters.
  +   */
  +  private String delim = null;
  +
  +  /**
  +   * Flag indicating whether to return the delimiters as tokens.
  +   */
  +  private boolean returnTokens = false;
  +
  +  /**
  +   * Previous token start.
  +   */
  +  private int previous = -1;
  +
  +  /**
  +   * Current position in str string.
  +   */
  +  private int current = 0;
  +
  +  /**
  +   * Maximal position in str string.
  +   */
  +  private int max = 0;
  +}
  +
  +
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +208 -208  
xml-cocoon/src/org/apache/cocoon/xml/Attic/AbstractXMLConsumer.java
  
  Index: AbstractXMLConsumer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/Attic/AbstractXMLConsumer.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- AbstractXMLConsumer.java  2000/07/22 20:42:04     1.1.2.3
  +++ AbstractXMLConsumer.java  2000/07/29 18:30:43     1.1.2.4
  @@ -1,208 +1,208 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.xml;
  -
  -import org.xml.sax.Attributes;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.ext.LexicalHandler;
  -
  -/**
  - * This abstract class provides default implementation of the methods 
specified
  - * by the <code>XMLConsumer</code> interface.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:42:04 $
  - */
  -public abstract class AbstractXMLConsumer implements XMLConsumer {
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     *
  -     * @param locator An object that can return the location of any SAX
  -     *                document event.
  -     */
  -    public void setDocumentLocator(Locator locator) {
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument()
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument()
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     *
  -     * @param prefix The Namespace prefix being declared.
  -     * @param uri The Namespace URI the prefix is mapped to.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     *
  -     * @param prefix The prefix that was being mapping.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     *
  -     * @param uri The Namespace URI, or the empty string if the element has 
no
  -     *            Namespace URI or if Namespace
  -     *            processing is not being performed.
  -     * @param loc The local name (without prefix), or the empty string if
  -     *            Namespace processing is not being performed.
  -     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
  -     *            raw names are not available.
  -     * @param a The attributes attached to the element. If there are no
  -     *          attributes, it shall be an empty Attributes object.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes 
a)
  -    throws SAXException {
  -    }
  -
  -
  -    /**
  -     * Receive notification of the end of an element.
  -     *
  -     * @param uri The Namespace URI, or the empty string if the element has 
no
  -     *            Namespace URI or if Namespace
  -     *            processing is not being performed.
  -     * @param loc The local name (without prefix), or the empty string if
  -     *            Namespace processing is not being performed.
  -     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
  -     *            raw names are not available.
  -     */
  -    public void endElement(String uri, String loc, String raw)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     *
  -     * @param ch The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     */
  -    public void characters(char ch[], int start, int len)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     *
  -     * @param ch The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     */
  -    public void ignorableWhitespace(char ch[], int start, int len)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Receive notification of a processing instruction.
  -     *
  -     * @param target The processing instruction target.
  -     * @param data The processing instruction data, or null if none was
  -     *             supplied.
  -     */
  -    public void processingInstruction(String target, String data)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Receive notification of a skipped entity.
  -     *
  -     * @param name The name of the skipped entity.  If it is a  parameter
  -     *             entity, the name will begin with '%'.
  -     */
  -    public void skippedEntity(String name)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Report the start of DTD declarations, if any.
  -     *
  -     * @param name The document type name.
  -     * @param publicId The declared public identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     * @param systemId The declared system identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     */
  -    public void startDTD(String name, String publicId, String systemId)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Report the end of DTD declarations.
  -     */
  -    public void endDTD()
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Report the beginning of an entity.
  -     *
  -     * @param name The name of the entity. If it is a parameter entity, the
  -     *             name will begin with '%'.
  -     */
  -    public void startEntity(String name)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Report the end of an entity.
  -     *
  -     * @param name The name of the entity that is ending.
  -     */
  -    public void endEntity(String name)
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Report the start of a CDATA section.
  -     */
  -    public void startCDATA()
  -    throws SAXException {
  -    }
  -
  -    /**
  -     * Report the end of a CDATA section.
  -     */
  -    public void endCDATA()
  -    throws SAXException {
  -    }
  -
  -
  -    /**
  -     * Report an XML comment anywhere in the document.
  -     *
  -     * @param ch An array holding the characters in the comment.
  -     * @param start The starting position in the array.
  -     * @param len The number of characters to use from the array.
  -     */
  -    public void comment(char ch[], int start, int len)
  -    throws SAXException {
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.xml;
  +
  +import org.xml.sax.Attributes;
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.ext.LexicalHandler;
  +
  +/**
  + * This abstract class provides default implementation of the methods 
specified
  + * by the <code>XMLConsumer</code> interface.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:43 $
  + */
  +public abstract class AbstractXMLConsumer implements XMLConsumer {
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     *
  +     * @param locator An object that can return the location of any SAX
  +     *                document event.
  +     */
  +    public void setDocumentLocator(Locator locator) {
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +    public void startDocument()
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +    public void endDocument()
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping.
  +     *
  +     * @param prefix The Namespace prefix being declared.
  +     * @param uri The Namespace URI the prefix is mapped to.
  +     */
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping.
  +     *
  +     * @param prefix The prefix that was being mapping.
  +     */
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of an element.
  +     *
  +     * @param uri The Namespace URI, or the empty string if the element has 
no
  +     *            Namespace URI or if Namespace
  +     *            processing is not being performed.
  +     * @param loc The local name (without prefix), or the empty string if
  +     *            Namespace processing is not being performed.
  +     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
  +     *            raw names are not available.
  +     * @param a The attributes attached to the element. If there are no
  +     *          attributes, it shall be an empty Attributes object.
  +     */
  +    public void startElement(String uri, String loc, String raw, Attributes 
a)
  +    throws SAXException {
  +    }
  +
  +
  +    /**
  +     * Receive notification of the end of an element.
  +     *
  +     * @param uri The Namespace URI, or the empty string if the element has 
no
  +     *            Namespace URI or if Namespace
  +     *            processing is not being performed.
  +     * @param loc The local name (without prefix), or the empty string if
  +     *            Namespace processing is not being performed.
  +     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
  +     *            raw names are not available.
  +     */
  +    public void endElement(String uri, String loc, String raw)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Receive notification of character data.
  +     *
  +     * @param ch The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     */
  +    public void characters(char ch[], int start, int len)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     *
  +     * @param ch The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     */
  +    public void ignorableWhitespace(char ch[], int start, int len)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Receive notification of a processing instruction.
  +     *
  +     * @param target The processing instruction target.
  +     * @param data The processing instruction data, or null if none was
  +     *             supplied.
  +     */
  +    public void processingInstruction(String target, String data)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Receive notification of a skipped entity.
  +     *
  +     * @param name The name of the skipped entity.  If it is a  parameter
  +     *             entity, the name will begin with '%'.
  +     */
  +    public void skippedEntity(String name)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Report the start of DTD declarations, if any.
  +     *
  +     * @param name The document type name.
  +     * @param publicId The declared public identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     * @param systemId The declared system identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     */
  +    public void startDTD(String name, String publicId, String systemId)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Report the end of DTD declarations.
  +     */
  +    public void endDTD()
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Report the beginning of an entity.
  +     *
  +     * @param name The name of the entity. If it is a parameter entity, the
  +     *             name will begin with '%'.
  +     */
  +    public void startEntity(String name)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Report the end of an entity.
  +     *
  +     * @param name The name of the entity that is ending.
  +     */
  +    public void endEntity(String name)
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Report the start of a CDATA section.
  +     */
  +    public void startCDATA()
  +    throws SAXException {
  +    }
  +
  +    /**
  +     * Report the end of a CDATA section.
  +     */
  +    public void endCDATA()
  +    throws SAXException {
  +    }
  +
  +
  +    /**
  +     * Report an XML comment anywhere in the document.
  +     *
  +     * @param ch An array holding the characters in the comment.
  +     * @param start The starting position in the array.
  +     * @param len The number of characters to use from the array.
  +     */
  +    public void comment(char ch[], int start, int len)
  +    throws SAXException {
  +    }
  +}
  
  
  
  1.1.2.4   +62 -62    
xml-cocoon/src/org/apache/cocoon/xml/Attic/AbstractXMLProducer.java
  
  Index: AbstractXMLProducer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/Attic/AbstractXMLProducer.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- AbstractXMLProducer.java  2000/07/22 20:42:04     1.1.2.3
  +++ AbstractXMLProducer.java  2000/07/29 18:30:43     1.1.2.4
  @@ -1,62 +1,62 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.xml;
  -
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.ext.LexicalHandler;
  -
  -/**
  - * This abstract class provides default implementation of the methods 
specified
  - * by the <code>XMLProducer</code> interface. 
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:42:04 $
  - */
  -public abstract class AbstractXMLProducer implements XMLProducer {
  -    
  -    /** The <code>ContentHandler</code> receiving SAX events. */
  -    protected ContentHandler contentHandler=null;
  -    /** The <code>LexicalHandler</code> receiving SAX events. */
  -    protected LexicalHandler lexicalHandler=null;
  -
  -    /**
  -     * Set the <code>XMLConsumer</code> that will receive XML data.
  -     * <br>
  -     * This method will simply call <code>setContentHandler(consumer)</code>
  -     * and <code>setLexicalHandler(consumer)</code>.
  -     */
  -    public void setConsumer(XMLConsumer consumer) {
  -        this.contentHandler=consumer;
  -        this.lexicalHandler=consumer;
  -    }
  -
  -    /**
  -     * Set the <code>ContentHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>ContentHandler</code> instance
  -     * accessing the protected <code>super.contentHandler</code> field.
  -     */
  -    public void setContentHandler(ContentHandler content) {
  -        this.contentHandler=content;
  -    }
  -
  -    /**
  -     * Set the <code>LexicalHandler</code> that will receive XML data.
  -     * <br>
  -     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  -     * accessing the protected <code>super.lexicalHandler</code> field.
  -     *
  -     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  -     *                                  the <code>XMLConsumer</code> were
  -     *                                  already set.
  -     */
  -    public void setLexicalHandler(LexicalHandler lexical) {
  -        this.lexicalHandler=lexical;
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.xml;
  +
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.ext.LexicalHandler;
  +
  +/**
  + * This abstract class provides default implementation of the methods 
specified
  + * by the <code>XMLProducer</code> interface. 
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:43 $
  + */
  +public abstract class AbstractXMLProducer implements XMLProducer {
  +    
  +    /** The <code>ContentHandler</code> receiving SAX events. */
  +    protected ContentHandler contentHandler=null;
  +    /** The <code>LexicalHandler</code> receiving SAX events. */
  +    protected LexicalHandler lexicalHandler=null;
  +
  +    /**
  +     * Set the <code>XMLConsumer</code> that will receive XML data.
  +     * <br>
  +     * This method will simply call <code>setContentHandler(consumer)</code>
  +     * and <code>setLexicalHandler(consumer)</code>.
  +     */
  +    public void setConsumer(XMLConsumer consumer) {
  +        this.contentHandler=consumer;
  +        this.lexicalHandler=consumer;
  +    }
  +
  +    /**
  +     * Set the <code>ContentHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>ContentHandler</code> instance
  +     * accessing the protected <code>super.contentHandler</code> field.
  +     */
  +    public void setContentHandler(ContentHandler content) {
  +        this.contentHandler=content;
  +    }
  +
  +    /**
  +     * Set the <code>LexicalHandler</code> that will receive XML data.
  +     * <br>
  +     * Subclasses may retrieve this <code>LexicalHandler</code> instance
  +     * accessing the protected <code>super.lexicalHandler</code> field.
  +     *
  +     * @exception IllegalStateException If the <code>LexicalHandler</code> or
  +     *                                  the <code>XMLConsumer</code> were
  +     *                                  already set.
  +     */
  +    public void setLexicalHandler(LexicalHandler lexical) {
  +        this.lexicalHandler=lexical;
  +    }
  +}
  
  
  
  1.1.2.4   +25 -25    
xml-cocoon/src/org/apache/cocoon/xml/Attic/XMLConsumer.java
  
  Index: XMLConsumer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/Attic/XMLConsumer.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- XMLConsumer.java  2000/07/22 20:42:04     1.1.2.3
  +++ XMLConsumer.java  2000/07/29 18:30:43     1.1.2.4
  @@ -1,25 +1,25 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.xml;
  -
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.ext.LexicalHandler;
  -
  -/**
  - * This interfaces identifies classes that consume XML data, receiving 
  - * notification of SAX events.
  - * <br>
  - * This interface unites the idea of SAX <code>ContentHandler</code> and
  - * <code>LexicalHandler</code>.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:42:04 $
  - */
  -public interface XMLConsumer extends ContentHandler, LexicalHandler {
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.xml;
  +
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.ext.LexicalHandler;
  +
  +/**
  + * This interfaces identifies classes that consume XML data, receiving 
  + * notification of SAX events.
  + * <br>
  + * This interface unites the idea of SAX <code>ContentHandler</code> and
  + * <code>LexicalHandler</code>.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:43 $
  + */
  +public interface XMLConsumer extends ContentHandler, LexicalHandler {
  +}
  
  
  
  1.1.2.4   +41 -41    
xml-cocoon/src/org/apache/cocoon/xml/Attic/XMLProducer.java
  
  Index: XMLProducer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/Attic/XMLProducer.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- XMLProducer.java  2000/07/22 20:42:04     1.1.2.3
  +++ XMLProducer.java  2000/07/29 18:30:43     1.1.2.4
  @@ -1,41 +1,41 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.xml;
  -
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.ext.LexicalHandler;
  -
  -/**
  - * This interfaces identifies classes that produce XML data, sending SAX
  - * events to the configured <code>XMLConsumer</code> (or SAX 
  - * <code>ContentHandler</code> and <code>LexicalHandler</code>).
  - * <br>
  - * It's beyond the scope of this interface to specify a way in wich the XML
  - * data production is started.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:42:04 $
  - */
  -public interface XMLProducer {
  -
  -    /**
  -     * Set the <code>XMLConsumer</code> that will receive XML data.
  -     */
  -    public void setConsumer(XMLConsumer consumer);
  -
  -    /**
  -     * Set the <code>ContentHandler</code> that will receive XML data.
  -     */
  -    public void setContentHandler(ContentHandler content);
  -
  -    /**
  -     * Set the <code>LexicalHandler</code> that will receive XML data.
  -     */
  -    public void setLexicalHandler(LexicalHandler lexical);
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.xml;
  +
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.ext.LexicalHandler;
  +
  +/**
  + * This interfaces identifies classes that produce XML data, sending SAX
  + * events to the configured <code>XMLConsumer</code> (or SAX 
  + * <code>ContentHandler</code> and <code>LexicalHandler</code>).
  + * <br>
  + * It's beyond the scope of this interface to specify a way in wich the XML
  + * data production is started.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:43 $
  + */
  +public interface XMLProducer {
  +
  +    /**
  +     * Set the <code>XMLConsumer</code> that will receive XML data.
  +     */
  +    public void setConsumer(XMLConsumer consumer);
  +
  +    /**
  +     * Set the <code>ContentHandler</code> that will receive XML data.
  +     */
  +    public void setContentHandler(ContentHandler content);
  +
  +    /**
  +     * Set the <code>LexicalHandler</code> that will receive XML data.
  +     */
  +    public void setLexicalHandler(LexicalHandler lexical);
  +}
  
  
  
  1.1.2.4   +7 -7      xml-cocoon/src/org/apache/cocoon/xml/Attic/package.html
  
  Index: package.html
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/xml/Attic/package.html,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- package.html      2000/07/22 20:42:04     1.1.2.3
  +++ package.html      2000/07/29 18:30:43     1.1.2.4
  @@ -1,7 +1,7 @@
  -<!-- version $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:42:04 $ -->
  -<html>
  -  <body>
  -    This package contains the basic interfaces and abstract classes used by
  -    Cocoon 2.0 to deal with XML data.
  -  </body>
  -</html>
  +<!-- version $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:43 $ -->
  +<html>
  +  <body>
  +    This package contains the basic interfaces and abstract classes used by
  +    Cocoon 2.0 to deal with XML data.
  +  </body>
  +</html>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.7   +563 -563  
xml-cocoon/src/org/apache/cocoon/xml/util/Attic/DOMBuilder.java
  
  Index: DOMBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/util/Attic/DOMBuilder.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- DOMBuilder.java   2000/07/22 20:42:05     1.1.2.6
  +++ DOMBuilder.java   2000/07/29 18:30:44     1.1.2.7
  @@ -1,563 +1,563 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.xml.util;
  -
  -import java.util.Vector;
  -import org.apache.cocoon.xml.XMLConsumer;
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.CDATASection;
  -import org.w3c.dom.Comment;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.DocumentType;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.EntityReference;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.ProcessingInstruction;
  -import org.w3c.dom.Text;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -
  -/**
  - * The <code>DOMBuilder</code> is a utility class that will generate a W3C
  - * DOM Document from SAX events.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/22 20:42:05 $
  - */
  -public class DOMBuilder implements XMLConsumer {
  -    /** The document was not started */
  -    private static final int S_AVAIL=0;
  -    /** State between startDTD() and endDTD() */
  -    private static final int S_DTD=1;
  -    /** State between startDocument() and endDocument() */
  -    private static final int S_DOC=2;
  -    /** State between the first startElement() and the last endElement() */
  -    private static final int S_BODY=3;
  -    /** State between the first startElement() and the last endElement() */
  -    private static final int S_CDATA=4;
  -    /** The state names (used by Location to output better error messages */
  -    private static final String stateName[]={
  -        "Available", "DTD Processing", "Document", "Body", "CDATA Section"
  -    };
  -    
  -    /** The current state */
  -    private int state=S_AVAIL;
  -    /** The locator */
  -    private Locator locator=null;
  -    /** The listener */
  -    private Listener listener=null;
  -    /** The namespaces table */
  -    private NamespacesTable namespaces=null;
  -    /** The current document */
  -    private Document document=null;
  -    /** The current node */
  -    private Node current=null;
  -    /** The document name (tag name of the root element) */
  -    private String name=null;
  -    /** The vector of namespaces declarations to include in the next element 
*/
  -    private Vector undecl=new Vector();
  -
  -    /** The document factory */
  -    protected DOMFactory factory=null;
  -
  -    /**
  -     * Construct a new instance of this TreeGenerator.
  -     */
  -    protected DOMBuilder() {
  -        this(null,null);
  -    }
  -
  -    /**
  -     * Construct a new instance of this TreeGenerator.
  -     */
  -    public DOMBuilder(DOMFactory factory) {
  -        this(factory,null);
  -    }
  -
  -    /**
  -     * Construct a new instance of this TreeGenerator.
  -     */
  -    public DOMBuilder(DOMFactory factory, Listener listener) {
  -        super();
  -        this.factory=factory;
  -        this.listener=listener;
  -    }
  -
  -    /**
  -     * Return the newly built Document.
  -     */
  -    public Document getDocument() {
  -        return(this.document);
  -    }
  -
  -    /**
  -     * Set the SAX Document Locator.
  -     *
  -     * @param loc The SAX Locator.
  -     */
  -    public void setDocumentLocator (Locator loc) {
  -        this.locator=loc;
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     *
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void startDocument()
  -    throws SAXException {
  -        if(state!=S_AVAIL) throw new SAXException("Invalid 
state"+location());
  -        // Create the namespaces table
  -        this.namespaces=new NamespacesTable();
  -        // Create a new Document empty document object
  -        this.document=this.factory.newDocument();
  -        // Set the current node
  -        this.current=this.document;
  -        // Do a state change
  -        state=S_DOC;
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of a document.
  -     *
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void endDocument ()
  -    throws SAXException {
  -        if(state!=S_DOC) throw new SAXException("Invalid state"+location());
  -        // Check if the current element is the document
  -        if(this.document!=this.current)
  -            throw new SAXException("Invalid current node"+location());
  -        // Reset the current node and the document name
  -        this.current=null;
  -        this.name=null;
  -        // Do a state change and reset the DTD flag
  -        state=S_AVAIL;
  -        // Notify the listener
  -        this.notify(this.document);
  -    }
  -
  -    /**
  -     * Report the start of DTD declarations, if any. 
  -     *
  -     * @param name The document type name.
  -     * @param publicId The declared public identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     * @param systemId The declared system identifier for the external DTD
  -     *                 subset, or null if none was declared.
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void startDTD(String name, String publicId, String systemId) 
  -    throws SAXException {
  -        // This method can be called only at DOCUMENT level
  -        if(state!=S_DOC) throw new SAXException("Invalid state"+location());
  -        // Check wether this method was already invoked
  -        if(this.name!=null)
  -            throw new SAXException("Duplicate DTD definition"+location());
  -        // Remember the specified document name
  -        this.name=name;
  -        // Recreate the document element
  -        Document doc=this.factory.newDocument(name,publicId,systemId);
  -        // Copy the old document root PIs
  -        NodeList list=this.document.getChildNodes();
  -        for (int x=0; x<list.getLength(); x++) {
  -            if (list.item(x).getNodeType()!=Node.DOCUMENT_TYPE_NODE)
  -                doc.appendChild(doc.importNode(list.item(x),true));
  -        }
  -        // Declare the new document as the new real document
  -        this.document=doc;
  -        this.current=this.document;
  -        // Do a state change
  -        state=S_DTD;
  -    }
  -
  -    /**
  -     * Report the end of DTD declarations. 
  -     *
  -     * @param chars The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void endDTD() 
  -    throws SAXException {
  -        // This method can be called only at DTD level
  -        if(state!=S_DTD) throw new SAXException("Invalid state"+location());
  -        // Do a state change
  -        state=S_DOC;
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     *
  -     * @parameter uri The Namespace URI, or the empty string if the element
  -     *                has no Namespace URI or if Namespace processing is not
  -     *                being performed.
  -     * @parameter loc The local name (without prefix), or the empty
  -     *                string if Namespace processing is not being
  -     *                performed.
  -     * @parameter raw The raw XML 1.0 name (with prefix), or the empty
  -     *                string if raw names are not available.
  -     * @parameter a The attributes attached to the element. If there are no
  -     *              attributes, it shall be an empty Attributes object.
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes 
a)
  -    throws SAXException {
  -        NamespacesTable.Name n=this.namespaces.resolve(uri,raw,null,loc);
  -        // Check if this is we are defining the document root element
  -        if(state==S_DOC) {
  -            // Check if the DTD was specified
  -            if (this.name!=null) {
  -                // Check that this root element is equal to the one specified
  -                // in the DTD
  -                if (!this.name.equals(n.getQName()))
  -                    throw new SAXException("The name specified in the DTD '"+
  -                                          this.name+"' differs from the root 
"+
  -                                          "element name '"+n.getQName()+
  -                                          "'"+location());
  -            // Recreate the document since no DTD was specified
  -            } else {
  -                // Recreate the document element
  -                Document doc=this.factory.newDocument(n.getQName());
  -                // Copy the old document root PIs
  -                NodeList list=this.document.getChildNodes();
  -                for (int x=0; x<list.getLength(); x++) {
  -                    if (list.item(x).getNodeType()!=Node.DOCUMENT_TYPE_NODE)
  -                        doc.appendChild(doc.importNode(list.item(x),true));
  -                }
  -                // Declare the new document as the new real document
  -                this.document=doc;
  -                this.current=this.document;
  -            }
  -            // Change the state before continuing
  -            state=S_BODY;
  -        }
  -        // Now that we initialized the root element we can perform the 
standard
  -        // element check
  -        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  -        // Create the Element node
  -        Element e=this.document.createElementNS(n.getUri(),n.getQName());
  -        // Process all attributes
  -        for(int x=0;x<a.getLength();x++) {
  -            String auri=a.getURI(x);
  -            String aloc=a.getLocalName(x);
  -            String araw=a.getQName(x);
  -            String aval=a.getValue(x);
  -            NamespacesTable.Name 
k=this.namespaces.resolve(auri,araw,null,aloc);
  -            // Set the attribute into the element
  -            auri=k.getPrefix().length()==0?"":k.getUri();
  -            e.setAttributeNS(auri,k.getQName(),aval);
  -        }
  -        // Append the xmlns... attributes
  -        if (this.undecl.size()>0) {
  -            for (int x=0; x<this.undecl.size(); x++) {
  -                NamespacesTable.Declaration dec=null;
  -                dec=(NamespacesTable.Declaration)this.undecl.elementAt(x);
  -                String aname="xmlns";
  -                if (dec.getPrefix().length()>0) 
aname="xmlns:"+dec.getPrefix();
  -                e.setAttribute(aname,dec.getUri());
  -            }
  -            this.undecl.clear();
  -        }
  -        // Append this element to the parent and declare it current
  -        this.current.appendChild(e);
  -        this.current=e;
  -    }
  -
  -    /**
  -     * Receive notification of the end of an element.
  -     *
  -     * @parameter uri The Namespace URI, or the empty string if the element
  -     *                has no Namespace URI or if Namespace processing is not
  -     *                being performed.
  -     * @parameter local The local name (without prefix), or the empty
  -     *                  string if Namespace processing is not being
  -     *                  performed.
  -     * @parameter raw The raw XML 1.0 name (with prefix), or the empty
  -     *                string if raw names are not available.
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void endElement (String uri, String loc, String raw)
  -    throws SAXException {
  -        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  -
  -        // Check if the current node is an element
  -        if (this.current.getNodeType()!=Node.ELEMENT_NODE)
  -            throw new SAXException("Current node is not an 
element"+location());
  -
  -        // Check if the current element has the same tag name of this event
  -        NamespacesTable.Name n=this.namespaces.resolve(uri,raw,null,loc);
  -        String oldname=((Element)this.current).getTagName();
  -        if (!oldname.equals(n.getQName()))
  -            throw new SAXException("Element end tag name '"+n.getQName()+
  -                                   "' differs from start tag name '"+
  -                                   oldname+"'"+location());
  -        // Restore the old node as current
  -        this.current=this.current.getParentNode();
  -        if (this.current==null) throw new SAXException("No 
parent"+location());
  -        // Update the state if the current node is the document
  -        if (this.current==this.document) state=S_DOC;
  -    }
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping. 
  -     *
  -     * @param pre The Namespace prefix being declared.
  -     * @param uri The Namespace URI the prefix is mapped to.
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -        // This method can only called at DOCUMENT or BODY levels
  -        if((state<S_DOC)||(state>S_BODY))
  -            throw new SAXException("Invalid state"+location());
  -        // Insert this namespace in tables avoiding duplicates
  -        this.undecl.addElement(this.namespaces.addDeclaration(prefix,uri));
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping. 
  -     *
  -     * @param prefix The Namespace prefix that was being mapped.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -        // This method can only called at DOCUMENT or BODY levels
  -        if((state<S_DOC)||(state>S_BODY))
  -            throw new SAXException("Invalid state"+location());
  -        // Check if the namespace we're asked to remove was declared
  -        if (this.namespaces.removeDeclaration(prefix)==null)
  -            throw new SAXException("Prefix \""+prefix+"\" never declared"+
  -                                   location());
  -    }
  -
  -    /**
  -     * Report the start of a CDATA section. 
  -     *
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void startCDATA() 
  -    throws SAXException {
  -        // This method can only called at BODY level
  -        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  -        CDATASection cdata=this.document.createCDATASection("");
  -        // Set the CDATASection as the current element
  -        this.current.appendChild(cdata);
  -        this.current=cdata;
  -        // Do a state change        
  -        state=S_CDATA;
  -    }
  -
  -    /**
  -     * Report the end of a CDATA section. 
  -     *
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void endCDATA() 
  -    throws SAXException {
  -        // This method can only called at BODY level
  -        if(state!=S_CDATA) throw new SAXException("Invalid 
state"+location());
  -        // Set the parent of the CDATASection as the current element
  -        // We don't need to check the node type because in CDATA state the 
  -        // current element can be ONLY a CDATASection node
  -        this.current=this.current.getParentNode();
  -        if (this.current==null) throw new SAXException("No 
parent"+location());
  -        // Do a state change, and revert to the BODY state
  -        state=S_BODY;
  -    }
  -
  -    /**
  -     * Report the beginning of an entity. 
  -     *
  -     * @param chars The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void startEntity(java.lang.String name) 
  -    throws SAXException {
  -        // This method can only called at BODY level
  -        if((state!=S_BODY)&&(state!=S_DTD))
  -            throw new SAXException("Invalid state"+location());
  -        // Update the current element with the entity reference node
  -        EntityReference eref=this.document.createEntityReference(name);
  -        this.current.appendChild(eref);
  -        this.current=eref;
  -    }
  -
  -    /**
  -     * Report the end of an entity. 
  -     *
  -     * @param chars The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void endEntity(java.lang.String name) 
  -    throws SAXException {
  -        // This method can only called at BODY level
  -        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  -
  -        // Check if the current node is an entity reference
  -        if (this.current.getNodeType()!=Node.ENTITY_REFERENCE_NODE)
  -            throw new SAXException("Current node is not an entity reference"+
  -                                   location());
  -        // Check if the current element has the same tag name of this event
  -        String oldname=((EntityReference)this.current).getNodeName();
  -        if (!oldname.equals(name))
  -            throw new SAXException("Entity reference closing name '"+name+"' 
"+
  -                                   "differs from start name '"+oldname+"'"+
  -                                   location());
  -        // Restore the old node as current
  -        this.current=this.current.getParentNode();
  -        if (this.current==null) throw new SAXException("No 
parent"+location());
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     *
  -     * @param chars The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void characters (char chars[], int start, int len)
  -    throws SAXException {
  -        // This method can only called at BODY or CDATA levels
  -        if(state<S_BODY) throw new SAXException("Invalid state "+location());
  -        // Check if we are in the CDATA state
  -        String data=new String(chars,start,len);        
  -        if(state==S_CDATA) {
  -            ((CDATASection)this.current).appendData(data);
  -        } else {
  -            Text text=this.document.createTextNode(data);
  -            this.current.appendChild(text);
  -        }
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace data.
  -     *
  -     * @param chars The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void ignorableWhitespace (char chars[], int start, int len)
  -    throws SAXException {
  -        // This is because some parsers may report ignorable whitespace 
outside
  -        // the scope of the root element
  -        if(state==S_DOC) return;
  -        // This method can only called at BODY or CDATA levels
  -        if(state<S_BODY) throw new SAXException("Invalid state"+location());
  -        // Check if we are in the CDATA state
  -        if(state==S_CDATA)
  -            throw new SAXException("CDATA sections cannot contain ignorable 
"+
  -                                   "whitespace"+location());
  -        // Create and append a text node
  -        Text text=this.document.createTextNode(new String(chars,start,len));
  -        this.current.appendChild(text);
  -    }
  -
  -    /**
  -     * Receive notification of a processing instruction.
  -     *
  -     * @param target The processing instruction target.
  -     * @param data The processing instruction data.
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void processingInstruction (String target, String data)
  -    throws SAXException {
  -        // This is because Xerces reports processing instructions inside DTDs
  -        if(state==S_DTD) return;
  -        // This method can only called at DOCUMENT or BODY levels
  -        if((state<S_DOC)||(state>S_BODY))
  -            throw new SAXException("Invalid state"+location());
  -        // Create and append a processing instruction node
  -        ProcessingInstruction pi;
  -        pi=this.document.createProcessingInstruction(target,data);
  -        this.current.appendChild(pi);
  -    }
  -
  -    /**
  -     * Report an XML comment anywhere in the document. 
  -     *
  -     * @param chars The characters from the XML document.
  -     * @param start The start position in the array.
  -     * @param len The number of characters to read from the array.
  -     * @exception SAXException If this method was not called appropriately.
  -     */
  -    public void comment(char chars[], int start, int len) 
  -    throws SAXException {
  -        // This is because Xerces reports comments inside DTDs
  -        if(state==S_DTD) return;
  -        // This method can only called at DOCUMENT or BODY levels
  -        if((state<S_DOC)||(state>S_BODY))
  -            throw new SAXException("Invalid state"+location());
  -        // Create and append a comment node
  -        Comment com=this.document.createComment(new String(chars,start,len));
  -        this.current.appendChild(com);
  -    }
  -
  -    /**
  -     * Receive notification of a skipped entity. 
  -     *
  -     * @param name The name of the skipped entity. If it is a parameter 
entity,
  -     *             the name will begin with '%'.
  -     */
  -    public void skippedEntity(java.lang.String name)
  -    throws SAXException {
  -        // This method can only called at BODY level
  -        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  -        // Create and append a comment node
  -        EntityReference eref=this.document.createEntityReference(name);
  -        this.current.appendChild(eref);
  -    }
  -
  -    /**
  -     * Receive notification of a successfully completed DOM tree generation.
  -     */
  -    protected void notify(Document doc)
  -    throws SAXException {
  -        if (this.listener!=null) this.listener.notify(this.document);
  -    }
  -
  -    /** Create a location string */
  -    private String location() {
  -        if (this.locator==null) return("");
  -        String pub=this.locator.getPublicId();
  -        String sys=this.locator.getSystemId();
  -        pub=((pub==null) ? "" : ("Public ID=\""+pub+"\" "));
  -        sys=((sys==null) ? "" : ("System ID=\""+sys+"\" "));
  -        int l=this.locator.getLineNumber();
  -        int c=this.locator.getColumnNumber();
  -        String lin=((l<0) ? "" : ("line="+l+""));
  -        String col=((c<0) ? "" : (" col="+c+""));
  -        return new String(" ("+sys+pub+lin+col+" State: "+
  -                          stateName[this.state]+")");
  -    }
  -
  -    /**
  -     * The Listener interface must be implemented by those objects willing to
  -     * be notified of a successful DOM tree generation.
  -     */
  -    public static interface Listener {
  -    
  -        /**
  -         * Receive notification of a successfully completed DOM tree 
generation.
  -         */
  -        public void notify(Document doc)
  -        throws SAXException;
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.xml.util;
  +
  +import java.util.Vector;
  +import org.apache.cocoon.xml.XMLConsumer;
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.CDATASection;
  +import org.w3c.dom.Comment;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.DocumentType;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.EntityReference;
  +import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.ProcessingInstruction;
  +import org.w3c.dom.Text;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +
  +/**
  + * The <code>DOMBuilder</code> is a utility class that will generate a W3C
  + * DOM Document from SAX events.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.7 $ $Date: 2000/07/29 18:30:44 $
  + */
  +public class DOMBuilder implements XMLConsumer {
  +    /** The document was not started */
  +    private static final int S_AVAIL=0;
  +    /** State between startDTD() and endDTD() */
  +    private static final int S_DTD=1;
  +    /** State between startDocument() and endDocument() */
  +    private static final int S_DOC=2;
  +    /** State between the first startElement() and the last endElement() */
  +    private static final int S_BODY=3;
  +    /** State between the first startElement() and the last endElement() */
  +    private static final int S_CDATA=4;
  +    /** The state names (used by Location to output better error messages */
  +    private static final String stateName[]={
  +        "Available", "DTD Processing", "Document", "Body", "CDATA Section"
  +    };
  +    
  +    /** The current state */
  +    private int state=S_AVAIL;
  +    /** The locator */
  +    private Locator locator=null;
  +    /** The listener */
  +    private Listener listener=null;
  +    /** The namespaces table */
  +    private NamespacesTable namespaces=null;
  +    /** The current document */
  +    private Document document=null;
  +    /** The current node */
  +    private Node current=null;
  +    /** The document name (tag name of the root element) */
  +    private String name=null;
  +    /** The vector of namespaces declarations to include in the next element 
*/
  +    private Vector undecl=new Vector();
  +
  +    /** The document factory */
  +    protected DOMFactory factory=null;
  +
  +    /**
  +     * Construct a new instance of this TreeGenerator.
  +     */
  +    protected DOMBuilder() {
  +        this(null,null);
  +    }
  +
  +    /**
  +     * Construct a new instance of this TreeGenerator.
  +     */
  +    public DOMBuilder(DOMFactory factory) {
  +        this(factory,null);
  +    }
  +
  +    /**
  +     * Construct a new instance of this TreeGenerator.
  +     */
  +    public DOMBuilder(DOMFactory factory, Listener listener) {
  +        super();
  +        this.factory=factory;
  +        this.listener=listener;
  +    }
  +
  +    /**
  +     * Return the newly built Document.
  +     */
  +    public Document getDocument() {
  +        return(this.document);
  +    }
  +
  +    /**
  +     * Set the SAX Document Locator.
  +     *
  +     * @param loc The SAX Locator.
  +     */
  +    public void setDocumentLocator (Locator loc) {
  +        this.locator=loc;
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     *
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void startDocument()
  +    throws SAXException {
  +        if(state!=S_AVAIL) throw new SAXException("Invalid 
state"+location());
  +        // Create the namespaces table
  +        this.namespaces=new NamespacesTable();
  +        // Create a new Document empty document object
  +        this.document=this.factory.newDocument();
  +        // Set the current node
  +        this.current=this.document;
  +        // Do a state change
  +        state=S_DOC;
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of a document.
  +     *
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void endDocument ()
  +    throws SAXException {
  +        if(state!=S_DOC) throw new SAXException("Invalid state"+location());
  +        // Check if the current element is the document
  +        if(this.document!=this.current)
  +            throw new SAXException("Invalid current node"+location());
  +        // Reset the current node and the document name
  +        this.current=null;
  +        this.name=null;
  +        // Do a state change and reset the DTD flag
  +        state=S_AVAIL;
  +        // Notify the listener
  +        this.notify(this.document);
  +    }
  +
  +    /**
  +     * Report the start of DTD declarations, if any. 
  +     *
  +     * @param name The document type name.
  +     * @param publicId The declared public identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     * @param systemId The declared system identifier for the external DTD
  +     *                 subset, or null if none was declared.
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void startDTD(String name, String publicId, String systemId) 
  +    throws SAXException {
  +        // This method can be called only at DOCUMENT level
  +        if(state!=S_DOC) throw new SAXException("Invalid state"+location());
  +        // Check wether this method was already invoked
  +        if(this.name!=null)
  +            throw new SAXException("Duplicate DTD definition"+location());
  +        // Remember the specified document name
  +        this.name=name;
  +        // Recreate the document element
  +        Document doc=this.factory.newDocument(name,publicId,systemId);
  +        // Copy the old document root PIs
  +        NodeList list=this.document.getChildNodes();
  +        for (int x=0; x<list.getLength(); x++) {
  +            if (list.item(x).getNodeType()!=Node.DOCUMENT_TYPE_NODE)
  +                doc.appendChild(doc.importNode(list.item(x),true));
  +        }
  +        // Declare the new document as the new real document
  +        this.document=doc;
  +        this.current=this.document;
  +        // Do a state change
  +        state=S_DTD;
  +    }
  +
  +    /**
  +     * Report the end of DTD declarations. 
  +     *
  +     * @param chars The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void endDTD() 
  +    throws SAXException {
  +        // This method can be called only at DTD level
  +        if(state!=S_DTD) throw new SAXException("Invalid state"+location());
  +        // Do a state change
  +        state=S_DOC;
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of an element.
  +     *
  +     * @parameter uri The Namespace URI, or the empty string if the element
  +     *                has no Namespace URI or if Namespace processing is not
  +     *                being performed.
  +     * @parameter loc The local name (without prefix), or the empty
  +     *                string if Namespace processing is not being
  +     *                performed.
  +     * @parameter raw The raw XML 1.0 name (with prefix), or the empty
  +     *                string if raw names are not available.
  +     * @parameter a The attributes attached to the element. If there are no
  +     *              attributes, it shall be an empty Attributes object.
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void startElement(String uri, String loc, String raw, Attributes 
a)
  +    throws SAXException {
  +        NamespacesTable.Name n=this.namespaces.resolve(uri,raw,null,loc);
  +        // Check if this is we are defining the document root element
  +        if(state==S_DOC) {
  +            // Check if the DTD was specified
  +            if (this.name!=null) {
  +                // Check that this root element is equal to the one specified
  +                // in the DTD
  +                if (!this.name.equals(n.getQName()))
  +                    throw new SAXException("The name specified in the DTD '"+
  +                                          this.name+"' differs from the root 
"+
  +                                          "element name '"+n.getQName()+
  +                                          "'"+location());
  +            // Recreate the document since no DTD was specified
  +            } else {
  +                // Recreate the document element
  +                Document doc=this.factory.newDocument(n.getQName());
  +                // Copy the old document root PIs
  +                NodeList list=this.document.getChildNodes();
  +                for (int x=0; x<list.getLength(); x++) {
  +                    if (list.item(x).getNodeType()!=Node.DOCUMENT_TYPE_NODE)
  +                        doc.appendChild(doc.importNode(list.item(x),true));
  +                }
  +                // Declare the new document as the new real document
  +                this.document=doc;
  +                this.current=this.document;
  +            }
  +            // Change the state before continuing
  +            state=S_BODY;
  +        }
  +        // Now that we initialized the root element we can perform the 
standard
  +        // element check
  +        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  +        // Create the Element node
  +        Element e=this.document.createElementNS(n.getUri(),n.getQName());
  +        // Process all attributes
  +        for(int x=0;x<a.getLength();x++) {
  +            String auri=a.getURI(x);
  +            String aloc=a.getLocalName(x);
  +            String araw=a.getQName(x);
  +            String aval=a.getValue(x);
  +            NamespacesTable.Name 
k=this.namespaces.resolve(auri,araw,null,aloc);
  +            // Set the attribute into the element
  +            auri=k.getPrefix().length()==0?"":k.getUri();
  +            e.setAttributeNS(auri,k.getQName(),aval);
  +        }
  +        // Append the xmlns... attributes
  +        if (this.undecl.size()>0) {
  +            for (int x=0; x<this.undecl.size(); x++) {
  +                NamespacesTable.Declaration dec=null;
  +                dec=(NamespacesTable.Declaration)this.undecl.elementAt(x);
  +                String aname="xmlns";
  +                if (dec.getPrefix().length()>0) 
aname="xmlns:"+dec.getPrefix();
  +                e.setAttribute(aname,dec.getUri());
  +            }
  +            this.undecl.clear();
  +        }
  +        // Append this element to the parent and declare it current
  +        this.current.appendChild(e);
  +        this.current=e;
  +    }
  +
  +    /**
  +     * Receive notification of the end of an element.
  +     *
  +     * @parameter uri The Namespace URI, or the empty string if the element
  +     *                has no Namespace URI or if Namespace processing is not
  +     *                being performed.
  +     * @parameter local The local name (without prefix), or the empty
  +     *                  string if Namespace processing is not being
  +     *                  performed.
  +     * @parameter raw The raw XML 1.0 name (with prefix), or the empty
  +     *                string if raw names are not available.
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void endElement (String uri, String loc, String raw)
  +    throws SAXException {
  +        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  +
  +        // Check if the current node is an element
  +        if (this.current.getNodeType()!=Node.ELEMENT_NODE)
  +            throw new SAXException("Current node is not an 
element"+location());
  +
  +        // Check if the current element has the same tag name of this event
  +        NamespacesTable.Name n=this.namespaces.resolve(uri,raw,null,loc);
  +        String oldname=((Element)this.current).getTagName();
  +        if (!oldname.equals(n.getQName()))
  +            throw new SAXException("Element end tag name '"+n.getQName()+
  +                                   "' differs from start tag name '"+
  +                                   oldname+"'"+location());
  +        // Restore the old node as current
  +        this.current=this.current.getParentNode();
  +        if (this.current==null) throw new SAXException("No 
parent"+location());
  +        // Update the state if the current node is the document
  +        if (this.current==this.document) state=S_DOC;
  +    }
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping. 
  +     *
  +     * @param pre The Namespace prefix being declared.
  +     * @param uri The Namespace URI the prefix is mapped to.
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +        // This method can only called at DOCUMENT or BODY levels
  +        if((state<S_DOC)||(state>S_BODY))
  +            throw new SAXException("Invalid state"+location());
  +        // Insert this namespace in tables avoiding duplicates
  +        this.undecl.addElement(this.namespaces.addDeclaration(prefix,uri));
  +    }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping. 
  +     *
  +     * @param prefix The Namespace prefix that was being mapped.
  +     */
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +        // This method can only called at DOCUMENT or BODY levels
  +        if((state<S_DOC)||(state>S_BODY))
  +            throw new SAXException("Invalid state"+location());
  +        // Check if the namespace we're asked to remove was declared
  +        if (this.namespaces.removeDeclaration(prefix)==null)
  +            throw new SAXException("Prefix \""+prefix+"\" never declared"+
  +                                   location());
  +    }
  +
  +    /**
  +     * Report the start of a CDATA section. 
  +     *
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void startCDATA() 
  +    throws SAXException {
  +        // This method can only called at BODY level
  +        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  +        CDATASection cdata=this.document.createCDATASection("");
  +        // Set the CDATASection as the current element
  +        this.current.appendChild(cdata);
  +        this.current=cdata;
  +        // Do a state change        
  +        state=S_CDATA;
  +    }
  +
  +    /**
  +     * Report the end of a CDATA section. 
  +     *
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void endCDATA() 
  +    throws SAXException {
  +        // This method can only called at BODY level
  +        if(state!=S_CDATA) throw new SAXException("Invalid 
state"+location());
  +        // Set the parent of the CDATASection as the current element
  +        // We don't need to check the node type because in CDATA state the 
  +        // current element can be ONLY a CDATASection node
  +        this.current=this.current.getParentNode();
  +        if (this.current==null) throw new SAXException("No 
parent"+location());
  +        // Do a state change, and revert to the BODY state
  +        state=S_BODY;
  +    }
  +
  +    /**
  +     * Report the beginning of an entity. 
  +     *
  +     * @param chars The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void startEntity(java.lang.String name) 
  +    throws SAXException {
  +        // This method can only called at BODY level
  +        if((state!=S_BODY)&&(state!=S_DTD))
  +            throw new SAXException("Invalid state"+location());
  +        // Update the current element with the entity reference node
  +        EntityReference eref=this.document.createEntityReference(name);
  +        this.current.appendChild(eref);
  +        this.current=eref;
  +    }
  +
  +    /**
  +     * Report the end of an entity. 
  +     *
  +     * @param chars The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void endEntity(java.lang.String name) 
  +    throws SAXException {
  +        // This method can only called at BODY level
  +        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  +
  +        // Check if the current node is an entity reference
  +        if (this.current.getNodeType()!=Node.ENTITY_REFERENCE_NODE)
  +            throw new SAXException("Current node is not an entity reference"+
  +                                   location());
  +        // Check if the current element has the same tag name of this event
  +        String oldname=((EntityReference)this.current).getNodeName();
  +        if (!oldname.equals(name))
  +            throw new SAXException("Entity reference closing name '"+name+"' 
"+
  +                                   "differs from start name '"+oldname+"'"+
  +                                   location());
  +        // Restore the old node as current
  +        this.current=this.current.getParentNode();
  +        if (this.current==null) throw new SAXException("No 
parent"+location());
  +    }
  +
  +    /**
  +     * Receive notification of character data.
  +     *
  +     * @param chars The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void characters (char chars[], int start, int len)
  +    throws SAXException {
  +        // This method can only called at BODY or CDATA levels
  +        if(state<S_BODY) throw new SAXException("Invalid state "+location());
  +        // Check if we are in the CDATA state
  +        String data=new String(chars,start,len);        
  +        if(state==S_CDATA) {
  +            ((CDATASection)this.current).appendData(data);
  +        } else {
  +            Text text=this.document.createTextNode(data);
  +            this.current.appendChild(text);
  +        }
  +    }
  +
  +    /**
  +     * Receive notification of ignorable whitespace data.
  +     *
  +     * @param chars The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void ignorableWhitespace (char chars[], int start, int len)
  +    throws SAXException {
  +        // This is because some parsers may report ignorable whitespace 
outside
  +        // the scope of the root element
  +        if(state==S_DOC) return;
  +        // This method can only called at BODY or CDATA levels
  +        if(state<S_BODY) throw new SAXException("Invalid state"+location());
  +        // Check if we are in the CDATA state
  +        if(state==S_CDATA)
  +            throw new SAXException("CDATA sections cannot contain ignorable 
"+
  +                                   "whitespace"+location());
  +        // Create and append a text node
  +        Text text=this.document.createTextNode(new String(chars,start,len));
  +        this.current.appendChild(text);
  +    }
  +
  +    /**
  +     * Receive notification of a processing instruction.
  +     *
  +     * @param target The processing instruction target.
  +     * @param data The processing instruction data.
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void processingInstruction (String target, String data)
  +    throws SAXException {
  +        // This is because Xerces reports processing instructions inside DTDs
  +        if(state==S_DTD) return;
  +        // This method can only called at DOCUMENT or BODY levels
  +        if((state<S_DOC)||(state>S_BODY))
  +            throw new SAXException("Invalid state"+location());
  +        // Create and append a processing instruction node
  +        ProcessingInstruction pi;
  +        pi=this.document.createProcessingInstruction(target,data);
  +        this.current.appendChild(pi);
  +    }
  +
  +    /**
  +     * Report an XML comment anywhere in the document. 
  +     *
  +     * @param chars The characters from the XML document.
  +     * @param start The start position in the array.
  +     * @param len The number of characters to read from the array.
  +     * @exception SAXException If this method was not called appropriately.
  +     */
  +    public void comment(char chars[], int start, int len) 
  +    throws SAXException {
  +        // This is because Xerces reports comments inside DTDs
  +        if(state==S_DTD) return;
  +        // This method can only called at DOCUMENT or BODY levels
  +        if((state<S_DOC)||(state>S_BODY))
  +            throw new SAXException("Invalid state"+location());
  +        // Create and append a comment node
  +        Comment com=this.document.createComment(new String(chars,start,len));
  +        this.current.appendChild(com);
  +    }
  +
  +    /**
  +     * Receive notification of a skipped entity. 
  +     *
  +     * @param name The name of the skipped entity. If it is a parameter 
entity,
  +     *             the name will begin with '%'.
  +     */
  +    public void skippedEntity(java.lang.String name)
  +    throws SAXException {
  +        // This method can only called at BODY level
  +        if(state!=S_BODY) throw new SAXException("Invalid state"+location());
  +        // Create and append a comment node
  +        EntityReference eref=this.document.createEntityReference(name);
  +        this.current.appendChild(eref);
  +    }
  +
  +    /**
  +     * Receive notification of a successfully completed DOM tree generation.
  +     */
  +    protected void notify(Document doc)
  +    throws SAXException {
  +        if (this.listener!=null) this.listener.notify(this.document);
  +    }
  +
  +    /** Create a location string */
  +    private String location() {
  +        if (this.locator==null) return("");
  +        String pub=this.locator.getPublicId();
  +        String sys=this.locator.getSystemId();
  +        pub=((pub==null) ? "" : ("Public ID=\""+pub+"\" "));
  +        sys=((sys==null) ? "" : ("System ID=\""+sys+"\" "));
  +        int l=this.locator.getLineNumber();
  +        int c=this.locator.getColumnNumber();
  +        String lin=((l<0) ? "" : ("line="+l+""));
  +        String col=((c<0) ? "" : (" col="+c+""));
  +        return new String(" ("+sys+pub+lin+col+" State: "+
  +                          stateName[this.state]+")");
  +    }
  +
  +    /**
  +     * The Listener interface must be implemented by those objects willing to
  +     * be notified of a successful DOM tree generation.
  +     */
  +    public static interface Listener {
  +    
  +        /**
  +         * Receive notification of a successfully completed DOM tree 
generation.
  +         */
  +        public void notify(Document doc)
  +        throws SAXException;
  +    }
  +}
  
  
  
  1.1.2.4   +36 -36    
xml-cocoon/src/org/apache/cocoon/xml/util/Attic/DOMFactory.java
  
  Index: DOMFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/util/Attic/DOMFactory.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- DOMFactory.java   2000/07/22 20:42:05     1.1.2.3
  +++ DOMFactory.java   2000/07/29 18:30:44     1.1.2.4
  @@ -1,36 +1,36 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.xml.util;
  -
  -import org.w3c.dom.Document;
  -
  -/**
  - * This interface identifies classes producing instances of DOM
  - * <code>Document</code> objects.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:42:05 $
  - */
  -public interface DOMFactory {
  -    /** 
  -     * Create a new Document object.
  -     */
  -    public Document newDocument();
  -
  -    /** 
  -     * Create a new Document object with a specified DOCTYPE.
  -     */
  -    public Document newDocument(String name);
  -
  -    /** 
  -     * Create a new Document object with a specified DOCTYPE, public ID and 
  -     * system ID.
  -     */
  -    public Document newDocument(String name, String publicId, String 
systemId);
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.xml.util;
  +
  +import org.w3c.dom.Document;
  +
  +/**
  + * This interface identifies classes producing instances of DOM
  + * <code>Document</code> objects.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:44 $
  + */
  +public interface DOMFactory {
  +    /** 
  +     * Create a new Document object.
  +     */
  +    public Document newDocument();
  +
  +    /** 
  +     * Create a new Document object with a specified DOCTYPE.
  +     */
  +    public Document newDocument(String name);
  +
  +    /** 
  +     * Create a new Document object with a specified DOCTYPE, public ID and 
  +     * system ID.
  +     */
  +    public Document newDocument(String name, String publicId, String 
systemId);
  +}
  
  
  
  1.1.2.6   +263 -263  
xml-cocoon/src/org/apache/cocoon/xml/util/Attic/DOMStreamer.java
  
  Index: DOMStreamer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/util/Attic/DOMStreamer.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- DOMStreamer.java  2000/07/22 20:42:05     1.1.2.5
  +++ DOMStreamer.java  2000/07/29 18:30:44     1.1.2.6
  @@ -1,263 +1,263 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.xml.util;
  -
  -import java.util.Vector;
  -import org.apache.cocoon.xml.AbstractXMLProducer;
  -import org.apache.cocoon.xml.XMLConsumer;
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.CDATASection;
  -import org.w3c.dom.Comment;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.DocumentType;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.EntityReference;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.ProcessingInstruction;
  -import org.w3c.dom.Text;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.ext.LexicalHandler;
  -import org.xml.sax.helpers.AttributesImpl;
  -
  -/**
  - * The <code>DOMStreamer</code> is a utility class that will generate SAX
  - * events from a W3C DOM Document.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/22 20:42:05 $
  - */
  -public class DOMStreamer extends AbstractXMLProducer {
  -
  -    /**
  -     * Create a new <code>DOMStreamer</code> instance.
  -     */
  -    public DOMStreamer() {
  -        super();
  -    }
  -
  -    /**
  -     * Create a new <code>DOMStreamer</code> instance.
  -     */
  -    public DOMStreamer(XMLConsumer consumer) {
  -        this(consumer,consumer);
  -    }
  -
  -    /**
  -     * Create a new <code>DOMStreamer</code> instance.
  -     */
  -    public DOMStreamer(ContentHandler content) {
  -        this(content,null);
  -    }
  -
  -    /**
  -     * Create a new <code>DOMStreamer</code> instance.
  -     */
  -    public DOMStreamer(LexicalHandler lexical) {
  -        this(null,lexical);
  -    }
  -
  -    /**
  -     * Create a new <code>DOMStreamer</code> instance.
  -     */
  -    public DOMStreamer(ContentHandler content, LexicalHandler lexical) {
  -        this();
  -        super.setContentHandler(content);
  -        super.setLexicalHandler(lexical);
  -    }
  -
  -    /**
  -     * Start the production of SAX events.
  -     */
  -    public void stream(Object object)
  -    throws SAXException {
  -             try {
  -             processNode((Node)object);
  -             } catch (ClassCastException e) {
  -                     throw new SAXException(e);
  -             }
  -    }
  -    
  -    /** Process a generic node */
  -    private void processNode(Node n)
  -    throws SAXException {
  -        if (n==null) return;
  -        try { 
  -            switch (n.getNodeType()) {
  -                case Node.DOCUMENT_NODE:
  -                    this.setDocument((Document)n);
  -                    break;
  -                case Node.DOCUMENT_TYPE_NODE:
  -                    this.setDocumentType((DocumentType)n);
  -                    break;
  -                case Node.ELEMENT_NODE:
  -                    this.setElement((Element)n);
  -                    break;
  -                case Node.TEXT_NODE:
  -                    this.setText((Text)n);
  -                    break;
  -                case Node.CDATA_SECTION_NODE:
  -                    this.setCDATASection((CDATASection)n);
  -                    break;
  -                case Node.PROCESSING_INSTRUCTION_NODE:
  -                    this.setProcessingInstruction((ProcessingInstruction)n);
  -                    break;
  -                case Node.COMMENT_NODE:
  -                    this.setComment((Comment)n);
  -                    break;
  -                case Node.ENTITY_REFERENCE_NODE:
  -                    this.setEntityReference((EntityReference)n);
  -                    break;
  -                case Node.ENTITY_NODE:
  -                case Node.NOTATION_NODE:
  -                    // Do nothing for ENTITY and NOTATION nodes
  -                    break;
  -                case Node.DOCUMENT_FRAGMENT_NODE:
  -                    throw new SAXException("Unexpected Document Fragment 
node");
  -                case Node.ATTRIBUTE_NODE:
  -                    throw new SAXException("Unexpected Attribute node");
  -                default:
  -                    throw new SAXException("Unknown node type 
"+n.getNodeType()+
  -                                           " class "+n.getClass().getName());
  -            }
  -        } catch (ClassCastException e) {
  -            throw new SAXException("Error casting node to appropriate type");
  -        }
  -    }
  -
  -    /** Process all children nodes of a Node */
  -    private void processChildren(Node n)
  -    throws SAXException {
  -        NodeList l=n.getChildNodes();
  -        for(int x=0;x<l.getLength();x++) processNode(l.item(x));
  -    }
  -    
  -    /** Process a Document node */
  -    private void setDocument(Document n)
  -    throws SAXException {
  -        if (super.contentHandler!=null) super.contentHandler.startDocument();
  -        this.processChildren(n);
  -        if (super.contentHandler!=null) super.contentHandler.endDocument();
  -    }
  -    
  -    /** Process a DocumentType node */
  -    private void setDocumentType(DocumentType n)
  -    throws SAXException {
  -        if (super.lexicalHandler==null) return;
  -        
super.lexicalHandler.startDTD(n.getName(),n.getPublicId(),n.getSystemId());
  -        super.lexicalHandler.endDTD();
  -    }
  -
  -    /** Process a Element node */
  -    private void setElement(Element n)
  -    throws SAXException {
  -        if (super.contentHandler==null) {
  -            this.processChildren(n);
  -            return;
  -        }
  -        // Setup attributes
  -        AttributesImpl atts=new AttributesImpl();
  -        NamedNodeMap map=n.getAttributes();
  -        Vector nslist=new Vector();
  -        for (int x=0; x<map.getLength(); x++) {
  -            if (map.item(x).getNodeType()!=Node.ATTRIBUTE_NODE) continue;
  -            Attr a=(Attr)map.item(x);
  -            // Start getting and normalizing the values from the attribute
  -            String uri=a.getNamespaceURI(); uri=(uri==null)?"":uri;
  -            String pre=a.getPrefix();       pre=(pre==null)?"":pre;
  -            String loc=a.getLocalName();    loc=(loc==null)?"":loc;
  -            String raw=a.getName();         raw=(raw==null)?"":raw;
  -            String val=a.getValue();        val=(val==null)?"":val;
  -            // Check if we need to declare the start of a namespace prefix
  -            // Should we rely on URI instead of prefixes???
  -            if (raw.equals("xmlns") || raw.startsWith("xmlns:")) {
  -                String prefix="";
  -                if (raw.length()>5) prefix=raw.substring(6);
  -                nslist.addElement(prefix);
  -                super.contentHandler.startPrefixMapping(prefix,val);
  -            } else atts.addAttribute(uri,loc,raw,"CDATA",val);
  -        }
  -        // Get and normalize values for the Element
  -        String uri=n.getNamespaceURI(); uri=(uri==null)?"":uri;
  -        String pre=n.getPrefix();       pre=(pre==null)?"":pre;
  -        String loc=n.getLocalName();    loc=(loc==null)?"":loc;
  -        String raw=n.getTagName();      raw=(raw==null)?"":raw;
  -        super.contentHandler.startElement(uri,loc,raw,atts);
  -        this.processChildren(n);
  -        super.contentHandler.endElement(uri,loc,raw);
  -        // Rerun through attributes to check for namespaces we declared.
  -        // Should we store those before in, maybe, a hashtable?
  -        for (int x=0; x<nslist.size(); x++) {
  -            String prefix=(String)nslist.elementAt(x);
  -            super.contentHandler.endPrefixMapping(prefix);
  -        }
  -    }
  -    
  -    /** Process a Text node */
  -    private void setText(Text n)
  -    throws SAXException {
  -        char data[]=n.getData().toCharArray();
  -        if (super.contentHandler!=null)
  -            super.contentHandler.characters(data,0,data.length);
  -    }
  -    
  -    /** Process a CDATASection node */
  -    private void setCDATASection(CDATASection n)
  -    throws SAXException {
  -        if (super.lexicalHandler!=null) super.lexicalHandler.startCDATA();
  -        char data[]=n.getData().toCharArray();
  -        if (super.contentHandler!=null)
  -            super.contentHandler.characters(data,0,data.length);
  -        if (super.lexicalHandler!=null) super.lexicalHandler.endCDATA();
  -    }
  -    
  -    /** Process a ProcessingInstruction node */
  -    private void setProcessingInstruction(ProcessingInstruction n)
  -    throws SAXException {
  -        if (super.contentHandler==null) return;
  -        
super.contentHandler.processingInstruction(n.getTarget(),n.getData());
  -    }
  -    
  -    /** Process a Comment node */
  -    private void setComment(Comment n)
  -    throws SAXException {
  -        if (super.lexicalHandler==null) return;
  -        char data[]=n.getData().toCharArray();
  -        super.lexicalHandler.comment(data,0,data.length);
  -    }
  -    
  -    /** Process a EntityReference node */
  -    private void setEntityReference(EntityReference n)
  -    throws SAXException {
  -        if (n.hasChildNodes()) {
  -            if (super.lexicalHandler==null) this.processChildren(n);
  -            else {
  -                super.lexicalHandler.startEntity(n.getNodeName());
  -                this.processChildren(n);
  -                super.lexicalHandler.endEntity(n.getNodeName());
  -            }
  -            return;
  -        } else {
  -            if (n.getNodeValue()==null) {
  -                if (super.contentHandler==null) return;
  -                else super.contentHandler.skippedEntity(n.getNodeName());
  -            } else {
  -                char value[]=n.getNodeValue().toCharArray();
  -                if (super.lexicalHandler!=null)
  -                    super.lexicalHandler.startEntity(n.getNodeName());
  -                if (super.contentHandler!=null)
  -                    super.contentHandler.characters(value,0,value.length);
  -                if (super.lexicalHandler!=null)
  -                    super.lexicalHandler.endEntity(n.getNodeName());
  -            }
  -        }
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.xml.util;
  +
  +import java.util.Vector;
  +import org.apache.cocoon.xml.AbstractXMLProducer;
  +import org.apache.cocoon.xml.XMLConsumer;
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.CDATASection;
  +import org.w3c.dom.Comment;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.DocumentType;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.EntityReference;
  +import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.ProcessingInstruction;
  +import org.w3c.dom.Text;
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.ext.LexicalHandler;
  +import org.xml.sax.helpers.AttributesImpl;
  +
  +/**
  + * The <code>DOMStreamer</code> is a utility class that will generate SAX
  + * events from a W3C DOM Document.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/29 18:30:44 $
  + */
  +public class DOMStreamer extends AbstractXMLProducer {
  +
  +    /**
  +     * Create a new <code>DOMStreamer</code> instance.
  +     */
  +    public DOMStreamer() {
  +        super();
  +    }
  +
  +    /**
  +     * Create a new <code>DOMStreamer</code> instance.
  +     */
  +    public DOMStreamer(XMLConsumer consumer) {
  +        this(consumer,consumer);
  +    }
  +
  +    /**
  +     * Create a new <code>DOMStreamer</code> instance.
  +     */
  +    public DOMStreamer(ContentHandler content) {
  +        this(content,null);
  +    }
  +
  +    /**
  +     * Create a new <code>DOMStreamer</code> instance.
  +     */
  +    public DOMStreamer(LexicalHandler lexical) {
  +        this(null,lexical);
  +    }
  +
  +    /**
  +     * Create a new <code>DOMStreamer</code> instance.
  +     */
  +    public DOMStreamer(ContentHandler content, LexicalHandler lexical) {
  +        this();
  +        super.setContentHandler(content);
  +        super.setLexicalHandler(lexical);
  +    }
  +
  +    /**
  +     * Start the production of SAX events.
  +     */
  +    public void stream(Object object)
  +    throws SAXException {
  +             try {
  +             processNode((Node)object);
  +             } catch (ClassCastException e) {
  +                     throw new SAXException(e);
  +             }
  +    }
  +    
  +    /** Process a generic node */
  +    private void processNode(Node n)
  +    throws SAXException {
  +        if (n==null) return;
  +        try { 
  +            switch (n.getNodeType()) {
  +                case Node.DOCUMENT_NODE:
  +                    this.setDocument((Document)n);
  +                    break;
  +                case Node.DOCUMENT_TYPE_NODE:
  +                    this.setDocumentType((DocumentType)n);
  +                    break;
  +                case Node.ELEMENT_NODE:
  +                    this.setElement((Element)n);
  +                    break;
  +                case Node.TEXT_NODE:
  +                    this.setText((Text)n);
  +                    break;
  +                case Node.CDATA_SECTION_NODE:
  +                    this.setCDATASection((CDATASection)n);
  +                    break;
  +                case Node.PROCESSING_INSTRUCTION_NODE:
  +                    this.setProcessingInstruction((ProcessingInstruction)n);
  +                    break;
  +                case Node.COMMENT_NODE:
  +                    this.setComment((Comment)n);
  +                    break;
  +                case Node.ENTITY_REFERENCE_NODE:
  +                    this.setEntityReference((EntityReference)n);
  +                    break;
  +                case Node.ENTITY_NODE:
  +                case Node.NOTATION_NODE:
  +                    // Do nothing for ENTITY and NOTATION nodes
  +                    break;
  +                case Node.DOCUMENT_FRAGMENT_NODE:
  +                    throw new SAXException("Unexpected Document Fragment 
node");
  +                case Node.ATTRIBUTE_NODE:
  +                    throw new SAXException("Unexpected Attribute node");
  +                default:
  +                    throw new SAXException("Unknown node type 
"+n.getNodeType()+
  +                                           " class "+n.getClass().getName());
  +            }
  +        } catch (ClassCastException e) {
  +            throw new SAXException("Error casting node to appropriate type");
  +        }
  +    }
  +
  +    /** Process all children nodes of a Node */
  +    private void processChildren(Node n)
  +    throws SAXException {
  +        NodeList l=n.getChildNodes();
  +        for(int x=0;x<l.getLength();x++) processNode(l.item(x));
  +    }
  +    
  +    /** Process a Document node */
  +    private void setDocument(Document n)
  +    throws SAXException {
  +        if (super.contentHandler!=null) super.contentHandler.startDocument();
  +        this.processChildren(n);
  +        if (super.contentHandler!=null) super.contentHandler.endDocument();
  +    }
  +    
  +    /** Process a DocumentType node */
  +    private void setDocumentType(DocumentType n)
  +    throws SAXException {
  +        if (super.lexicalHandler==null) return;
  +        
super.lexicalHandler.startDTD(n.getName(),n.getPublicId(),n.getSystemId());
  +        super.lexicalHandler.endDTD();
  +    }
  +
  +    /** Process a Element node */
  +    private void setElement(Element n)
  +    throws SAXException {
  +        if (super.contentHandler==null) {
  +            this.processChildren(n);
  +            return;
  +        }
  +        // Setup attributes
  +        AttributesImpl atts=new AttributesImpl();
  +        NamedNodeMap map=n.getAttributes();
  +        Vector nslist=new Vector();
  +        for (int x=0; x<map.getLength(); x++) {
  +            if (map.item(x).getNodeType()!=Node.ATTRIBUTE_NODE) continue;
  +            Attr a=(Attr)map.item(x);
  +            // Start getting and normalizing the values from the attribute
  +            String uri=a.getNamespaceURI(); uri=(uri==null)?"":uri;
  +            String pre=a.getPrefix();       pre=(pre==null)?"":pre;
  +            String loc=a.getLocalName();    loc=(loc==null)?"":loc;
  +            String raw=a.getName();         raw=(raw==null)?"":raw;
  +            String val=a.getValue();        val=(val==null)?"":val;
  +            // Check if we need to declare the start of a namespace prefix
  +            // Should we rely on URI instead of prefixes???
  +            if (raw.equals("xmlns") || raw.startsWith("xmlns:")) {
  +                String prefix="";
  +                if (raw.length()>5) prefix=raw.substring(6);
  +                nslist.addElement(prefix);
  +                super.contentHandler.startPrefixMapping(prefix,val);
  +            } else atts.addAttribute(uri,loc,raw,"CDATA",val);
  +        }
  +        // Get and normalize values for the Element
  +        String uri=n.getNamespaceURI(); uri=(uri==null)?"":uri;
  +        String pre=n.getPrefix();       pre=(pre==null)?"":pre;
  +        String loc=n.getLocalName();    loc=(loc==null)?"":loc;
  +        String raw=n.getTagName();      raw=(raw==null)?"":raw;
  +        super.contentHandler.startElement(uri,loc,raw,atts);
  +        this.processChildren(n);
  +        super.contentHandler.endElement(uri,loc,raw);
  +        // Rerun through attributes to check for namespaces we declared.
  +        // Should we store those before in, maybe, a hashtable?
  +        for (int x=0; x<nslist.size(); x++) {
  +            String prefix=(String)nslist.elementAt(x);
  +            super.contentHandler.endPrefixMapping(prefix);
  +        }
  +    }
  +    
  +    /** Process a Text node */
  +    private void setText(Text n)
  +    throws SAXException {
  +        char data[]=n.getData().toCharArray();
  +        if (super.contentHandler!=null)
  +            super.contentHandler.characters(data,0,data.length);
  +    }
  +    
  +    /** Process a CDATASection node */
  +    private void setCDATASection(CDATASection n)
  +    throws SAXException {
  +        if (super.lexicalHandler!=null) super.lexicalHandler.startCDATA();
  +        char data[]=n.getData().toCharArray();
  +        if (super.contentHandler!=null)
  +            super.contentHandler.characters(data,0,data.length);
  +        if (super.lexicalHandler!=null) super.lexicalHandler.endCDATA();
  +    }
  +    
  +    /** Process a ProcessingInstruction node */
  +    private void setProcessingInstruction(ProcessingInstruction n)
  +    throws SAXException {
  +        if (super.contentHandler==null) return;
  +        
super.contentHandler.processingInstruction(n.getTarget(),n.getData());
  +    }
  +    
  +    /** Process a Comment node */
  +    private void setComment(Comment n)
  +    throws SAXException {
  +        if (super.lexicalHandler==null) return;
  +        char data[]=n.getData().toCharArray();
  +        super.lexicalHandler.comment(data,0,data.length);
  +    }
  +    
  +    /** Process a EntityReference node */
  +    private void setEntityReference(EntityReference n)
  +    throws SAXException {
  +        if (n.hasChildNodes()) {
  +            if (super.lexicalHandler==null) this.processChildren(n);
  +            else {
  +                super.lexicalHandler.startEntity(n.getNodeName());
  +                this.processChildren(n);
  +                super.lexicalHandler.endEntity(n.getNodeName());
  +            }
  +            return;
  +        } else {
  +            if (n.getNodeValue()==null) {
  +                if (super.contentHandler==null) return;
  +                else super.contentHandler.skippedEntity(n.getNodeName());
  +            } else {
  +                char value[]=n.getNodeValue().toCharArray();
  +                if (super.lexicalHandler!=null)
  +                    super.lexicalHandler.startEntity(n.getNodeName());
  +                if (super.contentHandler!=null)
  +                    super.contentHandler.characters(value,0,value.length);
  +                if (super.lexicalHandler!=null)
  +                    super.lexicalHandler.endEntity(n.getNodeName());
  +            }
  +        }
  +    }
  +}
  
  
  
  1.1.2.5   +196 -196  
xml-cocoon/src/org/apache/cocoon/xml/util/Attic/DocumentHandlerAdapter.java
  
  Index: DocumentHandlerAdapter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/util/Attic/DocumentHandlerAdapter.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- DocumentHandlerAdapter.java       2000/07/22 20:42:05     1.1.2.4
  +++ DocumentHandlerAdapter.java       2000/07/29 18:30:44     1.1.2.5
  @@ -1,196 +1,196 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.xml.util;
  -
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.Vector;
  -import org.apache.cocoon.xml.AbstractXMLProducer;
  -import org.apache.cocoon.xml.XMLConsumer;
  -import org.xml.sax.AttributeList;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.DocumentHandler;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.helpers.AttributesImpl;
  -
  -/**
  - * This class is an utility class &quot;adapting&quot; a SAX version 1.0
  - * <code>DocumentHandler</code>, to SAX version 2 
<code>ContentHandler</code>.
  - * <br>
  - * This class fully supports XML namespaces, converting <code>xmlns</code> 
and
  - * <code>xmlns:...</code> element attributes into appropriate
  - * <code>startPrefixMapping(...)</code> and 
<code>endPrefixMapping(...)</code>
  - * calls.
  - * 
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:42:05 $
  - */
  -public class DocumentHandlerAdapter extends AbstractXMLProducer
  -implements DocumentHandler {
  -
  -    /** The element-oriented namespace-uri stacked mapping table. */
  -    private Hashtable stackedNS=new Hashtable();
  -    /** The current namespaces table. */
  -    private NamespacesTable namespaces=new NamespacesTable();
  -    /** The current stack depth.*/
  -    private int stack=0;
  -
  -    /**
  -     * Create a new <code>DocumentHandlerAdapter</code> instance.
  -     */
  -    public DocumentHandlerAdapter() {
  -        super();
  -    }
  -
  -    /**
  -     * Create a new <code>DocumentHandlerAdapter</code> instance.
  -     */
  -    public DocumentHandlerAdapter(XMLConsumer consumer) {
  -        this();
  -        super.setConsumer(consumer);
  -    }
  -
  -    /**
  -     * Create a new <code>DocumentHandlerAdapter</code> instance.
  -     */
  -    public DocumentHandlerAdapter(ContentHandler content) {
  -        this();
  -        super.setContentHandler(content);
  -    }
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     */
  -    public void setDocumentLocator (Locator locator) {
  -        if (super.contentHandler==null) return;
  -        else super.contentHandler.setDocumentLocator(locator);
  -    }
  -    
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument ()
  -     throws SAXException {
  -        if (super.contentHandler==null)
  -            throw new SAXException("ContentHandler not set");
  -        super.contentHandler.startDocument();
  -    }    
  -    
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument ()
  -     throws SAXException {
  -        if (super.contentHandler==null)
  -            throw new SAXException("ContentHandler not set");
  -        super.contentHandler.endDocument();
  -    }    
  -    
  -    /**
  -     * Receive notification of the beginning of an element.
  -     */
  -    public void startElement (String name, AttributeList a)
  -     throws SAXException {
  -        if (super.contentHandler==null)
  -            throw new SAXException("ContentHandler not set");
  -        // Check for namespace declarations (two loops because we're not sure
  -        // about attribute ordering.
  -        AttributesImpl a2=new AttributesImpl();
  -        Vector nslist=new Vector();
  -        for (int x=0; x<a.getLength(); x++) {
  -            String att=a.getName(x);
  -            String uri=a.getValue(x);
  -            if (att.equals("xmlns") || att.startsWith("xmlns:")) {
  -                String pre="";
  -                if (att.length()>5) pre=att.substring(6);
  -                this.namespaces.addDeclaration(pre,uri);
  -                nslist.addElement(pre);
  -                super.contentHandler.startPrefixMapping(pre,uri);
  -            }
  -        }
  -        if (nslist.size()>0) this.stackedNS.put(new 
Integer(this.stack),nslist);
  -        // Resolve the element namespaced name
  -        NamespacesTable.Name w=this.namespaces.resolve(null,name,null,null);
  -        // Second loop through attributes to fill AttributesImpl
  -        for (int x=0; x<a.getLength(); x++) {
  -            String att=a.getName(x);
  -            if (att.equals("xmlns") || att.startsWith("xmlns:")) continue;
  -            // We have something different from a namespace declaration
  -            NamespacesTable.Name 
k=this.namespaces.resolve(null,att,null,null);
  -            String val=a.getValue(x);
  -            String typ=a.getType(x);
  -            String uri=k.getPrefix().length()==0?"":k.getUri();
  -            a2.addAttribute(uri,k.getLocalName(),k.getQName(),typ,val);
  -        }
  -        // Notify the contentHandler
  -        super.contentHandler.startElement(w.getUri(),w.getLocalName(),
  -                                          w.getQName(),a2);
  -        // Forward on the stack
  -        this.stack++;
  -    }    
  -    
  -    /**
  -     * Receive notification of the end of an element.
  -     */
  -    public void endElement (String name)
  -     throws SAXException {
  -        if (super.contentHandler==null)
  -            throw new SAXException("ContentHandler not set");
  -         // Get back on the stack
  -         this.stack--;
  -        // Notify the contentHandler
  -        NamespacesTable.Name w=this.namespaces.resolve(null,name,null,null);
  -        super.contentHandler.endElement(w.getUri(),w.getLocalName(),
  -                                        w.getQName());
  -        // Undeclare namespaces
  -        Vector nslist=(Vector)this.stackedNS.remove(new Integer(this.stack));
  -        if (nslist==null) return;
  -        if (nslist.size()==0) return;
  -        Enumeration e=nslist.elements();
  -        while (e.hasMoreElements()) {
  -            String prefix=(String)e.nextElement();
  -            NamespacesTable.Declaration 
d=namespaces.removeDeclaration(prefix);
  -            super.contentHandler.endPrefixMapping(d.getPrefix());
  -        }
  -    }    
  -    
  -    
  -    /**
  -     * Receive notification of character data.
  -     */
  -    public void characters (char ch[], int start, int len)
  -     throws SAXException {
  -        if (super.contentHandler==null)
  -            throw new SAXException("ContentHandler not set");
  -        super.contentHandler.characters(ch,start,len);
  -    }    
  -    
  -    
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     */
  -    public void ignorableWhitespace (char ch[], int start, int len)
  -     throws SAXException {
  -        if (super.contentHandler==null)
  -            throw new SAXException("ContentHandler not set");
  -        super.contentHandler.ignorableWhitespace(ch,start,len);
  -    }    
  -    
  -    
  -    /**
  -     * Receive notification of a processing instruction.
  -     */
  -    public void processingInstruction (String target, String data)
  -     throws SAXException {
  -        if (super.contentHandler==null)
  -            throw new SAXException("ContentHandler not set");
  -        super.contentHandler.processingInstruction(target,data);
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.xml.util;
  +
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import java.util.Vector;
  +import org.apache.cocoon.xml.AbstractXMLProducer;
  +import org.apache.cocoon.xml.XMLConsumer;
  +import org.xml.sax.AttributeList;
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.DocumentHandler;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.helpers.AttributesImpl;
  +
  +/**
  + * This class is an utility class &quot;adapting&quot; a SAX version 1.0
  + * <code>DocumentHandler</code>, to SAX version 2 
<code>ContentHandler</code>.
  + * <br>
  + * This class fully supports XML namespaces, converting <code>xmlns</code> 
and
  + * <code>xmlns:...</code> element attributes into appropriate
  + * <code>startPrefixMapping(...)</code> and 
<code>endPrefixMapping(...)</code>
  + * calls.
  + * 
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/29 18:30:44 $
  + */
  +public class DocumentHandlerAdapter extends AbstractXMLProducer
  +implements DocumentHandler {
  +
  +    /** The element-oriented namespace-uri stacked mapping table. */
  +    private Hashtable stackedNS=new Hashtable();
  +    /** The current namespaces table. */
  +    private NamespacesTable namespaces=new NamespacesTable();
  +    /** The current stack depth.*/
  +    private int stack=0;
  +
  +    /**
  +     * Create a new <code>DocumentHandlerAdapter</code> instance.
  +     */
  +    public DocumentHandlerAdapter() {
  +        super();
  +    }
  +
  +    /**
  +     * Create a new <code>DocumentHandlerAdapter</code> instance.
  +     */
  +    public DocumentHandlerAdapter(XMLConsumer consumer) {
  +        this();
  +        super.setConsumer(consumer);
  +    }
  +
  +    /**
  +     * Create a new <code>DocumentHandlerAdapter</code> instance.
  +     */
  +    public DocumentHandlerAdapter(ContentHandler content) {
  +        this();
  +        super.setContentHandler(content);
  +    }
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     */
  +    public void setDocumentLocator (Locator locator) {
  +        if (super.contentHandler==null) return;
  +        else super.contentHandler.setDocumentLocator(locator);
  +    }
  +    
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +    public void startDocument ()
  +     throws SAXException {
  +        if (super.contentHandler==null)
  +            throw new SAXException("ContentHandler not set");
  +        super.contentHandler.startDocument();
  +    }    
  +    
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +    public void endDocument ()
  +     throws SAXException {
  +        if (super.contentHandler==null)
  +            throw new SAXException("ContentHandler not set");
  +        super.contentHandler.endDocument();
  +    }    
  +    
  +    /**
  +     * Receive notification of the beginning of an element.
  +     */
  +    public void startElement (String name, AttributeList a)
  +     throws SAXException {
  +        if (super.contentHandler==null)
  +            throw new SAXException("ContentHandler not set");
  +        // Check for namespace declarations (two loops because we're not sure
  +        // about attribute ordering.
  +        AttributesImpl a2=new AttributesImpl();
  +        Vector nslist=new Vector();
  +        for (int x=0; x<a.getLength(); x++) {
  +            String att=a.getName(x);
  +            String uri=a.getValue(x);
  +            if (att.equals("xmlns") || att.startsWith("xmlns:")) {
  +                String pre="";
  +                if (att.length()>5) pre=att.substring(6);
  +                this.namespaces.addDeclaration(pre,uri);
  +                nslist.addElement(pre);
  +                super.contentHandler.startPrefixMapping(pre,uri);
  +            }
  +        }
  +        if (nslist.size()>0) this.stackedNS.put(new 
Integer(this.stack),nslist);
  +        // Resolve the element namespaced name
  +        NamespacesTable.Name w=this.namespaces.resolve(null,name,null,null);
  +        // Second loop through attributes to fill AttributesImpl
  +        for (int x=0; x<a.getLength(); x++) {
  +            String att=a.getName(x);
  +            if (att.equals("xmlns") || att.startsWith("xmlns:")) continue;
  +            // We have something different from a namespace declaration
  +            NamespacesTable.Name 
k=this.namespaces.resolve(null,att,null,null);
  +            String val=a.getValue(x);
  +            String typ=a.getType(x);
  +            String uri=k.getPrefix().length()==0?"":k.getUri();
  +            a2.addAttribute(uri,k.getLocalName(),k.getQName(),typ,val);
  +        }
  +        // Notify the contentHandler
  +        super.contentHandler.startElement(w.getUri(),w.getLocalName(),
  +                                          w.getQName(),a2);
  +        // Forward on the stack
  +        this.stack++;
  +    }    
  +    
  +    /**
  +     * Receive notification of the end of an element.
  +     */
  +    public void endElement (String name)
  +     throws SAXException {
  +        if (super.contentHandler==null)
  +            throw new SAXException("ContentHandler not set");
  +         // Get back on the stack
  +         this.stack--;
  +        // Notify the contentHandler
  +        NamespacesTable.Name w=this.namespaces.resolve(null,name,null,null);
  +        super.contentHandler.endElement(w.getUri(),w.getLocalName(),
  +                                        w.getQName());
  +        // Undeclare namespaces
  +        Vector nslist=(Vector)this.stackedNS.remove(new Integer(this.stack));
  +        if (nslist==null) return;
  +        if (nslist.size()==0) return;
  +        Enumeration e=nslist.elements();
  +        while (e.hasMoreElements()) {
  +            String prefix=(String)e.nextElement();
  +            NamespacesTable.Declaration 
d=namespaces.removeDeclaration(prefix);
  +            super.contentHandler.endPrefixMapping(d.getPrefix());
  +        }
  +    }    
  +    
  +    
  +    /**
  +     * Receive notification of character data.
  +     */
  +    public void characters (char ch[], int start, int len)
  +     throws SAXException {
  +        if (super.contentHandler==null)
  +            throw new SAXException("ContentHandler not set");
  +        super.contentHandler.characters(ch,start,len);
  +    }    
  +    
  +    
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     */
  +    public void ignorableWhitespace (char ch[], int start, int len)
  +     throws SAXException {
  +        if (super.contentHandler==null)
  +            throw new SAXException("ContentHandler not set");
  +        super.contentHandler.ignorableWhitespace(ch,start,len);
  +    }    
  +    
  +    
  +    /**
  +     * Receive notification of a processing instruction.
  +     */
  +    public void processingInstruction (String target, String data)
  +     throws SAXException {
  +        if (super.contentHandler==null)
  +            throw new SAXException("ContentHandler not set");
  +        super.contentHandler.processingInstruction(target,data);
  +    }
  +}
  
  
  
  1.1.2.7   +189 -189  
xml-cocoon/src/org/apache/cocoon/xml/util/Attic/DocumentHandlerWrapper.java
  
  Index: DocumentHandlerWrapper.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/util/Attic/DocumentHandlerWrapper.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- DocumentHandlerWrapper.java       2000/07/25 18:48:50     1.1.2.6
  +++ DocumentHandlerWrapper.java       2000/07/29 18:30:45     1.1.2.7
  @@ -1,189 +1,189 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.xml.util;
  -
  -import java.util.Vector;
  -import org.apache.cocoon.xml.AbstractXMLConsumer;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.DocumentHandler;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.helpers.AttributeListImpl;
  -
  -/**
  - * This class is an utility class &quot;wrapping&quot; around a SAX version 
1.0
  - * <code>DocumentHandler</code> and forwarding it those events received 
throug
  - * its <code>XMLConsumers</code> interface.
  - * <br>
  - * This class fully supports XML namespaces, converting 
  - * <code>startPrefixMapping(...)</code> and 
<code>endPrefixMapping(...)</code>
  - * calls into appropriate <code>xmlns</code> and <code>xmlns:...</code> 
element
  - * attributes.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/07/25 18:48:50 $
  - */
  -public class DocumentHandlerWrapper extends AbstractXMLConsumer {
  -
  -    /** The current namespaces table. */
  -    private NamespacesTable namespaces=new NamespacesTable();
  -    /** The vector of namespaces declarations to include in the next 
element. */
  -    private Vector undecl=new Vector();
  -
  -    /** The current <code>DocumentHandler</code>. */
  -    protected DocumentHandler documentHandler=null;
  -
  -    /**
  -     * Create a new <code>DocumentHandlerWrapper</code> instance.
  -     */
  -    public DocumentHandlerWrapper() {
  -        super();
  -     }
  -
  -    /**
  -     * Create a new <code>DocumentHandlerWrapper</code> instance.
  -     */
  -    public DocumentHandlerWrapper(DocumentHandler document) {
  -        this();
  -        this.setDocumentHandler(document);
  -    }
  -
  -    /**
  -     * Set the <code>DocumentHandler</code> that will receive XML data.
  -     *
  -     * @exception IllegalStateException If the <code>DocumentHandler</code>
  -     *                                  was already set.
  -     */
  -    public void setDocumentHandler(DocumentHandler document)
  -    throws IllegalStateException {
  -        if (this.documentHandler!=null) throw new IllegalStateException();
  -        this.documentHandler=document;
  -    }
  -
  -    /**
  -     * Receive an object for locating the origin of SAX document events.
  -     */
  -    public void setDocumentLocator (Locator locator) {
  -        if (this.documentHandler==null) return;
  -        else this.documentHandler.setDocumentLocator(locator);
  -    }
  -    
  -    /**
  -     * Receive notification of the beginning of a document.
  -     */
  -    public void startDocument ()
  -     throws SAXException {
  -        if (this.documentHandler==null)
  -            throw new SAXException("DocumentHandler not set");
  -        this.documentHandler.startDocument();
  -    }    
  -    
  -    /**
  -     * Receive notification of the end of a document.
  -     */
  -    public void endDocument ()
  -     throws SAXException {
  -        if (this.documentHandler==null)
  -            throw new SAXException("DocumentHandler not set");
  -        this.documentHandler.endDocument();
  -    }    
  -
  -    /**
  -     * Begin the scope of a prefix-URI Namespace mapping.
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -    throws SAXException {
  -        this.undecl.addElement(this.namespaces.addDeclaration(prefix,uri));
  -    }
  -
  -    /**
  -     * End the scope of a prefix-URI mapping.
  -     */
  -    public void endPrefixMapping(String prefix)
  -    throws SAXException {
  -        if (namespaces.removeDeclaration(prefix)==null)
  -            throw new SAXException("Namespace prefix \""+prefix+
  -                                   "\" never declared");
  -    }
  -
  -    /**
  -     * Receive notification of the beginning of an element.
  -     */
  -    public void startElement(String uri, String loc, String raw, Attributes 
a)
  -    throws SAXException {
  -        if (this.documentHandler==null)
  -            throw new SAXException("DocumentHandler not set");
  -        NamespacesTable.Name name=this.namespaces.resolve(uri,raw,null,loc);
  -        // Create the AttributeList
  -        AttributeListImpl a2=new AttributeListImpl();
  -        // Set the xmlns:...="..." attributes
  -        if (this.undecl.size()>0) {
  -            for (int x=0; x<this.undecl.size(); x++) {
  -                NamespacesTable.Declaration dec=null;
  -                dec=(NamespacesTable.Declaration)this.undecl.elementAt(x);
  -                String aname="xmlns";
  -                if (dec.getPrefix().length()>0) 
aname="xmlns:"+dec.getPrefix();
  -                a2.addAttribute(aname,"CDATA",dec.getUri());
  -            }
  -            this.undecl.clear();
  -        }
  -        // Set the real attributes
  -        for (int x=0; x<a.getLength(); x++) {
  -            NamespacesTable.Name aname=namespaces.resolve(a.getURI(x),
  -                                                          a.getQName(x),
  -                                                          null,
  -                                                          a.getLocalName(x));
  -            a2.addAttribute(aname.getQName(),a.getType(x),a.getValue(x));
  -        }
  -        // Call the document handler startElement() method.
  -        this.documentHandler.startElement(name.getQName(),a2);
  -    }
  -
  -
  -    /**
  -     * Receive notification of the end of an element.
  -     */
  -    public void endElement(String uri, String loc, String raw)
  -    throws SAXException {
  -        if (this.documentHandler==null)
  -            throw new SAXException("DocumentHandler not set");
  -        NamespacesTable.Name name=this.namespaces.resolve(uri,raw,null,loc);
  -        this.documentHandler.endElement(name.getQName());
  -    }
  -
  -    /**
  -     * Receive notification of character data.
  -     */
  -    public void characters(char ch[], int start, int len)
  -    throws SAXException {
  -        if (this.documentHandler==null)
  -            throw new SAXException("DocumentHandler not set");
  -        this.documentHandler.characters(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of ignorable whitespace in element content.
  -     */
  -    public void ignorableWhitespace(char ch[], int start, int len)
  -    throws SAXException {
  -        if (this.documentHandler==null)
  -            throw new SAXException("DocumentHandler not set");
  -        this.documentHandler.ignorableWhitespace(ch,start,len);
  -    }
  -
  -    /**
  -     * Receive notification of a processing instruction.
  -     */
  -    public void processingInstruction(String target, String data)
  -    throws SAXException {
  -        if (this.documentHandler==null)
  -            throw new SAXException("DocumentHandler not set");
  -        this.documentHandler.processingInstruction(target,data);
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.xml.util;
  +
  +import java.util.Vector;
  +import org.apache.cocoon.xml.AbstractXMLConsumer;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.DocumentHandler;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.helpers.AttributeListImpl;
  +
  +/**
  + * This class is an utility class &quot;wrapping&quot; around a SAX version 
1.0
  + * <code>DocumentHandler</code> and forwarding it those events received 
throug
  + * its <code>XMLConsumers</code> interface.
  + * <br>
  + * This class fully supports XML namespaces, converting 
  + * <code>startPrefixMapping(...)</code> and 
<code>endPrefixMapping(...)</code>
  + * calls into appropriate <code>xmlns</code> and <code>xmlns:...</code> 
element
  + * attributes.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.7 $ $Date: 2000/07/29 18:30:45 $
  + */
  +public class DocumentHandlerWrapper extends AbstractXMLConsumer {
  +
  +    /** The current namespaces table. */
  +    private NamespacesTable namespaces=new NamespacesTable();
  +    /** The vector of namespaces declarations to include in the next 
element. */
  +    private Vector undecl=new Vector();
  +
  +    /** The current <code>DocumentHandler</code>. */
  +    protected DocumentHandler documentHandler=null;
  +
  +    /**
  +     * Create a new <code>DocumentHandlerWrapper</code> instance.
  +     */
  +    public DocumentHandlerWrapper() {
  +        super();
  +     }
  +
  +    /**
  +     * Create a new <code>DocumentHandlerWrapper</code> instance.
  +     */
  +    public DocumentHandlerWrapper(DocumentHandler document) {
  +        this();
  +        this.setDocumentHandler(document);
  +    }
  +
  +    /**
  +     * Set the <code>DocumentHandler</code> that will receive XML data.
  +     *
  +     * @exception IllegalStateException If the <code>DocumentHandler</code>
  +     *                                  was already set.
  +     */
  +    public void setDocumentHandler(DocumentHandler document)
  +    throws IllegalStateException {
  +        if (this.documentHandler!=null) throw new IllegalStateException();
  +        this.documentHandler=document;
  +    }
  +
  +    /**
  +     * Receive an object for locating the origin of SAX document events.
  +     */
  +    public void setDocumentLocator (Locator locator) {
  +        if (this.documentHandler==null) return;
  +        else this.documentHandler.setDocumentLocator(locator);
  +    }
  +    
  +    /**
  +     * Receive notification of the beginning of a document.
  +     */
  +    public void startDocument ()
  +     throws SAXException {
  +        if (this.documentHandler==null)
  +            throw new SAXException("DocumentHandler not set");
  +        this.documentHandler.startDocument();
  +    }    
  +    
  +    /**
  +     * Receive notification of the end of a document.
  +     */
  +    public void endDocument ()
  +     throws SAXException {
  +        if (this.documentHandler==null)
  +            throw new SAXException("DocumentHandler not set");
  +        this.documentHandler.endDocument();
  +    }    
  +
  +    /**
  +     * Begin the scope of a prefix-URI Namespace mapping.
  +     */
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +        this.undecl.addElement(this.namespaces.addDeclaration(prefix,uri));
  +    }
  +
  +    /**
  +     * End the scope of a prefix-URI mapping.
  +     */
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +        if (namespaces.removeDeclaration(prefix)==null)
  +            throw new SAXException("Namespace prefix \""+prefix+
  +                                   "\" never declared");
  +    }
  +
  +    /**
  +     * Receive notification of the beginning of an element.
  +     */
  +    public void startElement(String uri, String loc, String raw, Attributes 
a)
  +    throws SAXException {
  +        if (this.documentHandler==null)
  +            throw new SAXException("DocumentHandler not set");
  +        NamespacesTable.Name name=this.namespaces.resolve(uri,raw,null,loc);
  +        // Create the AttributeList
  +        AttributeListImpl a2=new AttributeListImpl();
  +        // Set the xmlns:...="..." attributes
  +        if (this.undecl.size()>0) {
  +            for (int x=0; x<this.undecl.size(); x++) {
  +                NamespacesTable.Declaration dec=null;
  +                dec=(NamespacesTable.Declaration)this.undecl.elementAt(x);
  +                String aname="xmlns";
  +                if (dec.getPrefix().length()>0) 
aname="xmlns:"+dec.getPrefix();
  +                a2.addAttribute(aname,"CDATA",dec.getUri());
  +            }
  +            this.undecl.clear();
  +        }
  +        // Set the real attributes
  +        for (int x=0; x<a.getLength(); x++) {
  +            NamespacesTable.Name aname=namespaces.resolve(a.getURI(x),
  +                                                          a.getQName(x),
  +                                                          null,
  +                                                          a.getLocalName(x));
  +            a2.addAttribute(aname.getQName(),a.getType(x),a.getValue(x));
  +        }
  +        // Call the document handler startElement() method.
  +        this.documentHandler.startElement(name.getQName(),a2);
  +    }
  +
  +
  +    /**
  +     * Receive notification of the end of an element.
  +     */
  +    public void endElement(String uri, String loc, String raw)
  +    throws SAXException {
  +        if (this.documentHandler==null)
  +            throw new SAXException("DocumentHandler not set");
  +        NamespacesTable.Name name=this.namespaces.resolve(uri,raw,null,loc);
  +        this.documentHandler.endElement(name.getQName());
  +    }
  +
  +    /**
  +     * Receive notification of character data.
  +     */
  +    public void characters(char ch[], int start, int len)
  +    throws SAXException {
  +        if (this.documentHandler==null)
  +            throw new SAXException("DocumentHandler not set");
  +        this.documentHandler.characters(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of ignorable whitespace in element content.
  +     */
  +    public void ignorableWhitespace(char ch[], int start, int len)
  +    throws SAXException {
  +        if (this.documentHandler==null)
  +            throw new SAXException("DocumentHandler not set");
  +        this.documentHandler.ignorableWhitespace(ch,start,len);
  +    }
  +
  +    /**
  +     * Receive notification of a processing instruction.
  +     */
  +    public void processingInstruction(String target, String data)
  +    throws SAXException {
  +        if (this.documentHandler==null)
  +            throw new SAXException("DocumentHandler not set");
  +        this.documentHandler.processingInstruction(target,data);
  +    }
  +}
  
  
  
  1.1.2.5   +305 -305  
xml-cocoon/src/org/apache/cocoon/xml/util/Attic/NamespacesTable.java
  
  Index: NamespacesTable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/util/Attic/NamespacesTable.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- NamespacesTable.java      2000/07/22 20:42:05     1.1.2.4
  +++ NamespacesTable.java      2000/07/29 18:30:45     1.1.2.5
  @@ -1,305 +1,305 @@
  
-/*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  - * ------------------------------------------------------------------------- 
*
  - * This software is published under the terms of the Apache Software License 
*
  - * version 1.1, a copy of which has been included  with this distribution in 
*
  - * the LICENSE file.                                                         
*
  - 
*****************************************************************************/
  -package org.apache.cocoon.xml.util;
  -
  -import org.xml.sax.SAXException;
  -
  -/**
  - * This utility class is used to keep track namespaces declarations and 
resolve
  - * namespaces names.
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/07/22 20:42:05 $
  - */
  -public class NamespacesTable {
  -    /** The initial namespace declaration. */
  -    private Entry entry=null;
  -
  -    /**
  -     * Construct a new <code>NamespacesTable</code> instance.
  -     */
  -    public NamespacesTable() {
  -        super();
  -        this.entry=Entry.create("","");
  -        // Set the previous declaration of this namespace as self, so it will
  -        // not be possible to remove it :)
  -        this.entry.previousDeclaration=this.entry;
  -    }
  -
  -    /**
  -     * Declare a new namespace prefix-uri mapping.
  -     *
  -     * @return The newly added <code>Declaration</code>.
  -     */
  -    public Declaration addDeclaration(String prefix, String uri) {
  -        Entry e=Entry.create(prefix,uri);
  -        Entry previous=null;
  -        Entry current=this.entry;
  -        while (current!=null) {
  -            if (current.prefixHash==e.prefixHash) {
  -                // Set the current entry to be the previous declaration for 
the
  -                // specified prefix and remove it from the chain.
  -                e.previousDeclaration=current;
  -                e.nextEntry=current.nextEntry;
  -                current.nextEntry=null;
  -                // Set the new entry in the chain
  -                if (previous==null) this.entry=e;
  -                else previous.nextEntry=e;
  -                return(e);
  -            } else {
  -                previous=current;
  -                current=current.nextEntry;
  -            }
  -        }
  -        if (previous==null) this.entry=e;
  -        else previous.nextEntry=e;
  -        return(e);
  -    }
  -
  -    /**
  -     * Undeclare a namespace prefix-uri mapping.
  -     * <br>
  -     * If the prefix was previously declared mapping another URI, its value
  -     * is restored.
  -     *
  -     * @return The removed <code>Declaration</code> or <b>null</b>.
  -     */
  -    public Declaration removeDeclaration(String prefix) {
  -        int hash=prefix.hashCode();
  -        Entry previous=null;
  -        Entry current=this.entry;
  -        while (current!=null) {
  -            if (current.prefixHash==hash) {
  -                if (current.previousDeclaration==null) {
  -                    if (previous==null) this.entry=current.nextEntry;
  -                    else previous.nextEntry=current.nextEntry;
  -                } else {
  -                    current.previousDeclaration.nextEntry=current.nextEntry;
  -                    if (previous==null) 
this.entry=current.previousDeclaration;
  -                    else previous.nextEntry=current.previousDeclaration;
  -                }
  -                return(current);
  -            } else {
  -                previous=current;
  -                current=current.nextEntry;
  -            }
  -        }
  -        return(null);
  -    }
  -
  -    /**
  -     * Return the URI associated with the given prefix or <b>null</b> if the
  -     * prefix was not mapped.
  -     */
  -    public String getUri(String prefix) {
  -        int hash=prefix.hashCode();
  -        Entry current=this.entry;
  -        while (current!=null) {
  -            if(current.prefixHash==hash) return(current.uri);
  -            else current=current.nextEntry;
  -        }
  -        return(null);
  -    }
  -
  -    /**
  -     * Return an array with all prefixes currently mapped to the specified 
URI.
  -     * <br>
  -     * The array length might be <b>zero</b> if no prefixes are associated 
with
  -     * the specified uri.
  -     *
  -     * @return A <b>non-null</b> <code>String</code> array. 
  -     */
  -    public String[] getPrefixes(String uri) {
  -        int hash=uri.hashCode();
  -        Entry current=this.entry;
  -        int count=0;
  -        while (current!=null) {
  -            if(current.uriHash==hash) count++;
  -            current=current.nextEntry;
  -        }
  -        if (count==0) return(new String[0]);
  -        String prefixes[]=new String[count];
  -        count=0;
  -        while (current!=null) {
  -            if(current.uriHash==hash) prefixes[count++]=current.prefix;
  -            current=current.nextEntry;
  -        }
  -        return(prefixes);
  -    }
  -
  -
  -    /**
  -     * Return one of the prefixes currently mapped to the specified URI or
  -     * <b>null</b>.
  -     */
  -    public String getPrefix(String uri) {
  -        int hash=uri.hashCode();
  -        Entry current=this.entry;
  -        while (current!=null) {
  -            if(current.uriHash==hash) return(current.prefix);
  -            current=current.nextEntry;
  -        }
  -        return(null);
  -    }
  -
  -    /**
  -     * Resolve a namespace-aware name against the current namespaces
  -     * declarations.
  -     *
  -     * @param uri The namespace URI or <b>null</b> if not known.
  -     * @param raw The raw (complete) name or <b>null</b> if not known.
  -     * @param prefix The namespace prefix or <b>null</b> if not known.
  -     * @param local The local name or <b>null</b> if not known.
  -     * @return A <b>non-null</b> <code>Name</code>.
  -     * @exception SAXException If the name cannot be resolved.
  -     */
  -    public Name resolve(String uri, String raw, String prefix, String local)
  -    throws SAXException {
  -        if (uri==null) uri="";
  -        if (raw==null) raw="";
  -        if (prefix==null) prefix="";
  -        if (local==null) local="";
  -        // Start examining the URI
  -        if (raw.length()>0) {
  -            // The raw name was specified
  -            int pos=raw.indexOf(':');
  -            if (pos>0) {
  -                // We have a namespace prefix:local separator
  -                String pre=raw.substring(0,pos);
  -                String loc=raw.substring(pos+1);
  -                if (prefix.length()==0) prefix=pre;
  -                else if (!prefix.equals(pre))
  -                    throw new SAXException("Raw/Prefix mismatch");
  -                if (local.length()==0) local=loc;
  -                else if (!local.equals(loc))
  -                    throw new SAXException("Raw/Local Name mismatch");
  -            } else {
  -                // We don't have a prefix:local separator
  -                if (prefix.length()>0)
  -                    throw new SAXException("Raw Name/Prefix mismatch");
  -                if (local.length()==0) local=raw;
  -                else if (!local.equals(raw))
  -                    throw new SAXException("Raw Name/Local Name mismatch");
  -            }
  -        } else {
  -            // The raw name was not specified
  -            if (local.length()==0) throw new SAXException("No Raw/Local 
Name");
  -            if (prefix.length()==0) raw=local;
  -            else raw=prefix+':'+local;
  -        }
  -        // We have resolved and checked data between the raw, local, and
  -        // prefix... We have to doublecheck the namespaces.
  -        if (uri.length()>0) {
  -            // We have a URI and a prefix, check them
  -            if ((prefix.length()>0) &&  (!uri.equals(this.getUri(prefix)))) {
  -                throw new SAXException("URI/Prefix mismatch");
  -            } else {
  -                String temp=this.getPrefix(uri);
  -                if (temp==null) throw new SAXException("URI not declared");
  -                else if (temp.length()>0) {
  -                    prefix=temp;
  -                    raw=prefix+':'+local;
  -                }
  -            }
  -        } else {
  -            // We don't have a URI, check if we can find one from the prefix.
  -            String temp=this.getUri(prefix);
  -            if (temp==null) throw new SAXException("Prefix not declared");
  -            else uri=temp;
  -        }
  -        NameImpl name=new NameImpl();
  -        name.uri=uri;
  -        name.raw=raw;
  -        name.prefix=prefix;
  -        name.local=local;
  -        return(name);
  -    }
  -
  -    /** The internal entry structure for this table. */
  -    private static class Entry implements Declaration {
  -        /** The URI hashcode. */
  -        private int uriHash=0;
  -        /** The prefix hashcode. */
  -        private int prefixHash=0;
  -        /** The URI string. */
  -        private String uri="";
  -        /** The prefix string. */
  -        private String prefix="";
  -        /** The previous declaration for the same prefix. */
  -        private Entry previousDeclaration=null;
  -        /** The declaration following this one in the table. */
  -        private Entry nextEntry=null;
  -
  -        /** Create a new namespace declaration. */
  -        private static Entry create(String prefix, String uri) {
  -            // Create a new entry
  -            Entry e=new Entry();
  -            // Set the prefix string and hash code.
  -            if (prefix!=null) e.prefix=prefix;
  -            e.prefixHash=e.prefix.hashCode();
  -            // Set the uri string and hash code.
  -            if (uri!=null) e.uri=uri;
  -            e.uriHash=e.uri.hashCode();
  -            // Return the entry
  -            return(e);
  -        }
  -
  -        /** Return the namespace URI. */
  -        public String getUri() { return(this.uri); }
  -        /** Return the namespace prefix. */
  -        public String getPrefix() { return(this.prefix); }
  -    }
  -
  -    /** The default namespace-aware name declaration implementation */
  -    private static class NameImpl implements Name {
  -        /** The namespace URI. */
  -        private String uri=null;
  -        /** The namespace prefix. */
  -        private String prefix=null;
  -        /** The namespace local name. */
  -        private String local=null;
  -        /** The namespace raw name. */
  -        private String raw=null;
  -        
  -        /** Return the namespace URI. */
  -        public String getUri() { return(this.uri); }
  -        /** Return the namespace prefix. */
  -        public String getPrefix() { return(this.prefix); }
  -        /** Return the namespace local name. */
  -        public String getLocalName() { return(this.local); }
  -        /** Return the namespace raw name. */
  -        public String getQName() { return(this.raw); }
  -    }
  -
  -    /**
  -     * A namespace-aware name. (This interface is used in conjunction
  -     * with <code>NamespacesTable</code>).
  -     */
  -    public static interface Name {
  -        /** Return the namespace URI. */
  -        public String getUri();
  -        /** Return the namespace prefix. */
  -        public String getPrefix();
  -        /** Return the namespace local name. */
  -        public String getLocalName();
  -        /** Return the namespace raw name. */
  -        public String getQName();
  -    }
  -
  -    /**
  -     * A namespace declaration. (This interface is used in conjunction
  -     * with <code>NamespacesTable</code>).
  -     */
  -    public static interface Declaration {
  -        /** Return the namespace URI. */
  -        public String getUri();
  -        /** Return the namespace prefix. */
  -        public String getPrefix();
  -    }
  -}
  
+/*****************************************************************************
  + * Copyright (C) The Apache Software Foundation. All rights reserved.        
*
  + * ------------------------------------------------------------------------- 
*
  + * This software is published under the terms of the Apache Software License 
*
  + * version 1.1, a copy of which has been included  with this distribution in 
*
  + * the LICENSE file.                                                         
*
  + 
*****************************************************************************/
  +package org.apache.cocoon.xml.util;
  +
  +import org.xml.sax.SAXException;
  +
  +/**
  + * This utility class is used to keep track namespaces declarations and 
resolve
  + * namespaces names.
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  + *         (Apache Software Foundation, Exoffice Technologies)
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/07/29 18:30:45 $
  + */
  +public class NamespacesTable {
  +    /** The initial namespace declaration. */
  +    private Entry entry=null;
  +
  +    /**
  +     * Construct a new <code>NamespacesTable</code> instance.
  +     */
  +    public NamespacesTable() {
  +        super();
  +        this.entry=Entry.create("","");
  +        // Set the previous declaration of this namespace as self, so it will
  +        // not be possible to remove it :)
  +        this.entry.previousDeclaration=this.entry;
  +    }
  +
  +    /**
  +     * Declare a new namespace prefix-uri mapping.
  +     *
  +     * @return The newly added <code>Declaration</code>.
  +     */
  +    public Declaration addDeclaration(String prefix, String uri) {
  +        Entry e=Entry.create(prefix,uri);
  +        Entry previous=null;
  +        Entry current=this.entry;
  +        while (current!=null) {
  +            if (current.prefixHash==e.prefixHash) {
  +                // Set the current entry to be the previous declaration for 
the
  +                // specified prefix and remove it from the chain.
  +                e.previousDeclaration=current;
  +                e.nextEntry=current.nextEntry;
  +                current.nextEntry=null;
  +                // Set the new entry in the chain
  +                if (previous==null) this.entry=e;
  +                else previous.nextEntry=e;
  +                return(e);
  +            } else {
  +                previous=current;
  +                current=current.nextEntry;
  +            }
  +        }
  +        if (previous==null) this.entry=e;
  +        else previous.nextEntry=e;
  +        return(e);
  +    }
  +
  +    /**
  +     * Undeclare a namespace prefix-uri mapping.
  +     * <br>
  +     * If the prefix was previously declared mapping another URI, its value
  +     * is restored.
  +     *
  +     * @return The removed <code>Declaration</code> or <b>null</b>.
  +     */
  +    public Declaration removeDeclaration(String prefix) {
  +        int hash=prefix.hashCode();
  +        Entry previous=null;
  +        Entry current=this.entry;
  +        while (current!=null) {
  +            if (current.prefixHash==hash) {
  +                if (current.previousDeclaration==null) {
  +                    if (previous==null) this.entry=current.nextEntry;
  +                    else previous.nextEntry=current.nextEntry;
  +                } else {
  +                    current.previousDeclaration.nextEntry=current.nextEntry;
  +                    if (previous==null) 
this.entry=current.previousDeclaration;
  +                    else previous.nextEntry=current.previousDeclaration;
  +                }
  +                return(current);
  +            } else {
  +                previous=current;
  +                current=current.nextEntry;
  +            }
  +        }
  +        return(null);
  +    }
  +
  +    /**
  +     * Return the URI associated with the given prefix or <b>null</b> if the
  +     * prefix was not mapped.
  +     */
  +    public String getUri(String prefix) {
  +        int hash=prefix.hashCode();
  +        Entry current=this.entry;
  +        while (current!=null) {
  +            if(current.prefixHash==hash) return(current.uri);
  +            else current=current.nextEntry;
  +        }
  +        return(null);
  +    }
  +
  +    /**
  +     * Return an array with all prefixes currently mapped to the specified 
URI.
  +     * <br>
  +     * The array length might be <b>zero</b> if no prefixes are associated 
with
  +     * the specified uri.
  +     *
  +     * @return A <b>non-null</b> <code>String</code> array. 
  +     */
  +    public String[] getPrefixes(String uri) {
  +        int hash=uri.hashCode();
  +        Entry current=this.entry;
  +        int count=0;
  +        while (current!=null) {
  +            if(current.uriHash==hash) count++;
  +            current=current.nextEntry;
  +        }
  +        if (count==0) return(new String[0]);
  +        String prefixes[]=new String[count];
  +        count=0;
  +        while (current!=null) {
  +            if(current.uriHash==hash) prefixes[count++]=current.prefix;
  +            current=current.nextEntry;
  +        }
  +        return(prefixes);
  +    }
  +
  +
  +    /**
  +     * Return one of the prefixes currently mapped to the specified URI or
  +     * <b>null</b>.
  +     */
  +    public String getPrefix(String uri) {
  +        int hash=uri.hashCode();
  +        Entry current=this.entry;
  +        while (current!=null) {
  +            if(current.uriHash==hash) return(current.prefix);
  +            current=current.nextEntry;
  +        }
  +        return(null);
  +    }
  +
  +    /**
  +     * Resolve a namespace-aware name against the current namespaces
  +     * declarations.
  +     *
  +     * @param uri The namespace URI or <b>null</b> if not known.
  +     * @param raw The raw (complete) name or <b>null</b> if not known.
  +     * @param prefix The namespace prefix or <b>null</b> if not known.
  +     * @param local The local name or <b>null</b> if not known.
  +     * @return A <b>non-null</b> <code>Name</code>.
  +     * @exception SAXException If the name cannot be resolved.
  +     */
  +    public Name resolve(String uri, String raw, String prefix, String local)
  +    throws SAXException {
  +        if (uri==null) uri="";
  +        if (raw==null) raw="";
  +        if (prefix==null) prefix="";
  +        if (local==null) local="";
  +        // Start examining the URI
  +        if (raw.length()>0) {
  +            // The raw name was specified
  +            int pos=raw.indexOf(':');
  +            if (pos>0) {
  +                // We have a namespace prefix:local separator
  +                String pre=raw.substring(0,pos);
  +                String loc=raw.substring(pos+1);
  +                if (prefix.length()==0) prefix=pre;
  +                else if (!prefix.equals(pre))
  +                    throw new SAXException("Raw/Prefix mismatch");
  +                if (local.length()==0) local=loc;
  +                else if (!local.equals(loc))
  +                    throw new SAXException("Raw/Local Name mismatch");
  +            } else {
  +                // We don't have a prefix:local separator
  +                if (prefix.length()>0)
  +                    throw new SAXException("Raw Name/Prefix mismatch");
  +                if (local.length()==0) local=raw;
  +                else if (!local.equals(raw))
  +                    throw new SAXException("Raw Name/Local Name mismatch");
  +            }
  +        } else {
  +            // The raw name was not specified
  +            if (local.length()==0) throw new SAXException("No Raw/Local 
Name");
  +            if (prefix.length()==0) raw=local;
  +            else raw=prefix+':'+local;
  +        }
  +        // We have resolved and checked data between the raw, local, and
  +        // prefix... We have to doublecheck the namespaces.
  +        if (uri.length()>0) {
  +            // We have a URI and a prefix, check them
  +            if ((prefix.length()>0) &&  (!uri.equals(this.getUri(prefix)))) {
  +                throw new SAXException("URI/Prefix mismatch");
  +            } else {
  +                String temp=this.getPrefix(uri);
  +                if (temp==null) throw new SAXException("URI not declared");
  +                else if (temp.length()>0) {
  +                    prefix=temp;
  +                    raw=prefix+':'+local;
  +                }
  +            }
  +        } else {
  +            // We don't have a URI, check if we can find one from the prefix.
  +            String temp=this.getUri(prefix);
  +            if (temp==null) throw new SAXException("Prefix not declared");
  +            else uri=temp;
  +        }
  +        NameImpl name=new NameImpl();
  +        name.uri=uri;
  +        name.raw=raw;
  +        name.prefix=prefix;
  +        name.local=local;
  +        return(name);
  +    }
  +
  +    /** The internal entry structure for this table. */
  +    private static class Entry implements Declaration {
  +        /** The URI hashcode. */
  +        private int uriHash=0;
  +        /** The prefix hashcode. */
  +        private int prefixHash=0;
  +        /** The URI string. */
  +        private String uri="";
  +        /** The prefix string. */
  +        private String prefix="";
  +        /** The previous declaration for the same prefix. */
  +        private Entry previousDeclaration=null;
  +        /** The declaration following this one in the table. */
  +        private Entry nextEntry=null;
  +
  +        /** Create a new namespace declaration. */
  +        private static Entry create(String prefix, String uri) {
  +            // Create a new entry
  +            Entry e=new Entry();
  +            // Set the prefix string and hash code.
  +            if (prefix!=null) e.prefix=prefix;
  +            e.prefixHash=e.prefix.hashCode();
  +            // Set the uri string and hash code.
  +            if (uri!=null) e.uri=uri;
  +            e.uriHash=e.uri.hashCode();
  +            // Return the entry
  +            return(e);
  +        }
  +
  +        /** Return the namespace URI. */
  +        public String getUri() { return(this.uri); }
  +        /** Return the namespace prefix. */
  +        public String getPrefix() { return(this.prefix); }
  +    }
  +
  +    /** The default namespace-aware name declaration implementation */
  +    private static class NameImpl implements Name {
  +        /** The namespace URI. */
  +        private String uri=null;
  +        /** The namespace prefix. */
  +        private String prefix=null;
  +        /** The namespace local name. */
  +        private String local=null;
  +        /** The namespace raw name. */
  +        private String raw=null;
  +        
  +        /** Return the namespace URI. */
  +        public String getUri() { return(this.uri); }
  +        /** Return the namespace prefix. */
  +        public String getPrefix() { return(this.prefix); }
  +        /** Return the namespace local name. */
  +        public String getLocalName() { return(this.local); }
  +        /** Return the namespace raw name. */
  +        public String getQName() { return(this.raw); }
  +    }
  +
  +    /**
  +     * A namespace-aware name. (This interface is used in conjunction
  +     * with <code>NamespacesTable</code>).
  +     */
  +    public static interface Name {
  +        /** Return the namespace URI. */
  +        public String getUri();
  +        /** Return the namespace prefix. */
  +        public String getPrefix();
  +        /** Return the namespace local name. */
  +        public String getLocalName();
  +        /** Return the namespace raw name. */
  +        public String getQName();
  +    }
  +
  +    /**
  +     * A namespace declaration. (This interface is used in conjunction
  +     * with <code>NamespacesTable</code>).
  +     */
  +    public static interface Declaration {
  +        /** Return the namespace URI. */
  +        public String getUri();
  +        /** Return the namespace prefix. */
  +        public String getPrefix();
  +    }
  +}
  
  
  
  1.1.2.3   +221 -221  xml-cocoon/src/org/apache/cocoon/xml/util/XPathAPI.java
  
  Index: XPathAPI.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/xml/util/XPathAPI.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- XPathAPI.java     2000/07/22 20:42:05     1.1.2.2
  +++ XPathAPI.java     2000/07/29 18:30:45     1.1.2.3
  @@ -1,221 +1,221 @@
  -/*
  - * The Apache Software License, Version 1.1
  - *
  - *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *     the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software itself,
  - *    if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Xalan" and "Apache Software Foundation" must
  - *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written
  - *    permission, please contact [EMAIL PROTECTED]
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - *    nor may "Apache" appear in their name, without prior written
  - *    permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation and was
  - * originally based on software copyright (c) 1999, Lotus
  - * Development Corporation., http://www.lotus.com.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  -package org.apache.cocoon.xml.util;
  -
  -import org.xml.sax.SAXException;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.NodeList;
  -import org.apache.xalan.xpath.XPathSupport;
  -import org.apache.xalan.xpath.XPath;
  -import org.apache.xalan.xpath.XPathProcessorImpl;
  -import org.apache.xalan.xpath.xml.XMLParserLiaisonDefault;
  -import org.apache.xalan.xpath.xml.PrefixResolverDefault;
  -import org.apache.xalan.xpath.XObject;
  -
  -/**
  - * The methods in this class are convenience methods into the
  - * low-level XPath API.  We would like to eventually move these
  - * methods into the XPath core, but would like to do some peer
  - * review first to make sure we have it right.
  - * Please note that these methods execute pure XPaths. They do not
  - * implement those parts of XPath extended by XSLT, such as the
  - * document() function).  If you want to install XSLT functions, you
  - * have to use the low-level API.
  - * These functions tend to be a little slow, since a number of objects must 
be
  - * created for each evaluation.  A faster way is to precompile the
  - * XPaths using the low-level API, and then just use the XPaths
  - * over and over.
  - * @see http://www.w3.org/TR/xpath
  - */
  -public class XPathAPI
  -{
  -  /**
  -   * Use an XPath string to select a single node. XPath namespace
  -   * prefixes are resolved from the context node, which may not
  -   * be what you want (see the next method).
  -   *
  -   * @param contextNode The node to start searching from.
  -   * @param str A valid XPath string.
  -   * @return The first node found that matches the XPath, or null.
  -   */
  -  public static Node selectSingleNode(Node contextNode, String str)
  -    throws SAXException
  -  {
  -    return selectSingleNode(contextNode, str, contextNode);
  -  }
  -
  -  /**
  -   * Use an XPath string to select a single node.
  -   * XPath namespace prefixes are resolved from the namespaceNode.
  -   *
  -   * @param contextNode The node to start searching from.
  -   * @param str A valid XPath string.
  -   * @param namespaceNode The node from which prefixes in the XPath will be 
resolved to namespaces.
  -   * @return The first node found that matches the XPath, or null.
  -   */
  -  public static Node selectSingleNode(Node contextNode, String str, Node 
namespaceNode)
  -    throws SAXException
  -  {
  -    // Have the XObject return its result as a NodeSet.
  -    NodeList nl = selectNodeList(contextNode, str, namespaceNode);
  -
  -    // Return the first node, or null
  -    return (nl.getLength() > 0) ? nl.item(0) : null;
  -  }
  -
  - /**
  -   * Use an XPath string to select a nodelist.
  -   * XPath namespace prefixes are resolved from the contextNode.
  -   *
  -   * @param contextNode The node to start searching from.
  -   * @param str A valid XPath string.
  -   * @return A nodelist, should never be null.
  -   */
  -  public static NodeList selectNodeList(Node contextNode, String str)
  -    throws SAXException
  -  {
  -    return selectNodeList(contextNode, str, contextNode);
  -  }
  -
  - /**
  -   * Use an XPath string to select a nodelist.
  -   * XPath namespace prefixes are resolved from the namespaceNode.
  -   *
  -   * @param contextNode The node to start searching from.
  -   * @param str A valid XPath string.
  -   * @param namespaceNode The node from which prefixes in the XPath will be 
resolved to namespaces.
  -   * @return A nodelist, should never be null.
  -   */
  -  public static NodeList selectNodeList(Node contextNode, String str, Node 
namespaceNode)
  -    throws SAXException
  -  {
  -    // Execute the XPath, and have it return the result
  -    XObject list = eval(contextNode, str, namespaceNode);
  -
  -    // Have the XObject return its result as a NodeSet.
  -    return list.nodeset();
  -
  -  }
  -
  - /**
  -   * Evaluate XPath string to an XObject.  Using this method,
  -   * XPath namespace prefixes will be resolved from the namespaceNode.
  -   * @param contextNode The node to start searching from.
  -   * @param str A valid XPath string.
  -   * @param namespaceNode The node from which prefixes in the XPath will be 
resolved to namespaces.
  -   * @return An XObject, which can be used to obtain a string, number, 
nodelist, etc, should never be null.
  -   * @see org.apache.xalan.xpath.XObject
  -   * @see org.apache.xalan.xpath.XNull
  -   * @see org.apache.xalan.xpath.XBoolean
  -   * @see org.apache.xalan.xpath.XNumber
  -   * @see org.apache.xalan.xpath.XString
  -   * @see org.apache.xalan.xpath.XRTreeFrag
  -   */
  -  public static XObject eval(Node contextNode, String str)
  -    throws SAXException
  -  {
  -    return eval(contextNode, str, contextNode);
  -  }
  -
  - /**
  -   * Evaluate XPath string to an XObject.
  -   * XPath namespace prefixes are resolved from the namespaceNode.
  -   * The implementation of this is a little slow, since it creates
  -   * a number of objects each time it is called.  This could be optimized
  -   * to keep the same objects around, but then thread-safety issues would 
arise.
  -   *
  -   * @param contextNode The node to start searching from.
  -   * @param str A valid XPath string.
  -   * @param namespaceNode The node from which prefixes in the XPath will be 
resolved to namespaces.
  -   * @return An XObject, which can be used to obtain a string, number, 
nodelist, etc, should never be null.
  -   * @see org.apache.xalan.xpath.XObject
  -   * @see org.apache.xalan.xpath.XNull
  -   * @see org.apache.xalan.xpath.XBoolean
  -   * @see org.apache.xalan.xpath.XNumber
  -   * @see org.apache.xalan.xpath.XString
  -   * @see org.apache.xalan.xpath.XRTreeFrag
  -   */
  -  public static XObject eval(Node contextNode, String str, Node 
namespaceNode)
  -    throws SAXException
  -  {
  -    // Since we don't have a XML Parser involved here, install some default 
support
  -    // for things like namespaces, etc.
  -    // (Changed from: XPathSupportDefault xpathSupport = new 
XPathSupportDefault();
  -    //    because XPathSupportDefault is weak in a number of areas... perhaps
  -    //    XPathSupportDefault should be done away with.)
  -    XPathSupport xpathSupport = new XMLParserLiaisonDefault();
  -
  -    // Create an object to resolve namespace prefixes.
  -    // XPath namespaces are resolved from the input context node's document 
element
  -    // if it is a root node, or else the current context node (for lack of a 
better
  -    // resolution space, given the simplicity of this sample code).
  -    PrefixResolverDefault prefixResolver = new 
PrefixResolverDefault((contextNode.getNodeType() == Node.DOCUMENT_NODE)
  -                                                         ? 
((Document)contextNode).getDocumentElement() :
  -                                                           contextNode);
  -
  -    // Create the XPath object.
  -    XPath xpath = new XPath();
  -
  -    // Create a XPath parser.
  -    XPathProcessorImpl parser = new XPathProcessorImpl(xpathSupport);
  -    parser.initXPath(xpath, str, prefixResolver);
  -
  -    // Execute the XPath, and have it return the result
  -    return xpath.execute(xpathSupport, contextNode, prefixResolver);
  -  }
  -}
  +/*
  + * The Apache Software License, Version 1.1
  + *
  + *
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *     the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Xalan" and "Apache Software Foundation" must
  + *    not be used to endorse or promote products derived from this
  + *    software without prior written permission. For written
  + *    permission, please contact [EMAIL PROTECTED]
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    nor may "Apache" appear in their name, without prior written
  + *    permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation and was
  + * originally based on software copyright (c) 1999, Lotus
  + * Development Corporation., http://www.lotus.com.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +package org.apache.cocoon.xml.util;
  +
  +import org.xml.sax.SAXException;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.NodeList;
  +import org.apache.xalan.xpath.XPathSupport;
  +import org.apache.xalan.xpath.XPath;
  +import org.apache.xalan.xpath.XPathProcessorImpl;
  +import org.apache.xalan.xpath.xml.XMLParserLiaisonDefault;
  +import org.apache.xalan.xpath.xml.PrefixResolverDefault;
  +import org.apache.xalan.xpath.XObject;
  +
  +/**
  + * The methods in this class are convenience methods into the
  + * low-level XPath API.  We would like to eventually move these
  + * methods into the XPath core, but would like to do some peer
  + * review first to make sure we have it right.
  + * Please note that these methods execute pure XPaths. They do not
  + * implement those parts of XPath extended by XSLT, such as the
  + * document() function).  If you want to install XSLT functions, you
  + * have to use the low-level API.
  + * These functions tend to be a little slow, since a number of objects must 
be
  + * created for each evaluation.  A faster way is to precompile the
  + * XPaths using the low-level API, and then just use the XPaths
  + * over and over.
  + * @see http://www.w3.org/TR/xpath
  + */
  +public class XPathAPI
  +{
  +  /**
  +   * Use an XPath string to select a single node. XPath namespace
  +   * prefixes are resolved from the context node, which may not
  +   * be what you want (see the next method).
  +   *
  +   * @param contextNode The node to start searching from.
  +   * @param str A valid XPath string.
  +   * @return The first node found that matches the XPath, or null.
  +   */
  +  public static Node selectSingleNode(Node contextNode, String str)
  +    throws SAXException
  +  {
  +    return selectSingleNode(contextNode, str, contextNode);
  +  }
  +
  +  /**
  +   * Use an XPath string to select a single node.
  +   * XPath namespace prefixes are resolved from the namespaceNode.
  +   *
  +   * @param contextNode The node to start searching from.
  +   * @param str A valid XPath string.
  +   * @param namespaceNode The node from which prefixes in the XPath will be 
resolved to namespaces.
  +   * @return The first node found that matches the XPath, or null.
  +   */
  +  public static Node selectSingleNode(Node contextNode, String str, Node 
namespaceNode)
  +    throws SAXException
  +  {
  +    // Have the XObject return its result as a NodeSet.
  +    NodeList nl = selectNodeList(contextNode, str, namespaceNode);
  +
  +    // Return the first node, or null
  +    return (nl.getLength() > 0) ? nl.item(0) : null;
  +  }
  +
  + /**
  +   * Use an XPath string to select a nodelist.
  +   * XPath namespace prefixes are resolved from the contextNode.
  +   *
  +   * @param contextNode The node to start searching from.
  +   * @param str A valid XPath string.
  +   * @return A nodelist, should never be null.
  +   */
  +  public static NodeList selectNodeList(Node contextNode, String str)
  +    throws SAXException
  +  {
  +    return selectNodeList(contextNode, str, contextNode);
  +  }
  +
  + /**
  +   * Use an XPath string to select a nodelist.
  +   * XPath namespace prefixes are resolved from the namespaceNode.
  +   *
  +   * @param contextNode The node to start searching from.
  +   * @param str A valid XPath string.
  +   * @param namespaceNode The node from which prefixes in the XPath will be 
resolved to namespaces.
  +   * @return A nodelist, should never be null.
  +   */
  +  public static NodeList selectNodeList(Node contextNode, String str, Node 
namespaceNode)
  +    throws SAXException
  +  {
  +    // Execute the XPath, and have it return the result
  +    XObject list = eval(contextNode, str, namespaceNode);
  +
  +    // Have the XObject return its result as a NodeSet.
  +    return list.nodeset();
  +
  +  }
  +
  + /**
  +   * Evaluate XPath string to an XObject.  Using this method,
  +   * XPath namespace prefixes will be resolved from the namespaceNode.
  +   * @param contextNode The node to start searching from.
  +   * @param str A valid XPath string.
  +   * @param namespaceNode The node from which prefixes in the XPath will be 
resolved to namespaces.
  +   * @return An XObject, which can be used to obtain a string, number, 
nodelist, etc, should never be null.
  +   * @see org.apache.xalan.xpath.XObject
  +   * @see org.apache.xalan.xpath.XNull
  +   * @see org.apache.xalan.xpath.XBoolean
  +   * @see org.apache.xalan.xpath.XNumber
  +   * @see org.apache.xalan.xpath.XString
  +   * @see org.apache.xalan.xpath.XRTreeFrag
  +   */
  +  public static XObject eval(Node contextNode, String str)
  +    throws SAXException
  +  {
  +    return eval(contextNode, str, contextNode);
  +  }
  +
  + /**
  +   * Evaluate XPath string to an XObject.
  +   * XPath namespace prefixes are resolved from the namespaceNode.
  +   * The implementation of this is a little slow, since it creates
  +   * a number of objects each time it is called.  This could be optimized
  +   * to keep the same objects around, but then thread-safety issues would 
arise.
  +   *
  +   * @param contextNode The node to start searching from.
  +   * @param str A valid XPath string.
  +   * @param namespaceNode The node from which prefixes in the XPath will be 
resolved to namespaces.
  +   * @return An XObject, which can be used to obtain a string, number, 
nodelist, etc, should never be null.
  +   * @see org.apache.xalan.xpath.XObject
  +   * @see org.apache.xalan.xpath.XNull
  +   * @see org.apache.xalan.xpath.XBoolean
  +   * @see org.apache.xalan.xpath.XNumber
  +   * @see org.apache.xalan.xpath.XString
  +   * @see org.apache.xalan.xpath.XRTreeFrag
  +   */
  +  public static XObject eval(Node contextNode, String str, Node 
namespaceNode)
  +    throws SAXException
  +  {
  +    // Since we don't have a XML Parser involved here, install some default 
support
  +    // for things like namespaces, etc.
  +    // (Changed from: XPathSupportDefault xpathSupport = new 
XPathSupportDefault();
  +    //    because XPathSupportDefault is weak in a number of areas... perhaps
  +    //    XPathSupportDefault should be done away with.)
  +    XPathSupport xpathSupport = new XMLParserLiaisonDefault();
  +
  +    // Create an object to resolve namespace prefixes.
  +    // XPath namespaces are resolved from the input context node's document 
element
  +    // if it is a root node, or else the current context node (for lack of a 
better
  +    // resolution space, given the simplicity of this sample code).
  +    PrefixResolverDefault prefixResolver = new 
PrefixResolverDefault((contextNode.getNodeType() == Node.DOCUMENT_NODE)
  +                                                         ? 
((Document)contextNode).getDocumentElement() :
  +                                                           contextNode);
  +
  +    // Create the XPath object.
  +    XPath xpath = new XPath();
  +
  +    // Create a XPath parser.
  +    XPathProcessorImpl parser = new XPathProcessorImpl(xpathSupport);
  +    parser.initXPath(xpath, str, prefixResolver);
  +
  +    // Execute the XPath, and have it return the result
  +    return xpath.execute(xpathSupport, contextNode, prefixResolver);
  +  }
  +}
  
  
  
  1.1.2.4   +8 -8      
xml-cocoon/src/org/apache/cocoon/xml/util/Attic/package.html
  
  Index: package.html
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/xml/util/Attic/package.html,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- package.html      2000/07/22 20:42:06     1.1.2.3
  +++ package.html      2000/07/29 18:30:45     1.1.2.4
  @@ -1,9 +1,9 @@
  -<!-- version $Revision: 1.1.2.3 $ $Date: 2000/07/22 20:42:06 $ -->
  -<html>
  -<html>
  -  <body>
  -    This package contains utility classes to use the deprecated SAX 1.0
  -    <code>DocumentHandler</code> interface and the W3C Document Object Model
  -    in the Cocoon 2.0 environment.
  -  </body>
  +<!-- version $Revision: 1.1.2.4 $ $Date: 2000/07/29 18:30:45 $ -->
  +<html>
  +<html>
  +  <body>
  +    This package contains utility classes to use the deprecated SAX 1.0
  +    <code>DocumentHandler</code> interface and the W3C Document Object Model
  +    in the Cocoon 2.0 environment.
  +  </body>
   </html>
  
  
  

Reply via email to