cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/sitemap/patterns PatternMatcher.java PatternTranslator.java
Date Sun, 27 Feb 2000 12:56:22 GMT
pier        00/02/27 04:56:21

  Modified:    src/org/apache/cocoon/generators Tag: xml-cocoon2
                        RequestGenerator.java
               src/org/apache/cocoon/servlet Tag: xml-cocoon2
                        CocoonServlet.java
               src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        GenericProcessor.java Sitemap.java
                        SitemapPartition.java
               src/org/apache/cocoon/sitemap/patterns Tag: xml-cocoon2
                        PatternMatcher.java PatternTranslator.java
  Added:       src/org/apache/cocoon/generators Tag: xml-cocoon2
                        DirectoryGenerator.java
  Log:
  [Cocoon 2.0] Tons o' bugs. Fixing in progress.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +2 -2      xml-cocoon/src/org/apache/cocoon/generators/Attic/RequestGenerator.java
  
  Index: RequestGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generators/Attic/RequestGenerator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- RequestGenerator.java	2000/02/27 07:13:17	1.1.2.1
  +++ RequestGenerator.java	2000/02/27 12:56:17	1.1.2.2
  @@ -15,7 +15,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/02/27 07:13:17 $
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/27 12:56:17 $
    */
   public class RequestGenerator extends AbstractGenerator {
   
  @@ -103,7 +103,7 @@
           this.end("request");
   
           // Finish
  -        this.contentHandler.endPrefixMapping("cocoon");
  +        this.contentHandler.endPrefixMapping("");
           this.contentHandler.endDocument();
       }
       
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +96 -0     xml-cocoon/src/org/apache/cocoon/generators/Attic/DirectoryGenerator.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.5   +2 -3      xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java,v
  retrieving revision 1.1.4.4
  retrieving revision 1.1.4.5
  diff -u -r1.1.4.4 -r1.1.4.5
  --- CocoonServlet.java	2000/02/27 05:45:19	1.1.4.4
  +++ CocoonServlet.java	2000/02/27 12:56:18	1.1.4.5
  @@ -28,7 +28,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.4 $ $Date: 2000/02/27 05:45:19 $
  + * @version CVS $Revision: 1.1.4.5 $ $Date: 2000/02/27 12:56:18 $
    */
   public class CocoonServlet extends HttpServlet {
       private Cocoon cocoon=null;
  @@ -116,8 +116,7 @@
           // We got it... Process the request
           String uri=req.getPathInfo();
           if (uri!=null) try {
  -            // Strip the leading '/' character
  -            if ((uri.length()>0)&&(uri.charAt(0)=='/')) uri=uri.substring(1);
  +            //if (uri.charAt(0)=='/') uri=uri.substring(1);
               CocoonServletRequest request=new CocoonServletRequest(req,uri);
               CocoonServletResponse response=new CocoonServletResponse(res);
               if (!this.cocoon.process(request,response,out)) {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +6 -4      xml-cocoon/src/org/apache/cocoon/sitemap/Attic/GenericProcessor.java
  
  Index: GenericProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/GenericProcessor.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- GenericProcessor.java	2000/02/27 07:14:32	1.1.2.4
  +++ GenericProcessor.java	2000/02/27 12:56:19	1.1.2.5
  @@ -35,7 +35,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/02/27 07:14:32 $
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/02/27 12:56:19 $
    */
   public class GenericProcessor implements Composer, Configurable, Processor {
   
  @@ -59,12 +59,15 @@
       private String serializer=null;
       /** The serializer role */
       private Parameters serializerParam=null;
  +    /** The sitemap partition */
  +    private SitemapPartition partition=null;
   
       /**
        * Create a new <code>SitemapPartition</code> instance.
        */
  -    public GenericProcessor() {
  +    public GenericProcessor(SitemapPartition partition) {
           super();
  +        this.partition=partition;
       }
   
       /**
  @@ -82,6 +85,7 @@
       public void setConfiguration(Configuration conf)
       throws ConfigurationException {
           String uri=conf.getAttribute("uri");
  +        if ((uri.length()==0)||(uri.charAt(0)!='/')) uri='/'+uri;
           String source=conf.getAttribute("source",null);
           try {
               if(source==null) {
  @@ -112,8 +116,6 @@
               Configuration f=(Configuration)e.nextElement();
               this.filters.addElement("filter:"+c.getAttribute("name"));
           }
  -        // NOTE NOTE NOTE NOTE NOTE NOTE
  -        // STILL MISSING PARAMETERS RETRIEVAL
       }
   
       /**
  
  
  
  1.1.4.3   +4 -4      xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Sitemap.java
  
  Index: Sitemap.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Sitemap.java,v
  retrieving revision 1.1.4.2
  retrieving revision 1.1.4.3
  diff -u -r1.1.4.2 -r1.1.4.3
  --- Sitemap.java	2000/02/27 01:33:09	1.1.4.2
  +++ Sitemap.java	2000/02/27 12:56:19	1.1.4.3
  @@ -27,7 +27,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.4.2 $ $Date: 2000/02/27 01:33:09 $
  + * @version CVS $Revision: 1.1.4.3 $ $Date: 2000/02/27 12:56:19 $
    */
   public class Sitemap implements Composer, Configurable, Processor {
       
  @@ -67,12 +67,12 @@
           Enumeration e=conf.getConfigurations("partition");
           while (e.hasMoreElements()) {
               Configuration co=(Configuration)e.nextElement();
  -            SitemapPartition p=new SitemapPartition();
  +            SitemapPartition p=new SitemapPartition(this);
               p.setComponentManager(this.manager);
               p.setConfiguration(co);
               
  -            String name=co.getAttribute("name",null);
  -            if ((name==null)||("default".equals(name))) {
  +            String name=co.getAttribute("name","default");
  +            if ("default".equals(name)) {
                   if (this.partition==null) this.partition=p;
                   else throw new ConfigurationException("Dupliacate definition "+
                                                  "of the default partition",co);
  
  
  
  1.1.2.3   +8 -5      xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapPartition.java
  
  Index: SitemapPartition.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapPartition.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- SitemapPartition.java	2000/02/27 01:33:09	1.1.2.2
  +++ SitemapPartition.java	2000/02/27 12:56:19	1.1.2.3
  @@ -27,7 +27,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/02/27 01:33:09 $
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/02/27 12:56:19 $
    */
   public class SitemapPartition implements Composer, Configurable, Processor {
   
  @@ -35,14 +35,18 @@
       private Vector processors=new Vector();
       /** The component manager instance */
       private ComponentManager manager=null;
  +    /** The sitemap */
  +    private Sitemap sitemap=null;
       /** This partition name */
       protected String name=null;
  +    
   
       /**
        * Create a new <code>SitemapPartition</code> instance.
        */
  -    public SitemapPartition() {
  +    public SitemapPartition(Sitemap sitemap) {
           super();
  +        this.sitemap=sitemap;
       }
   
       /**
  @@ -62,13 +66,12 @@
           if (!conf.getName().equals("partition"))
               throw new ConfigurationException("Invalid partition configuration",
                                                conf);
  -        this.name=conf.getAttribute("name",null);
  -        this.name=this.name!=null?this.name:"default";
  +        this.name=conf.getAttribute("name","default");
           // Set components
           Enumeration e=conf.getConfigurations("process");
           while (e.hasMoreElements()) {
               Configuration co=(Configuration)e.nextElement();
  -            GenericProcessor p=new GenericProcessor();
  +            GenericProcessor p=new GenericProcessor(this);
               p.setComponentManager(this.manager);
               p.setConfiguration(co);
               this.processors.addElement(p);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +43 -44    xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternMatcher.java
  
  Index: PatternMatcher.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternMatcher.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- PatternMatcher.java	2000/02/27 07:15:11	1.1.2.4
  +++ PatternMatcher.java	2000/02/27 12:56:20	1.1.2.5
  @@ -24,7 +24,7 @@
    * 
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/02/27 07:15:11 $
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/02/27 12:56:20 $
    */
   public class PatternMatcher {
   
  @@ -153,6 +153,8 @@
        * <b>FIXME: This routine doesn't match when the pattern ends with a
        *    wildcard. Need to fix together with <code>translatePattern()</code>,
        *    in <code>PatternTranslator</code> otherwise it won't work.</b>
  +     * <br>
  +     * <i>Seems ok now</i>
        *
        * @param buff The <code>char []</code> of the path to be matched.
        * @param expr The <code>int []</code> representing the pattern, as
  @@ -161,51 +163,48 @@
        */
       protected boolean matchPattern(char buff[], int expr[])
       throws NullPointerException {
  -        // Set the current position in buffers to zero
  -        int k=0;
  +                
  +        // The previous and current position of the expression character
  +        // (MATCH_*)
  +        int charpos=0;
  +        // Search the fist expression character
  +        while (expr[charpos]>=0) charpos++;
  +        // The expression charater (MATCH_*)
  +        int exprchr=expr[charpos];
  +
  +        // The position in the expression, input, translation and result arrays
           int exprpos=0;
           int buffpos=0;
  -        // This value represent the type of the last whildcard matching. It
  -        // will store MATCH_FILE '*' and MATCH_PATH for '**'
  -        int exprchr=0;
  -        // Go in loop :)
  -        while(true) {
  -            // Search the first MATCH_FILE ('*'), MATCH_PATH ('**') or
  -            // MATCH_END (end-of-buffer) character
  -            int end=exprpos;
  -            while(expr[end]>=0) end++;
  -
  -            // Get the offset of the token included between '?', '*' or '**'
  -            int off=this.matchArray(expr,exprpos,end,buff,buffpos);
  -
  -            // If the substring was not found, we have no match
  -            if(off==-1) return(false);
  -
  -            // If the previous wildcard was MATCH_FILE ('*') then we have to
  -            // check that the part that was ignored doesn't contain a path
  -            // separator '/'
  -            // While we check, we also copy the characters that need to be 
  -            // substituted to '*' in the target array
  -            if(exprchr==MATCH_FILE) for(int x=buffpos; x<off; x++) {
  -                if (buff[x]=='/') return(false);
  -            }
  -
  -            // Check if we reached the end of the expression
  -            if(expr[end]==MATCH_END) {
  -                // If the data buffer is finished we have a match
  -                if(off+end-exprpos==buff.length) return(true);
  -                // Otherwise there is no match
  -                return(true);
  +        int offset=-1;
  +        
  +        while (true) {
  +            // Check if the data in the expression array before the current
  +            // expression character matches the data in the input buffer
  +            offset=this.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(false);
  +
  +            if (exprchr==MATCH_END) return(true);
  +            
  +            // Search the next expression character
  +            buffpos+=(charpos-exprpos);
  +            exprpos=++charpos;
  +            while (expr[charpos]>=0) charpos++;
  +            int prevchr=exprchr;
  +            exprchr=expr[charpos];
  +   
  +            offset=this.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(false);
  +    
  +            // Copy the data from the source buffer into the result buffer
  +            // to substitute the expression character
  +            if (prevchr==MATCH_PATH) {
  +                while (buffpos<offset) buffpos++;
  +            } else {
  +                // Matching file, don't copy '/'
  +                while (buffpos<offset) {
  +                    if (buff[buffpos++]=='/') return(false);
  +                }
               }
  -
  -            // Set the current data buffer position to the first character
  -            // after the matched token
  -            buffpos=off+end-exprpos;
  -            // Set the current expression buffer position to the first
  -            // character after the wildcard
  -            exprpos=end+1;
  -            // Update the last expression character ('*' or '**')
  -            exprchr=expr[end];
           }
       }
   
  @@ -228,7 +227,7 @@
           // 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(dpos);
  +        if(rend==rpos) return(d.length);
           // If we need to match a 1 char length string do it simply
           if(rend-rpos==1) {
               // Search for the specified character
  
  
  
  1.1.2.5   +69 -58    xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternTranslator.java
  
  Index: PatternTranslator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/patterns/Attic/PatternTranslator.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- PatternTranslator.java	2000/02/27 07:15:11	1.1.2.4
  +++ PatternTranslator.java	2000/02/27 12:56:21	1.1.2.5
  @@ -19,13 +19,12 @@
    * 
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/02/27 07:15:11 $
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/02/27 12:56:21 $
    */
   public class PatternTranslator extends PatternMatcher {
   
       /** Wether the source and the target patterns are equal. */
       private boolean identityTranslation=false;
  -
       /** The int array identifying the pattern to match. */
       protected int[] targetPattern=null;
   
  @@ -71,8 +70,8 @@
           if ((this.targetPattern==null) || (super.sourcePattern==null))
               throw new IllegalStateException("Null internals");
           if (!super.match(data)) throw new IllegalArgumentException("No match");
  -        char x[]=data.toCharArray();
           
  +        char x[]=data.toCharArray();
           return(this.translatePattern(x,super.sourcePattern,this.targetPattern));
       }
   
  @@ -123,68 +122,80 @@
        * <b>FIXME: This routine doesn't match when the pattern ends with a
        *    wildcard. Need to fix together with <code>matchPattern()</code>,
        *    in <code>PatternMatcher</code> otherwise it won't work.</b>
  +     * <br>
  +     * <i>Seems ok now</i>
        */
       protected String translatePattern(char buff[], int expr[], int trns[])
       throws NullPointerException {
  +        // Allocate the result buffer
           char rslt[]=new char[expr.length+trns.length+buff.length];
  -        // Set the current position in buffers to zero
  -        int k=0;
  -        int rsltpos=0;
  +        
  +        // The previous and current position of the expression character
  +        // (MATCH_*)
  +        int charpos=0;
  +        // Search the fist expression character
  +        while (expr[charpos]>=0) charpos++;
  +        // The expression charater (MATCH_*)
  +        int exprchr=expr[charpos];
  +
  +        // The position in the expression, input, translation and result arrays
           int exprpos=0;
           int buffpos=0;
  -        // This value represent the type of the last whildcard matching. It
  -        // will store MATCH_FILE '*' and MATCH_PATH for '**'
  -        int exprchr=0;
  -        // Go in loop :)
  -        while(true) {
  -            // Search the first MATCH_FILE ('*'), MATCH_PATH ('**') or
  -            // MATCH_END (end-of-buffer) character
  -            int end=exprpos;
  -            while(expr[end]>=0) end++;
  -
  -            // Get the offset of the token included between '?', '*' or '**'
  -            int off=super.matchArray(expr,exprpos,end,buff,buffpos);
  -
  -            // If the substring was not found, we have no match
  -            if(off==-1) return(null);
  -
  -            // If the previous wildcard was MATCH_FILE ('*') then we have to
  -            // check that the part that was ignored doesn't contain a path
  -            // separator '/'
  -            // While we check, we also copy the characters that need to be 
  -            // substituted to '*' in the target array
  -            if(exprchr==MATCH_FILE) for(int x=buffpos; x<off; x++) {
  -                if (buff[x]=='/') return(null);
  -                else rslt[rsltpos++]=buff[x];
  -            }
  -
  -            // If the previous wildcard was MATCH_FILE ('*') then we just copy
  -            // the characters that need to be substituted to '**' in the target
  -            // array
  -            else if(exprchr==MATCH_PATH) {
  -                for(int x=buffpos; x<off; x++) rslt[rsltpos++]=buff[x];
  -            }                
  -
  -            // Copy the current token of characters from the source array
  -            while(trns[k]>=0) rslt[rsltpos++]=(char)trns[k++]; k++;
  -
  -            // Check if we reached the end of the expression
  -            if(expr[end]==MATCH_END) {
  -                // If the data buffer is finished we have a match
  -                if(off+end-exprpos==buff.length)
  -                    return(new String(rslt,0,rsltpos));
  -                // Otherwise return the null string
  -                return(null);
  +        int trnspos=0;
  +        int rsltpos=0;
  +        int offset=-1;
  +        
  +        while (true) {
  +            // Check if the data in the expression array before the current
  +            // expression character matches the data in the input buffer
  +            offset=super.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(null);
  +
  +            // Copy the data from the translation buffer into the result buffer
  +            // up to the next expression character (arriving to the current in the
  +            // expression buffer)        
  +            while (trns[trnspos]>=0) rslt[rsltpos++]=(char)trns[trnspos++];
  +            trnspos++;
  +                
  +            if (exprchr==MATCH_END) return(new String(rslt,0,rsltpos));
  +            
  +            // Search the next expression character
  +            buffpos+=(charpos-exprpos);
  +            exprpos=++charpos;
  +            while (expr[charpos]>=0) charpos++;
  +            int prevchr=exprchr;
  +            exprchr=expr[charpos];
  +   
  +            offset=super.matchArray(expr,exprpos,charpos,buff,buffpos);
  +            if (offset<0) return(null);
  +    
  +            // Copy the data from the source buffer into the result buffer
  +            // to substitute the expression character
  +            if (prevchr==MATCH_PATH) {
  +                while (buffpos<offset) rslt[rsltpos++]=buff[buffpos++];
  +            } else {
  +                // Matching file, don't copy '/'
  +                while (buffpos<offset) {
  +                    if (buff[buffpos]=='/') return(null);
  +                    rslt[rsltpos++]=buff[buffpos++];
  +                }
               }
  -
  -            // Set the current data buffer position to the first character
  -            // after the matched token
  -            buffpos=off+end-exprpos;
  -            // Set the current expression buffer position to the first
  -            // character after the wildcard
  -            exprpos=end+1;
  -            // Update the last expression character ('*' or '**')
  -            exprchr=expr[end];
  +        }
  +    }
  +    
  +    /** Testing */
  +    public static void main(String argv[]) {
  +        try {
  +            if (argv.length<3) return;
  +            PatternTranslator t=new PatternTranslator(argv[0],argv[1]);
  +            System.out.println("Matching Expr.    \""+argv[0]+"\"");
  +            System.out.println("Translation Expr. \""+argv[1]+"\"");
  +            System.out.println("Source Data       \""+argv[2]+"\"");
  +            System.out.println(" - Math returned \""+t.match(argv[2])+"\"");
  +            System.out.println(" - Translation   \""+t.translate(argv[2])+"\"");
  +        } catch (Exception e) {
  +            System.out.println(e.getClass().getName());
  +            System.out.println(e.getMessage());
           }
       }
   }
  
  
  

Mime
View raw message