cziegeler    02/05/28 06:08:13

  Modified:    src/java/org/apache/cocoon/components/source
                        SitemapSource.java
               src/java/org/apache/cocoon/components/source/impl
                        SitemapSource.java
               src/java/org/apache/cocoon/generation FileGenerator.java
                        FragmentExtractorGenerator.java HTMLGenerator.java
               src/java/org/apache/cocoon/reading ResourceReader.java
               src/java/org/apache/cocoon/serialization
                        AbstractTextSerializer.java FOPSerializer.java
                        SVGSerializer.java
               src/java/org/apache/cocoon/sitemap ContentAggregator.java
               src/java/org/apache/cocoon/transformation
                        EncodeURLTransformer.java FilterTransformer.java
                        FragmentExtractorTransformer.java
                        RoleFilterTransformer.java
                        SourceWritingTransformer.java TraxTransformer.java
                        XMLFormTransformer.java
  Log:
  Moved more components from Cacheable to CacheablePC
  
  Revision  Changes    Path
  1.16      +1 -2      
xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java
  
  Index: SitemapSource.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SitemapSource.java        27 May 2002 14:56:28 -0000      1.15
  +++ SitemapSource.java        28 May 2002 13:08:12 -0000      1.16
  @@ -65,7 +65,6 @@
   import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
   import org.apache.cocoon.serialization.Serializer;
  -import org.apache.cocoon.util.HashUtil;
   import org.apache.cocoon.xml.AbstractXMLConsumer;
   import org.apache.cocoon.xml.ContentHandlerWrapper;
   import org.apache.cocoon.xml.XMLConsumer;
  @@ -88,7 +87,7 @@
    *
    * @deprecated by the Avalon Excalibur Source Resolving
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: SitemapSource.java,v 1.15 2002/05/27 14:56:28 cziegeler Exp $
  + * @version CVS $Id: SitemapSource.java,v 1.16 2002/05/28 13:08:12 cziegeler Exp $
    */
   
   public final class SitemapSource
  
  
  
  1.9       +1 -2      
xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
  
  Index: SitemapSource.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SitemapSource.java        27 May 2002 14:56:28 -0000      1.8
  +++ SitemapSource.java        28 May 2002 13:08:12 -0000      1.9
  @@ -70,7 +70,6 @@
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
   import org.apache.cocoon.serialization.Serializer;
  -import org.apache.cocoon.util.HashUtil;
   import org.apache.cocoon.xml.AbstractXMLConsumer;
   import org.apache.cocoon.xml.ContentHandlerWrapper;
   import org.apache.cocoon.xml.XMLConsumer;
  @@ -93,7 +92,7 @@
    * Description of a source which is defined by a pipeline.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: SitemapSource.java,v 1.8 2002/05/27 14:56:28 cziegeler Exp $
  + * @version CVS $Id: SitemapSource.java,v 1.9 2002/05/28 13:08:12 cziegeler Exp $
    */
   
   public final class SitemapSource
  
  
  
  1.12      +2 -2      
xml-cocoon2/src/java/org/apache/cocoon/generation/FileGenerator.java
  
  Index: FileGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/FileGenerator.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FileGenerator.java        28 May 2002 09:06:33 -0000      1.11
  +++ FileGenerator.java        28 May 2002 13:08:12 -0000      1.12
  @@ -67,12 +67,12 @@
    *
    * The <code>FileGenerator</code> is a class that reads XML from a source
    * and generates SAX Events.
  - * The FileGenerator implements the <code>Cacheable</code> interface.
  + * The FileGenerator implements the <code>CacheableProcessingComponent</code> 
interface.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: FileGenerator.java,v 1.11 2002/05/28 09:06:33 cziegeler Exp $
  + * @version CVS $Id: FileGenerator.java,v 1.12 2002/05/28 13:08:12 cziegeler Exp $
    */
   public class FileGenerator extends ComposerGenerator
   implements CacheableProcessingComponent {
  
  
  
  1.9       +9 -11     
xml-cocoon2/src/java/org/apache/cocoon/generation/FragmentExtractorGenerator.java
  
  Index: FragmentExtractorGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/FragmentExtractorGenerator.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FragmentExtractorGenerator.java   21 May 2002 06:08:05 -0000      1.8
  +++ FragmentExtractorGenerator.java   28 May 2002 13:08:12 -0000      1.9
  @@ -53,14 +53,12 @@
   import org.apache.avalon.framework.component.ComponentException;
   
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.NOPCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.components.sax.XMLDeserializer;
  -import org.apache.cocoon.util.HashUtil;
   
   import org.apache.excalibur.store.Store;
  -
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.NOPValidity;
   import org.xml.sax.SAXException;
   
   import java.io.IOException;
  @@ -77,10 +75,10 @@
    * <p>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Paul Russell</a>
  - * @version CVS $Id: FragmentExtractorGenerator.java,v 1.8 2002/05/21 06:08:05 
cziegeler Exp $
  + * @version CVS $Id: FragmentExtractorGenerator.java,v 1.9 2002/05/28 13:08:12 
cziegeler Exp $
    */
   public class FragmentExtractorGenerator extends ComposerGenerator
  -        implements Cacheable {
  +        implements CacheableProcessingComponent {
   
       /**
        * Generate the unique key.
  @@ -88,8 +86,8 @@
        *
        * @return The generated key hashes the src
        */
  -    public long generateKey() {
  -        return HashUtil.hash(source);
  +    public java.io.Serializable generateKey() {
  +        return this.source;
       }
   
       /**
  @@ -98,8 +96,8 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  -        return NOPCacheValidity.CACHE_VALIDITY;
  +    public SourceValidity generateValidity() {
  +        return NOPValidity.SHARED_INSTANCE;
       }
   
       public void generate() throws SAXException {
  
  
  
  1.15      +21 -26    
xml-cocoon2/src/java/org/apache/cocoon/generation/HTMLGenerator.java
  
  Index: HTMLGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/HTMLGenerator.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- HTMLGenerator.java        21 Mar 2002 04:31:35 -0000      1.14
  +++ HTMLGenerator.java        28 May 2002 13:08:12 -0000      1.15
  @@ -56,17 +56,16 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.TimeStampCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.avalon.excalibur.xml.xpath.XPathProcessor;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
  -import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.environment.SourceResolver;
  -import org.apache.cocoon.util.HashUtil;
   import org.apache.cocoon.xml.dom.DOMStreamer;
   import org.apache.cocoon.xml.XMLUtils;
  +import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceException;
  +import org.apache.excalibur.source.SourceValidity;
   import org.w3c.dom.NodeList;
   import org.w3c.tidy.Tidy;
   import org.xml.sax.SAXException;
  @@ -87,10 +86,10 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Davanum Srinivas</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a>
  - * @version CVS $Id: HTMLGenerator.java,v 1.14 2002/03/21 04:31:35 vgritsenko Exp $
  + * @version CVS $Id: HTMLGenerator.java,v 1.15 2002/05/28 13:08:12 cziegeler Exp $
    */
   public class HTMLGenerator extends ComposerGenerator
  -implements Cacheable, Disposable {
  +implements CacheableProcessingComponent, Disposable {
   
       /** The  source */
       private Source inputSource;
  @@ -118,7 +117,7 @@
       public void recycle() {
           super.recycle();
           if (this.inputSource != null) {
  -            this.inputSource.recycle();
  +            this.resolver.release( this.inputSource );
               this.inputSource = null;
           }
           this.xpath = null;
  @@ -146,7 +145,11 @@
               super.source = query.toString();
           }
   
  -        this.inputSource = resolver.resolve(super.source);
  +        try {
  +            this.inputSource = resolver.resolveURI(super.source);
  +        } catch (SourceException se) {
  +            throw new ProcessingException("Unable to resolve " + super.source, se);
  +        }
       }
   
       /**
  @@ -157,17 +160,14 @@
        * @return The generated key or <code>0</code> if the component
        *              is currently not cacheable.
        */
  -    public long generateKey() {
  -        if (this.inputSource.getLastModified() != 0) {
  -            if (this.xpath != null) {
  -                StringBuffer buffer = new 
StringBuffer(this.inputSource.getSystemId());
  -                buffer.append(':').append(this.xpath);
  -                return HashUtil.hash(buffer.toString());
  -            } else {
  -                return HashUtil.hash(this.inputSource.getSystemId());
  -            }
  +    public java.io.Serializable generateKey() {
  +        if (this.xpath != null) {
  +            StringBuffer buffer = new StringBuffer(this.inputSource.getSystemId());
  +            buffer.append(':').append(this.xpath);
  +            return buffer.toString();
  +        } else {
  +            return this.inputSource.getSystemId();
           }
  -        return 0;
       }
   
       /**
  @@ -178,11 +178,8 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  -        if (this.inputSource.getLastModified() != 0) {
  -            return new TimeStampCacheValidity(this.inputSource.getLastModified());
  -        }
  -        return null;
  +    public SourceValidity generateValidity() {
  +        return this.inputSource.getValidity();
       }
   
       /**
  @@ -241,8 +238,6 @@
                   + this.inputSource.getSystemId(), e);
           } catch (SAXException e){
               getLogger().error("HTMLGenerator.generate()", e);
  -            throw e;
  -        } catch (ProcessingException e){
               throw e;
           } catch (Exception e){
               getLogger().error("Could not setup jtidy", e);
  
  
  
  1.10      +7 -13     
xml-cocoon2/src/java/org/apache/cocoon/reading/ResourceReader.java
  
  Index: ResourceReader.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/reading/ResourceReader.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ResourceReader.java       24 May 2002 08:52:33 -0000      1.9
  +++ ResourceReader.java       28 May 2002 13:08:12 -0000      1.10
  @@ -56,11 +56,8 @@
   import org.apache.excalibur.source.SourceException;
   import org.apache.excalibur.source.SourceValidity;
   import org.apache.excalibur.source.impl.validity.TimeStampValidity;
  -
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.SourceCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.environment.Context;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Response;
  @@ -91,11 +88,11 @@
    *   </dl>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
  - * @version CVS $Id: ResourceReader.java,v 1.9 2002/05/24 08:52:33 cziegeler Exp $
  + * @version CVS $Id: ResourceReader.java,v 1.10 2002/05/28 13:08:12 cziegeler Exp $
    */
   public class ResourceReader
     extends AbstractReader
  -  implements Cacheable {
  +  implements CacheableProcessingComponent {
   
       /** The  source */
       private Source      inputSource;
  @@ -131,8 +128,8 @@
        *
        * @return The generated key hashes the src
        */
  -    public long generateKey() {
  -        return HashUtil.hash(this.inputSource.getSystemId());
  +    public java.io.Serializable generateKey() {
  +        return this.inputSource.getSystemId();
       }
   
       /**
  @@ -141,11 +138,8 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  -        if (this.inputSource.getValidity() != null) {
  -            return new SourceCacheValidity(this.inputSource.getValidity());
  -        }
  -        return null;
  +    public SourceValidity generateValidity() {
  +        return this.inputSource.getValidity();
       }
   
       /**
  
  
  
  1.10      +9 -9      
xml-cocoon2/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java
  
  Index: AbstractTextSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbstractTextSerializer.java       22 Feb 2002 07:03:55 -0000      1.9
  +++ AbstractTextSerializer.java       28 May 2002 13:08:13 -0000      1.10
  @@ -54,12 +54,12 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.cocoon.Constants;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.NOPCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.util.TraxErrorHandler;
   import org.apache.cocoon.xml.AbstractXMLPipe;
   import org.apache.cocoon.xml.XMLConsumer;
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.NOPValidity;
   import org.xml.sax.Attributes;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.ext.LexicalHandler;
  @@ -85,11 +85,11 @@
    *         (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Id: AbstractTextSerializer.java,v 1.9 2002/02/22 07:03:55 
cziegeler Exp $
  + * @version CVS $Id: AbstractTextSerializer.java,v 1.10 2002/05/28 13:08:13 
cziegeler Exp $
    */
   public abstract class AbstractTextSerializer
   extends AbstractSerializer
  -implements Configurable, Cacheable {
  +implements Configurable, CacheableProcessingComponent {
   
       /**
        * The trax <code>TransformerFactory</code> used by this serializer.
  @@ -266,8 +266,8 @@
        * @return The generated key or <code>0</code> if the component
        *              is currently not cacheable.
        */
  -    public long generateKey() {
  -        return 1;
  +    public java.io.Serializable generateKey() {
  +        return "1";
       }
   
       /**
  @@ -278,8 +278,8 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  -        return NOPCacheValidity.CACHE_VALIDITY;
  +    public SourceValidity generateValidity() {
  +        return NOPValidity.SHARED_INSTANCE;
       }
   
       /**
  
  
  
  1.8       +11 -11    
xml-cocoon2/src/java/org/apache/cocoon/serialization/FOPSerializer.java
  
  Index: FOPSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/serialization/FOPSerializer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FOPSerializer.java        19 Mar 2002 09:05:56 -0000      1.7
  +++ FOPSerializer.java        28 May 2002 13:08:13 -0000      1.8
  @@ -54,12 +54,12 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.Loggable;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.NOPCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.components.renderer.ExtendableRendererFactory;
   import org.apache.cocoon.components.renderer.RendererFactory;
   import org.apache.cocoon.util.ClassUtils;
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.NOPValidity;
   import org.apache.fop.apps.Driver;
   import org.apache.fop.apps.Options;
   import org.apache.fop.render.Renderer;
  @@ -68,11 +68,11 @@
   
   /**
    * @author ?
  - * @version CVS $Id: FOPSerializer.java,v 1.7 2002/03/19 09:05:56 sylvain Exp $
  + * @version CVS $Id: FOPSerializer.java,v 1.8 2002/05/28 13:08:13 cziegeler Exp $
    */
   public class FOPSerializer
   extends AbstractSerializer
  -implements Configurable, Cacheable {
  +implements Configurable, CacheableProcessingComponent {
   
       /**
         * The <code>Options</code> used by FOP.
  @@ -103,7 +103,7 @@
        * The renderer name if configured
        */
       protected String rendererName;
  -    
  +
       /**
        * Should we set the content length ?
        */
  @@ -126,7 +126,7 @@
                       // No config file specified
                   }
               }
  -            
  +
               this.setContentLength = 
conf.getChild("set-content-length").getValueAsBoolean(true);
           }
   
  @@ -221,8 +221,8 @@
        * @return The generated key or <code>0</code> if the component
        *              is currently not cacheable.
        */
  -    public long generateKey() {
  -        return 1;
  +    public java.io.Serializable generateKey() {
  +        return "1";
       }
   
       /**
  @@ -233,8 +233,8 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  -        return NOPCacheValidity.CACHE_VALIDITY;
  +    public SourceValidity generateValidity() {
  +        return NOPValidity.SHARED_INSTANCE;
       }
   
       /**
  
  
  
  1.6       +9 -9      
xml-cocoon2/src/java/org/apache/cocoon/serialization/SVGSerializer.java
  
  Index: SVGSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/serialization/SVGSerializer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SVGSerializer.java        22 Feb 2002 07:03:55 -0000      1.5
  +++ SVGSerializer.java        28 May 2002 13:08:13 -0000      1.6
  @@ -65,9 +65,7 @@
   import org.apache.batik.transcoder.TranscodingHints;
   import org.apache.batik.util.ParsedURL;
   import org.apache.cocoon.Constants;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.NOPCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.components.transcoder.ExtendableTranscoderFactory;
   import org.apache.cocoon.components.transcoder.TranscoderFactory;
   import org.apache.cocoon.components.url.ParsedContextURLProtocolHandler;
  @@ -76,6 +74,8 @@
   import org.apache.cocoon.util.ClassUtils;
   import org.apache.cocoon.xml.XMLConsumer;
   import org.apache.cocoon.xml.dom.SVGBuilder;
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.NOPValidity;
   import org.w3c.dom.Document;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
  @@ -90,10 +90,10 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Davanum Srinivas</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Ross Burton</a>
  - * @version CVS $Id: SVGSerializer.java,v 1.5 2002/02/22 07:03:55 cziegeler Exp $
  + * @version CVS $Id: SVGSerializer.java,v 1.6 2002/05/28 13:08:13 cziegeler Exp $
    */
   public class SVGSerializer extends SVGBuilder
  -implements Composable, Serializer, Configurable, Poolable, Cacheable, 
Contextualizable {
  +implements Composable, Serializer, Configurable, Poolable, 
CacheableProcessingComponent, Contextualizable {
   
       /**
        * Get the context
  @@ -288,8 +288,8 @@
        * @return The generated key or <code>0</code> if the component
        *              is currently not cacheable.
        */
  -    public long generateKey() {
  -        return 1;
  +    public java.io.Serializable generateKey() {
  +        return "1";
       }
   
       /**
  @@ -300,8 +300,8 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  -        return NOPCacheValidity.CACHE_VALIDITY;
  +    public SourceValidity generateValidity() {
  +        return NOPValidity.SHARED_INSTANCE;
       }
   
       /**
  
  
  
  1.5       +48 -41    
xml-cocoon2/src/java/org/apache/cocoon/sitemap/ContentAggregator.java
  
  Index: ContentAggregator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/sitemap/ContentAggregator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContentAggregator.java    22 Feb 2002 07:03:55 -0000      1.4
  +++ ContentAggregator.java    28 May 2002 13:08:13 -0000      1.5
  @@ -53,16 +53,15 @@
   import org.apache.avalon.excalibur.pool.Recyclable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.caching.AggregatedCacheValidity;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.TimeStampCacheValidity;
  -import org.apache.cocoon.environment.Source;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.generation.Generator;
  -import org.apache.cocoon.util.HashUtil;
   import org.apache.cocoon.xml.ContentHandlerWrapper;
   import org.apache.cocoon.xml.XMLConsumer;
  +import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceException;
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.AggregatedValidity;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
  @@ -73,13 +72,17 @@
   import java.util.Map;
   
   /**
  + * This generator implements the sitemap content aggregation.
  + * It combines several parts into one big XML document which is streamed
  + * into the pipeline.
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: ContentAggregator.java,v 1.4 2002/02/22 07:03:55 cziegeler Exp 
$
  + * @version CVS $Id: ContentAggregator.java,v 1.5 2002/05/28 13:08:13 cziegeler Exp 
$
    */
   public class ContentAggregator
   extends ContentHandlerWrapper
  -implements Generator, Cacheable, Recyclable {
  +implements Generator, CacheableProcessingComponent, Recyclable {
   
       /** the root element of the aggregated content */
       protected Element rootElement;
  @@ -96,6 +99,9 @@
       /** The element used for the current part */
       protected Element currentElement;
   
  +    /** The SourceResolver */
  +    protected SourceResolver resolver;
  +
       /** This object holds the part parts :) */
       protected final class Part {
           public String uri;
  @@ -145,7 +151,7 @@
                   }
   
                   try {
  -                    part.source.toSAX(this);
  +                    this.resolver.toSAX(part.source, this);
                   } finally {
                       if (part.element != null) {
                           this.endElem(part.element);
  @@ -165,39 +171,34 @@
        *
        * @return The generated key hashes the src
        */
  -    public long generateKey() {
  +    public java.io.Serializable generateKey() {
           try {
  -            long key = HashUtil.hash("CA(" +
  -                                     this.rootElement.prefix +
  -                                     ':' +
  -                                     this.rootElement.name +
  -                                     '<' + this.rootElement.namespace + ">)");
  +            StringBuffer buffer = new StringBuffer();
  +            buffer.append("CA(")
  +                  .append(this.rootElement.prefix).append(':')
  +                  .append(this.rootElement.name).append('<')
  +                  .append(this.rootElement.namespace).append(">)");
               Source current;
               for (int i = 0; i < this.parts.size(); i++) {
                   final Part part = (Part)this.parts.get(i);
                   current = part.source;
  -                if (current.getLastModified() == 0) {
  -                        return 0;
  +                if (part.element == null) {
  +                    buffer.append("P=")
  +                          .append(part.stripRootElement).append(':')
  +                          .append(current.getSystemId()).append(';');
                   } else {
  -                    if (part.element == null) {
  -                        key += HashUtil.hash("P=" +
  -                                         part.stripRootElement + ':' +
  -                                         current.getSystemId() + ';');
  -                    } else {
  -                        key += HashUtil.hash("P=" +
  -                                         part.element.prefix +
  -                                         ':' +
  -                                         part.element.name +
  -                                         '<' + part.element.namespace + ">:" +
  -                                         part.stripRootElement + ':' +
  -                                         current.getSystemId() + ';');
  -                    }
  +                    buffer.append("P=")
  +                          .append(part.element.prefix).append(':')
  +                          .append(part.element.name)
  +                          .append('<').append(part.element.namespace).append(">:")
  +                          .append(part.stripRootElement).append(':')
  +                          .append(current.getSystemId()).append(';');
                   }
               }
  -            return key;
  +            return buffer.toString();
           } catch (Exception e) {
               getLogger().error("ContentAggregator: could not generateKey", e);
  -            return 0;
  +            return null;
           }
       }
   
  @@ -207,16 +208,17 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  +    public SourceValidity generateValidity() {
           try {
  -            AggregatedCacheValidity v = new AggregatedCacheValidity();
  +            AggregatedValidity v = new AggregatedValidity();
               Source current;
               for (int i = 0; i < this.parts.size(); i++) {
                   current = ((Part)this.parts.get(i)).source;
  -                if (current.getLastModified() == 0) {
  -                        return null;
  +                SourceValidity sv = current.getValidity();
  +                if (sv == null) {
  +                    return null;
                   } else {
  -                    v.add(new TimeStampCacheValidity(current.getLastModified()));
  +                    v.add(sv);
                   }
               }
               return v;
  @@ -287,9 +289,10 @@
           super.recycle();
           this.rootElement = null;
           for (Iterator i = this.parts.iterator(); i.hasNext();)
  -            ((Part)i.next()).source.recycle();
  +            this.resolver.release(((Part)i.next()).source);
           this.parts.clear();
           this.currentElement = null;
  +        this.resolver = null;
       }
   
       /**
  @@ -299,9 +302,13 @@
       public void setup(SourceResolver resolver, Map objectModel, String src, 
Parameters par)
       throws ProcessingException, SAXException, IOException {
           // get the Source for each part
  -        for(int i=0; i<this.parts.size();i++) {
  -            final Part current = (Part)this.parts.get(i);
  -            current.source = resolver.resolve(current.uri);
  +        try {
  +            for(int i=0; i<this.parts.size();i++) {
  +                final Part current = (Part)this.parts.get(i);
  +                current.source = resolver.resolveURI(current.uri);
  +            }
  +        } catch (SourceException se) {
  +            throw new ProcessingException("Unable to resolve source.", se);
           }
       }
   
  
  
  
  1.2       +11 -11    
xml-cocoon2/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java
  
  Index: EncodeURLTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EncodeURLTransformer.java 14 Mar 2002 07:09:50 -0000      1.1
  +++ EncodeURLTransformer.java 28 May 2002 13:08:13 -0000      1.2
  @@ -57,15 +57,15 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.NOPCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Response;
   import org.apache.cocoon.environment.Session;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.transformation.AbstractTransformer;
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.NOPValidity;
   import org.apache.regexp.RE;
   import org.apache.regexp.RESyntaxException;
   import org.xml.sax.Attributes;
  @@ -110,7 +110,7 @@
    * </pre></tt>
    *
    * @author     <a href="mailto:[EMAIL PROTECTED]";>Bernhard Huber</a>
  - * @version    CVS $Id: EncodeURLTransformer.java,v 1.1 2002/03/14 07:09:50 
cziegeler Exp $
  + * @version    CVS $Id: EncodeURLTransformer.java,v 1.2 2002/05/28 13:08:13 
cziegeler Exp $
    *
    * @cocoon:name encodeURL
    * @cocoon:status scratchpad
  @@ -125,7 +125,7 @@
   
   public class EncodeURLTransformer
     extends AbstractTransformer
  -  implements Configurable {
  +  implements Configurable, CacheableProcessingComponent {
   
       /**
        * Configuration name for specifying excluding patterns,
  @@ -250,11 +250,11 @@
        *
        * @return The generated key hashes the src
        */
  -    public long generateKey() {
  +    public java.io.Serializable generateKey() {
           if ( null == this.session ) {
  -            return 1;
  +            return "1";
           }
  -        return 0;
  +        return null;
       }
   
       /**
  @@ -263,9 +263,9 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  +    public SourceValidity generateValidity() {
           if ( null == this.session ) {
  -            return NOPCacheValidity.CACHE_VALIDITY;
  +            return NOPValidity.SHARED_INSTANCE;
           }
           return null;
       }
  @@ -319,7 +319,7 @@
        * </p>
        *
        * @author     <a href="mailto:[EMAIL PROTECTED]";>Bernhard Huber</a>
  -     * @version    CVS $Id: EncodeURLTransformer.java,v 1.1 2002/03/14 07:09:50 
cziegeler Exp $
  +     * @version    CVS $Id: EncodeURLTransformer.java,v 1.2 2002/05/28 13:08:13 
cziegeler Exp $
        */
       public class ElementAttributeMatching {
           /**
  
  
  
  1.8       +9 -10     
xml-cocoon2/src/java/org/apache/cocoon/transformation/FilterTransformer.java
  
  Index: FilterTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/FilterTransformer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FilterTransformer.java    22 Feb 2002 07:03:56 -0000      1.7
  +++ FilterTransformer.java    28 May 2002 13:08:13 -0000      1.8
  @@ -52,11 +52,10 @@
   
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.NOPCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.environment.SourceResolver;
  -import org.apache.cocoon.util.HashUtil;
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.NOPValidity;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
  @@ -79,12 +78,12 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sven Beauprez</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: FilterTransformer.java,v 1.7 2002/02/22 07:03:56 cziegeler Exp 
$
  + * @version CVS $Id: FilterTransformer.java,v 1.8 2002/05/28 13:08:13 cziegeler Exp 
$
    */
   
   public class FilterTransformer
   extends AbstractTransformer
  -implements Cacheable {
  +implements CacheableProcessingComponent {
   
       private static final String ELEMENT = "element-name";
       private static final String COUNT = "count";
  @@ -131,10 +130,10 @@
        * @return The generated key or <code>0</code> if the component
        *              is currently not cacheable.
        */
  -    public long generateKey() {
  +    public java.io.Serializable generateKey() {
           final StringBuffer hash = new StringBuffer(this.elementName);
           hash.append('<').append(this.count).append('>').append(this.blocknr);
  -        return HashUtil.hash(hash);
  +        return hash;
       }
   
       /**
  @@ -145,8 +144,8 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  -        return NOPCacheValidity.CACHE_VALIDITY;
  +    public SourceValidity generateValidity() {
  +        return NOPValidity.SHARED_INSTANCE;
       }
   
       /** BEGIN SAX ContentHandler handlers **/
  
  
  
  1.15      +13 -13    
xml-cocoon2/src/java/org/apache/cocoon/transformation/FragmentExtractorTransformer.java
  
  Index: FragmentExtractorTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/FragmentExtractorTransformer.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- FragmentExtractorTransformer.java 21 May 2002 06:08:05 -0000      1.14
  +++ FragmentExtractorTransformer.java 28 May 2002 13:08:13 -0000      1.15
  @@ -61,14 +61,14 @@
   import org.apache.avalon.framework.parameters.Parameters;
   
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.NOPCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.components.sax.XMLSerializer;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.util.HashUtil;
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.NOPValidity;
   
   import org.apache.excalibur.store.Store;
   
  @@ -97,10 +97,10 @@
    * <p>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Paul Russell</a>
  - * @version CVS $Id: FragmentExtractorTransformer.java,v 1.14 2002/05/21 06:08:05 
cziegeler Exp $
  + * @version CVS $Id: FragmentExtractorTransformer.java,v 1.15 2002/05/28 13:08:13 
cziegeler Exp $
    */
   public class FragmentExtractorTransformer extends AbstractTransformer
  -    implements Cacheable, Configurable, Composable, Disposable, Recyclable {
  +    implements CacheableProcessingComponent, Configurable, Composable, Disposable, 
Recyclable {
   
       private static final String EXTRACT_URI_NAME = "extract-uri";
       private static final String EXTRACT_ELEMENT_NAME = "extract-element";
  @@ -160,7 +160,7 @@
       public void compose(ComponentManager manager) throws ComponentException {
           this.manager = manager;
       }
  -    
  +
       /**
        * Release all resources.
        */
  @@ -169,7 +169,7 @@
           this.serializer = null;
           this.manager = null;
       }
  -    
  +
       /**
        * Recycle this component
        */
  @@ -184,8 +184,8 @@
        *
        * @return The generated key hashes the src
        */
  -    public long generateKey() {
  -        return 1;
  +    public java.io.Serializable generateKey() {
  +        return "1";
       }
   
       /**
  @@ -194,8 +194,8 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  -        return NOPCacheValidity.CACHE_VALIDITY;
  +    public SourceValidity generateValidity() {
  +        return NOPValidity.SHARED_INSTANCE;
       }
   
       /**
  @@ -328,7 +328,7 @@
                       try {
                           store = (Store) this.manager.lookup(Store.TRANSIENT_STORE);
   
  -                        store.store(id, this.serializer.getSAXFragment()); 
  +                        store.store(id, this.serializer.getSAXFragment());
                       } catch (ComponentException ce) {
                           getLogger().error("Could not lookup for transient store.", 
ce);
                           throw new SAXException("Could not lookup for transient 
store.", ce);
  @@ -341,7 +341,7 @@
                           this.manager.release(this.serializer);
                           this.serializer = null;
                       }
  -               
  +
                       getLogger().debug("FragmentExtractorTransformer stored document 
" + id + ".");
   
                       // Insert ref.
  
  
  
  1.7       +3 -3      
xml-cocoon2/src/java/org/apache/cocoon/transformation/RoleFilterTransformer.java
  
  Index: RoleFilterTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/RoleFilterTransformer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RoleFilterTransformer.java        22 Feb 2002 07:03:56 -0000      1.6
  +++ RoleFilterTransformer.java        28 May 2002 13:08:13 -0000      1.7
  @@ -87,7 +87,7 @@
    * will work as expected.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
  - * @version CVS $Id: RoleFilterTransformer.java,v 1.6 2002/02/22 07:03:56 cziegeler 
Exp $
  + * @version CVS $Id: RoleFilterTransformer.java,v 1.7 2002/05/28 13:08:13 cziegeler 
Exp $
    */
   public class RoleFilterTransformer extends FilterTransformer {
       private final static String URI = "http://apache.org/cocoon/role-filter/1.0";;
  @@ -107,8 +107,8 @@
       /**
        * Disable caching
        */
  -    public long generateKey() {
  -        return 0;
  +    public java.io.Serializable generateKey() {
  +        return null;
       }
   
       public final void startElement(String uri, String loc, String raw, Attributes a)
  
  
  
  1.2       +0 -2      
xml-cocoon2/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java
  
  Index: SourceWritingTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/SourceWritingTransformer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SourceWritingTransformer.java     21 May 2002 08:29:35 -0000      1.1
  +++ SourceWritingTransformer.java     28 May 2002 13:08:13 -0000      1.2
  @@ -62,8 +62,6 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.serialization.Serializer;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.components.source.WriteableSource;
  
  
  
  1.27      +21 -29    
xml-cocoon2/src/java/org/apache/cocoon/transformation/TraxTransformer.java
  
  Index: TraxTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/TraxTransformer.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- TraxTransformer.java      2 May 2002 12:09:21 -0000       1.26
  +++ TraxTransformer.java      28 May 2002 13:08:13 -0000      1.27
  @@ -52,6 +52,7 @@
   
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceException;
  +import org.apache.excalibur.source.SourceValidity;
   import org.apache.avalon.excalibur.xml.xslt.XSLTProcessor;
   import org.apache.avalon.excalibur.xml.xslt.XSLTProcessorException;
   import org.apache.avalon.framework.activity.Disposable;
  @@ -65,9 +66,7 @@
   import org.apache.avalon.framework.logger.Loggable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.SourceCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.components.browser.Browser;
   import org.apache.cocoon.components.deli.Deli;
   import org.apache.cocoon.environment.Session;
  @@ -75,7 +74,6 @@
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.SourceResolver;
  -import org.apache.cocoon.util.HashUtil;
   import org.apache.cocoon.xml.XMLConsumer;
   import org.xml.sax.SAXException;
   
  @@ -159,10 +157,10 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Ovidiu Predescu</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Mark H. Butler</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
  - * @version CVS $Id: TraxTransformer.java,v 1.26 2002/05/02 12:09:21 cziegeler Exp $
  + * @version CVS $Id: TraxTransformer.java,v 1.27 2002/05/28 13:08:13 cziegeler Exp $
    */
   public class TraxTransformer extends AbstractTransformer
  -implements Transformer, Composable, Configurable, Cacheable, Disposable {
  +implements Transformer, Composable, Configurable, CacheableProcessingComponent, 
Disposable {
   
       /** The Browser service instance */
       private Browser browser = null;
  @@ -331,26 +329,23 @@
        *
        * @return The generated key hashes the src
        */
  -    public long generateKey() {
  -        if (this.inputSource.getValidity() != null) {
  -            HashMap map = getLogicSheetParameters();
  -            if (map == null) {
  -                return HashUtil.hash(this.inputSource.getSystemId());
  -            }
  +    public java.io.Serializable generateKey() {
  +        HashMap map = this.getLogicSheetParameters();
  +        if (map == null) {
  +            return this.inputSource.getSystemId();
  +        }
   
  -            StringBuffer sb = new StringBuffer();
  -            sb.append(this.inputSource.getSystemId());
  -            Set entries = map.entrySet();
  -            for(Iterator i=entries.iterator(); i.hasNext();){
  -                sb.append(';');
  -                Map.Entry entry = (Map.Entry)i.next();
  -                sb.append(entry.getKey());
  -                sb.append('=');
  -                sb.append(entry.getValue());
  -            }
  -            return HashUtil.hash(sb.toString());
  +        StringBuffer sb = new StringBuffer();
  +        sb.append(this.inputSource.getSystemId());
  +        Set entries = map.entrySet();
  +        for(Iterator i=entries.iterator(); i.hasNext();){
  +            sb.append(';');
  +            Map.Entry entry = (Map.Entry)i.next();
  +            sb.append(entry.getKey());
  +            sb.append('=');
  +            sb.append(entry.getValue());
           }
  -        return 0;
  +        return sb.toString();
       }
   
       /**
  @@ -359,17 +354,14 @@
        * @return The generated validity object or <code>null</code> if the
        *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  +    public SourceValidity generateValidity() {
           /*
           * VG: Key is generated using parameter/value pairs,
           * so this information does not need to be verified again
           * (if parameter added/removed or value changed, key should
           * change also), only stylesheet's modified time is included.
           */
  -        if (this.inputSource.getValidity() != null) {
  -            return new SourceCacheValidity(this.inputSource.getValidity());
  -        }
  -        return null;
  +        return this.inputSource.getValidity();
       }
   
       /**
  
  
  
  1.3       +156 -161  
xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java
  
  Index: XMLFormTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLFormTransformer.java   20 May 2002 07:27:53 -0000      1.2
  +++ XMLFormTransformer.java   28 May 2002 13:08:13 -0000      1.3
  @@ -58,7 +58,7 @@
   import java.util.Collection;
   import java.util.SortedSet;
   import java.util.Stack;
  -import java.lang.reflect.Array; 
  +import java.lang.reflect.Array;
   
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  @@ -84,12 +84,12 @@
   import org.apache.cocoon.components.xmlform.Form;
   
   /**
  - * Transforms a document with XMLForm 
  + * Transforms a document with XMLForm
    * elements into a document in the same namespace,
    * but with populated values for the XPath references
    * to the form's model attributes
    *
  - * The original code was built by Torsten Curdt as 
  + * The original code was built by Torsten Curdt as
    * part of the Preceptor API
    *
    * @author: Ivelin Ivanov <[EMAIL PROTECTED]>, May 2002
  @@ -97,23 +97,18 @@
    * @author: Torsten Curdt <[EMAIL PROTECTED]>, March 2002
    */
   
  -public class XMLFormTransformer extends AbstractSAXTransformer 
  +public class XMLFormTransformer extends AbstractSAXTransformer
   {
   
  -
  -  //implements Cacheable {
  -
  -
  -
     public final static String NS = "http://xml.apache.org/cocoon/xmlform/2002";;
     private final static String NS_PREFIX = "xf";
     public final static Attributes NOATTR = new AttributesImpl();
     private final static String XMLNS_PREFIX = "xmlns";
   
  -  /** 
  +  /**
      * The main tag in the XMLForm namespace
      * almost all other tags have to appear within the form tag
  -   * The id attribute refers to a xmlform.Form object 
  +   * The id attribute refers to a xmlform.Form object
      * available in the current Request or Session
      *
      * &lt;form id="form-feedback">
  @@ -124,7 +119,7 @@
     public final static String TAG_FORM = "form";
     public final static String TAG_FORM_ATTR_ID = "id";
   
  -  /** 
  +  /**
      * the only tag which can be used outside of the form tag
      * with reference to the form id,
      * &lt;output ref="user/age" id="form-feedback"/>
  @@ -132,7 +127,7 @@
     public final static String TAG_OUTPUT = "output";
     public final static String TAG_OUTPUT_ATTR_FORM = TAG_FORM;
   
  -  /** 
  +  /**
      * can be used directly under the form tag
      * to enlist all field violations or
      * within a field tag to enlist only the violations for the field.
  @@ -159,7 +154,7 @@
      *
      */
     public final static String TAG_INSERTVIOLATIONS = "violations";
  -  
  +
     /** the name of the elements which replace the violations tag */
     public final static String TAG_VIOLATION = "violation";
   
  @@ -167,7 +162,7 @@
     public final static String TAG_SUBMIT = "submit";
     public final static String TAG_CANCEL = "cancel";
     public final static String TAG_RESET = "reset";
  -  
  +
     public final static String TAG_CAPTION = "caption";
     public final static String TAG_TEXTBOX = "textbox";
     public final static String TAG_TEXTAREA = "textarea";
  @@ -175,9 +170,9 @@
     public final static String TAG_SELECTBOOLEAN = "selectBoolean";
     public final static String TAG_SELECTONE = "selectOne";
     public final static String TAG_SELECTMANY = "selectMany";
  -  
  +
     /**
  -   * grouping tag 
  +   * grouping tag
      *
      * <pre>
      *  <group ref="address">
  @@ -193,13 +188,13 @@
      *     </input>
      * </group>
      * </pre>
  -   *   
  +   *
      *
      */
     public final static String TAG_GROUP = "group";
  -  
  -  /** 
  -   *  repeat tag 
  +
  +  /**
  +   *  repeat tag
      *
      *  <repeat nodeset="/cart/items/item">
      *    <input ref="." .../><html:br/>
  @@ -210,68 +205,68 @@
   
     public final static String TAG_REPEAT = "repeat";
   
  -  
  -  /** 
  -   * this attribute is used within the 
  +
  +  /**
  +   * this attribute is used within the
      * <code>repeat</code> tag
      * to represent an XPath node set selector from
      * the underlying xmlform model.
      */
     public final static String TAG_REPEAT_ATTR_NODESET = "nodeset";
  -    
  +
     /**
  -   * The current fully expanded reference 
  +   * The current fully expanded reference
      * in the form model.
      *
      */
     private String cannonicalRef = null;
  -  
  +
     /**
  -   * Tracks the current repeat tag depth, 
  +   * Tracks the current repeat tag depth,
      * when there is one in scope
      */
     private int repeatTagDepth = -1;
   
     /**
  -   * The nodeset selector string of the 
  +   * The nodeset selector string of the
      * currently processed repeat tag (if any)
      */
     private String nodeset = null;
  -  
  -  
  +
  +
     /**
      * The flag annotating if the transformer is
      * working on a repeat tag
      */
     private boolean isRecording = false;
  -  
  -  
  +
  +
     /**
      * the ref value of the current field
      * used by the violations tag
      */
     private Stack refStack = null;
  -  
  +
     /**
      * Tracks the current depth of the XML tree
      */
     private int currentTagDepth = 0;
   
  -  
  -  /** 
  +
  +  /**
      * this attribute is used within all field tags
  -   * to represent an XPath reference to the attribute of 
  +   * to represent an XPath reference to the attribute of
      * the underlying model.
      */
     public final static String TAG_COMMON_ATTR_REF = "ref";
  -  
  +
   
     // the current Form being processed
     private Form currentForm;
   
     private Object value_;
   
  -  
  +
   
       /**
        * Setup the next round.
  @@ -288,15 +283,15 @@
                         Parameters        par)
       throws ProcessingException,
              SAXException,
  -           IOException 
  +           IOException
       {
         super.setup( resolver, objectModel, src, par );
  -      if (request == null) 
  +      if (request == null)
         {
           getLogger().debug("no request object");
           throw new ProcessingException("no request object");
         }
  -      
  +
         // set the XMLForm namespace as the one
         // this transformer is interested to work on
         namespaceURI = NS;
  @@ -311,7 +306,7 @@
         nodeset = null;
     }
   
  -  
  +
       /**
        * Start processing elements of our namespace.
        * This hook is invoked for each sax event with our namespace.
  @@ -324,7 +319,7 @@
                                            String name,
                                            String raw,
                                            Attributes attributes )
  -    throws ProcessingException, IOException, SAXException 
  +    throws ProcessingException, IOException, SAXException
       {
         try
         {
  @@ -332,7 +327,7 @@
           // when outputting the elements themselves
           this.ignoreHooksCount = 1;
   
  -        if (this.getLogger().isDebugEnabled() == true) 
  +        if (this.getLogger().isDebugEnabled() == true)
           {
               this.getLogger().debug("BEGIN startTransformingElement uri=" + uri + ", 
name=" + name + ", raw=" + raw + ", attr=" + attributes + ")");
           }
  @@ -377,7 +372,7 @@
         {
            throw new SAXException( name + " element should provide a '" + 
TAG_REPEAT_ATTR_NODESET + "' attribute" );
         }
  -       
  +
          // open the repeat tag in the output document
          super.startElement( uri, name, raw, attributes);
          // and start recording its content
  @@ -388,32 +383,32 @@
           // if this tag has a "ref" attribute, then
           // add its value to the refStack
           String aref = attributes.getValue( TAG_COMMON_ATTR_REF );
  -        if ( aref != null ) 
  +        if ( aref != null )
           {
             // put on top of the ref stack the full ref
             // append the new ref to the last stack top if not referencing the root
             cannonicalRef = aref.startsWith ("/") ? aref : ( ((Entry) 
refStack.peek()).getValue() + "/" + aref );
             Entry entry = new Entry( new Integer(currentTagDepth), cannonicalRef);
             refStack.push( entry );
  -          
  +
             // replace the ref attribute's value(path) with its full cannonical form
             AttributesImpl atts = new AttributesImpl( attributes );
             int refIdx = atts.getIndex ( TAG_COMMON_ATTR_REF );
             atts.setValue ( refIdx, cannonicalRef );
  -          attributes = atts;          
  +          attributes = atts;
           }
   
  -        // match tag name and apply transformation logic 
  -        if (TAG_FORM.equals(name)) 
  +        // match tag name and apply transformation logic
  +        if (TAG_FORM.equals(name))
           {
  -          startElementForm( uri, name, raw, attributes ); 
  +          startElementForm( uri, name, raw, attributes );
           }
  -        else if ( TAG_OUTPUT.equals(name) ) 
  +        else if ( TAG_OUTPUT.equals(name) )
           {
             startElementOutput( uri, name, raw, attributes );
           } // end if TAG_OUTPUT
  -        else if ( TAG_CAPTION.equals( name ) ) 
  -        { 
  +        else if ( TAG_CAPTION.equals( name ) )
  +        {
             super.startElement( uri, name, raw, attributes);
             this.ignoreHooksCount = 0;
           }
  @@ -421,32 +416,32 @@
           // then we can't process nested form tags
           else if (currentForm != null)
           {
  -          if (TAG_INSERTVIOLATIONS.equals(name)) 
  +          if (TAG_INSERTVIOLATIONS.equals(name))
             {
               startElementViolations( uri, name, raw, attributes );
             } // end if TAG_INSERTVIOLATIONS
   
  -          else if ( 
  +          else if (
                       TAG_TEXTBOX.equals(name) ||
                       TAG_TEXTAREA.equals(name) ||
                       TAG_PASSWORD.equals(name) ||
                       TAG_SELECTBOOLEAN.equals(name) ||
  -                    TAG_SELECTONE.equals(name)) 
  +                    TAG_SELECTONE.equals(name))
             {
                 startElementSimpleField( uri, name, raw, attributes, currentForm );
             }
  -          else if (TAG_SELECTMANY.equals(name)) 
  +          else if (TAG_SELECTMANY.equals(name))
             {
               startElementSimpleField( uri, name, raw, attributes, currentForm );
             }
             else if (
               TAG_SUBMIT.equals(name) ||
               TAG_CANCEL.equals(name) ||
  -            TAG_RESET.equals(name) ) 
  +            TAG_RESET.equals(name) )
             {
               super.startElement(uri, name, raw, attributes);
             }
  -          else 
  +          else
             {
                 getLogger().error("unknown element [" + String.valueOf(name) + "]");
                 super.startElement(uri, name, raw, attributes);
  @@ -454,21 +449,21 @@
           }
         } // end else (not a repeat tag)
       }
  -    finally 
  +    finally
       {
         // reset ignore counter
         this.ignoreHooksCount = 0;
       }
   
  -    
  -    if (this.getLogger().isDebugEnabled() == true) 
  +
  +    if (this.getLogger().isDebugEnabled() == true)
       {
             this.getLogger().debug("END startTransformingElement");
       }
     } // end of startTransformingElement
   
   
  -  protected void startElementForm(String uri, String name, String raw, Attributes 
attributes) throws SAXException 
  +  protected void startElementForm(String uri, String name, String raw, Attributes 
attributes) throws SAXException
     {
       String id = attributes.getValue(TAG_FORM_ATTR_ID);
   
  @@ -481,8 +476,8 @@
   
       super.startElement(uri, name, raw, attributes);
   
  -    // load up the referenced form 
  -    currentForm =  Form.lookup( objectModel, id ); 
  +    // load up the referenced form
  +    currentForm =  Form.lookup( objectModel, id );
   
       // if the form wasn't found, we're in trouble
       if (currentForm == null)
  @@ -491,9 +486,9 @@
       }
     } // end of startElementForm
   
  -  
  -  
  -  protected void startElementViolations(String uri, String name, String raw, 
Attributes attributes) throws SAXException 
  +
  +
  +  protected void startElementViolations(String uri, String name, String raw, 
Attributes attributes) throws SAXException
     {
         SortedSet violations = currentForm.getViolations();
   
  @@ -502,9 +497,9 @@
   
         // if we're immediately under the form tag
         // and parent "ref" attribute is not available
  -      if ( refStack.isEmpty () ) 
  +      if ( refStack.isEmpty () )
         {
  -        for (Iterator it = violations.iterator(); it.hasNext();) 
  +        for (Iterator it = violations.iterator(); it.hasNext();)
           {
             Violation violation = (Violation) it.next();
   
  @@ -523,14 +518,14 @@
             // now start the element
             super.startElement(uri, TAG_VIOLATION, NS_PREFIX + ":" + TAG_VIOLATION, 
atts);
   
  -          // set message 
  +          // set message
             String vm = violation.getMessage();
             super.characters( vm.toCharArray(), 0, vm.length());
   
             super.endElement(uri, TAG_VIOLATION, NS_PREFIX + ":" + TAG_VIOLATION);
           }
  -      } // end if (currentRef_ == null) 
  -      else 
  +      } // end if (currentRef_ == null)
  +      else
         {
           Entry entry = (Entry) refStack.peek ();
           String currentRef = (String) entry.getValue ();
  @@ -544,10 +539,10 @@
             // we're only interested in violations
             // with matching reference
             if ( !currentRef.equals (nextViolation.getPath () ) ) break;
  -          
  +
             // render <violation> tag
             super.startElement(uri, TAG_VIOLATION, NS_PREFIX + ":" + TAG_VIOLATION, 
attributes );
  -          // set message 
  +          // set message
             String vm = nextViolation.getMessage();
             super.characters( vm.toCharArray(), 0, vm.length());
             super.endElement(uri, TAG_VIOLATION, NS_PREFIX + ":" + TAG_VIOLATION);
  @@ -555,22 +550,22 @@
         }
     } // end of startElementViolations
   
  -  
  +
   
     /**
      * Since the ouput tag is the only one which can be used
      * outside of a form tag, it needs some special treatment
      *
      */
  -  protected void startElementOutput(String uri, String name, String raw, Attributes 
attributes) 
  +  protected void startElementOutput(String uri, String name, String raw, Attributes 
attributes)
       throws SAXException
     {
   
  -        // we will either use the locally referenced form id 
  +        // we will either use the locally referenced form id
           // or the global id. At least one of the two must be available
           Form form = null;
           String formAttr = attributes.getValue( TAG_OUTPUT_ATTR_FORM );
  -        if (formAttr == null) 
  +        if (formAttr == null)
           {
             if (currentForm == null)
             {
  @@ -582,14 +577,14 @@
           {
             form = Form.lookup( objectModel, formAttr );
           }
  -        
  +
           startElementSimpleField( uri, name, raw, attributes, form );
   
     } // end of startElementOutput
  -  
   
  -  
  -  protected void startElementSimpleField(String uri, String name, String raw, 
Attributes attributes, Form form) 
  +
  +
  +  protected void startElementSimpleField(String uri, String name, String raw, 
Attributes attributes, Form form)
       throws SAXException
     {
         String ref = attributes.getValue(TAG_COMMON_ATTR_REF);
  @@ -598,7 +593,7 @@
         {
            throw new SAXException( name + " element should provide a '" + 
TAG_COMMON_ATTR_REF + "' attribute" );
         }
  -      
  +
         if ( form == null)
         {
            throw new SAXException( name + " element should be either nested within a 
form tag or provide a form attribute" );
  @@ -617,11 +612,11 @@
         // render the value subelement(s)
         if (value_ instanceof Collection)
         {
  -             Iterator i=((Collection) value_).iterator();
  -             while (i.hasNext())
  -             {
  +        Iterator i=((Collection) value_).iterator();
  +        while (i.hasNext())
  +        {
             renderValueSubElement( i.next() );
  -             }
  +        }
         }
         else if ( value_ != null && value_.getClass().isArray () )
         {
  @@ -634,31 +629,31 @@
         else
         {
           renderValueSubElement( value_ );
  -       }
  +      }
     } // end of startElementSimpleField
  -  
  +
   
     /**
      * Outputs a <xf:value> element.
      * Used when transforming XMLForm elements
      * with reference to the model
      *
  -   * @param vobj provides the text content 
  +   * @param vobj provides the text content
      * within the <xf:value> element
  -   *  
  +   *
      */
     protected void renderValueSubElement( Object vobj )
       throws SAXException
     {
       super.startElement( NS, "value", NS_PREFIX + ":" + "value", NOATTR);
  -      if (vobj != null) 
  +      if (vobj != null)
         {
           String v = String.valueOf( vobj );
           super.characters(v.toCharArray(),0,v.length());
         }
  -      super.endElement( NS, "value", NS_PREFIX + ":" + "value" );    
  +      super.endElement( NS, "value", NS_PREFIX + ":" + "value" );
     }
  -  
  +
       /**
        * Start processing elements of our namespace.
        * This hook is invoked for each sax event with our namespace.
  @@ -670,22 +665,22 @@
            String uri,
            String name,
            String raw)
  -    throws ProcessingException, IOException, SAXException 
  +    throws ProcessingException, IOException, SAXException
     {
  -    if (this.getLogger().isDebugEnabled() == true) 
  +    if (this.getLogger().isDebugEnabled() == true)
       {
           this.getLogger().debug("BEGIN endTransformingElement uri=" + uri + ", 
name=" + name + ", raw=" + raw + ")");
       }
  -            
  +
   
       try
       {
           // avoid endless loop for elements in our namespace
           this.ignoreHooksCount = 1;
   
  -        
  +
        // when the end of an active repeat tag is reached
  -     // stop recording, unroll the repeat tag content 
  +     // stop recording, unroll the repeat tag content
        // for each node in the node set,
        // then close the repeat tag
        if (TAG_REPEAT.equals( name) && (repeatTagDepth == currentTagDepth))
  @@ -712,7 +707,7 @@
           {
             Entry entry = (Entry) refStack.peek();
             Integer refDepth = (Integer) entry.getKey ();
  -          if ( currentTagDepth <= refDepth.intValue () ) 
  +          if ( currentTagDepth <= refDepth.intValue () )
             {
               refStack.pop();
               cannonicalRef = refStack.isEmpty () ? "" : (String)( (Entry) 
(refStack.peek ()) ).getValue();
  @@ -720,11 +715,11 @@
           }
   
   
  -        if (TAG_INSERTVIOLATIONS.equals(name)) 
  +        if (TAG_INSERTVIOLATIONS.equals(name))
           {
             // all violations were rendered completely in the startElement method
           }
  -        else if (TAG_FORM.equals(name)) 
  +        else if (TAG_FORM.equals(name))
           {
             // nullify currentForm since we're getting out of its scope
             currentForm = null;
  @@ -734,23 +729,23 @@
                   TAG_TEXTBOX.equals(name) ||
                   TAG_PASSWORD.equals(name) ||
                   TAG_SELECTBOOLEAN.equals(name) ||
  -                TAG_SELECTONE.equals(name) ) 
  +                TAG_SELECTONE.equals(name) )
           {
             super.endElement(uri, name, raw);
           }
  -        else if (TAG_SELECTMANY.equals(name)) 
  +        else if (TAG_SELECTMANY.equals(name))
           {
             super.endElement(uri, name, raw);
           }
  -        else if (TAG_SUBMIT.equals(name)) 
  +        else if (TAG_SUBMIT.equals(name))
           {
             super.endElement(uri, name, raw);
  -        } 
  -        else if ( TAG_CAPTION.equals( name ) ) 
  -        { 
  +        }
  +        else if ( TAG_CAPTION.equals( name ) )
  +        {
             super.endElement(uri, name, raw);
           }
  -        else 
  +        else
           {
             getLogger().error("unknown element [" + String.valueOf(name) + "]");
             super.endElement(uri, name, raw);
  @@ -765,23 +760,23 @@
         // track the tree depth
         --currentTagDepth;
       }
  -    
  -    if (this.getLogger().isDebugEnabled() == true) 
  +
  +    if (this.getLogger().isDebugEnabled() == true)
       {
         this.getLogger().debug("END endTransformingElement");
       }
  -    
  +
     } // end of endTransformingElement
   
  -    
  +
     /**
      * Unroll the repeat tag.
      * For each node in the repeat tag's nodeset selector result,
  -   * render a <code>group</code> tag with a <code>ref</code> 
  +   * render a <code>group</code> tag with a <code>ref</code>
      * attribute which points to the location of the current node
      * in the nodeset. Within each <code>group</code> tag,
      * output the content of the repeat tag,
  -   * by resolving all form model references within nested xmlform tags, 
  +   * by resolving all form model references within nested xmlform tags,
      * relative to the <code>ref</code> attribute of the <code>group</code> element.
      *
      * @param docFragment the content of the repeat tag
  @@ -808,7 +803,7 @@
           atts.addAttribute( null, TAG_COMMON_ATTR_REF, TAG_COMMON_ATTR_REF, "CDATA", 
nextNodeLocation);
   
           super.startElement(NS, TAG_GROUP, NS_PREFIX + ":" + TAG_GROUP, atts);
  -        if (value_ != null) 
  +        if (value_ != null)
           {
             // stream back the recorder repeat content
             DOMStreamer streamer = new DOMStreamer( this, this);
  @@ -824,55 +819,55 @@
         ignoreHooksCount = oldIgnoreHooksCount;
       }
     } // unrollRepeatTag
  -    
  -    
  -    
  +
  +
  +
   
   
       /**
        * refStack entry.
        */
     private static class Entry implements Map.Entry {
  -     Object key;
  -     Object value;
  +    Object key;
  +    Object value;
  +
  +    Entry(Object key, Object value) {
  +        this.key = key;
  +        this.value = value;
  +    }
  +
  +    // Map.Entry Ops
  +
  +    public Object getKey() {
  +        return key;
  +    }
  +
  +    public Object getValue() {
  +        return value;
  +    }
  +
  +    public Object setValue(Object value) {
  +        Object oldValue = this.value;
  +        this.value = value;
  +        return oldValue;
  +    }
   
  -     Entry(Object key, Object value) {
  -         this.key = key;
  -         this.value = value;
  -     }
  -
  -     // Map.Entry Ops 
  -
  -     public Object getKey() {
  -         return key;
  -     }
  -
  -     public Object getValue() {
  -         return value;
  -     }
  -
  -     public Object setValue(Object value) {
  -         Object oldValue = this.value;
  -         this.value = value;
  -         return oldValue;
  -     }
  -
  -     public boolean equals(Object o) {
  -         if (!(o instanceof Map.Entry))
  -             return false;
  -         Map.Entry e = (Map.Entry)o;
  -
  -         return (key==null ? e.getKey()==null : key.equals(e.getKey())) &&
  -            (value==null ? e.getValue()==null : value.equals(e.getValue()));
  -     }
  -
  -     public int hashCode() {
  -         return getKey().hashCode () ^ (value==null ? 0 : value.hashCode());
  -     }
  -
  -     public String toString() {
  -         return key+"="+value;
  -     }
  +    public boolean equals(Object o) {
  +        if (!(o instanceof Map.Entry))
  +        return false;
  +        Map.Entry e = (Map.Entry)o;
  +
  +        return (key==null ? e.getKey()==null : key.equals(e.getKey())) &&
  +           (value==null ? e.getValue()==null : value.equals(e.getValue()));
  +    }
  +
  +    public int hashCode() {
  +        return getKey().hashCode () ^ (value==null ? 0 : value.hashCode());
  +    }
  +
  +    public String toString() {
  +        return key+"="+value;
  +    }
   }
   
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to