You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ni...@apache.org on 2002/12/26 19:38:58 UTC

cvs commit: xml-cocoon2/src/deprecated/java/org/apache/cocoon/xml XMLizable.java

nicolaken    2002/12/26 10:38:58

  Added:       src/deprecated/java/org/apache/cocoon/components/parser
                        JaxpParser.java Parser.java PooledJaxpParser.java
                        XercesParser.java
               src/deprecated/java/org/apache/cocoon/components/resolver
                        Resolver.java
               src/deprecated/java/org/apache/cocoon/components/source
                        AbstractSAXSource.java AbstractStreamSource.java
                        AbstractStreamWriteableSource.java
                        DelayedRefreshSourceWrapper.java SitemapSource.java
                        SourceFactory.java SourceHandler.java
                        SourceHandlerImpl.java URLSource.java
               src/deprecated/java/org/apache/cocoon/components/store
                        FilesystemStore.java MemoryStore.java
                        MRUMemoryStore.java Store.java StoreJanitor.java
                        StoreJanitorImpl.java
               src/deprecated/java/org/apache/cocoon/components/treeprocessor
                        MapStackResolver.java
               src/deprecated/java/org/apache/cocoon/components/url
                        ContextURLFactory.java ResourceURLFactory.java
                        URLFactory.java URLFactoryImpl.java
               src/deprecated/java/org/apache/cocoon/components/xpath
                        JaxenProcessorImpl.java XPathProcessor.java
                        XPathProcessorImpl.java
               src/deprecated/java/org/apache/cocoon/components/xslt
                        XSLTProcessor.java XSLTProcessorImpl.java
               src/deprecated/java/org/apache/cocoon/environment
                        ModifiableSource.java Source.java
                        SourceResolver.java URLFactorySourceResolver.java
                        WriteableSource.java
               src/deprecated/java/org/apache/cocoon/generation
                        xmldb.samplesxpipe xmldb.xmap
                        XMLDBCollectionGenerator.java XMLDBGenerator.java
               src/deprecated/java/org/apache/cocoon/matching
                        RegexpTargetHostMatcher.java
                        RequestParamMatcher.java
                        WildcardParameterValueMatcher.java
                        WildcardURIMatcher.java
               src/deprecated/java/org/apache/cocoon/selection
                        RequestSelector.java SessionStateSelector.java
               src/deprecated/java/org/apache/cocoon/xml XMLizable.java
  Log:
    <action dev="NKB" type="update">
      Moved all classes marked @deprecated to the src/deprecated directory.
      Since Many classes are still a dependency for the core, while this is fixed
      the build process still copies them with the core during compilation.
      To compile with the deprecation separation, do "build -Ddeprecate=true".
    </action>
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/parser/JaxpParser.java
  
  Index: JaxpParser.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.parser;
  
  import org.apache.avalon.excalibur.pool.Poolable;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.cocoon.components.resolver.Resolver;
  import org.apache.cocoon.util.ClassUtils;
  import org.apache.cocoon.xml.AbstractXMLProducer;
  import org.w3c.dom.DOMImplementation;
  import org.w3c.dom.Document;
  import org.xml.sax.*;
  
  import javax.xml.parsers.*;
  import java.io.IOException;
  
  /**
   * An XMLParser that is only dependant on JAXP 1.1 compliant parsers.
   *
   * The configuration can contain the following parameters :
   * <ul>
   * <li>validate (boolean, default = <code>false</code>) : should the parser
   *     validate parsed documents ?
   * </li>
   * <li>namespace-prefixes (boolean, default = <code>false</code>) : do we want
   *     namespaces declarations also as 'xmlns:' attributes ?<br>
   *     <i>Note</i> : setting this to <code>true</code> confuses some XSL
   *     processors (e.g. Saxon).
   * </li>
   * <li>reuse-parsers (boolean, default = <code>true</code>) : do we want to reuse
   *     parsers or create a new parser for each parse ?<br>
   *     <i>Note</i> : even if this parameter is <code>true</code>, parsers are not
   *     recycled in case of parsing errors : some parsers (e.g. Xerces) don't like
   *     to be reused after failure.
   * </li>
   * <li>sax-parser-factory (string, optional) : the name of the <code>SAXParserFactory</code>
   *     implementation class to be used instead of using the standard JAXP mechanism
   *     (<code>SAXParserFactory.newInstance()</code>). This allows to choose
   *     unambiguously the JAXP implementation to be used when several of them are
   *     available in the classpath.
   * </li>
   * <li>document-builder-factory (string, optional) : the name of the
   *     <code>DocumentBuilderFactory</code> implementation to be used (similar to
   *     <code>sax-parser-factory</code> for DOM).
   * </li>
   * </ul>
   *
   * @deprecated The Avalon XML Parser is now used inside Cocoon. This role
   *             will be removed in future releases.
  
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @version CVS $Id: JaxpParser.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public class JaxpParser extends AbstractXMLProducer
  implements Parser, ErrorHandler, Composable, Parameterizable, Disposable, Poolable {
  
      /** the SAX Parser factory */
      protected SAXParserFactory factory;
  
      /** the Document Builder factory */
      protected DocumentBuilderFactory docFactory;
  
      /** The SAX reader. It is created lazily by {@link #setupXMLReader()}
          and cleared if a parsing error occurs. */
      protected XMLReader reader;
  
      /** The DOM builder. It is created lazily by {@link #setupDocumentBuilder()}
          and cleared if a parsing error occurs. */
      protected DocumentBuilder docBuilder;
  
      /** the component manager */
      protected ComponentManager manager;
  
      /** the Entity Resolver */
      protected Resolver resolver;
  
      /** do we want namespaces also as attributes ? */
      protected boolean nsPrefixes;
  
      /** do we want to reuse parsers ? */
      protected boolean reuseParsers;
  
      /**
       * Get the Entity Resolver from the component manager
       */
      public void compose(ComponentManager manager)
      throws ComponentException {
          this.manager = manager;
          if ( manager.hasComponent( Resolver.ROLE ) ) {
              if (getLogger().isDebugEnabled()) {
                  getLogger().debug("Looking up " + Resolver.ROLE);
              }
              this.resolver = (Resolver)manager.lookup(Resolver.ROLE);
          }
      }
  
      /**
       * Dispose
       */
      public void dispose() {
          if (this.manager != null) {
              this.manager.release( this.resolver );
          }
      }
  
      /**
       * Configure
       */
      public void parameterize(Parameters params)
      throws ParameterException  {
          // Validation and namespace prefixes parameters
          boolean validate = params.getParameterAsBoolean("validate", false);
          this.nsPrefixes = params.getParameterAsBoolean("namespace-prefixes", false);
          this.reuseParsers = params.getParameterAsBoolean("reuse-parsers", true);
  
          // Get the SAXFactory
          String className = params.getParameter("sax-parser-factory", null);
          if (className == null) {
              factory = SAXParserFactory.newInstance();
          } else {
              // Will use specific class
              try {
                  Class factoryClass = ClassUtils.loadClass(className);
                  factory = (SAXParserFactory)factoryClass.newInstance();
              } catch(Exception e) {
                  throw new ParameterException("Cannot load SAXParserFactory class " + className, e);
              }
          }
          // FIXME(VG): This always prints "SAXParserFactory: null"
          // getLogger().debug("SAXParserFactory: " + ClassUtils.which(factory.getClass()));
          factory.setNamespaceAware(true);
          factory.setValidating(validate);
  
          // Get the DocumentFactory
          className = params.getParameter("document-builder-factory", null);
          if (className == null) {
              this.docFactory = DocumentBuilderFactory.newInstance();
          } else {
              // Will use specific class
              try {
                  Class factoryClass = ClassUtils.loadClass(className);
                  this.docFactory = (DocumentBuilderFactory)factoryClass.newInstance();
              } catch(Exception e) {
                  throw new ParameterException("Cannot load DocumentBuilderFactory class " + className, e);
              }
          }
          // FIXME(VG): This always prints "DocumentBuilderFactory: null"
          // getLogger().debug("DocumentBuilderFactory: " + ClassUtils.which(docFactory.getClass()));
  
          docFactory.setNamespaceAware(true);
          docFactory.setValidating(validate);
      }
  
      public void parse(InputSource in)
      throws SAXException, IOException {
          setupXMLReader();
          try {
              this.reader.setProperty("http://xml.org/sax/properties/lexical-handler", super.lexicalHandler);
          } catch (SAXException e) {
              getLogger().warn("SAX2 driver does not support property: "+
                               "'http://xml.org/sax/properties/lexical-handler'");
          }
  
          this.reader.setErrorHandler(this);
          this.reader.setContentHandler(super.contentHandler);
          if(this.resolver != null) {
              reader.setEntityResolver(this.resolver);
          }
  
          // Ensure we will use a fresh new parser at next parse in case of failure
          XMLReader tmpReader = this.reader;
          this.reader = null;
  
          tmpReader.parse(in);
  
          // Here, parsing was successful : restore this.reader
          if (this.reuseParsers)
              this.reader = tmpReader;
      }
  
      /**
       * Create a new Document object.
       */
      public Document newDocument() {
          setupDocumentBuilder();
          return this.docBuilder.newDocument();
      }
  
      /**
       * Create a new Document object with a specified DOCTYPE.
       */
      public Document newDocument(String name) {
          return this.newDocument(name, null, null);
      }
  
      /**
       * Create a new Document object with a specified DOCTYPE, public ID and
       * system ID.
       */
      public Document newDocument(String name, String publicId, String systemId) {
          setupDocumentBuilder();
          // Fixme: is there a better way to achieve this?
          DOMImplementation impl = this.docBuilder.newDocument().getImplementation();
          return impl.createDocument(
              null,
              name,
              impl.createDocumentType(name, publicId, systemId)
          );
      }
  
      /**
       * Parses a new Document object from the given InputSource.
       */
      public Document parseDocument(InputSource input) throws SAXException, IOException {
          setupDocumentBuilder();
  
          // Ensure we will use a fresh new parser at next parse in case of failure
          DocumentBuilder tmpBuilder = this.docBuilder;
          this.docBuilder = null;
  
          Document result = tmpBuilder.parse(input);
  
          // Here, parsing was successful : restore this.builder
          if (this.reuseParsers)
              this.docBuilder = tmpBuilder;
  
          return result;
      }
  
      /**
       * Creates a new <code>XMLReader</code> if needed.
       */
      protected void setupXMLReader() throws SAXException {
          if (this.reader == null) {
              // Create the XMLReader
              try {
                  this.reader = factory.newSAXParser().getXMLReader();
                  this.reader.setFeature("http://xml.org/sax/features/namespace-prefixes", nsPrefixes);
              } catch(Exception e) {
                  getLogger().error("Cannot produce a valid parser", e);
                  throw new SAXException("Cannot produce a valid parser", e);
              }
          }
      }
  
      /**
       * Creates a new <code>DocumentBuilder</code> if needed.
       */
      protected void setupDocumentBuilder() {
          if (this.docBuilder == null) {
              try {
                  this.docBuilder = this.docFactory.newDocumentBuilder();
              } catch (ParserConfigurationException pce) {
                  getLogger().error("Could not create DocumentBuilder", pce);
                  throw new org.apache.avalon.framework.CascadingRuntimeException(
                      "Could not create DocumentBuilder", pce);
              }
          }
      }
  
      /**
       * 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);
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/parser/Parser.java
  
  Index: Parser.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.parser;
  
  import org.apache.avalon.framework.component.Component;
  import org.apache.cocoon.xml.XMLProducer;
  import org.apache.cocoon.xml.dom.DOMFactory;
  import org.w3c.dom.Document;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  import org.xml.sax.ext.LexicalHandler;
  
  import java.io.IOException;
  
  /**
   * @deprecated The Avalon XML Parser is now used inside Cocoon. This role
   *             will be removed in future releases.
   *
   * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
   *         (Apache Software Foundation, Exoffice Technologies)
   * @version CVS $Id: Parser.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public interface Parser extends Component, XMLProducer, DOMFactory {
  
      String ROLE = Parser.class.getName();
  
      void setContentHandler(ContentHandler contentHandler);
  
      void setLexicalHandler(LexicalHandler lexicalHandler);
  
      void parse(InputSource in) throws SAXException, IOException;
  
      Document parseDocument(InputSource in) throws SAXException, IOException;
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/parser/PooledJaxpParser.java
  
  Index: PooledJaxpParser.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.parser;
  
  
  /**
   * @deprecated <code>PooledJaxpParser</code> is now the default parser for Cocoon
   *             and has thus been moved to {@link JaxpParser} - this class will be
   *             removed in a future release.
   *             The Avalon XML Parser is now used inside Cocoon. This role
   *             will be removed in future releases.
   *
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @version CVS $Id: PooledJaxpParser.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public class PooledJaxpParser extends JaxpParser {
  
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/parser/XercesParser.java
  
  Index: XercesParser.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.parser;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.cocoon.components.resolver.Resolver;
  import org.apache.cocoon.xml.AbstractXMLProducer;
  import org.apache.xerces.dom.DocumentImpl;
  import org.apache.xerces.dom.DocumentTypeImpl;
  import org.apache.xerces.parsers.DOMParser;
  import org.apache.xerces.parsers.SAXParser;
  import org.w3c.dom.Document;
  import org.xml.sax.ErrorHandler;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  import org.xml.sax.SAXParseException;
  
  import java.io.IOException;
  
  /**
   *
   * @deprecated The Avalon XML Parser is now used inside Cocoon. This role
   *             will be removed in future releases.
  
   * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
   *         (Apache Software Foundation, Exoffice Technologies)
   * @version CVS $Id: XercesParser.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public class XercesParser extends AbstractXMLProducer
  implements Parser, ErrorHandler, Composable, Disposable {
  
      /** the SAX Parser */
      final SAXParser parser;
  
      /** the component manager */
      protected ComponentManager manager;
  
      /** the Entity Resolver */
      protected Resolver resolver = null;
  
      public XercesParser ()
      throws SAXException {
          this.parser = new SAXParser();
  
          this.parser.setFeature("http://xml.org/sax/features/validation", false);
          this.parser.setFeature("http://xml.org/sax/features/namespaces", true);
      }
  
      /**
       * Get the Entity Resolver from the component manager
       */
      public void compose(ComponentManager manager) throws ComponentException {
          this.manager = manager;
          if (getLogger().isDebugEnabled()) {
              getLogger().debug("Looking up " + Resolver.ROLE);
          }
          if ( manager.hasComponent( Resolver.ROLE ) ) {
              this.resolver = (Resolver)manager.lookup(Resolver.ROLE);
          }
      }
  
      /**
       * Dispose
       */
      public void dispose() {
          if (this.manager != null) {
              this.manager.release( this.resolver );
          }
      }
  
      public void parse(InputSource in)
      throws SAXException, IOException {
          this.parser.setProperty("http://xml.org/sax/properties/lexical-handler",
                                  super.lexicalHandler);
          this.parser.setErrorHandler(this);
          this.parser.setContentHandler(super.contentHandler);
          if(this.resolver != null)
              this.parser.setEntityResolver(this.resolver);
          this.parser.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);
      }
  
      /**
       * Parses a new Document object from the given InputSource.
       */
      public Document parseDocument(InputSource input) throws SAXException, IOException {
          DOMParser parser = null;
  
          try {
              parser = new DOMParser();
  
              parser.setFeature("http://xml.org/sax/features/validation",false);
              parser.setFeature("http://xml.org/sax/features/namespaces",true);
  
              parser.parse(input);
          } catch (Exception pce) {
              getLogger().error("Could not build DocumentBuilder", pce);
              return null;
          }
  
          return parser.getDocument();
      }
  
      /**
       * 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);
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/resolver/Resolver.java
  
  Index: Resolver.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.resolver;
  
  import org.apache.avalon.framework.component.Component;
  import org.xml.sax.EntityResolver;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  import java.io.IOException;
  
  /**
   * A component that uses catalogs for resolving entities.
   * @deprecated Use the Avalon Excalibur EntityResolver instead
   *
   * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
   * @author <a href="mailto:crossley@indexgeo.com.au">David Crossley</a>
   * @version CVS $Id: Resolver.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public interface Resolver extends Component, EntityResolver {
  
      String ROLE = "org.apache.cocoon.components.resolver.Resolver";
  
      /**
       * Allow the application to resolve external entities.
       *
       * <p>The Parser will call this method before opening any external
       * entity except the top-level document entity (including the
       * external DTD subset, external entities referenced within the
       * DTD, and external entities referenced within the document
       * element): the application may request that the parser resolve
       * the entity itself, that it use an alternative URI, or that it
       * use an entirely different input source.</p>
       *
       * <p>Application writers can use this method to redirect external
       * system identifiers to secure and/or local URIs, to look up
       * public identifiers in a catalogue, or to read an entity from a
       * database or other input source (including, for example, a dialog
       * box).</p>
       *
       * <p>If the system identifier is a URL, the SAX parser must
       * resolve it fully before reporting it to the application.</p>
       *
       * @param publicId The public identifier of the external entity
       *        being referenced, or null if none was supplied.
       * @param systemId The system identifier of the external entity
       *        being referenced.
       * @return An InputSource object describing the new input source,
       *         or null to request that the parser open a regular
       *         URI connection to the system identifier.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @exception java.io.IOException A Java-specific IO exception,
       *            possibly the result of creating a new InputStream
       *            or Reader for the InputSource.
       * @see org.xml.sax.InputSource
       */
      InputSource resolveEntity(String publicId, String systemId)
          throws SAXException, IOException;
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/source/AbstractSAXSource.java
  
  Index: AbstractSAXSource.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.source;
  
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.ComponentSelector;
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.environment.Environment;
  import org.apache.cocoon.environment.Source;
  import org.apache.cocoon.serialization.Serializer;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  
  /**
   * This abstract class provides convenience methods to implement
   * a SAX based Source. Implement toSAX() and getSystemId() and
   * optionally override getLastModified() and getContentLength() to
   * obtain a valid Source implementation.
   *
   * @deprecated Use the new Avalon Excalibur Source Resolving
   * @author <a href="mailto:gianugo@apache.org">Gianugo Rabellino</a>
   * @version $Id: AbstractSAXSource.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  
  public abstract class AbstractSAXSource
    implements Source {
  
      /** The Logger instance */
      protected Logger log;
  
      /** The ComponentManager instance */
      protected ComponentManager manager;
  
      /**
       * The constructor.
       *
       * @param environment the Cocoon Environment.
       * @param manager an Avalon Component Manager
       * @param logger A LogKit logger
       */
  
      public AbstractSAXSource(Environment environment,
                         ComponentManager manager,
                         Logger logger) {
        this.log = logger;
        this.manager = manager;
  
      }
  
      /**
       * Get an InputSource for the given URL. Shamelessly stolen
       * from SitemapSource.
       *
       */
  
      public InputStream getInputStream()
        throws ProcessingException, IOException {
  
          ComponentSelector serializerSelector = null;
          Serializer serializer = null;
          try {
  
              serializerSelector = (ComponentSelector) this.manager.lookup(Serializer.ROLE + "Selector");
              serializer = (Serializer)serializerSelector.select("xml");
              ByteArrayOutputStream os = new ByteArrayOutputStream();
              serializer.setOutputStream(os);
  
              this.toSAX(serializer);
  
              return new ByteArrayInputStream(os.toByteArray());
          } catch (ComponentException cme) {
              throw new ProcessingException("could not lookup pipeline components", cme);
          } catch (ProcessingException e) {
              throw e;
          } catch (Exception e) {
              throw new ProcessingException("Exception during processing of " + this.getSystemId(), e);
          } finally {
              if (serializer != null) serializerSelector.release(serializer);
              if (serializerSelector != null) this.manager.release(serializerSelector);
          }
      }
  
      /**
       * Get an InputSource for the given URL.
       *
       */
  
      public InputSource getInputSource()
        throws ProcessingException, IOException {
        InputSource is = new InputSource(this.getInputStream());
        is.setSystemId(this.getSystemId());
  
        return is;
      }
  
      /**
       * Implement this method to obtain SAX events.
       *
       */
  
      public abstract void toSAX(ContentHandler handler)
        throws SAXException, ProcessingException;
  
      /**
       * Implement this method to set the unique identifier.
       *
       */
  
      public abstract String getSystemId();
  
      /**
       * Override this method to set the Content Length
       *
       */
  
      public long getContentLength() {
        return -1;
      }
  
      /**
       * Override this method to set the Last Modification date
       *
       */
  
      public long getLastModified() {
        return 0;
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/source/AbstractStreamSource.java
  
  Index: AbstractStreamSource.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 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 "Apache Cocoon" 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 apache@apache.org.
   *
   * 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cocoon.components.source;
  
  import org.apache.avalon.excalibur.xml.Parser;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.environment.ModifiableSource;
  import org.apache.cocoon.util.ClassUtils;
  import org.w3c.dom.Document;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  
  import javax.xml.transform.OutputKeys;
  import javax.xml.transform.Transformer;
  import javax.xml.transform.TransformerFactory;
  import javax.xml.transform.dom.DOMSource;
  import javax.xml.transform.stream.StreamResult;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.StringWriter;
  import java.lang.reflect.Method;
  import java.util.Properties;
  
  /**
   * This abstract class provides convenience methods to implement
   * a stream based Source. Implement getInputStream(), getSystemId() and
   * optionally override refresh(), recycle(), getLastModified() and
   * getContentLength() to obtain a valid Source implementation.
   * <p>
   * This base implementation provides services to parse HTML sources
   * (HTML is not valid XML) using JTidy, if present. The source is
   * considered to contain HTML if <code>isHTMLContent()</code> returns
   * true.
   *
   * @deprecated Use the new Avalon Excalibur Source Resolving
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version $Id: AbstractStreamSource.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  
  public abstract class AbstractStreamSource extends AbstractLogEnabled
      implements ModifiableSource {
  // FIXME(SW) : this implements *Modifiable*Source just to call refresh()
  //             if JTidy fails. Can we avoid this ?
  
      /** Is JTidy available? */
      private static Class jtidyClass;
  
      /** Properties used for converting HTML to XML */
      private static Properties xmlProperties;
  
      /** The TrAX factory for serializing xml */
      public static TransformerFactory transformerFactory = TransformerFactory.newInstance();
  
      /**
       * Test if JTidy is available
       */
      static {
          jtidyClass = null;
          try {
              jtidyClass = ClassUtils.loadClass("org.w3c.tidy.Tidy");
          } catch (ClassNotFoundException cnfe) {
              // ignore
          }
          xmlProperties = new Properties();
          xmlProperties.put(OutputKeys.METHOD, "xml");
          xmlProperties.put(OutputKeys.OMIT_XML_DECLARATION, "no");
      }
  
      /** The ComponentManager needed for streaming */
      protected ComponentManager manager;
  
      /**
       * Construct a new object
       */
      protected AbstractStreamSource(ComponentManager manager) {
          this.manager = manager;
      }
  
      /**
       * Does this source contain HTML ? If true, JTidy will be used (if available) to
       * parse the input as XML.
       * <p>
       * The default here is to return false. Concrete subclasses should override
       * this if needed.
       */
      protected boolean isHTMLContent() {
          return false;
      }
  
      /**
       * Return a new <code>InputSource</code> object
       */
      public InputSource getInputSource() throws IOException, ProcessingException {
  
          InputStream stream = this.getInputStream();
          if (jtidyClass != null && isHTMLContent()) {
              try {
                  // FIXME (CZ) we need to speed up this!
                  final Object xhtmlconvert = jtidyClass.newInstance();
                  Method m = jtidyClass.getMethod("setXmlOut", new Class[] { Class.forName("java.lang.Boolean")});
                  m.invoke(xhtmlconvert, new Object[] { new Boolean(true) });
                  m = jtidyClass.getMethod("setXHTML", new Class[] {Class.forName("java.lang.Boolean")});
                  m.invoke(xhtmlconvert, new Object[] { new Boolean(true) });
                  m = jtidyClass.getMethod("setShowWarnings", new Class[] { Class.forName("java.lang.Boolean")});
                  m.invoke(xhtmlconvert, new Object[] { new Boolean(false) });
                  m = jtidyClass.getMethod("parseDOM", new Class[] { Class.forName("java.io.InputStream"), Class.forName("java.io.OutputStream")});
                  final Document doc = (Document)m.invoke(xhtmlconvert, new Object[] { stream, null });
                  final StringWriter writer = new StringWriter();
                  final Transformer transformer;
                  transformer = transformerFactory.newTransformer();
                  transformer.setOutputProperties(xmlProperties);
                  transformer.transform(new DOMSource(doc), new StreamResult(writer));
                  final String xmlstring = writer.toString();
                  InputSource newObject = new InputSource(new java.io.StringReader(xmlstring));
                  newObject.setSystemId(this.getSystemId());
                  return newObject;
              } catch (Exception ignore) {
                  // Let someone else worry about what we got . This is as before.
                  this.refresh();
                  stream = this.getInputStream();
              }
          }
          InputSource newObject = new InputSource(stream);
          newObject.setSystemId(this.getSystemId());
          return newObject;
      }
  
      /**
       * Stream content to a content handler or to an XMLConsumer.
       *
       * @throws ResourceNotFoundException if file not found or
       *         HTTP location does not exist.
       * @throws SAXException if failed to parse source document.
       */
      public void toSAX(ContentHandler handler) throws SAXException, ProcessingException {
          Parser parser = null;
          try {
              parser = (Parser)this.manager.lookup(Parser.ROLE);
  
              parser.parse( this.getInputSource(), handler);
          } catch (SAXException e) {
              // Preserve original exception
              throw e;
          } catch (ProcessingException e){
              // Preserve original exception
              throw e;
          } catch (Exception e){
              throw new ProcessingException("Exception during processing of "
                                            + this.getSystemId(), e);
          } finally {
              if (parser != null) this.manager.release(parser);
          }
      }
  
      /**
       * Override this method to set the Content Length
       *
       */
      public long getContentLength() {
        return -1;
      }
  
      /**
       * Override this method to set the Last Modification date
       *
       */
      public long getLastModified() {
        return 0;
      }
  
      /**
       * Returns <code>true</code> if <code>getInputStream()</code> succeeds.
       * Subclasses can provide a more efficient implementation.
       */
      public boolean exists() {
          try {
              InputStream stream = getInputStream();
              stream.close();
              return true;
          } catch(Exception e) {
              return false;
          }
      }
  
      /**
       * To be overriden in concrete subclasses if needed.
       */
      public void recycle() {
      }
  
      /**
       * To be overriden in concrete subclasses if needed.
       */
      public void refresh() {
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/source/AbstractStreamWriteableSource.java
  
  Index: AbstractStreamWriteableSource.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 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 "Apache Cocoon" 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 apache@apache.org.
   *
   * 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.cocoon.components.source;
  
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.ComponentSelector;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.serialization.Serializer;
  import org.apache.cocoon.xml.AbstractXMLPipe;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXException;
  
  import java.io.IOException;
  import java.io.OutputStream;
  
  /**
   * This abstract class provides convenience methods to implement
   * a stream based <code>org.apache.cocoon.environment.WriteableSource</code>.
   * Implement getOutputStream() to obtain a valid implementation.
   * <p>
   * This base implementation creates a <code>ContentHandler</code> by using
   * the sitemap 'xml' serializer to write SAX events to the stream returned by
   * <code>getOutputStream()</code>.
   *
   * @deprecated Use the new Avalon Excalibur Source Resolving
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @version $Id: AbstractStreamWriteableSource.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  
  public abstract class AbstractStreamWriteableSource
      extends AbstractStreamSource
      implements org.apache.cocoon.environment.WriteableSource {
  
      protected AbstractStreamWriteableSource(ComponentManager manager) {
          super(manager);
      }
  
      /**
       * Checks if the <code>OutputStream</code> under <code>handler</code> can be cancelled.
       *
       * @see #canCancel(OutputStream)
       */
      public boolean canCancel(ContentHandler handler) {
          if (handler instanceof WritingPipe) {
              WritingPipe pipe = (WritingPipe)handler;
              if (pipe.getSource() == this) {
                  return pipe.canCancel();
              }
          }
  
          // Not a valid handler for this source
          throw new IllegalArgumentException("The handler is not associated to this source");
      }
  
      /**
       * Always return <code>false</code>. To be redefined by implementations that support
       * <code>cancel()</code>.
       */
      public boolean canCancel(OutputStream stream) {
          return false;
      }
  
      /**
       * Cancels the <code>OutputStream</code> under <code>handler</code>.
       *
       * @see #cancel(OutputStream)
       */
      public void cancel(ContentHandler handler) throws Exception {
          if (handler instanceof WritingPipe) {
              WritingPipe pipe = (WritingPipe)handler;
              if (pipe.getSource() == this) {
                  pipe.cancel();
                  return;
              }
          }
  
          // Not a valid handler for this source
          throw new IllegalArgumentException("The handler is not associated to this source");
      }
  
      /**
       * Always throw <code>UnsupportedOperationException</code>. To be redefined by
       * implementations that support <code>cancel()</code>.
       */
      public void cancel(OutputStream stream) throws Exception {
          throw new UnsupportedOperationException("Cancel is not implemented on " +
              this.getClass().getName());
      }
  
      /**
       * Get a <code>ContentHandler</code> to write a SAX stream to this source. It
       * uses either the 'xml' or 'html' serializer depending on the result of
       * {@link #isHTMLContent()} to serialize events, and thus these serializers must
       * exist in this source's component manager.
       */
      public ContentHandler getContentHandler() throws SAXException, ProcessingException {
  
          Serializer serializer;
          ComponentSelector selector;
  
          String serializerName = this.isHTMLContent() ? "html" : "xml";
  
          // Get the serializer
          try {
              selector =
                  (ComponentSelector)this.manager.lookup(Serializer.ROLE + "Selector");
              serializer = (Serializer)selector.select(serializerName);
          } catch(ComponentException ce) {
              throw new ProcessingException("Cannot get '" + serializerName + "' serializer");
          }
  
          try {
              return new WritingPipe(getOutputStream(), selector, serializer);
          } catch(IOException ioe) {
              selector.release(serializer);
              throw new ProcessingException("Cannot open stream for " + this.getSystemId(), ioe);
          }
      }
  
      /**
       * A pipe that closes the outputstream at the end of the document and handles cancel().
       */
      private class WritingPipe extends AbstractXMLPipe {
  
          // The output stream
          private OutputStream output;
  
          // Serialier and its selector for proper release
          private Serializer serializer;
          private ComponentSelector selector;
  
          public WritingPipe(OutputStream output, ComponentSelector selector, Serializer serializer)
            throws IOException {
              this.output = output;
              this.selector = selector;
              this.serializer = serializer;
  
              // Connect this pipe, the serializer and the output stream
              this.setConsumer(this.serializer);
              this.serializer.setOutputStream(this.output);
          }
  
          public org.apache.cocoon.environment.WriteableSource getSource() {
              return AbstractStreamWriteableSource.this;
          }
  
          /**
           * Close the underlying stream
           */
          public void endDocument() throws SAXException {
              super.endDocument();
              try {
                  close();
              }
              catch(Exception e) {
                  throw new SAXException("Error while closing output stream", e);
              }
          }
  
          public boolean canCancel() {
              return this.output != null;
          }
  
          /**
           * Cancel the wrapped output stream
           */
          public void cancel() throws Exception {
              AbstractStreamWriteableSource.this.cancel(output);
              close();
          }
  
          private void close() throws IOException {
              if (this.serializer != null) {
                  // Disconnect serializer;
                  this.recycle();
                  // and release it
                  this.selector.release(this.serializer);
                  this.serializer = null;
              }
  
              if (this.output != null) {
                  this.output.close();
                  this.output = null;
              }
          }
  
          // Ensure all is closed properly
          protected void finalize() throws Throwable {
              close();
              super.finalize();
          }
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/source/DelayedRefreshSourceWrapper.java
  
  Index: DelayedRefreshSourceWrapper.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.source;
  
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.environment.ModifiableSource;
  import org.apache.cocoon.environment.Source;
  import org.apache.cocoon.xml.XMLizable;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  
  import java.io.IOException;
  import java.io.InputStream;
  
  /**
   * A wrapper around a <code>Source</code> that reduces the number of calls to
   * <code>Source.getLastModified()</code> which can be a costly operation.
   *
   * @deprecated by the Avalon Exalibur Source Resolving
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @version $Id: DelayedRefreshSourceWrapper.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public final class DelayedRefreshSourceWrapper implements Source, ModifiableSource, XMLizable {
  
      private Source source;
  
      private long delay;
  
      private long nextCheckTime = 0;
  
      private long lastModified = 0;
  
      private boolean isModifiableSource;
  
      /**
       * Creates a wrapper for a <code>Source</code> which ensures that
       * <code>Source.getLastModified()</code> won't be called more than once per
       * <code>delay</code> milliseconds period.
       *
       * @param source the wrapped <code>Source</code>
       * @param delay  the last-modified refresh delay, in milliseconds
       */
      public DelayedRefreshSourceWrapper(Source source, long delay) {
          this.source = source;
          this.delay = delay;
          this.isModifiableSource = source instanceof ModifiableSource;
      }
  
      /**
       * Get the last modification time for the wrapped <code>Source</code>. The
       * age of the returned information is guaranteed to be lower than or equal to
       * the delay specified in the constructor.
       * <p>
       * This method is also thread-safe, even if the underlying Source is not.
       *
       * @return the last modification time.
       */
      public final long getLastModified() {
  
          // Do we have to refresh the source ?
          if (System.currentTimeMillis() >= nextCheckTime) {
              // Yes
              this.refresh();
          }
  
          return this.lastModified;
      }
  
      /**
       * Force the refresh of the wrapped <code>Source</code>, even if the refresh period
       * isn't over, and starts a new period.
       * <p>
       * This method is thread-safe, even if the underlying Source is not.
       */
      public synchronized final void refresh() {
  
          this.nextCheckTime = System.currentTimeMillis() + this.delay;
          // Refresh modifiable sources
          if (this.isModifiableSource) {
              ((ModifiableSource)this.source).refresh();
          }
  
          // Keep the last modified date
          this.lastModified = source.getLastModified();
      }
  
      public final long getContentLength() {
          return this.source.getContentLength();
      }
  
      public final InputStream getInputStream() throws ProcessingException, IOException {
          return this.source.getInputStream();
      }
  
      public final InputSource getInputSource() throws ProcessingException, IOException {
          return this.source.getInputSource();
      }
  
      public final String getSystemId() {
          return this.source.getSystemId();
      }
  
      public final void recycle() {
          this.source.recycle();
      }
  
      public final void toSAX(ContentHandler handler) throws SAXException, ProcessingException {
          this.source.toSAX(handler);
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/source/SitemapSource.java
  
  Index: SitemapSource.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.source;
  
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.logger.Logger;
  
  import org.apache.excalibur.source.SourceException;
  
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.Processor;
  import org.apache.cocoon.components.CocoonComponentManager;
  import org.apache.cocoon.components.pipeline.ProcessingPipeline;
  import org.apache.cocoon.components.sax.XMLDeserializer;
  import org.apache.cocoon.components.sax.XMLSerializer;
  import org.apache.cocoon.environment.Environment;
  import org.apache.cocoon.environment.ModifiableSource;
  import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
  import org.apache.cocoon.xml.AbstractXMLConsumer;
  import org.apache.cocoon.xml.ContentHandlerWrapper;
  import org.apache.cocoon.xml.XMLConsumer;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  import org.xml.sax.ext.LexicalHandler;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.net.MalformedURLException;
  
  /**
   * Description of a source which is defined by a pipeline.
   *
   * @deprecated by the Avalon Excalibur Source Resolving
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: SitemapSource.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public final class SitemapSource
  extends AbstractXMLConsumer
  implements ModifiableSource {
  
      /** The last modification date or 0 */
      private long lastModificationDate;
  
      /** The system id */
      private String systemId;
  
      /** The uri */
      private String uri;
  
      /** The current ComponentManager */
      private ComponentManager manager;
  
      /** The processor */
      private Processor processor;
  
      /** The pipeline processor */
      private Processor pipelineProcessor;
  
      /** The environment */
      private EnvironmentWrapper environment;
  
      /** The prefix for the processing */
      private String prefix;
  
      /** The <code>ProcessingPipeline</code> */
      private ProcessingPipeline processingPipeline;
  
      /** The redirect <code>Source</code> */
      private org.apache.excalibur.source.Source redirectSource;
  
      /** The <code>SAXException</code> if unable to get resource */
      private ProcessingException exception;
  
      /** Do I need a refresh ? */
      private boolean needsRefresh;
  
      /** The unique key for this processing */
      private Object processKey;
  
      /**
       * Construct a new object
       */
      public SitemapSource(ComponentManager manager,
                           String           uri,
                           Logger           logger)
      throws IOException, ProcessingException {
  
          Environment env = CocoonComponentManager.getCurrentEnvironment();
          if ( env == null ) {
              throw new MalformedURLException("The cocoon protocol can not be used outside an environment.");
          }
  
          this.manager = manager;
          this.enableLogging(logger);
          boolean rawMode = false;
  
          // remove the protocol
          int position = uri.indexOf(':') + 1;
          if (position != 0) {
              // check for subprotocol
              if (uri.startsWith("raw:", position)) {
                  position += 4;
                  rawMode = true;
              }
          }
  
          // does the uri point to this sitemap or to the root sitemap?
          if (uri.startsWith("//", position)) {
              position += 2;
              try {
                  this.processor = (Processor)this.manager.lookup(Processor.ROLE);
              } catch (ComponentException e) {
                  throw new ProcessingException("Cannot get Processor instance", e);
              }
              this.prefix = ""; // start at the root
          } else if (uri.startsWith("/", position)) {
              position ++;
              this.prefix = null;
              this.processor = CocoonComponentManager.getCurrentProcessor();
          } else {
              throw new ProcessingException("Malformed cocoon URI.");
          }
  
          // create the queryString (if available)
          String queryString = null;
          int queryStringPos = uri.indexOf('?', position);
          if (queryStringPos != -1) {
              queryString = uri.substring(queryStringPos + 1);
              uri = uri.substring(position, queryStringPos);
          } else if (position > 0) {
              uri = uri.substring(position);
          }
  
          // build the request uri which is relative to the context
          String requestURI = (this.prefix == null ? env.getURIPrefix() + uri : uri);
  
          // create system ID
          this.systemId = queryString == null ?
              "cocoon://" + requestURI :
              "cocoon://" + requestURI + "?" + queryString;
  
          this.environment = new EnvironmentWrapper(env, requestURI, queryString, logger, manager, rawMode);
          this.uri = uri;
          this.refresh();
      }
  
      /**
       * Get the last modification date of the source or 0 if it
       * is not possible to determine the date.
       */
      public long getLastModified() {
          if (this.needsRefresh) {
              this.refresh();
          }
          return this.lastModificationDate;
      }
  
      /**
       * Get the content length of the source or -1 if it
       * is not possible to determine the length.
       */
      public long getContentLength() {
          return -1;
      }
  
      /**
       * Return an <code>InputStream</code> object to read from the source.
       */
      public InputStream getInputStream()
        throws ProcessingException, IOException {
  
          if (this.needsRefresh) {
              this.refresh();
          }
          // VG: Why exception is not thrown in constructor?
          if (this.exception != null) {
              throw this.exception;
          }
  
          if (this.redirectSource != null) {
              try {
                  return this.redirectSource.getInputStream();
              } catch (SourceException se) {
                  throw SourceUtil.handle(se);
              }
          }
  
          try {
              ByteArrayOutputStream os = new ByteArrayOutputStream();
              this.environment.setOutputStream(os);
              try {
                  CocoonComponentManager.enterEnvironment(this.environment,
                                                          this.environment.getObjectModel(),
                                                          this.pipelineProcessor);
                  this.processingPipeline.process(this.environment);
              } finally {
                  CocoonComponentManager.leaveEnvironment();
              }
              return new ByteArrayInputStream(os.toByteArray());
  
          } catch (ProcessingException e) {
              throw e;
          } catch (Exception e) {
              throw new ProcessingException("Exception during processing of " + this.systemId, e);
          } finally {
              // Unhide wrapped environment output stream
              this.environment.setOutputStream(null);
              reset();
          }
      }
  
      /**
       * Return the unique identifer for this source
       */
      public String getSystemId() {
          return this.systemId;
      }
  
      /**
       * Refresh this object and update the last modified date
       * and content length.
       */
      public void refresh() {
          reset();
          try {
              this.processKey = CocoonComponentManager.startProcessing(this.environment);
              this.environment.setURI(this.prefix, this.uri);
              this.processingPipeline = this.processor.processInternal(this.environment);
              this.pipelineProcessor = this.environment.changeToLastContext();
              String redirectURL = this.environment.getRedirectURL();
              if (redirectURL != null) {
                  if (redirectURL.indexOf(":") == -1) {
                      redirectURL = "cocoon:/" + redirectURL;
                  }
                  this.redirectSource = this.environment.resolveURI(redirectURL);
                  this.lastModificationDate = this.redirectSource.getLastModified();
              }
          } catch (ProcessingException e) {
              reset();
              this.exception = e;
          } catch (Exception e) {
              reset();
              this.exception = new ProcessingException("Could not get sitemap source "
                                                       + this.systemId, e);
          }
          this.needsRefresh = false;
      }
  
      /**
       * Return a new <code>InputSource</code> object
       */
      public InputSource getInputSource()
      throws ProcessingException, IOException {
          InputSource newObject = new InputSource(this.getInputStream());
          newObject.setSystemId(this.systemId);
          return newObject;
      }
  
      /**
       * Stream content to the content handler
       */
      public void toSAX(ContentHandler contentHandler)
          throws SAXException, ProcessingException
      {
          if (this.needsRefresh) {
              this.refresh();
          }
          if (this.exception != null) {
              throw this.exception;
          }
          try {
              XMLConsumer consumer;
              if (contentHandler instanceof XMLConsumer) {
                  consumer = (XMLConsumer)contentHandler;
              } else if (contentHandler instanceof LexicalHandler) {
                  consumer = new ContentHandlerWrapper(contentHandler, (LexicalHandler)contentHandler);
              } else {
                  consumer = new ContentHandlerWrapper(contentHandler);
              }
              if (this.redirectSource != null) {
                  this.environment.toSAX(this.redirectSource, consumer);
              } else {
                  // We have to buffer the result in order to get
                  // clean environment stack handling.
                  XMLSerializer xmls = (XMLSerializer) this.manager.lookup(XMLSerializer.ROLE);
                  Object fragment;
                  try {
                      CocoonComponentManager.enterEnvironment(this.environment,
                                                              this.environment.getObjectModel(),
                                                              this.pipelineProcessor);
                      this.processingPipeline.process(this.environment, xmls);
                      fragment = xmls.getSAXFragment();
                  } finally {
                      this.manager.release(xmls);
                      CocoonComponentManager.leaveEnvironment();
                  }
                  XMLDeserializer xmld = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE);
                  try {
                      xmld.setConsumer(consumer);
                      xmld.deserialize(fragment);
                  } finally {
                      this.manager.release(xmld);
                  }
              }
          } catch (ProcessingException e) {
              // Preserve original exception
              throw e;
          } catch (Exception e) {
              throw new ProcessingException("Exception during processing of "
                                            + this.systemId, e);
          } finally {
              reset();
          }
      }
  
      private void reset() {
          if (this.processingPipeline != null) this.processingPipeline.release();
          if (this.processKey != null) {
              CocoonComponentManager.endProcessing(this.environment, this.processKey);
              this.processKey = null;
          }
          this.processingPipeline = null;
          this.lastModificationDate = 0;
          this.environment.release(this.redirectSource);
          this.environment.reset();
          this.redirectSource = null;
          this.exception = null;
          this.needsRefresh = true;
          this.pipelineProcessor = null;
      }
  
      public void recycle() {
          reset();
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/source/SourceFactory.java
  
  Index: SourceFactory.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.source;
  
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.environment.Environment;
  import org.apache.cocoon.environment.Source;
  
  import java.io.IOException;
  import java.net.MalformedURLException;
  import java.net.URL;
  
  /**
   * @deprecated by the Avalon Exalibur Source Resolving
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version $Id: SourceFactory.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public interface SourceFactory extends ThreadSafe {
  
      /**
       * Get a <code>Source</code> object.
       * @param environment This is optional.
       */
      Source getSource(Environment environment, String location)
      throws ProcessingException, MalformedURLException, IOException;
  
      /**
       * Get a <code>Source</code> object.
       * @param environment This is optional.
       */
      Source getSource(Environment environment, URL base, String location)
      throws ProcessingException, MalformedURLException, IOException;
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/source/SourceHandler.java
  
  Index: SourceHandler.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.source;
  
  import org.apache.avalon.framework.component.Component;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.environment.Environment;
  import org.apache.cocoon.environment.Source;
  
  import java.io.IOException;
  import java.net.MalformedURLException;
  import java.net.URL;
  
  /**
   * @deprecated The Avalon Excalibur Source Resolving is now used.
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version $Id: SourceHandler.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public interface SourceHandler extends Component {
  
      String ROLE = "org.apache.cocoon.components.source.SourceHandler";
  
      /**
       * Get a <code>Source</code> object.
       * @param environment This is optional.
       */
      Source getSource(Environment environment, String location)
      throws ProcessingException, MalformedURLException, IOException;
  
      /**
       * Get a <code>Source</code> object.
       * @param environment This is optional.
       */
      Source getSource(Environment environment, URL base, String location)
      throws ProcessingException, MalformedURLException, IOException;
  
      /**
       * Add a new source factory.
       * The factory is initialized by the handler, this means the
       * handler test for the Avalon interfaces <code>Composable</code>,
       * <code>Contextualizable</code> and <code>LogEnabled</code>.
       * When the handler is disposed it should also test the
       * <code>Disposable</code> interface.
       * If a factory with the protocol already exists it is
       * overridden by this new factory.
       */
      void addFactory(String protocol, SourceFactory factory)
      throws ProcessingException;
  
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/source/SourceHandlerImpl.java
  
  Index: SourceHandlerImpl.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.source;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.components.url.URLFactory;
  import org.apache.cocoon.environment.Environment;
  import org.apache.cocoon.environment.Source;
  import org.apache.cocoon.util.ClassUtils;
  
  import java.io.IOException;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  /**
   * @deprecated The Avalon Excalibur Source Resolving is now used.
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version $Id: SourceHandlerImpl.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public final class SourceHandlerImpl extends AbstractLogEnabled
      implements Configurable, Disposable, Composable, Contextualizable, SourceHandler {
  
      /** The component manager */
      private ComponentManager manager;
  
      /** The url factory */
      private URLFactory urlFactory;
  
      /** The special Source factories */
      private Map sourceFactories;
  
      /** The context */
      private Context context;
  
      /**
       * Configure the SourceFactories
       */
      public void configure(final Configuration conf)
      throws ConfigurationException {
          try {
              if (this.getLogger().isDebugEnabled()) {
                  getLogger().debug("Getting the SourceFactories");
              }
              HashMap factories = new HashMap();
              Configuration[] configs = conf.getChildren("protocol");
              SourceFactory sourceFactory = null;
              String protocol = null;
              for (int i = 0; i < configs.length; i++) {
                  protocol = configs[i].getAttribute("name");
                  if (factories.containsKey(protocol)) {
                      throw new ConfigurationException("SourceFactory defined twice for protocol: " + protocol);
                  }
  
                  if (this.getLogger().isDebugEnabled()) {
                      getLogger().debug("\tfor protocol: " + protocol + " " + configs[i].getAttribute("class"));
                  }
                  sourceFactory = (SourceFactory) ClassUtils.newInstance(configs[i].getAttribute("class"));
                  this.init(sourceFactory, configs[i]);
                  factories.put(protocol, sourceFactory);
              }
  
              this.sourceFactories = java.util.Collections.synchronizedMap(factories);
          } catch (ConfigurationException e) {
              throw e;
          } catch (Exception e) {
              throw new ConfigurationException("Could not get parameters because: " +
                                             e.getMessage());
          }
      }
  
      /**
       * Get the context
       */
      public void contextualize(Context context)
      throws ContextException {
          this.context = context;
      }
  
      /**
       * Set the current <code>ComponentManager</code> instance used by this
       * <code>Composable</code>.
       */
      public void compose(ComponentManager manager)
      throws ComponentException {
          this.manager = manager;
          this.urlFactory = (URLFactory)this.manager.lookup(URLFactory.ROLE);
      }
  
      /**
       * Dispose
       */
      public void dispose() {
          this.manager.release(this.urlFactory);
  
          final Iterator iter = this.sourceFactories.values().iterator();
          SourceFactory current;
          while (iter.hasNext()) {
              current = (SourceFactory) iter.next();
              this.deinit(current);
          }
          this.sourceFactories = null;
      }
  
      /**
       * Get a <code>Source</code> object.
       */
      public Source getSource(Environment environment, String location)
      throws ProcessingException, MalformedURLException, IOException {
          final int protocolEnd = location.indexOf(':');
          if (protocolEnd != -1) {
              final String protocol = location.substring(0, protocolEnd);
              final SourceFactory sourceFactory = (SourceFactory)this.sourceFactories.get(protocol);
              if (sourceFactory != null) {
                  return sourceFactory.getSource(environment, location);
              }
          }
  
          // default implementation
          Source result = new URLSource(this.urlFactory.getURL(location), this.manager);
          if (result instanceof LogEnabled) {
              ((LogEnabled)result).enableLogging(getLogger());
          }
          return result;
      }
  
      /**
       * Get a <code>Source</code> object.
       */
      public Source getSource(Environment environment, URL base, String location)
      throws ProcessingException, MalformedURLException, IOException {
          final String protocol = base.getProtocol();
          final SourceFactory sourceFactory = (SourceFactory)this.sourceFactories.get(protocol);
          if (sourceFactory != null) {
              return sourceFactory.getSource(environment, base, location);
          }
  
          // default implementation
          return new URLSource(this.urlFactory.getURL(base, location), this.manager);
      }
  
      /**
       * Add a factory
       */
      public void addFactory(String protocol, SourceFactory factory)
      throws ProcessingException {
          try {
              this.init(factory, null);
              SourceFactory oldFactory = (SourceFactory)this.sourceFactories.put(protocol, factory);
              if (oldFactory != null) {
                  deinit(oldFactory);
              }
          } catch (ComponentException e) {
              throw new ProcessingException("cannot initialize factory: " + factory, e);
          } catch (ContextException e) {
              throw new ProcessingException("cannot initialize factory: " + factory, e);
          } catch (ConfigurationException e) {
              throw new ProcessingException("cannot configure factory: " + factory, e);
          }
      }
  
      /**
       * Init a source factory
       */
      private void init(SourceFactory factory, Configuration config)
      throws ContextException, ComponentException, ConfigurationException {
          if (factory instanceof LogEnabled) {
              ((LogEnabled) factory).enableLogging(getLogger());
          }
          if (factory instanceof Contextualizable) {
              ((Contextualizable) factory).contextualize (this.context);
          }
          if (factory instanceof Composable) {
              ((Composable) factory).compose(this.manager);
          }
          if (config != null && factory instanceof Configurable) {
              ((Configurable) factory).configure(config);
          }
      }
  
      /**
       * Deinit a source factory
       */
      private void deinit(SourceFactory factory) {
          if (factory instanceof Disposable) {
              ((Disposable) factory).dispose();
          }
      }
  
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/source/URLSource.java
  
  Index: URLSource.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.source;
  
  import org.apache.avalon.framework.component.ComponentManager;
  
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.ResourceNotFoundException;
  
  import org.apache.excalibur.source.SourceParameters;
  import org.apache.excalibur.source.SourceUtil;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.io.InputStream;
  import java.lang.reflect.Method;
  import java.net.HttpURLConnection;
  import java.net.JarURLConnection;
  import java.net.URL;
  import java.net.URLConnection;
  import java.util.Iterator;
  import java.util.jar.JarEntry;
  
  /**
   * Description of a source which is described by an URL.
   *
   * @deprecated by the Avalon Exalibur Source Resolving
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: URLSource.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  
  public class URLSource extends AbstractStreamSource {
  
      /** Identifier for file urls */
      private final String FILE = "file:";
  
      /** The last modification date or 0 */
      private long lastModificationDate;
  
      /** The content length */
      private long contentLength;
  
      /** Is the content html or xml? */
      private boolean isHTMLContent = false;
  
      /** The system id */
      private String systemId;
  
      /** The URL of the source */
      private URL url;
  
      /** The connection for a real URL */
      private URLConnection connection;
  
      /** Is this a file or a "real" URL */
      private boolean isFile;
  
      /** Are we initialized? */
      private boolean gotInfos;
  
      /** The <code>SourceParameters</code> for post */
      private SourceParameters postParameters;
  
      /**
       * Construct a new object
       */
      public URLSource(URL url, ComponentManager manager)
      throws IOException {
          super(manager);
          this.systemId = url.toExternalForm();
          this.isFile = systemId.startsWith(FILE);
          if (this.isFile == true) {
              if (systemId.endsWith(".htm") || systemId.endsWith(".html")) {
                  this.isHTMLContent = true;
              }
          }
          this.url = url;
          this.gotInfos = false;
      }
  
      protected boolean isHTMLContent() {
          return this.isHTMLContent;
      }
  
      /**
       * Get the last modification date and content length of the source.
       * Any exceptions are ignored.
       */
      private void getInfos() {
          if (!this.gotInfos) {
              if (this.isFile) {
                  File file = new File(systemId.substring(FILE.length()));
                  this.lastModificationDate = file.lastModified();
                  this.contentLength = file.length();
              } else {
                  if (this.postParameters == null) {
                      try {
                          if (this.connection == null) {
                              this.connection = this.url.openConnection();
                              String userInfo = this.getUserInfo();
                              if (this.url.getProtocol().startsWith("http") && userInfo != null) {
                                  this.connection.setRequestProperty("Authorization","Basic "+SourceUtil.encodeBASE64(userInfo));
                              }
                          }
                          if(this.connection instanceof JarURLConnection) {
                              JarEntry entry = ((JarURLConnection)this.connection).getJarEntry();
                              this.lastModificationDate = entry.getTime();
                          } else {
                              this.lastModificationDate = this.connection.getLastModified();
                          }
                          this.contentLength = this.connection.getContentLength();
                      } catch (IOException ignore) {
                          this.lastModificationDate = 0;
                          this.contentLength = -1;
                      }
                  } else {
                          // do not open connection when using post!
                          this.lastModificationDate = 0;
                          this.contentLength = -1;
                  }
              }
              this.gotInfos = true;
          }
      }
  
      /**
       * Get the last modification date of the source or 0 if it
       * is not possible to determine the date.
       */
      public long getLastModified() {
          this.getInfos();
          return this.lastModificationDate;
      }
  
      /**
       * Get the content length of the source or -1 if it
       * is not possible to determine the length.
       */
      public long getContentLength() {
          this.getInfos();
          return this.contentLength;
      }
  
      /**
       * Return an <code>InputStream</code> object to read from the source.
       *
       * @throws ResourceNotFoundException if file not found or
       *         HTTP location does not exist.
       * @throws IOException if I/O error occured.
       */
      public InputStream getInputStream()
      throws IOException, ProcessingException {
          this.getInfos();
          try {
              InputStream input = null;
              if ( this.isFile ) {
                  input = new FileInputStream(this.systemId.substring(FILE.length()));
              } else {
                  if (this.connection == null) {
                      this.connection = this.url.openConnection();
                      /* The following requires a jdk 1.3 */
                      String userInfo = this.getUserInfo();
                      if (this.url.getProtocol().startsWith("http") && userInfo != null) {
                          this.connection.setRequestProperty("Authorization","Basic "+SourceUtil.encodeBASE64(userInfo));
                      }
                      // do a post operation
                      if (this.connection instanceof HttpURLConnection
                          && this.postParameters != null) {
                          StringBuffer buffer = new StringBuffer(2000);
                          String key;
                          Iterator i = postParameters.getParameterNames();
                          Iterator values;
                          String value;
                          boolean first = true;
                          while ( i.hasNext() ) {
                              key = (String)i.next();
                              values = this.postParameters.getParameterValues(key);
                              while (values.hasNext() == true) {
                                  value = SourceUtil.encode((String)values.next());
                                  if (first == false) buffer.append('&');
                                  first = false;
                                  buffer.append(key.toString());
                                  buffer.append('=');
                                  buffer.append(value);
                              }
                          }
                          HttpURLConnection httpCon = (HttpURLConnection)connection;
                          httpCon.setDoInput(true);
  
                          if (buffer.length() > 1) { // only post if we have parameters
                              String postString = buffer.toString();
                              httpCon.setRequestMethod("POST"); // this is POST
                              httpCon.setDoOutput(true);
                              httpCon.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
  
                              // A content-length header must be contained in a POST request
                              httpCon.setRequestProperty("Content-length", Integer.toString(postString.length()));
                              java.io.OutputStream out = new java.io.BufferedOutputStream(httpCon.getOutputStream());
                              out.write(postString.getBytes());
                              out.close();
                          }
                          if ("text/html".equals(httpCon.getContentType()) == true) {
                              this.isHTMLContent = true;
                          }
                          input = httpCon.getInputStream();
                          this.connection = null; // make sure a new connection is created next time
                          return input;
                      }
                  }
                  if ("text/html".equals(this.connection.getContentType()) == true) {
                      this.isHTMLContent = true;
                  }
                  input = this.connection.getInputStream();
                  this.connection = null; // make sure a new connection is created next time
              }
              return input;
          } catch (FileNotFoundException e) {
              throw new ResourceNotFoundException("Resource not found "
                                                  + this.systemId, e);
          }
      }
  
      private static boolean checkedURLClass = false;
      private static boolean urlSupportsGetUserInfo = false;
      private static Method  urlGetUserInfo = null;
      private static Object[] emptyParams = new Object[0];
  
      /**
       * Check if the <code>URL</code> class supports the getUserInfo()
       * method which is introduced in jdk 1.3
       */
      private String getUserInfo() {
          if (URLSource.checkedURLClass) {
              if (URLSource.urlSupportsGetUserInfo) {
                  try {
                      return (String) URLSource.urlGetUserInfo.invoke(this.url, URLSource.emptyParams);
                  } catch (Exception e){
                      // ignore this anyway
                  }
              }
              return null;
          } else {
              // test if the url class supports the getUserInfo method
              try {
                  URLSource.urlGetUserInfo = URL.class.getMethod("getUserInfo", null);
                  String ui = (String)URLSource.urlGetUserInfo.invoke(this.url, URLSource.emptyParams);
                  URLSource.checkedURLClass = true;
                  URLSource.urlSupportsGetUserInfo = true;
                  return ui;
              } catch (Exception e){
              }
              URLSource.checkedURLClass = true;
              URLSource.urlSupportsGetUserInfo = false;
              URLSource.urlGetUserInfo = null;
              return null;
          }
      }
  
      /**
       * Return the unique identifer for this source
       */
      public String getSystemId() {
          return this.systemId;
      }
  
      /**
       * Refresh this object and update the last modified date
       * and content length.
       */
      public void refresh() {
          // reset connection
          this.connection = null;
          this.gotInfos = false;
      }
  
      public void recycle() {
          refresh();
      }
  
      /**
       * Set the post parameters
       */
      public void setPostParameters(SourceParameters pars) {
          this.postParameters = pars;
      }
  
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/store/FilesystemStore.java
  
  Index: FilesystemStore.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.store;
  
  import org.apache.avalon.framework.CascadingRuntimeException;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.cocoon.Constants;
  import org.apache.cocoon.util.IOUtils;
  import java.io.ByteArrayOutputStream;
  import java.io.File;
  import java.io.IOException;
  import java.io.OutputStreamWriter;
  import java.util.BitSet;
  import java.util.Enumeration;
  
  /**
   * Stores objects on the filesystem: String objects as text files,
   * all other objects are serialized.
   *
   * @deprecated Use the {@link org.apache.cocoon.components.store.impl.FilesystemStore}
   *
   * @author ?
   * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
   * @version CVS $Id: FilesystemStore.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public final class FilesystemStore extends AbstractLogEnabled
      implements Store, Contextualizable, Parameterizable, ThreadSafe {
  
      protected File workDir;
      protected File cacheDir;
  
      /** The directory repository */
      protected File directoryFile;
      protected volatile String directoryPath;
  
      /**
       * Sets the repository's location
       */
      public void setDirectory(final String directory)
      throws IOException {
          this.setDirectory(new File(directory));
      }
  
      public void contextualize(final Context context)
      throws ContextException {
          this.workDir = (File)context.get(Constants.CONTEXT_WORK_DIR);
          this.cacheDir = (File)context.get(Constants.CONTEXT_CACHE_DIR);
      }
  
      public void parameterize(Parameters params)
      throws ParameterException {
          try {
              if (params.getParameterAsBoolean("use-cache-directory", false)) {
                  if (this.getLogger().isDebugEnabled())
                      getLogger().debug("Using cache directory: " + cacheDir);
                  setDirectory(cacheDir);
              } else if (params.getParameterAsBoolean("use-work-directory", false)) {
                  if (this.getLogger().isDebugEnabled())
                      getLogger().debug("Using work directory: " + workDir);
                  setDirectory(workDir);
              } else if (params.getParameter("directory", null) != null) {
                  String dir = params.getParameter("directory");
                  dir = IOUtils.getContextFilePath(workDir.getPath(), dir);
                  if (this.getLogger().isDebugEnabled())
                      getLogger().debug("Using directory: " + dir);
                  setDirectory(new File(dir));
              } else {
                  try {
                      // Legacy: use working directory by default
                      setDirectory(workDir);
                  } catch (IOException e) {
                      // Legacy: Always was ignored
                  }
              }
          } catch (IOException e) {
              throw new ParameterException("Unable to set directory", e);
          }
      }
  
      /**
       * Sets the repository's location
       */
      public void setDirectory(final File directory)
      throws IOException {
          this.directoryFile = directory;
  
          /* 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 object associated with the given unique key name.
       */
      public synchronized Object get(final Object key) {
          final File file = fileFromKey(key);
  
          if (file != null && file.exists()) {
              if (this.getLogger().isDebugEnabled()) {
                  getLogger().debug("Found file: " + key);
              }
              try {
                  return IOUtils.deserializeObject(file);
              } catch (Exception any) {
                  getLogger().error("Error during deseralization.", any);
              }
          } else {
              if (this.getLogger().isDebugEnabled()) {
                  getLogger().debug("NOT Found file: " + key);
              }
          }
  
          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 synchronized void store(final Object key, final Object value)
      throws IOException {
          final File file = fileFromKey(key);
  
          /* Create subdirectories as needed */
          final File parent = file.getParentFile();
          if (parent != null) {
              parent.mkdirs();
          }
  
          /* Store object as file */
          if (value == null) { /* Directory */
              if (file.exists()) {
                  if (!file.delete()) { /* FAILURE */
                      getLogger().error("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);
          }
      }
  
      /**
       * Holds the given object in a volatile state.
       */
      public synchronized void hold(final Object key, final Object value)
      throws IOException {
          this.store(key, value);
          final File file = (File) this.fileFromKey(key);
          if (file != null) {
            file.deleteOnExit();
          }
      }
  
      /**
       * Remove the object associated to the given key.
       */
      public synchronized void remove(final Object key) {
          final File file = fileFromKey(key);
          if (file != null) {
              file.delete();
          }
      }
  
      /**
       * Indicates if the given key is associated to a contained object.
       */
      public synchronized boolean containsKey(final Object key) {
          final File file = fileFromKey(key);
          if (file == null) {
              return false;
          }
          return file.exists();
      }
  
      /**
       * Returns the list of stored files as an Enumeration of Files
       */
      public synchronized Enumeration keys() {
          final FSEnumeration enum = new FSEnumeration();
          this.addKeys(enum, this.directoryFile);
          return enum;
      }
  
      /**
       * Returns count of the objects in the store, or -1 if could not be
       * obtained.
       */
      public synchronized int size() {
          return countKeys(this.directoryFile);
      }
  
      protected void addKeys(FSEnumeration enum, File directory) {
          final int subStringBegin = this.directoryFile.getAbsolutePath().length() + 1;
          final File[] files = directory.listFiles();
          for (int i=0; i<files.length; i++) {
              if (files[i].isDirectory()) {
                  this.addKeys(enum, files[i]);
              } else {
                  enum.add(this.decode(files[i].getAbsolutePath().substring(subStringBegin)));
              }
          }
      }
  
      protected int countKeys(File directory) {
          int count = 0;
          final File[] files = directory.listFiles();
          for (int i=0; i<files.length; i++) {
              if (files[i].isDirectory()) {
                  count += this.countKeys(files[i]);
              } else {
                  count ++;
              }
          }
          return count;
      }
  
      final class FSEnumeration implements Enumeration {
          private String[] array;
          private int      index;
          private int      length;
  
          FSEnumeration() {
              this.array = new String[16];
              this.length = 0;
              this.index = 0;
          }
  
          public void add(String key) {
              if (this.length == array.length) {
                  String[] newarray = new String[this.length + 16];
                  System.arraycopy(this.array, 0, newarray, 0, this.array.length);
                  this.array = newarray;
              }
              this.array[this.length] = key;
              this.length++;
          }
  
          public boolean hasMoreElements() {
              return (this.index < this.length);
          }
  
          public Object nextElement() {
              if (this.hasMoreElements()) {
                  this.index++;
                  return this.array[index-1];
              }
              return null;
          }
      }
  
      /* Utility Methods*/
      protected File fileFromKey(final Object key) {
          return IOUtils.createFile(this.directoryFile, this.encode(key.toString()));
      }
  
      public String getString(final Object key)
      throws IOException {
          final File file = (File) this.fileFromKey(key);
          if (file != null) {
              return IOUtils.deserializeString(file);
          }
  
          return null;
      }
  
      public synchronized void free() {}
  
      public synchronized Object getObject(final Object key)
      throws IOException, ClassNotFoundException
      {
          final File file = (File) this.fileFromKey(key);
          if (file != null) {
              return IOUtils.deserializeObject(file);
          }
  
          return null;
      }
  
      /**
       * Inverse of encode exept it do not use path.
       * So decode(encode(s) - m_path) = s.
       * In other words it returns a String that can be used as key to retive
       * the record contained in the 'filename' file.
       */
      protected String decode( String filename )
      {
          try {
              return java.net.URLDecoder.decode( filename );
          } catch (Exception local) {
              throw new CascadingRuntimeException("Exception in decode", local);
          }
      }
  
      /** A BitSet defining the characters which don't need encoding */
      static BitSet charactersDontNeedingEncoding;
      static final int characterCaseDiff = ('a' - 'A');
  
      /** Initialize the BitSet */
      static
      {
          charactersDontNeedingEncoding = new BitSet(256);
          int i;
          for (i = 'a'; i <= 'z'; i++)
          {
              charactersDontNeedingEncoding.set(i);
          }
          for (i = 'A'; i <= 'Z'; i++)
          {
              charactersDontNeedingEncoding.set(i);
          }
          for (i = '0'; i <= '9'; i++)
          {
              charactersDontNeedingEncoding.set(i);
          }
          charactersDontNeedingEncoding.set('-');
          charactersDontNeedingEncoding.set('_');
          charactersDontNeedingEncoding.set('(');
          charactersDontNeedingEncoding.set(')');
      }
  
      /**
       * Returns a String that uniquely identifies the object.
       * <b>Note:</b> since this method uses the Object.toString()
       * method, it's up to the caller to make sure that this method
       * doesn't change between different JVM executions (like
       * it may normally happen). For this reason, it's highly recommended
       * (even if not mandated) that Strings be used as keys.
       */
      public String encode(String s) {
          final StringBuffer out = new StringBuffer( s.length() );
          final ByteArrayOutputStream buf = new ByteArrayOutputStream( 32 );
          final OutputStreamWriter writer = new OutputStreamWriter( buf );
          for (int i = 0; i < s.length(); i++)
          {
              int c = (int)s.charAt(i);
              if (charactersDontNeedingEncoding.get(c))
              {
                  out.append((char)c);
              }
              else
              {
                  try
                  {
                      writer.write(c);
                      writer.flush();
                  }
                  catch(IOException e)
                  {
                      buf.reset();
                      continue;
                  }
                  byte[] ba = buf.toByteArray();
                  for (int j = 0; j < ba.length; j++)
                  {
                      out.append('%');
                      char ch = Character.forDigit((ba[j] >> 4) & 0xF, 16);
                      // converting to use uppercase letter as part of
                      // the hex value if ch is a letter.
                      if (Character.isLetter(ch))
                      {
                          ch -= characterCaseDiff;
                      }
                      out.append(ch);
                      ch = Character.forDigit(ba[j] & 0xF, 16);
                      if (Character.isLetter(ch))
                      {
                          ch -= characterCaseDiff;
                      }
                      out.append(ch);
                  }
                  buf.reset();
              }
          }
  
          return out.toString();
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/store/MemoryStore.java
  
  Index: MemoryStore.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.store;
  
  import org.apache.avalon.framework.thread.ThreadSafe;
  
  import java.util.Enumeration;
  import java.util.Hashtable;
  
  /**
   *
   * @deprecated Use the Avalon Excalibur Store instead.
   *
   * @author <a href="mailto:scoobie@betaversion.org">Federico Barbieri</a>
   *         (Betaversion Productions)
   * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
   *         (Apache Software Foundation)
   * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
   *         (Apache Software Foundation, Exoffice Technologies)
   * @version CVS $Id: MemoryStore.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public class MemoryStore implements Store, ThreadSafe {
      /* WARNING: Hashtable is threadsafe, whereas HashMap is not.
       * Should we move this class over to the Collections API,
       * use Collections.synchronizedMap(Map map) to ensure
       * accesses are synchronized.
       */
  
      /** The shared store */
      private Hashtable table = new Hashtable();
  
      /**
       * Get the object associated to the given unique key.
       */
      public synchronized 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 synchronized 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 synchronized void hold(Object key, Object value) {
          table.put(key,value);
      }
  
      /**
       * Remove the object associated to the given key.
       */
      public synchronized void remove(Object key) {
          table.remove(key);
      }
  
      public synchronized void free() {}
  
      /**
       * Indicates if the given key is associated to a contained object.
       */
      public synchronized boolean containsKey(Object key) {
          return(table.containsKey(key));
      }
  
      /**
       * Returns the list of used keys as an Enumeration of Objects.
       */
      public synchronized Enumeration keys() {
          return(table.keys());
      }
  
      /**
       * Returns count of the objects in the store, or -1 if could not be
       * obtained.
       */
      public synchronized int size()
      {
          return table.size();
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/store/MRUMemoryStore.java
  
  Index: MRUMemoryStore.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.store;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.thread.ThreadSafe;
  
  import org.apache.cocoon.util.ClassUtils;
  
  import java.io.IOException;
  import java.net.URLEncoder;
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.LinkedList;
  import java.util.NoSuchElementException;
  
  /**
   * This class provides a cache algorithm for the requested documents.
   * It combines a HashMap and a LinkedList to create a so called MRU
   * (Most Recently Used) cache.
   *
   * The idea was taken from the "Writing Advanced Application Tutorial" from
   * javasoft. Many thanx to the writers!
   *
   * @deprecated Use the Avalon Excalibur Store instead.
   *
   * @author <a href="mailto:g-froehlich@gmx.de">Gerhard Froehlich</a>
   * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
   * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
   * @version CVS $Id: MRUMemoryStore.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public final class MRUMemoryStore extends AbstractLogEnabled
      implements Store, Parameterizable, Composable, Disposable, ThreadSafe {
  
      private int maxobjects;
      private boolean persistent;
      private Hashtable cache;
      private LinkedList mrulist;
      private Store persistentStore;
      private StoreJanitor storeJanitor;
      private ComponentManager manager;
  
      /**
       * Get components of the ComponentManager
       *
       * @param manager The ComponentManager
       */
      public void compose(ComponentManager manager) throws ComponentException {
          this.manager = manager;
          if (getLogger().isDebugEnabled()) {
              getLogger().debug("Looking up " + Store.PERSISTENT_CACHE);
              getLogger().debug("Looking up " + StoreJanitor.ROLE);
          }
          this.persistentStore = (Store)manager.lookup(Store.PERSISTENT_CACHE);
          this.storeJanitor = (StoreJanitor)manager.lookup(StoreJanitor.ROLE);
      }
  
      /**
       * Initialize the MRUMemoryStore.
       * A few options can be used:
       * <UL>
       *  <LI>maxobjects: Maximum number of objects stored in memory (Default: 100 objects)</LI>
       *  <LI>use-persistent-cache: Use persistent cache to keep objects persisted after
       *      container shutdown or not (Default: false)</LI>
       * </UL>
       *
       * @param params Store parameters
       * @exception ParameterException
       */
      public void parameterize(Parameters params) throws ParameterException {
          this.maxobjects = params.getParameterAsInteger("maxobjects", 100);
          this.persistent = params.getParameterAsBoolean("use-persistent-cache", false);
          if ((this.maxobjects < 1)) {
              throw new ParameterException("MRUMemoryStore maxobjects must be at least 1!");
          }
  
          this.cache = new Hashtable((int)(this.maxobjects * 1.2));
          this.mrulist = new LinkedList();
          this.storeJanitor.register(this);
      }
  
      /**
       * Dispose the component
       */
      public void dispose() {
          if (this.manager != null) {
              getLogger().debug("Disposing component!");
  
              if (this.storeJanitor != null)
                  this.storeJanitor.unregister(this);
              this.manager.release(this.storeJanitor);
              this.storeJanitor = null;
  
              // save all cache entries to filesystem
              if (this.persistent) {
                  if (getLogger().isDebugEnabled()) {
                      getLogger().debug("Final cache size: " + this.cache.size());
                  }
                  Enumeration enum = this.cache.keys();
                  while (enum.hasMoreElements()) {
                      Object key = enum.nextElement();
                      if (key == null) {
                          continue;
                      }
                      try {
                          Object value = this.cache.remove(key);
                          if(checkSerializable(value)) {
                               persistentStore.store(getFileName(key.toString()),
                                                     value);
                          }
                      } catch (IOException ioe) {
                          getLogger().error("Error in dispose()", ioe);
                      }
                  }
              }
              this.manager.release(this.persistentStore);
              this.persistentStore = null;
          }
  
          this.manager = null;
      }
  
      /**
       * 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.
       *
       * @param key The key for the object to store
       * @param value The object to store
       */
      public synchronized void store(Object key, Object value) {
          this.hold(key,value);
      }
  
      /**
       * This method holds the requested object in a HashMap combined
       * with a LinkedList to create the MRU.
       * It also stores objects onto the filesystem if configured.
       *
       * @param key The key of the object to be stored
       * @param value The object to be stored
       */
      public synchronized void hold(Object key, Object value) {
          if (getLogger().isDebugEnabled()) {
              getLogger().debug("Holding object in memory:");
              getLogger().debug("  key: " + key);
              getLogger().debug("  value: " + value);
          }
          /** ...first test if the max. objects in cache is reached... */
          while (this.mrulist.size() >= this.maxobjects) {
              /** ...ok, heapsize is reached, remove the last element... */
              this.free();
          }
          /** ..put the new object in the cache, on the top of course ... */
          this.cache.put(key, value);
          this.mrulist.remove(key);
          this.mrulist.addFirst(key);
      }
  
      /**
       * Get the object associated to the given unique key.
       *
       * @param key The key of the requested object
       * @return the requested object
       */
      public synchronized Object get(Object key) {
          Object value = this.cache.get(key);
          if (value != null) {
              /** put the accessed key on top of the linked list */
              this.mrulist.remove(key);
              this.mrulist.addFirst(key);
              if (getLogger().isDebugEnabled()) {
                  getLogger().debug("Found key: " + key.toString());
              }
              return value;
          }
  
          if (getLogger().isDebugEnabled()) {
              getLogger().debug("NOT Found key: " + key.toString());
          }
  
          /** try to fetch from filesystem */
          if (this.persistent) {
              value = this.persistentStore.get(getFileName(key.toString()));
              if (value != null) {
                  try {
                      if(!this.cache.containsKey(key)) {
                          this.hold(key, value);
                      }
                      return value;
                  } catch (Exception e) {
                      getLogger().error("Error in get()!", e);
                      return null;
                  }
              }
          }
  
          return null;
      }
  
      /**
       * Remove the object associated to the given key.
       *
       * @param key The key of to be removed object
       */
      public synchronized void remove(Object key) {
          if (getLogger().isDebugEnabled()) {
              getLogger().debug("Removing object from store");
              getLogger().debug("  key: " + key);
          }
          this.cache.remove(key);
          this.mrulist.remove(key);
          if(this.persistent && key != null) {
              this.persistentStore.remove(getFileName(key.toString()));
          }
      }
  
      /**
       * Indicates if the given key is associated to a contained object.
       *
       * @param key The key of the object
       * @return true if the key exists
       */
      public synchronized boolean containsKey(Object key) {
          if(persistent) {
              return (cache.containsKey(key) || persistentStore.containsKey(key));
          } else {
              return cache.containsKey(key);
          }
      }
  
      /**
       * Returns the list of used keys as an Enumeration.
       *
       * @return the enumeration of the cache
       */
      public synchronized Enumeration keys() {
          return this.cache.keys();
      }
  
      /**
       * Returns count of the objects in the store, or -1 if could not be
       * obtained.
       */
      public synchronized int size() {
          return this.cache.size();
      }
  
      /**
       * Frees some of the fast memory used by this store.
       * It removes the last element in the store.
       */
      public synchronized void free() {
          try {
              if (this.cache.size() > 0) {
                  // This can throw NoSuchElementException
                  Object key = this.mrulist.removeLast();
                  Object value = this.cache.remove(key);
                  if (value == null) {
                      getLogger().warn("Concurrency condition in free()");
                  }
  
                  if (getLogger().isDebugEnabled()) {
                      getLogger().debug("Freeing cache.");
                      getLogger().debug("  key: " + key);
                      getLogger().debug("  value: " + value);
                  }
  
                  if (this.persistent) {
                      // Swap object on fs.
                      if(checkSerializable(value)) {
                          try {
                              this.persistentStore.store(
                                  getFileName(key.toString()), value);
                          } catch(Exception e) {
                              getLogger().error("Error storing object on fs", e);
                          }
                      }
                  }
              }
          } catch (NoSuchElementException e) {
              getLogger().warn("Concurrency error in free()", e);
          } catch (Exception e) {
              getLogger().error("Error in free()", e);
          }
      }
  
      /**
       * This method checks if an object is seriazable.
       * FIXME: In the moment only CachedEventObject or
       * CachedStreamObject are stored.
       *
       * @param object The object to be checked
       * @return true if the object is storeable
       */
      private boolean checkSerializable(Object object) {
  
          if (object == null) return false;
  
          try {
              String clazz = object.getClass().getName();
              // FIXME (VG): Can class identity check work here (==)? It will be faster.
              if((clazz.equals("org.apache.cocoon.caching.CachedEventObject"))
                || (clazz.equals("org.apache.cocoon.caching.CachedStreamObject"))
                || (ClassUtils.implementsInterface(clazz, "org.apache.cocoon.caching.CacheValidity"))) {
                  return true;
              } else {
                  return false;
              }
          } catch (Exception e) {
              getLogger().error("Error in checkSerializable()!", e);
              return false;
          }
      }
  
      /**
       * This method puts together a filename for
       * the object, which shall be stored on the
       * filesystem.
       *
       * @param key The key of the object
       * @return the filename of the key
       */
      private String getFileName(String key) {
          return URLEncoder.encode(key.toString());
      }
  }
  
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/store/Store.java
  
  Index: Store.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.store;
  
  import org.apache.avalon.framework.component.Component;
  
  import java.io.IOException;
  import java.util.Enumeration;
  
  /**
   *
   * @deprecated Use the Avalon Excalibur Store instead.
   *
   * @author <a href="mailto:scoobie@betaversion.org">Federico Barbieri</a>
   *         (Betaversion Productions)
   * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
   *         (Apache Software Foundation)
   * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
   *         (Apache Software Foundation, Exoffice Technologies)
   * @version CVS $Id: Store.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public interface Store extends Component {
  
      String ROLE = "org.apache.cocoon.components.store.Store/Repository";
  
      String TRANSIENT_CACHE = "org.apache.cocoon.components.store.Store/TransientCache";
      String PERSISTENT_CACHE = "org.apache.cocoon.components.store.Store/PersistentCache";
  
      /**
       * Get the object associated to the given unique key.
       */
      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.
       */
      void store(Object key, Object value) throws IOException;
  
      /**
       * 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.
       */
      void hold(Object key, Object value) throws IOException;
  
      void free();
  
      /**
       * Remove the object associated to the given key.
       */
      void remove(Object key);
  
      /**
       * Indicates if the given key is associated to a contained object.
       */
      boolean containsKey(Object key);
  
      /**
       * Returns the list of used keys as an Enumeration of Objects.
       */
      Enumeration keys();
  
      /**
       * Returns count of the objects in the store, or -1 if could not be
       * obtained.
       */
      int size();
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/store/StoreJanitor.java
  
  Index: StoreJanitor.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.store;
  
  import org.apache.avalon.framework.component.Component;
  import java.util.Iterator;
  
  /**
   * Interface for the StoreJanitors
   *
   * @deprecated Use the Avalon Excalibur Store instead.
   *
   * @author <a href="mailto:g-froehlich@gmx.de">Gerhard Froehlich</a>
   * @version CVS $Id: StoreJanitor.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public interface StoreJanitor extends Component {
  
      String ROLE = "org.apache.cocoon.components.store.StoreJanitor";
  
      /** register method for the stores */
      void register(Store store);
  
      /** unregister method for the stores */
      void unregister(Store store);
  
      /** get an iterator to list registered stores */
      Iterator iterator();
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/store/StoreJanitorImpl.java
  
  Index: StoreJanitorImpl.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.store;
  
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.thread.ThreadSafe;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  
  /**
   * This class is a implentation of a StoreJanitor. Store classes
   * can register to the StoreJanitor. When memory is too low,
   * the StoreJanitor frees the registered caches until memory is normal.
   *
   * @deprecated Use the Avalon Excalibur Store instead.
   *
   * @author <a href="mailto:cs@ffzj0ia9.bank.dresdner.net">Christian Schmitt</a>
   * @author <a href="mailto:g-froehlich@gmx.de">Gerhard Froehlich</a>
   * @author <a href="mailto:proyal@managingpartners.com">Peter Royal</a>
   * @version CVS $Id: StoreJanitorImpl.java,v 1.1 2002/12/26 18:38:56 nicolaken Exp $
   */
  public class StoreJanitorImpl extends AbstractLogEnabled
      implements StoreJanitor,
                 Configurable,
                 ThreadSafe,
                 Runnable,
                 Startable {
  
      private int freememory = -1;
      private int heapsize = -1;
      private int cleanupthreadinterval = -1;
      private int priority = -1;
      private Runtime jvm;
      private ArrayList storelist;
      private int index = -1;
      private static boolean doRun = false;
      private double fraction;
  
      /**
       * Initialize the StoreJanitorImpl.
       * A few options can be used :
       * <UL>
       *  <LI>freememory = how many bytes shall be always free in the jvm</LI>
       *  <LI>heapsize = max. size of jvm memory consumption</LI>
       *  <LI>cleanupthreadinterval = how often (sec) shall run the cleanup thread</LI>
       *  <LI>threadpriority = priority of the thread (1-10). (Default: 10)</LI>
       * </UL>
       *
       * @param conf the Configuration of the application
       * @exception ConfigurationException
       */
      public void configure(Configuration conf) throws ConfigurationException {
          if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("Configure StoreJanitorImpl");
          }
          this.setJVM(Runtime.getRuntime());
  
          Parameters params = Parameters.fromConfiguration(conf);
          this.setFreememory(params.getParameterAsInteger("freememory",1000000));
          this.setHeapsize(params.getParameterAsInteger("heapsize",60000000));
          this.setCleanupthreadinterval(params.getParameterAsInteger("cleanupthreadinterval",10));
          this.setPriority(params.getParameterAsInteger( "threadpriority",
                                          Thread.currentThread().getPriority()));
          int percent = params.getParameterAsInteger("percent_to_free", 10);
  
          if ((this.getFreememory() < 1)) {
              throw new ConfigurationException("StoreJanitorImpl freememory parameter has to be greater then 1");
          }
          if ((this.getHeapsize() < 1)) {
              throw new ConfigurationException("StoreJanitorImpl heapsize parameter has to be greater then 1");
          }
          if ((this.getCleanupthreadinterval() < 1)) {
              throw new ConfigurationException("StoreJanitorImpl cleanupthreadinterval parameter has to be greater then 1");
          }
          if ((this.getPriority() < 1)) {
              throw new ConfigurationException("StoreJanitorImpl threadpriority has to be greater then 1");
          }
          if ((percent > 100 && percent < 1)) {
              throw new ConfigurationException("StoreJanitorImpl percent_to_free, has to be between 1 and 100");
          }
  
          this.fraction = percent / 100.0;
          this.setStoreList(new ArrayList());
      }
  
      public void start() {
          doRun = true;
          Thread checker = new Thread(this);
          if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("Intializing checker thread");
          }
          checker.setPriority(this.getPriority());
          checker.setDaemon(true);
          checker.setName("checker");
          checker.start();
      }
  
      public void stop() {
          doRun = false;
      }
  
      /**
       * The "checker" thread checks if memory is running low in the jvm.
       */
      public void run() {
          while (doRun) {
              // amount of memory used is greater then heapsize
              if (this.memoryLow()) {
                  if (this.getLogger().isDebugEnabled()) {
                      this.getLogger().debug("Invoking garbage collection, total memory = "
                              + this.getJVM().totalMemory() + ", free memory = "
                              + this.getJVM().freeMemory());
                  }
  
                  //this.freePhysicalMemory();
  
                  if (this.getLogger().isDebugEnabled()) {
                      this.getLogger().debug("Garbage collection complete, total memory = "
                          + this.getJVM().totalMemory() + ", free memory = "
                          + this.getJVM().freeMemory());
                  }
  
                  synchronized (this) {
                      if (this.memoryLow() && this.getStoreList().size() > 0) {
                          this.freeMemory();
                          this.setIndex(this.getIndex() + 1);
                      }
                 }
              }
              try {
                  Thread.currentThread().sleep(this.cleanupthreadinterval * 1000);
              } catch (InterruptedException ignore) {}
          }
      }
  
      /**
       * Method to check if memory is running low in the JVM.
       *
       * @return true if memory is low
       */
      private boolean memoryLow() {
          if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("JVM total Memory: " + this.getJVM().totalMemory());
              this.getLogger().debug("JVM free Memory: " + this.getJVM().freeMemory());
          }
  
          if((this.getJVM().totalMemory() >= this.getHeapsize())
              && (this.getJVM().freeMemory() < this.getFreememory())) {
              if (this.getLogger().isDebugEnabled()) {
                  this.getLogger().debug("Memory is low = true");
              }
              return true;
          } else {
              if (this.getLogger().isDebugEnabled()) {
                  this.getLogger().debug("Memory is low = false");
              }
              return false;
          }
      }
  
      /**
       * This method register the stores
       *
       * @param store the store to be registered
       */
      public void register(Store store) {
          this.getStoreList().add(store);
          if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("Registering store instance");
              this.getLogger().debug("Size of StoreJanitor now:"
                                     + this.getStoreList().size());
          }
      }
  
      /**
       * This method unregister the stores
       *
       * @param store the store to be unregistered
       */
      public void unregister(Store store) {
          this.getStoreList().remove(store);
          if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("Unregister store instance");
              this.getLogger().debug("Size of StoreJanitor now:"
                                     + this.getStoreList().size());
          }
      }
  
      /**
       * This method return a java.util.Iterator of every registered stores
       *
       * <i>The iterators returned is fail-fast: if list is structurally
       * modified at any time after the iterator is created, in any way, the
       * iterator will throw a ConcurrentModificationException.  Thus, in the
       * face of concurrent modification, the iterator fails quickly and
       * cleanly, rather than risking arbitrary, non-deterministic behavior at
       * an undetermined time in the future.</i>
       *
       * @return a java.util.Iterator
       */
      public Iterator iterator() {
          return this.getStoreList().iterator();
       }
  
      /**
       * Round Robin alghorithm for freeing the registerd caches.
       */
      private void freeMemory() {
          Store store;
  
          try {
              //Determine elements in Store:
              if (this.getLogger().isDebugEnabled()) {
                  this.getLogger().debug("StoreList size=" + this.getStoreList().size());
                  this.getLogger().debug("Actual Index position: " + this.getIndex());
              }
              if (this.getIndex() < this.getStoreList().size()) {
                  if(this.getIndex() == -1) {
                      this.setIndex(0);
                      store = (Store)this.getStoreList().get(this.getIndex());
  
                      if (this.getLogger().isDebugEnabled()) {
                          this.getLogger().debug("Freeing Store: " + this.getIndex());
                      }
  
                      //delete proportionate elements out of the cache as
                      //configured.
                      int limit = this.calcToFree(store);
                      for (int i=0; i < limit; i++) {
                          store.free();
                      }
                  } else {
                      store = (Store)this.getStoreList().get(this.getIndex());
  
                      if (this.getLogger().isDebugEnabled()) {
                          this.getLogger().debug("Freeing Store: " + this.getIndex());
                      }
  
                      //delete proportionate elements out of the cache as
                      //configured.
                      int limit = this.calcToFree(store);
                      for (int i=0; i < limit; i++) {
                          store.free();
                      }
                  }
              } else {
                  if (this.getLogger().isDebugEnabled()) {
                      this.getLogger().debug("Starting from the beginning");
                  }
  
                  this.resetIndex();
                  this.setIndex(0);
                  store = (Store)this.getStoreList().get(this.getIndex());
  
                  //delete proportionate elements out of the cache as
                  //configured.
                  int limit = this.calcToFree(store);
                  for (int i=0; i < limit; i++) {
                      store.free();
                  }
              }
          } catch(Exception e) {
              this.getLogger().error("Error in freeMemory()",e);
          }
      }
  
      /**
       * This method calculates the number of Elements to be freememory
       * out of the Cache.
       *
       * @param store the Store which was selected as victim
       * @return number of elements to be removed!
       */
      private int calcToFree(Store store) {
          int cnt = store.size();
          if (cnt < 0) {
              if (getLogger().isDebugEnabled()) {
                  getLogger().debug("Unknown size of the store: " + store);
              }
              return 0;
          }
          return (int)(cnt * fraction);
      }
  
      /**
       * This method forces the garbage collector
      private void freePhysicalMemory() {
          this.getJVM().runFinalization();
          this.getJVM().gc();
      }
       */
  
      private int getFreememory() {
          return freememory;
      }
  
      private void setFreememory(int _freememory) {
          this.freememory = _freememory;
      }
  
      private int getHeapsize() {
          return this.heapsize;
      }
  
      private void setHeapsize(int _heapsize) {
          this.heapsize = _heapsize;
      }
  
      private int getCleanupthreadinterval() {
          return this.cleanupthreadinterval;
      }
  
      private void setCleanupthreadinterval(int _cleanupthreadinterval) {
          this.cleanupthreadinterval = _cleanupthreadinterval;
      }
  
      private int getPriority() {
          return this.priority;
      }
  
      private void setPriority(int _priority) {
          this.priority = _priority;
      }
  
      private Runtime getJVM() {
          return this.jvm;
      }
  
      private void setJVM(Runtime _runtime) {
          this.jvm = _runtime;
      }
  
      private ArrayList getStoreList() {
          return this.storelist;
      }
  
      private void setStoreList(ArrayList _storelist) {
          this.storelist = _storelist;
      }
  
      private void setIndex(int _index) {
          if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("Setting index=" + _index);
          }
          this.index = _index;
      }
  
      private int getIndex() {
          return this.index;
      }
  
      private void resetIndex() {
          if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("Reseting index");
          }
          this.index = -1;
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/treeprocessor/MapStackResolver.java
  
  Index: MapStackResolver.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.treeprocessor;
  
  import org.apache.avalon.framework.parameters.Parameters;
  
  import org.apache.cocoon.sitemap.PatternException;
  
  import java.util.*;
  
  /**
   * Utility class for handling {...} pattern substitutions from a List of Maps.
   *
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @version CVS $Id: MapStackResolver.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   * @deprecated use {@link org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory}
   */
  
  public abstract class MapStackResolver {
  
      public static final Map EMPTY_MAP = Collections.unmodifiableMap(new java.util.HashMap(0));
  
      /**
       * Resolve all {...} patterns using the values given in the list of maps.
       */
      public abstract String resolve(List mapStack) throws PatternException;
  
      /**
       * Does an expression need resolving (i.e. contain {...} patterns) ?
       */
      public static boolean needsResolve(String expression) {
          if (expression == null || expression.length() == 0) {
              return false;
          }
  
          // Is the first char a '{' ?
          if (expression.charAt(0) == '{') {
              return true;
          }
  
          if (expression.length() < 2) {
              return false;
          }
  
          // Is there any unescaped '{' ?
          int pos = 1;
          while ( (pos = expression.indexOf('{', pos)) != -1) {
              // Found a '{' : is it escaped ?
              if (expression.charAt(pos - 1) != '\\') {
                  // No : need to resolve
                  return true;
              }
              pos++;
          }
          // Nothing found...
          return false;
      }
  
      /**
       * Unescape an expression that doesn't need to be resolved, but may contain
       * escaped '{' characters.
       *
       * @param expression the expression to unescape.
       * @return the unescaped result, or <code>expression</code> if unescaping isn't necessary.
       */
      public static String unescape(String expression) {
          // Does it need escaping ?
          if (expression == null || expression.indexOf("\\{") == -1) {
              return expression;
          }
  
          StringBuffer buf = new StringBuffer();
          for (int i = 0; i < expression.length(); i++) {
              char ch = expression.charAt(i);
              if (ch != '\\' || i >= (expression.length() - 1) || expression.charAt(i+1) != '{') {
                  buf.append(ch);
              }
          }
  
          return buf.toString();
      }
  
      /**
       * Get a resolver for a given expression. Chooses the most efficient implementation
       * depending on <code>expression</code>.
       */
      public static MapStackResolver getResolver(String expression) throws PatternException {
          if (needsResolve(expression)) {
  //            return new RealResolver(expression);
              return new CompiledResolver(expression);
          } else {
              return new NullResolver(expression);
          }
      }
  
      /**
       * Build a <code>Parameters</code> object from a Map of named <code>ListOfMapResolver</code>s and
       * a list of Maps used for resolution.
       *
       * @return a fully resolved <code>Parameters</code>.
       */
      public static Parameters buildParameters(Map expressions, List mapStack) throws PatternException {
          if (expressions == null || expressions.size() == 0) {
              return Parameters.EMPTY_PARAMETERS;
          }
  
          Parameters result = new Parameters();
  
          Iterator iter = expressions.entrySet().iterator();
          while (iter.hasNext()) {
              Map.Entry entry = (Map.Entry)iter.next();
              result.setParameter(
                  ((MapStackResolver)entry.getKey()).resolve(mapStack),
                  ((MapStackResolver)entry.getValue()).resolve(mapStack)
              );
          }
  
          return result;
      }
  
      /**
       * Resolve all values of a <code>Map</code> from a Map of named <code>ListOfMapResolver</code>s and
       * a list of Maps used for resolution.
       *
       * @return a fully resolved <code>Map</code>.
       */
      public static Map resolveMap(Map expressions, List mapStack) throws PatternException {
          int size;
          if (expressions == null || (size = expressions.size()) == 0) {
              return EMPTY_MAP;
          }
  
          Map result = new HashMap(size);
  
          Iterator iter = expressions.entrySet().iterator();
          while (iter.hasNext()) {
              Map.Entry entry = (Map.Entry)iter.next();
              result.put(
                  ((MapStackResolver)entry.getKey()).resolve(mapStack),
                  ((MapStackResolver)entry.getValue()).resolve(mapStack)
              );
          }
  
          return result;
      }
  
      //-------------------------------------------------------------------------
      /**
       * No-op resolver for expressions that don't need to be resolved.
       */
      private static class NullResolver extends MapStackResolver {
          private String originalExpr = null;
          private String expression = null;
  
          public NullResolver(String expression) {
              if (expression != null) {
                  this.originalExpr = expression;
                  this.expression = this.unescape(expression);
              }
          }
  
          public String toString() {
              return this.originalExpr;
          }
  
          public final String resolve(List mapStack) {
              return this.expression;
          }
      }
  
      //-------------------------------------------------------------------------
  
      /**
       * Compiled form for faster substitution
       */
      private static class CompiledResolver extends MapStackResolver {
          private String originalExpr;
  
          private String[] strings;
          private int[] levels;
  
          public CompiledResolver(String expression) throws PatternException {
              this.originalExpr = expression;
              compile(expression);
          }
  
          public String toString() {
              return this.originalExpr;
          }
  
          private void compile(String expr) throws PatternException {
              // We're sure here that expr *contains* some substitutions
  
              List stringList = new ArrayList();
              List levelList  = new ArrayList();
  
              int length = expr.length();
              int prev = 0; // position after last closing brace
  
              comp : while(prev < length) {
                  // find next unescaped '{'
                  int pos = prev;
                  while(pos < length &&
                        (pos = expr.indexOf('{', pos)) != -1 &&
                        (pos != 0 && expr.charAt(pos - 1) == '\\')) {
                      pos++;
                  }
  
                  if (pos >= length || pos == -1) {
                      // no more braces
                      if (prev < length) {
                          stringList.add(this.unescape(expr.substring(prev)));
                          levelList.add(new Integer(-1));
                      }
                      break comp;
                  }
  
                  // Pass closing brace
                  pos++;
  
                  // Add litteral strings between closing and next opening brace
                  if (prev < pos-1) {
                      stringList.add(this.unescape(expr.substring(prev, pos - 1)));
                      levelList.add(new Integer(-1));
                  }
  
                  // Determine subst level
                  int level = 1; // Start at 1 since it will be substracted from list.size()
                  while(expr.startsWith("../", pos)) {
                      level++;
                      pos += "../".length();
                  }
  
                  int end = expr.indexOf('}', pos);
                  if (end == -1) {
                      throw new PatternException("Unmatched '{' in " + expr);
                  }
  
                  stringList.add(expr.substring(pos, end));
                  levelList.add(new Integer(level));
  
                  prev = end + 1;
              }
  
              this.strings = new String[stringList.size()];
              this.levels = new int[stringList.size()];
              for (int i = 0; i < strings.length; i++) {
                  this.strings[i] = (String)stringList.get(i);
                  this.levels[i] = ((Integer)levelList.get(i)).intValue();
              }
          }
  
          public final String resolve(List mapStack) throws PatternException {
              StringBuffer result = new StringBuffer();
              int stackSize = mapStack.size();
  
              for (int i = 0; i < this.strings.length; i++) {
                  int level = this.levels[i];
                  if (level == -1) {
                      result.append(this.strings[i]);
  
                  } else {
                      if (level > stackSize) {
                          throw new PatternException("Error while evaluating '" + this.originalExpr +
                              "' : not so many levels");
                      }
  
                      Object value = ((Map)mapStack.get(stackSize - level)).get(this.strings[i]);
                      if (value != null) {
                          result.append(value);
                      }
                  }
              }
  
              return result.toString();
          }
  
  //        public void dump() {
  //            System.out.println(this.originalExpr + " compiled in :");
  //            for (int i = 0; i < this.strings.length; i++) {
  //                System.out.print("[" + this.levels[i] + ":'" + this.strings[i] + "'] ");
  //            }
  //            System.out.println();
  //            System.out.println();
  //        }
      }
  
  //    public static void main(String [] args) throws Exception {
  //
  //        new CompiledResolver("&{../../blah}").dump();
  //        new CompiledResolver("{t1}tt{t2}x").dump();
  //        new CompiledResolver("\\{t1}tt{t2}xx").dump();
  //        new CompiledResolver("{t1}tt\\{t2}xx").dump();
  //        new CompiledResolver("{t1}tt{t2}xx").dump();
  //        new CompiledResolver("xx{../t1}{../../../t2}zz").dump();
  //        new CompiledResolver("xx{../t1}\\{../../../t2}zz").dump();
  //
  //    }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/url/ContextURLFactory.java
  
  Index: ContextURLFactory.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.url;
  
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  
  import org.apache.cocoon.Constants;
  import org.apache.cocoon.environment.Context;
  
  import java.net.MalformedURLException;
  import java.net.URL;
  
  /**
   * @deprecated by the new source resolving of avalon excalibur
   *
   * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
   * @version $Id: ContextURLFactory.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  public class ContextURLFactory extends AbstractLogEnabled implements URLFactory, Contextualizable {
  
      /**
       * The context
       */
      protected org.apache.avalon.framework.context.Context context;
  
      /**
       * Create a URL from a location. This method supports the
       * <i>context://</i> pseudo-protocol for loading
       * resources accessible from the context root path
       *
       * @param location The location
       * @return The URL pointed to by the location
       * @exception MalformedURLException If the location is malformed
       */
      public URL getURL(String location) throws MalformedURLException {
          Context envContext = null;
          try {
              envContext = (Context)this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
          } catch (ContextException e){
              getLogger().error("ContextException in getURL",e);
          }
          if (envContext == null) {
              getLogger().warn("no environment-context in application context (making an absolute URL)");
              return new URL(location);
          }
          URL u = envContext.getResource("/" + location);
          if (u != null)
              return u;
          else {
              getLogger().info(location + " could not be found. (possible context problem)");
              throw new MalformedURLException(location + " could not be found. (possible context problem)");
          }
      }
  
      public URL getURL(URL base, String location) throws MalformedURLException {
          return getURL(base.toExternalForm() + location);
      }
  
      /**
       * Get the context
       */
      public void contextualize(org.apache.avalon.framework.context.Context context) throws ContextException {
          if (this.context == null) {
              this.context = context;
          }
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/url/ResourceURLFactory.java
  
  Index: ResourceURLFactory.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.url;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  
  import org.apache.cocoon.util.ClassUtils;
  
  import java.net.MalformedURLException;
  import java.net.URL;
  
  /**
   * @deprecated by the new source resolving of avalon excalibur
   *
   * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
   * @version $Id: ResourceURLFactory.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  public class ResourceURLFactory extends AbstractLogEnabled implements URLFactory, Contextualizable {
  
      /**
       * The context
       */
      protected Context context;
  
      /**
       * 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 URL getURL(String location) throws MalformedURLException {
          URL u = ClassUtils.getResource(location);
          if (u != null)
              return u;
          else {
              getLogger().error(location + " could not be found. (possible classloader problem)");
              throw new RuntimeException(location + " could not be found. (possible classloader problem)");
          }
      }
  
      public URL getURL(URL base, String location) throws MalformedURLException {
          return getURL (base.toExternalForm() + location);
      }
  
      /**
       * Get the context
       */
      public void contextualize(Context context) throws ContextException {
          if (this.context == null) {
              this.context = context;
          }
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/url/URLFactory.java
  
  Index: URLFactory.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.url;
  
  import org.apache.avalon.framework.component.Component;
  
  import java.net.MalformedURLException;
  import java.net.URL;
  
  /**
   * @deprecated by the new source resolving of avalon excalibur
   *
   * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
   * @version $Id: URLFactory.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  public interface URLFactory extends Component {
  
      String ROLE = "org.apache.cocoon.components.url.URLFactory";
      /**
       * Get an URL
       */
      URL getURL(String location) throws MalformedURLException;
      URL getURL(URL base, String location) throws MalformedURLException;
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/url/URLFactoryImpl.java
  
  Index: URLFactoryImpl.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.url;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.cocoon.Constants;
  import org.apache.cocoon.util.ClassUtils;
  
  import java.io.File;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  
  /**
   * @deprecated by the new source resolving of avalon excalibur
   *
   * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
   * @version $Id: URLFactoryImpl.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  public class URLFactoryImpl extends AbstractLogEnabled
      implements ThreadSafe, Configurable, Disposable, Composable, Contextualizable, URLFactory {
  
      /**
       * The context
       */
      protected Context context;
  
      /**
       * The special URL factories
       */
      protected Map factories;
  
      /** The component manager */
      private ComponentManager manager;
  
      /**
       * Create a URL from a location. This method supports specific
       * pseudo-protocol as defined in its configuration
       *
       * @param location The location
       * @return The URL pointed to by the location
       * @exception MalformedURLException If the location is malformed
       */
      public URL getURL(String location) throws MalformedURLException {
          Iterator iter = factories.keySet().iterator();
          String protocol = null;
          while (iter.hasNext()) {
              protocol = (String)iter.next();
              if (location.startsWith(protocol + "://")) {
                  return ((URLFactory)factories.get(protocol)).getURL(location.substring(protocol.length() + 3));
              }
          }
          try {
              if (getLogger().isDebugEnabled()) {
                  getLogger().debug("Making URL from " + location);
              }
              return new URL(location);
          } catch (MalformedURLException mue) {
              if (getLogger().isDebugEnabled()) {
                  getLogger().debug("Making URL - MalformedURLException in getURL:" , mue);
              }
  
              org.apache.cocoon.environment.Context envContext = null;
              try {
                  envContext = (org.apache.cocoon.environment.Context)
                                  context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
              } catch (ContextException e){
                  getLogger().error("Making URL - ContextException in getURL",e);
              }
  
              final String path = envContext.getRealPath(location);
              if (path != null)
                  return (new File(path)).toURL();
  
              if (getLogger().isDebugEnabled()) {
                  getLogger().debug("Making URL a Resource:" + location);
              }
              URL url = envContext.getResource(location);
              if(url != null)
                  return url;
  
              if (getLogger().isDebugEnabled()) {
                  getLogger().debug("Making URL a File (assuming that it is full path):" + location);
              }
              return (new File(location)).toURL();
          }
      }
  
      public URL getURL(URL base, String location) throws MalformedURLException {
          if ( base != null ) {
              if (base.getProtocol().equals("file")) {
                  File temp = new File(base.toExternalForm().substring("file:".length()), location);
                  String path = temp.getAbsolutePath();
                  // VG: M$ paths starts with drive letter
                  if (path.charAt(0) != File.separator.charAt(0)) {
                      return getURL("file:/" + path);
                  } else {
                      return getURL("file:" + path);
                  }
              }
  
              return getURL(new URL(base, location).toExternalForm());
          } else {
              return getURL(location);
          }
      }
  
      /**
       * Get the context
       */
      public void contextualize(Context context) throws ContextException {
          if (this.context == null) {
              this.context = context;
          }
      }
  
      /**
       * Configure the URLFactories
       */
      public void configure(final Configuration conf)
      throws ConfigurationException {
          try {
              getLogger().debug("Getting the URLFactories");
              factories = new HashMap();
              Configuration[] configs = conf.getChildren("protocol");
              URLFactory urlFactory = null;
              String protocol = null;
              for (int i = 0; i < configs.length; i++) {
                  protocol = configs[i].getAttribute("name");
                  if (factories.containsKey(protocol)) {
                      throw new ConfigurationException("URLFactory defined twice for protocol: " + protocol);
                  }
                  if (getLogger().isDebugEnabled()) {
                      getLogger().debug("\tfor protocol: " + protocol + " " + configs[i].getAttribute("class"));
                  }
                  urlFactory = (URLFactory) ClassUtils.newInstance(configs[i].getAttribute("class"));
                  this.init(urlFactory, configs[i]);
                  factories.put(protocol, urlFactory);
              }
          } catch (Exception e) {
              getLogger().error("Could not get URLFactories", e);
              throw new ConfigurationException("Could not get parameters because: " +
                                             e.getMessage());
          }
      }
  
      /**
       * Set the current <code>ComponentManager</code> instance used by this
       * <code>Composable</code>.
       */
      public void compose(ComponentManager manager)
      throws ComponentException {
          this.manager = manager;
      }
  
      /**
       * Dispose
       */
      public void dispose() {
          Iterator iter = this.factories.values().iterator();
          URLFactory current;
          while (iter.hasNext()) {
              current = (URLFactory) iter.next();
              this.deinit(current);
          }
          this.factories = null;
      }
  
      /**
       * Init a url factory
       */
      private void init(URLFactory factory, Configuration config)
      throws ContextException, ComponentException, ConfigurationException, ParameterException {
          if (factory instanceof LogEnabled) {
              ((LogEnabled) factory).enableLogging(getLogger());
          }
          if (factory instanceof Contextualizable) {
              ((Contextualizable) factory).contextualize (this.context);
          }
          if (factory instanceof Composable) {
              ((Composable) factory).compose(this.manager);
          }
          if (config != null && factory instanceof Configurable) {
              ((Configurable) factory).configure(config);
          }
          if (config != null && factory instanceof Parameterizable) {
              ((Parameterizable) factory).parameterize(Parameters.fromConfiguration(config));
          }
      }
  
      /**
       * Deinit a url factory
       */
      private void deinit(URLFactory factory) {
          if (factory instanceof Disposable) {
              ((Disposable) factory).dispose();
          }
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/xpath/JaxenProcessorImpl.java
  
  Index: JaxenProcessorImpl.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.xpath;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.thread.ThreadSafe;
  
  import org.jaxen.dom.DOMXPath;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  import java.util.List;
  
  /**
   * This class defines the implementation of the {@link XPathProcessor}
   * component.
   *
   * To configure it, add the following lines in the
   * <file>cocoon.xconf</file> file:
   *
   * <pre>
   * &lt;xslt-processor class="org.apache.cocoon.components.xpath.JaxenProcessorImpl"&gt;
   * &lt;/xslt-processor&gt;
   * </pre>
   * @deprecated Use the org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl instead.
   *
   * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
   * @version CVS $Id: JaxenProcessorImpl.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  public class JaxenProcessorImpl
    extends AbstractLogEnabled
    implements XPathProcessor, ThreadSafe
  {
      /**
       * 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 Node selectSingleNode(Node contextNode, String str)
      {
          try {
              DOMXPath path = new DOMXPath(str);
              return (Node)path.selectSingleNode((Object)contextNode);
          } catch (Exception e){
              // ignore it
          }
          return 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 NodeList selectNodeList(Node contextNode, String str)
      {
          try {
              DOMXPath path = new DOMXPath(str);
              List list = path.selectNodes((Object)contextNode);
              return new NodeListEx(list);
          } catch (Exception e){
              // ignore it
          }
          return new NodeListEx();
      }
  
      class NodeListEx implements NodeList{
          List list = null;
          NodeListEx(){
          }
          NodeListEx(List l){
              list = l;
          }
          public Node item(int index) {
              if(list==null)
                  return null;
              return (Node)list.get(index);
          }
          public int getLength(){
              if(list==null)
                  return 0;
              return list.size();
          }
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/xpath/XPathProcessor.java
  
  Index: XPathProcessor.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.xpath;
  
  import org.apache.avalon.framework.component.Component;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  /**
   * This is the interface of the XPath processor in Cocoon.
   *
   * @deprecated Use the org.apache.avalon.excalibur.xml.xpath.XPathProcessor instead.
   * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
   * @version CVS $Id: XPathProcessor.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  public interface XPathProcessor
  extends Component {
      /**
       * The role implemented by an <code>XPathProcessor</code>.
       */
      String ROLE = "org.apache.cocoon.components.xpath.XPathProcessor";
  
      /**
       * 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.
       */
      Node selectSingleNode(Node contextNode, String str);
  
      /**
       *  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 List, should never be null.
       */
      NodeList selectNodeList(Node contextNode, String str);
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/xpath/XPathProcessorImpl.java
  
  Index: XPathProcessorImpl.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.xpath;
  
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.xpath.XPathAPI;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  /**
   * This class defines the implementation of the {@link XPathProcessor}
   * component.
   *
   * To configure it, add the following lines in the
   * <file>cocoon.xconf</file> file:
   *
   * <pre>
   * &lt;xslt-processor class="org.apache.cocoon.components.xpath.XPathProcessorImpl"&gt;
   * &lt;/xslt-processor&gt;
   * </pre>
   *
   * @deprecated Use the org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl instead.
   * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
   * @version CVS $Id: XPathProcessorImpl.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  public class XPathProcessorImpl  extends AbstractLogEnabled
    implements XPathProcessor, ThreadSafe {
      /**
       * 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 Node selectSingleNode(Node contextNode, String str)
      {
          try {
              return XPathAPI.selectSingleNode(contextNode, str);
          } catch (javax.xml.transform.TransformerException e){
              return 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 NodeList selectNodeList(Node contextNode, String str)
      {
        try {
            return XPathAPI.selectNodeList(contextNode, str);
        } catch (javax.xml.transform.TransformerException e){
            return new NodeList(){
                public Node item(int index) { return null;}
                public int getLength(){return 0;}
            };
        }
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/xslt/XSLTProcessor.java
  
  Index: XSLTProcessor.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.xslt;
  
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.environment.Source;
  import org.apache.cocoon.environment.SourceResolver;
  import org.xml.sax.XMLFilter;
  
  import javax.xml.transform.Result;
  import javax.xml.transform.sax.TransformerHandler;
  
  /**
   * This is the interface of the XSLT processor in Cocoon.
   *
   * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
   * @version CVS $Id: XSLTProcessor.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   * @version 1.0
   * @since   July 11, 2001
   */
  public interface XSLTProcessor extends Component
  {
    /**
     * The role implemented by an <code>XSLTProcessor</code>.
     */
    String ROLE = XSLTProcessor.class.getName();
  
    /**
     * The default factory identifier. (simply used as a pointer, the actual
     * content is not meaningful)
     */
    String DEFAULT_FACTORY = "default";
  
    /**
     * Set the {@link org.apache.cocoon.environment.SourceResolver} for
     * this instance. The <code>resolver</code> is invoked to return a
     * <code>Source</code> object, given an HREF.
     *
     * @deprecated The processor can now simply lookup the source resolver.
     * @param resolver a <code>SourceResolver</code> value
     */
    void setSourceResolver(SourceResolver resolver);
  
    /**
     * Set the TransformerFactory for this instance.
     * The <code>factory</code> is invoked to return a
     * <code>TransformerHandler</code> to perform the transformation.
     *
     * @param classname the name of the class implementing
     * <code>TransformerFactory</code> value. If an error is found
     * or the indicated class doesn't implement the required interface
     * the original factory of the component is maintained.
     */
    void setTransformerFactory(String classname);
  
    /**
     * <p>Return a <code>TransformerHandler</code> for a given
     * stylesheet <code>Source</code>. This can be used in a pipeline to
     * handle the transformation of a stream of SAX events. See {@link
     * org.apache.cocoon.transformation.TraxTransformer#setConsumer} for
     * an example of how to use this method.
     *
     * <p>The additional <code>filter</code> argument, if it's not
     * <code>null</code>, is inserted in the chain SAX events as an XML
     * filter during the parsing or the source document.
     *
     * <p>This method caches the Source object and performs a reparsing
     * only if this changes.
     *
     * @param stylesheet a <code>Source</code> value
     * @param filter a <code>XMLFilter</code> value
     * @return a <code>TransformerHandler</code> value
     * @exception ProcessingException if an error occurs
     */
    TransformerHandler getTransformerHandler(Source stylesheet,
                                             XMLFilter filter)
      throws ProcessingException;
  
    /**
     * Same as {@link #getTransformerHandler(Source,XMLFilter)}, with
     * <code>filter</code> set to <code>null</code> and <code>factory</code>
     * set to <code>null</code>.
     *
     * @param stylesheet a <code>Source</code> value
     * @return a <code>TransformerHandler</code> value
     * @exception ProcessingException if an error occurs
     * @see org.apache.cocoon.transformation.TraxTransformer#setConsumer
     */
    TransformerHandler getTransformerHandler(Source stylesheet)
      throws ProcessingException;
  
    /**
     * Applies an XSLT stylesheet to an XML document. The source and
     * stylesheet documents are specified as <code>Source</code>
     * objects. The result of the transformation is placed in
     * <code>result</code>, which should be properly initialized before
     * invoking this method. Any additional parameters passed in
     * <code>params</code> will become arguments to the stylesheet.
     *
     * @param source a <code>Source</code> value
     * @param stylesheet a <code>Source</code> value
     * @param params a <code>Parameters</code> value
     * @param result a <code>Result</code> value
     * @exception ProcessingException if an error occurs
     */
    void transform(Source source, Source stylesheet, Parameters params,
                   Result result)
      throws ProcessingException;
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/components/xslt/XSLTProcessorImpl.java
  
  Index: XSLTProcessorImpl.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.xslt;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.util.ClassUtils;
  import org.apache.cocoon.util.TraxErrorHandler;
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceException;
  import org.apache.excalibur.source.SourceResolver;
  import org.apache.excalibur.store.Store;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXException;
  import org.xml.sax.XMLFilter;
  
  import javax.xml.transform.*;
  import javax.xml.transform.sax.SAXTransformerFactory;
  import javax.xml.transform.sax.TemplatesHandler;
  import javax.xml.transform.sax.TransformerHandler;
  import javax.xml.transform.stream.StreamSource;
  
  import java.io.File;
  import java.io.IOException;
  import java.util.HashMap;
  
  /**
   * This class defines the implementation of the {@link XSLTProcessor}
   * component.
   *
   * To configure it, add the following lines in the
   * <file>cocoon.xconf</file> file:
   *
   * <pre>
   * &lt;xslt-processor class="org.apache.cocoon.components.xslt.XSLTProcessorImpl"&gt;
   *    &lt;parameter name="use-store" value="true"/&gt;
   *    &lt;parameter name="transformer-factory" value="org.apache.xalan.processor.TransformerFactoryImpl"/&gt;
   * &lt;/xslt-processor&gt;
   * </pre>
   *
   * The &lt;use-store&gt; configuration forces the transformer to put the
   * <code>Templates</code> generated from the XSLT stylesheet into the
   * <code>Store</code>. This property is true by default.
   * <p>
   * The &lt;transformer-factory&gt; configuration tells the transformer to use a particular
   * implementation of <code>javax.xml.transform.TransformerFactory</code>. This allows to force
   * the use of a given TRAX implementation (e.g. xalan or saxon) if several are available in the
   * classpath. If this property is not set, the transformer uses the standard TRAX mechanism
   * (<code>TransformerFactory.newInstance()</code>).
   *
   * @deprecated Use the avalon excalibur xslt processor instead.
   * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
   * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
   * @version CVS $Id: XSLTProcessorImpl.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   * @version 1.0
   * @since   July 11, 2001
   */
  public class XSLTProcessorImpl
    extends AbstractLogEnabled
    implements XSLTProcessor,
               Composable,
               Disposable,
               Parameterizable,
               URIResolver {
  
      protected ComponentManager manager;
  
      /** The store service instance */
      protected Store store;
  
      /** The trax TransformerFactory lookup table*/
      protected HashMap factories;
  
      /** The trax TransformerFactory this component uses */
      protected SAXTransformerFactory factory;
  
      /** Is the store turned on? (default is on) */
      protected boolean useStore = true;
  
      /** Is incremental processing turned on? (default for Xalan: no) */
      protected boolean incrementalProcessing = false;
  
      /** The source resolver used by this processor **/
      protected SourceResolver resolver;
  
      /** The error handler for the transformer */
      protected TraxErrorHandler errorHandler;
  
      /**
       * Compose. Try to get the store
       */
      public void compose(ComponentManager manager)
      throws ComponentException {
          this.manager = manager;
          if (this.getLogger().isDebugEnabled())
              this.getLogger().debug("XSLTProcessorImpl component initialized.");
          this.store = (Store) manager.lookup(Store.TRANSIENT_STORE);
          this.errorHandler = new TraxErrorHandler( this.getLogger() );
          this.resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
      }
  
      /**
       * Dispose
       */
      public void dispose() {
          if (this.manager != null) {
              this.manager.release(this.store);
              this.store = null;
              this.manager.release(this.resolver);
              this.resolver = null;
          }
          this.errorHandler = null;
          this.manager = null;
      }
  
      /**
       * Configure the component
       */
      public void parameterize(Parameters params)
      throws ParameterException {
          this.useStore = params.getParameterAsBoolean("use-store", true);
          this.incrementalProcessing = params.getParameterAsBoolean("incremental-processing", false);
          this.factory = getTransformerFactory(params.getParameter("transformer-factory", DEFAULT_FACTORY));
      }
  
      /**
       * Set the source resolver used by this component
       * @deprecated The processor can now simply lookup the source resolver.
       */
      public void setSourceResolver(org.apache.cocoon.environment.SourceResolver resolver) {
          if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("XSLTProcessor: the setSourceResolver() method is deprecated.");
          }
      }
  
      /**
       * Set the transformer factory used by this component
       */
      public void setTransformerFactory(String classname) {
          this.factory = getTransformerFactory(classname);
      }
  
      public TransformerHandler getTransformerHandler(org.apache.cocoon.environment.Source stylesheet)
      throws ProcessingException {
          return getTransformerHandler(stylesheet, null);
      }
  
      public TransformerHandler getTransformerHandler(org.apache.cocoon.environment.Source stylesheet,
                                                      XMLFilter filter)
      throws ProcessingException {
          try {
              final String id = stylesheet.getSystemId();
              Templates templates = getTemplates(stylesheet, id);
              if (templates == null) {
                  if (this.getLogger().isDebugEnabled()) {
                      getLogger().debug("Creating new Templates for " + id);
                  }
  
                  // Create a Templates ContentHandler to handle parsing of the
                  // stylesheet.
                  TemplatesHandler templatesHandler = this.factory.newTemplatesHandler();
  
                  // Set the system ID for the template handler since some
                  // TrAX implementations (XSLTC) rely on this in order to obtain
                  // a meaningful identifier for the Templates instances.
                  templatesHandler.setSystemId(id);
  
                  if (filter != null) {
                      filter.setContentHandler(templatesHandler);
                  }
  
                  if (this.getLogger().isDebugEnabled()) {
                      getLogger().debug("Source = " + stylesheet
                      + ", templatesHandler = " + templatesHandler);
                  }
  
                  // Process the stylesheet.
                  stylesheet.toSAX(filter != null ?
                              (ContentHandler)filter : (ContentHandler)templatesHandler);
  
                  // Get the Templates object (generated during the parsing of
                  // the stylesheet) from the TemplatesHandler.
                  templates = templatesHandler.getTemplates();
                  putTemplates (templates, stylesheet, id);
              } else {
                  if (this.getLogger().isDebugEnabled()) {
                      getLogger().debug("Reusing Templates for " + id);
                  }
              }
  
              TransformerHandler handler = this.factory.newTransformerHandler(templates);
              handler.getTransformer().setErrorListener(this.errorHandler);
              handler.getTransformer().setURIResolver(this);
              return handler;
          } catch (ProcessingException e) {
              throw e;
          } catch (SAXException e) {
              if (e.getException() == null) {
                  throw new ProcessingException("Exception in creating Transform Handler", e);
              } else {
                  if (getLogger().isDebugEnabled())
                      getLogger().debug("Got SAXException. Rethrowing cause exception.", e);
                  throw new ProcessingException("Exception in creating Transform Handler", e.getException());
              }
          } catch (Exception e) {
              throw new ProcessingException("Exception in creating Transform Handler", e);
          }
      }
  
      public void transform(org.apache.cocoon.environment.Source source,
                            org.apache.cocoon.environment.Source stylesheet,
                            Parameters params,
                            Result result)
      throws ProcessingException {
          try {
              if (this.getLogger().isDebugEnabled()) {
                  getLogger().debug("XSLTProcessorImpl: transform source = " + source
                      + ", stylesheet = " + stylesheet
                      + ", parameters = " + params
                      + ", result = " + result);
              }
              TransformerHandler handler = getTransformerHandler(stylesheet);
  
              Transformer transformer = handler.getTransformer();
              if (params != null) {
                  transformer.clearParameters();
                  String[] names = params.getNames();
                  for (int i = names.length -1 ; i >= 0; i--) {
                      transformer.setParameter(names[i], params.getParameter(names[i]));
                  }
              }
  
              if (getLogger().isDebugEnabled())
                  this.getLogger().debug("XSLTProcessorImpl: starting transform");
              // FIXME (VG): Is it possible to use Source's toSAX method?
              handler.setResult(result);
              source.toSAX(handler);
  
              if (getLogger().isDebugEnabled())
                  this.getLogger().debug("XSLTProcessorImpl: transform done");
          } catch (Exception e) {
              throw new ProcessingException("Error in running Transformation", e);
          }
      }
  
      /**
       * Get the TransformerFactory associated with the given classname. If
       * the class can't be found or the given class doesn't implement
       * the required interface, the default factory is returned.
       */
      private SAXTransformerFactory getTransformerFactory(String factoryName) {
          SAXTransformerFactory _factory;
  
          if ((factoryName == null) || (factoryName == XSLTProcessor.DEFAULT_FACTORY)) {
              _factory = (SAXTransformerFactory) TransformerFactory.newInstance();
          } else {
              try {
                  _factory = (SAXTransformerFactory) ClassUtils.loadClass(factoryName).newInstance();
              } catch (ClassNotFoundException cnfe) {
                  if (getLogger().isErrorEnabled())
                      getLogger().error("Cannot find the requested TrAX factory '" + factoryName
                                        + "'. Using default TrAX Transformer Factory instead.");
                  if (this.factory != null) return this.factory;
                  _factory = (SAXTransformerFactory) TransformerFactory.newInstance();
              } catch (ClassCastException cce) {
                  if (getLogger().isErrorEnabled())
                      getLogger().error("The indicated class '" + factoryName
                                        + "' is not a TrAX Transformer Factory. Using default TrAX Transformer Factory instead.");
                  if (this.factory != null) return this.factory;
                  _factory = (SAXTransformerFactory) TransformerFactory.newInstance();
              } catch (Exception e) {
                  if (getLogger().isErrorEnabled())
                      getLogger().error("Error found loading the requested TrAX Transformer Factory '"
                                        + factoryName + "'. Using default TrAX Transformer Factory instead.");
                  if (this.factory != null) return this.factory;
                  _factory = (SAXTransformerFactory) TransformerFactory.newInstance();
              }
          }
  
          _factory.setErrorListener(this.errorHandler);
          _factory.setURIResolver(this);
  
          // FIXME (SM): implementation-specific parameter passing should be
          // made more extensible.
          if (_factory.getClass().getName().equals("org.apache.xalan.processor.TransformerFactoryImpl")) {
              _factory.setAttribute("http://xml.apache.org/xalan/features/incremental",
                      new Boolean (incrementalProcessing));
          }
  
          return _factory;
      }
  
      private Templates getTemplates(org.apache.cocoon.environment.Source stylesheet,
                                     String id)
      throws IOException, ProcessingException {
          if (!useStore) {
              return null;
          }
  
          // we must augment the template ID with the factory classname since one
          // transformer implementation cannot handle the instances of a
          // template created by another one.
          id += factory.getClass().getName();
  
          Templates templates = null;
          // only stylesheets with a last modification date are stored
          if (stylesheet.getLastModified() != 0) {
              // Stored is an array of the template and the caching time
              if (store.containsKey(id)) {
                  Object[] templateAndTime = (Object[])store.get(id);
  
                  if(templateAndTime != null && templateAndTime[1] != null) {
                      long storedTime = ((Long)templateAndTime[1]).longValue();
  
                      if (storedTime < stylesheet.getLastModified()) {
                          store.remove(id);
                      } else {
                          templates = (Templates)templateAndTime[0];
                      }
                  }
              }
          } else if (store.containsKey(id)) {
              // remove an old template if it exists
              store.remove(id);
          }
          return templates;
      }
  
      private void putTemplates (Templates templates, org.apache.cocoon.environment.Source stylesheet,
                                 String id)
      throws IOException, ProcessingException {
          if (!useStore) {
              return;
          }
  
          // we must augment the template ID with the factory classname since one
          // transformer implementation cannot handle the instances of a
          // template created by another one.
          id += factory.getClass().getName();
  
          // only stylesheets with a last modification date are stored
          if (stylesheet.getLastModified() != 0) {
  
              // Stored is an array of the template and the current time
              Object[] templateAndTime = new Object[2];
              templateAndTime[0] = templates;
              templateAndTime[1] = new Long(stylesheet.getLastModified());
              store.store(id, templateAndTime);
          }
      }
  
      /**
       * Called by the processor when it encounters
       * an xsl:include, xsl:import, or document() function.
       *
       * @param href An href attribute, which may be relative or absolute.
       * @param base The base URI in effect when the href attribute
       * was encountered.
       *
       * @return A Source object, or null if the href cannot be resolved,
       * and the processor should try to resolve the URI itself.
       *
       * @throws TransformerException if an error occurs when trying to
       * resolve the URI.
       */
      public javax.xml.transform.Source resolve(String href, String base)
      throws TransformerException {
          if (this.getLogger().isDebugEnabled()) {
              this.getLogger().debug("resolve(href = " + href +
                                     ", base = " + base + "); resolver = " + resolver);
          }
  
          Source xslSource = null;
          try {
              if (href.indexOf(":") > 1) {
                  xslSource = resolver.resolveURI(href);
              } else {
                  // patch for a null pointer passed as base
                  if (base == null)
                      throw new IllegalArgumentException("Null pointer passed as base");
  
                  // is the base a file or a real url
                  if (!base.startsWith("file:")) {
                      int lastPathElementPos = base.lastIndexOf('/');
                      if (lastPathElementPos == -1) {
                          // this should never occur as the base should
                          // always be protocol:/....
                          return null; // we can't resolve this
                      } else {
                          xslSource = resolver.resolveURI(new StringBuffer(base.substring(0, lastPathElementPos))
                          .append("/").append(href).toString());
                      }
                  } else {
                      File parent = new File(base.substring(5));
                      File parent2 = new File(parent.getParentFile(), href);
                      xslSource = resolver.resolveURI(parent2.toURL().toExternalForm());
                  }
              }
  
              if (this.getLogger().isDebugEnabled()) {
                  getLogger().debug("xslSource = " + xslSource
                  + ", system id = " + xslSource.getSystemId());
              }
  
              return new StreamSource(xslSource.getInputStream(), xslSource.getSystemId());
  
          } catch (java.net.MalformedURLException mue) {
              return null;
          } catch (IOException ioe) {
              return null;
          } catch (SourceException pe) {
              throw new TransformerException(pe);
          } finally {
              this.resolver.release( xslSource );
          }
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/environment/ModifiableSource.java
  
  Index: ModifiableSource.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.environment;
  
  /**
   * Describes a {@link Source} object whose data content can change.
   *
   * @deprecated Use the {@link org.apache.excalibur.source.Source} interface instead
   * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
   */
  public interface ModifiableSource extends Source
  {
    /**
     * Refresh the content of this object after the underlying data
     * content has changed.
     */
    void refresh();
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/environment/Source.java
  
  Index: Source.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.environment;
  
  import org.apache.avalon.excalibur.pool.Recyclable;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.xml.XMLizable;
  import org.xml.sax.InputSource;
  
  import java.io.IOException;
  import java.io.InputStream;
  
  /**
   * Description of a source. This interface provides a simple interface
   * for accessing a source of data. The source of data is assumed to
   * <b>not change</b> during the lifetime of the Source object. If you
   * have a data source that can change its content and you want it to
   * reflect in Cocoon, use a {@link ModifiableSource} object instead.
   *
   * @deprecated Use the {@link org.apache.excalibur.source.Source} interface instead
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
   * @version CVS $Id: Source.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  
  public interface Source extends Recyclable, XMLizable {
    /**
     * Get the last modification date of the source or 0 if it
     * is not possible to determine the date.
     */
    long getLastModified();
  
    /**
     * Get the content length of the source or -1 if it
     * is not possible to determine the length.
     */
    long getContentLength();
  
    /**
     * Return an <code>InputStream</code> object to read from the source.
     */
    InputStream getInputStream()
      throws ProcessingException, IOException;
  
    /**
     * Return an <code>InputSource</code> object to read the XML
     * content.
     *
     * @return an <code>InputSource</code> value
     * @exception ProcessingException if an error occurs
     * @exception IOException if an error occurs
     */
    InputSource getInputSource()
      throws ProcessingException, IOException;
  
    /**
     * Return the unique identifer for this source
     */
    String getSystemId();
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/environment/SourceResolver.java
  
  Index: SourceResolver.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.environment;
  
  import org.apache.cocoon.ProcessingException;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXException;
  import java.io.IOException;
  
  /**
   * Base interface for resolving a source by system identifiers.
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: SourceResolver.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  
  public interface SourceResolver
  extends org.apache.excalibur.source.SourceResolver {
  
      /**
       * Resolve the source.
       * @param systemID This is either a system identifier
       * (<code>java.net.URL</code> or a local file.
       * @deprecated Use the resolveURI methods instead
       */
      Source resolve(String systemID)
      throws ProcessingException, SAXException, IOException;
  
      /**
       * Generates SAX events from the given source
       * <b>NOTE</b> : if the implementation can produce lexical events, care should be taken
       * that <code>handler</code> can actually
       * directly implement the LexicalHandler interface!
       * @param  source    the data
       * @throws ProcessingException if no suitable converter is found
       */
      void toSAX( org.apache.excalibur.source.Source source,
                  ContentHandler handler )
      throws SAXException, IOException, ProcessingException;
  }
  
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/environment/URLFactorySourceResolver.java
  
  Index: URLFactorySourceResolver.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.environment;
  
  import org.apache.excalibur.source.SourceException;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.components.source.URLSource;
  import org.apache.cocoon.components.url.URLFactory;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXException;
  
  import java.io.IOException;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.Map;
  
  /**
   * A <code>SourceResolver</code> based on a <code>URLFactory</code>.
   * @deprecated by the new source resolving
   *
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @version CVS $Id: URLFactorySourceResolver.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  
  public class URLFactorySourceResolver implements SourceResolver {
  
      /** The component manager */
      protected ComponentManager manager;
  
      /** The URL factory */
      protected URLFactory urlFactory;
  
      /**
       * Creates an <code>URLFactorySourceResolver</code> with a component manager.
       * The <code>URLFactory</code> is looked up in the component manager.
       */
      public URLFactorySourceResolver(ComponentManager manager)
        throws ComponentException {
          this.manager = manager;
          this.urlFactory = (URLFactory)manager.lookup(URLFactory.ROLE);
      }
  
      /**
       * Creates an <code>URLFactorySourceResolver</code> with a component manager and
       * a <code>URLFactory</code> that will be used to resolve URLs.
       */
      public URLFactorySourceResolver(URLFactory factory, ComponentManager manager) {
          this.urlFactory = factory;
          this.manager = manager;
      }
  
      /**
       * Resolve the source.
       *
       * @param systemID This is either a system identifier
       *        (<code>java.net.URL</code>) or a local file.
       */
      public Source resolve(String systemID)
        throws ProcessingException, SAXException, IOException {
  
          URL url = this.urlFactory.getURL(systemID);
          return new URLSource(url, this.manager);
      }
  
      /**
       * Get a <code>Source</code> object.
       */
      public org.apache.excalibur.source.Source resolveURI(final String location)
      throws MalformedURLException, IOException, SourceException
      {
          return this.resolveURI(location, null, null);
      }
  
      /**
       * Get a <code>Source</code> object.
       */
      public org.apache.excalibur.source.Source resolveURI(final String location,
                                                                  String baseURI,
                                                                  final Map    parameters)
      throws MalformedURLException, IOException, SourceException {
          throw new RuntimeException("URLFactorySourceResolver.resolveURI() is not implemented yet.");
      }
  
      /**
       * Releases a resolved resource
       */
      public void release( final org.apache.excalibur.source.Source source ) {
          throw new RuntimeException("URLFactorySourceResolver.release() is not implemented yet.");
      }
  
      /**
       * Generates SAX events from the given source
       * <b>NOTE</b> : if the implementation can produce lexical events, care should be taken
       * that <code>handler</code> can actually
       * directly implement the LexicalHandler interface!
       * @param  source    the data
       * @throws ProcessingException if no suitable converter is found
       */
      public void toSAX( org.apache.excalibur.source.Source source,
                  ContentHandler handler )
      throws SAXException, IOException, ProcessingException {
          throw new RuntimeException("ProcessingException.toSAX() is not implemented yet.");
      }
  
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/environment/WriteableSource.java
  
  Index: WriteableSource.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 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 "Apache Cocoon" 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 apache@apache.org.
   *
   * 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cocoon.environment;
  
  import java.io.IOException;
  import java.io.OutputStream;
  
  import org.apache.cocoon.ProcessingException;
  
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXException;
  
  /**
   * A {@link Source} that can be written to. It provides two methods that
   * allow for SAX-based and byte-based output.
   * <p>
   * Callers will use the most appropriate method for their use and
   * it's up to the implementation to handle both sources. For example,
   * an XML-based implementation can use a parser to convert bytes written
   * to the <code>OutputStream</code> to SAX events, and a byte-based
   * implementation (such as file), can use a serializer to convert
   * SAX events to a byte stream.
   *
   * @deprecated Use the {@link org.apache.cocoon.components.source.WriteableSource} interface instead
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @version CVS $Id: WriteableSource.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  public interface WriteableSource extends ModifiableSource {
  
  //FIXME(SW) : should this be also Parameterizable to accept more parameters
  // such as user/password, headers, etc ?
  
      /**
       * Does this source actually exist ?
       *
       * @return true if the resource exists.
       */
      boolean exists();
  
      /**
       * Get a <code>ContentHandler</code> where an XML document can
       * be written using SAX events.
       * <p>
       * Care should be taken that the returned handler can actually
       * be a {@link org.apache.cocoon.xml.XMLConsumer} supporting also
       * lexical events such as comments.
       *
       * @return a handler for SAX events
       */
      ContentHandler getContentHandler() throws SAXException, ProcessingException;
  
      /**
       * Get an <code>InputStream</code> where raw bytes can be written to.
       * The signification of these bytes is implementation-dependent and
       * is not restricted to a serialized XML document.
       *
       * @return a stream to write to
       */
      OutputStream getOutputStream() throws IOException, ProcessingException;
  
      /**
       * Can the data sent to a <code>ContentHandler</code> returned by
       * {@link #getContentHandler()} be cancelled ?
       *
       * @return true if the handler can be cancelled
       */
      boolean canCancel(ContentHandler handler);
  
      /**
       * Can the data sent to an <code>OutputStream</code> returned by
       * {@link #getOutputStream()} be cancelled ?
       *
       * @return true if the stream can be cancelled
       */
      boolean canCancel(OutputStream stream);
  
      /**
       * Cancel the data sent to a <code>ContentHandler</code> returned by
       * {@link #getContentHandler()}.
       * <p>
       * After cancel, the handler should no more be used.
       */
      void cancel(ContentHandler handler) throws Exception;
  
      /**
       * Cancel the data sent to an <code>OutputStream</code> returned by
       * {@link #getOutputStream()}.
       * <p>
       * After cancel, the stream should no more be used.
       */
      void cancel(OutputStream stream) throws Exception;
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/generation/xmldb.samplesxpipe
  
  Index: xmldb.samplesxpipe
  ===================================================================
  <?xml version="1.0"?>
  
  <samplesxpipe xpath="/sitemap/pipelines/pipeline[@id='optional']"
         unless="match[@pattern='xmldb-generator/db/**/']">
  
      <!-- =================== XML:DB Generators ========================= -->
      <!-- BEWARE: the following examples use the unmaintained XML:DB      -->
      <!-- generators, going to be deprecated soon.                        -->
      <!-- You might want  to use the XML:DB pseudo protocol instead.      -->
      <map:match pattern="xmldb-generator/db/**/">
        <map:generate type="xmldbcollection" src="/{1}"/>
        <map:serialize type="xml"/>
      </map:match>
  
      <map:match pattern="xmldb-generator/db/**">
        <map:generate type="xmldb" src="/{1}"/>
        <map:serialize type="xml"/>
      </map:match>
  </samplesxpipe>
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/generation/xmldb.xmap
  
  Index: xmldb.xmap
  ===================================================================
  <?xml version="1.0"?>
  
  <xmap xpath="/sitemap/components/generators"
        unless="generator[@name='xmldb']">
  
      <!-- =================== XML:DB Generators ========================= -->
      <!-- BEWARE: these are unmaintained XML:DB generators, going to be   -->
      <!-- removed soon.                                                   -->
      <!-- You might want  to use the XML:DB pseudo protocol instead.      -->
      <map:generator name="xmldb" src="org.apache.cocoon.generation.XMLDBGenerator" label="content,data">
        <driver>org.apache.xindice.client.xmldb.DatabaseImpl</driver>
        <base>xmldb:xindice:///db/</base>
      </map:generator>
      <map:generator name="xmldbcollection" src="org.apache.cocoon.generation.XMLDBCollectionGenerator" label="content,data">
        <driver>org.apache.xindice.client.xmldb.DatabaseImpl</driver>
        <base>xmldb:xindice:///db/</base>
      </map:generator>
  </xmap>
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/generation/XMLDBCollectionGenerator.java
  
  Index: XMLDBCollectionGenerator.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.generation;
  
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.ResourceNotFoundException;
  import org.apache.cocoon.caching.CacheableProcessingComponent;
  import org.apache.cocoon.environment.SourceResolver;
  import org.apache.excalibur.source.SourceValidity;
  import org.xml.sax.SAXException;
  import org.xml.sax.helpers.AttributesImpl;
  import org.xmldb.api.DatabaseManager;
  import org.xmldb.api.base.Collection;
  import org.xmldb.api.base.Database;
  import org.xmldb.api.base.XMLDBException;
  
  import java.io.IOException;
  import java.util.Map;
  
  /**
   * This class implements generation of a XML:DB collection
   * contents as a directory listing.
   *
   * <pre>
   * &lt;driver&gt;
   *   (a valid DB:XML compliant driver)
   * &lt;/driver&gt;
   * &lt;base&gt;
   *   xmldb:yourdriver://host/an/optional/path/to/be/prepended
   * &lt;/base&gt;
   * </pre>
   *
   * NOTE: the driver can be any DB:XML compliant driver (although this
   * component has been tested only with
   * <a href="http://www.dbxml.org">dbXML</a>, and the trailing
   * slash in the base tag is important!
   *
   * @author <a href="mailto:gianugo@rabellino.it">Gianugo Rabellino</a>
   * @version CVS $Id: XMLDBCollectionGenerator.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   * @deprecated Use the XML:DB pseudo protocol instead.
   */
  
   public class XMLDBCollectionGenerator extends ComposerGenerator
     implements CacheableProcessingComponent, Configurable,Initializable {
  
      protected static final String URI =
        "http://apache.org/cocoon/xmldb/1.0";
      protected static final String PREFIX = "collection";
      protected static final String RESOURCE_COUNT_ATTR = "resources";
      protected static final String COLLECTION_COUNT_ATTR  = "collections";
      protected static final String COLLECTION  = "collection";
      protected static final String QCOLLECTION  = PREFIX + ":collection";
      protected static final String RESOURCE  = "resource";
      protected static final String QRESOURCE  = PREFIX + ":resource";
  
      protected String driver;
      protected String base;
      protected String col;
      protected Database database;
      protected Collection collection;
      protected AttributesImpl attributes = new AttributesImpl();
  
      public void compose(ComponentManager manager) throws ComponentException {
          super.compose(manager);
      }
  
      /**
       * Recycle the component, keep only the configuration variables
       * and the database instance for reuse.
       *
       */
  
      public void recycle() {
          super.recycle();
          this.col = null;
          this.collection = null;
          //this.attributes = null;
      }
  
     /**
      * Configure the component. This class is expecting a configuration
      * like the following one:
      * <pre>
      * &lt;driver&gt;org.dbxml.client.xmldb.DatabaseImpl&lt;/driver&gt;
      * &lt;base&gt;xmldb:dbxml:///db/&lt;/base&gt;
      * </pre>
      * NOTE: the driver can be any DB:XML compliant driver (although this
      * component has been tested only with
      * <a href="http://www.dbxml.org">dbXML</a>, and the trailing
      * slash in the base tag is important!
      *
      * @exception ConfigurationException (configuration invalid or missing)
      */
  
      public void configure(Configuration conf)
        throws ConfigurationException {
        if (conf != null) {
          this.driver = conf.getChild("driver").getValue();
          this.base = conf.getChild("base").getValue();
        } else {
          throw new ConfigurationException("XMLDB configuration not found");
        }
      }
  
     /**
      * Initialize the component getting a database instance.
      *
      * @exception Exception if an error occurs
      */
  
      public void initialize() throws Exception {
        try {
  
          Class c = Class.forName(driver);
          database = (Database)c.newInstance();
          DatabaseManager.registerDatabase(database);
  
        } catch (XMLDBException xde) {
  
          this.getLogger().error("Unable to connect to the XML:DB database");
          throw new ProcessingException("Unable to connect to the XML DB"
            + xde.getMessage());
  
        } catch (Exception e) {
  
          this.getLogger().error("There was a problem setting up the connection");
          this.getLogger().error("Make sure that your driver is available");
          throw new ProcessingException("Problem setting up the connection: "
            + e.getMessage());
  
        }
      }
  
      public void setup(SourceResolver resolver,
                        Map objectModel,
                        String src,
                        Parameters par)
        throws ProcessingException, SAXException,IOException {
  
        super.setup(resolver, objectModel, src, par);
  
      }
  
      /**
       * The component isn't cached (yet)
       */
      public SourceValidity getValidity() {
        return null;
      }
  
      /**
       * The component isn't cached (yet)
       */
      public SourceValidity generateValidity() {
        return null;
      }
  
      /**
       * The component isn't cached (yet)
       */
      public java.io.Serializable generateKey() {
        return null;
      }
  
     /**
      * Parse the requested URI, connect to the XML:DB database
      * and fetch the requested resource.
      *
      * @exception ProcessingException something unexpected happened with the DB
      */
      public void generate()
        throws IOException, SAXException, ProcessingException {
        //String col = "/";
  
        //if (source.indexOf('/') != -1)
        col = source;
  
  
        try {
          collection = DatabaseManager.getCollection(base + col);
  
          if (collection == null)
            throw new ResourceNotFoundException("Collection " + col +
              " not found");
  
          collectionToSAX(collection);
  
          collection.close();
  
        } catch (XMLDBException xde) {
  
          throw new ProcessingException("Unable to fetch content '"
            + source + "':" + xde.getMessage());
  
        } catch (NullPointerException npe) {
  
            this.getLogger().error("The XML:DB driver raised an exception");
            this.getLogger().error("probably the document was not found");
            throw new ProcessingException("Null pointer exception while " +
            "retrieving document : " + npe.getMessage());
  
        }
      }
  
      /**
       * Output SAX events listing the collection.
       *
       * @exception SAXException
       */
  
      public void collectionToSAX(Collection collection)
        throws SAXException {
  
        String ncollections;
        String nresources;
        String[] resources;
        String[] collections;
  
        try {
          ncollections = Integer.toString(collection.getChildCollectionCount());
          nresources = Integer.toString(collection.getResourceCount());
  
          attributes.clear();
          attributes.addAttribute("", RESOURCE_COUNT_ATTR,
            RESOURCE_COUNT_ATTR, "CDATA", nresources);
          attributes.addAttribute("", COLLECTION_COUNT_ATTR,
            COLLECTION_COUNT_ATTR, "CDATA", ncollections);
  
          collections = collection.listChildCollections();
          resources = collection.listResources();
  
          this.xmlConsumer.startDocument();
          this.xmlConsumer.startPrefixMapping(PREFIX, URI);
  
          this.xmlConsumer.startElement(URI, "collections",
            "collection:collections", attributes);
  
          // Print child collections
  
          for (int i = 0; i < collections.length; i++) {
            attributes.clear();
            attributes.addAttribute("", "name", "name", "CDATA", collections[i]);
            this.xmlConsumer.startElement(URI, COLLECTION,
              QCOLLECTION, attributes);
            this.xmlConsumer.endElement(URI, COLLECTION, COLLECTION);
          }
  
          // Print child resources
  
          for (int i = 0; i < resources.length; i++) {
            attributes.clear();
            attributes.addAttribute("", "name", "name", "CDATA", resources[i]);
            this.xmlConsumer.startElement(URI, RESOURCE,
              QRESOURCE, attributes);
            this.xmlConsumer.endElement(URI, RESOURCE, RESOURCE);
          }
  
          this.xmlConsumer.endElement(URI, "collections",
            "collection:collections");
  
          this.xmlConsumer.endPrefixMapping(PREFIX);
          this.xmlConsumer.endDocument();
  
        } catch (XMLDBException xde) {
          this.getLogger().warn("Collection listing failed" + xde.getMessage());
          throw new SAXException("Collection listing failed" + xde.getMessage());
        }
  
      }
  
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/generation/XMLDBGenerator.java
  
  Index: XMLDBGenerator.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.generation;
  
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.ResourceNotFoundException;
  import org.apache.cocoon.caching.CacheableProcessingComponent;
  import org.apache.cocoon.environment.SourceResolver;
  import org.apache.excalibur.source.SourceValidity;
  import org.xml.sax.SAXException;
  import org.xmldb.api.DatabaseManager;
  import org.xmldb.api.base.Collection;
  import org.xmldb.api.base.Database;
  import org.xmldb.api.base.XMLDBException;
  import org.xmldb.api.modules.XMLResource;
  
  import java.io.IOException;
  import java.util.Map;
  
  /**
   * This class implements generation of XML documents from a
   * XML:DB compliant database.
   * It must to be configured as follows:
   * <pre>
   * &lt;driver&gt;
   *   (a valid DB:XML compliant driver)
   * &lt;/driver&gt;
   * &lt;base&gt;
   *   xmldb:yourdriver://host/an/optional/path/to/be/prepended
   * &lt;/base&gt;
   * </pre>
   *
   * NOTE: the driver can be any DB:XML compliant driver (although this
   * component has been tested only with
   * <a href="http://www.dbxml.org">dbXML</a>, and the trailing
   * slash in the base tag is important!
   *
   * @author <a href="mailto:gianugo@rabellino.it">Gianugo Rabellino</a>
   * @version CVS $Id: XMLDBGenerator.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   * @deprecated Use the XML:DB pseudo protocol instead.
   */
  
   public class XMLDBGenerator extends ComposerGenerator
     implements CacheableProcessingComponent, Configurable,Initializable {
  
      protected String driver;
      protected String base;
      protected String col;
      protected String res;
      protected Database database;
      protected Collection collection;
      protected XMLResource xmlResource;
  
      public void compose(ComponentManager manager) throws ComponentException {
          super.compose(manager);
      }
  
      /**
       * Recycle the component, keep only the configuration variables
       * and the database instance for reuse.
       *
       */
  
      public void recycle() {
          super.recycle();
          this.col = null;
          this.res = null;
          this.xmlResource = null;
          this.collection = null;
      }
  
     /**
      * Configure the component. This class is expecting a configuration
      * like the following one:
      * <pre>
      * &lt;driver&gt;org.dbxml.client.xmldb.DatabaseImpl&lt;/driver&gt;
      * &lt;base&gt;xmldb:dbxml:///db/&lt;/base&gt;
      * </pre>
      * NOTE: the driver can be any DB:XML compliant driver (although this
      * component has been tested only with
      * <a href="http://www.dbxml.org">dbXML</a>, and the trailing
      * slash in the base tag is important!
      *
      * @exception ConfigurationException (configuration invalid or missing)
      */
  
      public void configure(Configuration conf)
        throws ConfigurationException {
        if (conf != null) {
          this.driver = conf.getChild("driver").getValue();
          this.base = conf.getChild("base").getValue();
        } else {
          throw new ConfigurationException("XML:DB configuration not found");
        }
      }
  
     /**
      * Initialize the component getting a database instance.
      *
      * @exception Exception if an error occurs
      */
  
      public void initialize() throws Exception {
        try {
  
          Class c = Class.forName(driver);
          database = (Database)c.newInstance();
          DatabaseManager.registerDatabase(database);
  
        } catch (XMLDBException xde) {
  
          this.getLogger().error("Unable to connect to the XML:DB database");
          throw new ProcessingException("Unable to connect to the XMLDB database"
            + xde.getMessage());
  
        } catch (Exception e) {
  
          this.getLogger().error("There was a problem setting up the connection");
          this.getLogger().error("Make sure that your driver is available");
          throw new ProcessingException("Problem setting up the connection: "
            + e.getMessage());
  
        }
      }
  
      public void setup(SourceResolver resolver,
                        Map objectModel,
                        String src,
                        Parameters par)
        throws ProcessingException, SAXException,IOException {
  
        super.setup(resolver, objectModel, src, par);
  
      }
  
      /**
       * The component isn't cached (yet)
       */
      public SourceValidity getValidity() {
        return null;
      }
  
      /**
       * The component isn't cached (yet)
       */
      public SourceValidity generateValidity() {
        return null;
      }
  
      /**
       * The component isn't cached (yet)
       */
      public java.io.Serializable generateKey() {
        return null;
      }
  
     /**
      * Parse the requested URI, connect to the XML:DB database
      * and fetch the requested resource.
      *
      * @exception ProcessingException something unexpected happened with the DB
      */
      public void generate()
        throws IOException, SAXException, ProcessingException {
        String col = "/";
  
        if (source.indexOf('/') != -1)
          col = "/" + source.substring(0, source.lastIndexOf('/'));
        res = source.substring(source.lastIndexOf('/') + 1);
  
        try {
          collection = DatabaseManager.getCollection(base + col);
          xmlResource = (XMLResource) collection.getResource(res);
  
          if (xmlResource == null)
            throw new ResourceNotFoundException("Document " + col + "/" + res +
              " not found");
  
          xmlResource.getContentAsSAX(this.xmlConsumer);
  
          collection.close();
  
        } catch (XMLDBException xde) {
  
          throw new ProcessingException("Unable to fetch content: " +
            xde.getMessage());
  
        } catch (NullPointerException npe) {
  
            this.getLogger().error("The XML:DB driver raised an exception");
            this.getLogger().error("probably the document was not found");
  
            throw new ProcessingException("Null pointer exception while " +
              "retrieving document : " + npe.getMessage());
  
        }
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/matching/RegexpTargetHostMatcher.java
  
  Index: RegexpTargetHostMatcher.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.matching;
  
  import org.apache.avalon.framework.activity.Initializable;
  
  /**
   * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
   * @version CVS $Id: RegexpTargetHostMatcher.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   * @deprecated Renamed to RegexpHostMatcher
   */
  public class RegexpTargetHostMatcher extends RegexpHostMatcher
      implements Initializable
  {
  
      public void initialize() {
          getLogger().warn("RegexpTargetHostMatcher is deprecated. Please use RegexpHostMatcher");
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/matching/RequestParamMatcher.java
  
  Index: RequestParamMatcher.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.matching;
  
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.logger.Logger;
  
  /**
   * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
   * @deprecated Renamed to RequestParameterMatcher
   * @version CVS $Id: RequestParamMatcher.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  public class RequestParamMatcher extends RequestParameterMatcher
      implements LogEnabled
  {
      public void enableLogging(Logger logger) {
          logger.warn("RequestParamMatcher is deprecated. Please use RequestParameterMatcher");
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/matching/WildcardParameterValueMatcher.java
  
  Index: WildcardParameterValueMatcher.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.matching;
  
  import org.apache.avalon.framework.activity.Initializable;
  
  /**
   * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
   * @deprecated Renamed to WildcardRequestParameterMatcher
   * @version CVS $Id: WildcardParameterValueMatcher.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   */
  public class WildcardParameterValueMatcher extends WildcardRequestParameterMatcher
      implements Initializable
  {
      public void initialize() {
          getLogger().warn("WildcardParameterValueMatcher is deprecated. Please use WildcardRequestParameterMatcher");
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/matching/WildcardURIMatcher.java
  
  Index: WildcardURIMatcher.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.matching.helpers;
  
  import java.util.HashMap;
  
  /**
   * This class is an utility class that perform wilcard-patterns matching and
   * isolation.
   *
   * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
   *         (Apache Software Foundation, Exoffice Technologies)
   * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
   * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
   * @version CVS $Id: WildcardURIMatcher.java,v 1.1 2002/12/26 18:38:57 nicolaken Exp $
   * @deprecated renamed to WildcardHelper
   */
  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 representing begin in the pattern <code>int []</code>. */
      protected static final int MATCH_BEGIN = -4;
      /** The int representing end in pattern <code>int []</code>. */
      protected static final int MATCH_THEEND = -5;
      /** 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 (HashMap map, String data,
              int[] expr) throws NullPointerException {
          if (map == null)
              throw new NullPointerException ("No map 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;
  
          // The position in the expression, input, translation and result arrays
          int exprpos = 0;
          int buffpos = 0;
          int rsltpos = 0;
          int offset = -1;
  
          // The matching count
          int mcount = 0;
  
          // We want the complete data be in {0}
          map.put(Integer.toString(mcount),data);
  
          // First check for MATCH_BEGIN
          boolean matchBegin = false;
          if (expr[charpos] == MATCH_BEGIN) {
              matchBegin = true;
              exprpos = ++charpos;
          }
  
          // Search the fist expression character (except MATCH_BEGIN - already skipped)
          while (expr[charpos] >= 0)
              charpos++;
  
          // The expression charater (MATCH_*)
          int exprchr = expr[charpos];
  
          while (true) {
              // Check if the data in the expression array before the current
              // expression character matches the data in the input buffer
              if (matchBegin) {
                  if (!matchArray(expr, exprpos, charpos, buff, buffpos))
                      return (false);
                  matchBegin = false;
              } else {
                  offset = indexOfArray (expr, exprpos, charpos, buff,
                          buffpos);
                  if (offset < 0)
                      return (false);
              }
  
              // Check for MATCH_BEGIN
              if (matchBegin) {
                  if (offset != 0)
                      return (false);
                  matchBegin = false;
              }
  
              // Advance buffpos
              buffpos += (charpos - exprpos);
  
              // Check for END's
              if (exprchr == MATCH_END) {
                  if (rsltpos > 0)
                      map.put(Integer.toString(++mcount),new String(rslt, 0, rsltpos));
                  // Don't care about rest of input buffer
                  return (true);
              } else if (exprchr == MATCH_THEEND) {
                  if (rsltpos > 0)
                      map.put (Integer.toString(++mcount),new String(rslt, 0, rsltpos));
                  // Check that we reach buffer's end
                  return (buffpos == buff.length);
              }
  
              // Search the next expression character
              exprpos = ++charpos;
              while (expr[charpos] >= 0)
                  charpos++;
              int prevchr = exprchr;
              exprchr = expr[charpos];
  
              // We have here prevchr == * or **.
              offset = (prevchr == MATCH_FILE) ?
                      indexOfArray (expr, exprpos, charpos, buff, buffpos) :
                      lastIndexOfArray (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++];
                  }
              }
  
              map.put(Integer.toString(++mcount),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 indexOfArray (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++])
                      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);
      }
  
      /**
        * Get the offset of a last occurance of an int array within a char array.
        * <br>
        * This method return the index in d of the last 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 last part of r matched in d or -1 if that was
        *         not found.
        */
      protected static int lastIndexOfArray (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 = d.length - 1; x > dpos; 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
          int l = d.length - (rend - rpos);
          while (l >= dpos) {
              // Set current startpoint in d
              int y = l;
              // 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 (l);
                  if (r[x] != d[y++])
                      break;
              }
              // Decrease l to search for the same string at next offset
              l--;
          }
          // The remaining chars in d buffer were not enough or the string
          // wasn't matched
          return (-1);
      }
  
      /**
        * Matches elements of array r from rpos to rend with array d, starting from dpos.
        * <br>
        * This method return true if elements of array r from rpos to rend
        * equals elements of array d starting from dpos to dpos+(rend-rpos).
        *
        * @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 d The array of char that should start from a part of r.
        * @param dpos The starting offset in d for the matching.
        * @return true if array d starts from portion of array r.
        */
      protected static boolean matchArray (int r[], int rpos, int rend,
              char d[], int dpos) {
          if (d.length - dpos < rend - rpos)
              return (false);
          for (int i = rpos; i < rend; i++)
              if (r[i] != d[dpos++])
                  return (false);
          return (true);
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/selection/RequestSelector.java
  
  Index: RequestSelector.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.selection;
  
  import org.apache.avalon.framework.activity.Initializable;
  
  /**
   * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
   * @version CVS $Id: RequestSelector.java,v 1.1 2002/12/26 18:38:58 nicolaken Exp $
   * @deprecated Renamed to RequestParameterSelector
   */
  public class RequestSelector extends RequestParameterSelector implements Initializable {
  
      public void initialize() {
          getLogger().warn("RequestSelector is deprecated. Please use RequestParameterSelector");
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/selection/SessionStateSelector.java
  
  Index: SessionStateSelector.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.selection;
  
  
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.cocoon.Constants;
  
  /**
   * This class generates source code to implement a selector that
   * matches a string against an arbitrary session attribute.
   *
   * <p><b>Global and local configuration</b></p>
   * <table border="1">
   * <tr><td><code>org.apache.cocoon.SessionState</code></td><td>String identifying the session attribute.</td></tr>
   * </table>
   *
   * @deprecated use SessionAttributeSelector instead
   *
   * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @version CVS $Id: SessionStateSelector.java,v 1.1 2002/12/26 18:38:58 nicolaken Exp $
   */
  public class SessionStateSelector extends SessionAttributeSelector {
  
      public SessionStateSelector() {
          this.defaultName = Constants.SESSION_STATE_ATTRIBUTE;
      }
  
      public void configure(Configuration config)
      {
          // ignore
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/deprecated/java/org/apache/cocoon/xml/XMLizable.java
  
  Index: XMLizable.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Apache Cocoon" 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.xml;
  
  import org.apache.cocoon.ProcessingException;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXException;
  
  /**
   * This interface can be implemented by classes willing to provide an XML representation
   * of their current state as SAX events.
   *
   * @deprecated Use org.apache.avalon.excalibur.xml.XMLizable instead
   *
   * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   * @version CVS $Id: XMLizable.java,v 1.1 2002/12/26 18:38:58 nicolaken Exp $
   */
  
  public interface XMLizable {
      /**
       * Generates SAX events representing the object's state.<br/>
       * <b>NOTE</b> : if the implementation can produce lexical events, care should be taken
       * that <code>handler</code> can actually be a {@link org.apache.cocoon.xml.XMLConsumer} that accepts such
       * events.
       */
      void toSAX(ContentHandler handler) throws SAXException, ProcessingException;
  
  }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org