cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject cvs commit: cocoon-2.2/src/test/org/apache/cocoon/environment/mock MockRequest.java
Date Sun, 28 Mar 2004 21:01:21 GMT
antonio     2004/03/28 13:01:21

  Modified:    src/java/org/apache/cocoon/util NetUtils.java
                        StringUtils.java IOUtils.java
               src/java/org/apache/cocoon/generation
                        LinkStatusGenerator.java
               src/java/org/apache/cocoon/components/crawler
                        SimpleCocoonCrawlerImpl.java
               src/java/org/apache/cocoon/sitemap ContentAggregator.java
               src/java/org/apache/cocoon/components/cprocessor/sitemap/impl
                        AggregateNode.java
               src/java/org/apache/cocoon/components/cprocessor/sitemap
                        ViewablePipelineComponentNode.java
                        AbstractComponentNode.java
               src/java/org/apache/cocoon/bean/helpers
                        BeanConfigurator.java
               src/java/org/apache/cocoon/environment
                        ForwardRedirector.java
               src/java/org/apache/cocoon Main.java
               src/java/org/apache/cocoon/acting
                        AbstractValidatorAction.java
               src/test/org/apache/cocoon/environment/mock MockRequest.java
  Log:
  Changing to use o.a.commons.lang.BooleanUtils
  
  Revision  Changes    Path
  1.8       +4 -3      cocoon-2.2/src/java/org/apache/cocoon/util/NetUtils.java
  
  Index: NetUtils.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/util/NetUtils.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- NetUtils.java	8 Mar 2004 14:03:30 -0000	1.7
  +++ NetUtils.java	28 Mar 2004 21:01:20 -0000	1.8
  @@ -27,6 +27,7 @@
   
   import org.apache.excalibur.source.SourceParameters;
   import org.apache.cocoon.environment.Request;
  +import org.apache.commons.lang.StringUtils;
   
   /**
    * A collection of <code>File</code>, <code>URL</code> and filename
  @@ -304,14 +305,14 @@
               return absoluteResource.substring(path.length());
           } else {
               // resource is not direct descendant
  -            int index = StringUtils.matchStrings(path, absoluteResource);
  +            int index = StringUtils.indexOfDifference(path, absoluteResource);
               if (index > 0 && path.charAt(index-1) != '/') {
                   index = path.substring(0, index).lastIndexOf('/');
                   index++;
               }
               String pathDiff = path.substring(index);
               String resource = absoluteResource.substring(index);
  -            int levels = StringUtils.count(pathDiff, '/');
  +            int levels = StringUtils.countMatches(pathDiff, "/");
               StringBuffer b = new StringBuffer();
               for (int i = 0; i < levels; i++) {
                   b.append("../");
  
  
  
  1.3       +1 -60     cocoon-2.2/src/java/org/apache/cocoon/util/StringUtils.java
  
  Index: StringUtils.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/util/StringUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringUtils.java	8 Mar 2004 14:03:30 -0000	1.2
  +++ StringUtils.java	28 Mar 2004 21:01:20 -0000	1.3
  @@ -15,8 +15,6 @@
    */
   package org.apache.cocoon.util;
   
  -
  -
   /**
    * A collection of <code>String</code> handling utility methods.
    *
  @@ -27,27 +25,6 @@
   public class StringUtils {
   
       /**
  -     * Split a string as an array using whitespace as separator
  -     *
  -     * @param line The string to be split
  -     * @return An array of whitespace-separated tokens
  -     */
  -    public static String[] split(String line) {
  -        return split(line, " \t\n\r");
  -    }
  -
  -    /**
  -     * Split a string as an array using a given set of separators
  -     *
  -     * @param line The string to be split
  -     * @param delimiter A string containing token separators
  -     * @return An array of token
  -     */
  -    public static String[] split(String line, String delimiter) {
  -        return Tokenizer.tokenize(line, delimiter, false);
  -    }
  -
  -    /**
        * Tests whether a given character is alphabetic, numeric or
        * underscore
        *
  @@ -59,42 +36,6 @@
               (c >= 'a' && c <= 'z') ||
               (c >= 'A' && c <= 'Z') ||
               (c >= '0' && c <= '9');
  -    }
  -
  -    /**
  -     * Counts the occurrence of the given char in the string.
  -     *
  -     * @param str The string to be tested
  -     * @param c the char to be counted
  -     * @return the occurrence of the character in the string.
  -     */
  -    public static int count(String str, char c) {
  -        int index = 0;
  -        char[] chars = str.toCharArray();
  -        for (int i = 0; i < chars.length; i++) {
  -            if (chars[i] == c) index++;
  -        }
  -        return index;
  -    }
  -
  -    /**
  -     * Matches two strings.
  -     *
  -     * @param a The first string
  -     * @param b The second string
  -     * @return the index where the two strings stop matching starting from 0
  -     */
  -    public static int matchStrings(String a, String b) {
  -        int i;
  -        char[] ca = a.toCharArray();
  -        char[] cb = b.toCharArray();
  -        int len = ( ca.length < cb.length ) ? ca.length : cb.length;
  -
  -        for (i = 0; i < len; i++) {
  -            if (ca[i] != cb[i]) break;
  -        }
  -
  -        return i;
       }
   
       /**
  
  
  
  1.3       +18 -5     cocoon-2.2/src/java/org/apache/cocoon/util/IOUtils.java
  
  Index: IOUtils.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/util/IOUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IOUtils.java	8 Mar 2004 14:03:30 -0000	1.2
  +++ IOUtils.java	28 Mar 2004 21:01:20 -0000	1.3
  @@ -15,13 +15,26 @@
    */
   package org.apache.cocoon.util;
   
  -import org.apache.log.Hierarchy;
  -
  -import java.io.*;
  +import java.io.BufferedInputStream;
  +import java.io.ByteArrayInputStream;
  +import java.io.ByteArrayOutputStream;
  +import java.io.File;
  +import java.io.FileInputStream;
  +import java.io.FileOutputStream;
  +import java.io.FileReader;
  +import java.io.FileWriter;
  +import java.io.IOException;
  +import java.io.ObjectInputStream;
  +import java.io.ObjectOutputStream;
  +import java.io.OutputStreamWriter;
  +import java.io.Writer;
   import java.text.Collator;
   import java.util.Arrays;
   import java.util.Locale;
   
  +import org.apache.commons.lang.StringUtils;
  +import org.apache.log.Hierarchy;
  +
   /**
    * A collection of <code>File</code>, <code>URL</code> and filename
    * utility methods
  @@ -215,7 +228,7 @@
             buffer.append('_');
   
           for (int j = 0; j < chars.length; j++) {
  -          if (StringUtils.isAlphaNumeric(chars[j])) {
  +          if (org.apache.cocoon.util.StringUtils.isAlphaNumeric(chars[j])) {
               buffer.append(chars[j]);
             } else {
               buffer.append('_');
  
  
  
  1.11      +8 -8      cocoon-2.2/src/java/org/apache/cocoon/generation/LinkStatusGenerator.java
  
  Index: LinkStatusGenerator.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/generation/LinkStatusGenerator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- LinkStatusGenerator.java	8 Mar 2004 21:21:10 -0000	1.10
  +++ LinkStatusGenerator.java	28 Mar 2004 21:01:21 -0000	1.11
  @@ -37,7 +37,7 @@
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
   import org.apache.cocoon.environment.SourceResolver;
  -import org.apache.cocoon.util.Tokenizer;
  +import org.apache.commons.lang.StringUtils;
   import org.apache.regexp.RE;
   import org.apache.regexp.RESyntaxException;
   import org.xml.sax.SAXException;
  @@ -240,9 +240,9 @@
               for (int i = 0; i < children.length; i++) {
                   String pattern = children[i].getValue();
                   try {
  -                    Tokenizer t = new Tokenizer(pattern, ", ");
  -                    while (t.hasMoreTokens()) {
  -                        String tokenized_pattern = t.nextToken();
  +                    String params[] = StringUtils.split(pattern, ", ");
  +                    for (int index = 0; index < params.length; index++) {
  +                        String tokenized_pattern = params[index];
                           this.includeCrawlingURL.add(new RE(tokenized_pattern));
                       }
                   } catch (RESyntaxException rese) {
  @@ -258,9 +258,9 @@
               for (int i = 0; i < children.length; i++) {
                   String pattern = children[i].getValue();
                   try {
  -                    Tokenizer t = new Tokenizer(pattern, ", ");
  -                    while (t.hasMoreTokens()) {
  -                        String tokenized_pattern = t.nextToken();
  +                    String params[] = StringUtils.split(pattern, ", ");
  +                    for (int index = 0; index < params.length; index++) {
  +                        String tokenized_pattern = params[index];
                           this.excludeCrawlingURL.add(new RE(tokenized_pattern));
                       }
                   } catch (RESyntaxException rese) {
  
  
  
  1.7       +9 -9      cocoon-2.2/src/java/org/apache/cocoon/components/crawler/SimpleCocoonCrawlerImpl.java
  
  Index: SimpleCocoonCrawlerImpl.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/components/crawler/SimpleCocoonCrawlerImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SimpleCocoonCrawlerImpl.java	8 Mar 2004 13:57:40 -0000	1.6
  +++ SimpleCocoonCrawlerImpl.java	28 Mar 2004 21:01:21 -0000	1.7
  @@ -22,7 +22,7 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.cocoon.Constants;
  -import org.apache.cocoon.util.Tokenizer;
  +import org.apache.commons.lang.StringUtils;
   import org.apache.regexp.RE;
   import org.apache.regexp.RESyntaxException;
   
  @@ -189,9 +189,9 @@
               for (int i = 0; i < children.length; i++) {
                   String pattern = children[i].getValue();
                   try {
  -                    Tokenizer t = new Tokenizer(pattern, ", ");
  -                    while (t.hasMoreTokens()) {
  -                        String tokenized_pattern = t.nextToken();
  +                    String params[] = StringUtils.split(pattern, ", ");
  +                    for (int index = 0; index < params.length; index++) {
  +                        String tokenized_pattern = params[index];
                           this.includeCrawlingURL.add(new RE(tokenized_pattern));
                       }
                   } catch (RESyntaxException rese) {
  @@ -211,9 +211,9 @@
               for (int i = 0; i < children.length; i++) {
                   String pattern = children[i].getValue();
                   try {
  -                    Tokenizer t = new Tokenizer(pattern, ", ");
  -                    while (t.hasMoreTokens()) {
  -                        String tokenized_pattern = t.nextToken();
  +                    String params[] = StringUtils.split(pattern, ", ");
  +                    for (int index = 0; index < params.length; index++) {
  +                        String tokenized_pattern = params[index];
                           this.excludeCrawlingURL.add(new RE(tokenized_pattern));
                       }
                   } catch (RESyntaxException rese) {
  
  
  
  1.10      +3 -2      cocoon-2.2/src/java/org/apache/cocoon/sitemap/ContentAggregator.java
  
  Index: ContentAggregator.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/sitemap/ContentAggregator.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ContentAggregator.java	8 Mar 2004 14:03:30 -0000	1.9
  +++ ContentAggregator.java	28 Mar 2004 21:01:21 -0000	1.10
  @@ -26,6 +26,7 @@
   import org.apache.cocoon.generation.Generator;
   import org.apache.cocoon.xml.ContentHandlerWrapper;
   import org.apache.cocoon.xml.XMLConsumer;
  +import org.apache.commons.lang.BooleanUtils;
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceException;
   import org.apache.excalibur.source.SourceValidity;
  @@ -87,7 +88,7 @@
           public Part(String uri, Element element, String stripRoot) {
               this.uri = uri;
               this.element = element;
  -            this.stripRootElement = (stripRoot.equals("yes") || stripRoot.equals("true"));
  +            this.stripRootElement = BooleanUtils.toBoolean(stripRoot);
           }
       }
   
  
  
  
  1.3       +2 -2      cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/impl/AggregateNode.java
  
  Index: AggregateNode.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/impl/AggregateNode.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AggregateNode.java	8 Mar 2004 13:57:38 -0000	1.2
  +++ AggregateNode.java	28 Mar 2004 21:01:21 -0000	1.3
  @@ -35,7 +35,7 @@
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.sitemap.ContentAggregator;
   import org.apache.cocoon.sitemap.PatternException;
  -import org.apache.cocoon.util.StringUtils;
  +import org.apache.commons.lang.StringUtils;
   
   /**
    *
  
  
  
  1.4       +1 -1      cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/ViewablePipelineComponentNode.java
  
  Index: ViewablePipelineComponentNode.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/ViewablePipelineComponentNode.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ViewablePipelineComponentNode.java	8 Mar 2004 13:57:37 -0000	1.3
  +++ ViewablePipelineComponentNode.java	28 Mar 2004 21:01:21 -0000	1.4
  @@ -24,7 +24,7 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.cocoon.util.StringUtils;
  +import org.apache.commons.lang.StringUtils;
   
   /**
    * @author <a href="mailto:unico@apache.org">Unico Hommes</a> 
  
  
  
  1.6       +1 -1      cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/AbstractComponentNode.java
  
  Index: AbstractComponentNode.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/AbstractComponentNode.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractComponentNode.java	8 Mar 2004 13:57:37 -0000	1.5
  +++ AbstractComponentNode.java	28 Mar 2004 21:01:21 -0000	1.6
  @@ -23,7 +23,7 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.cocoon.components.cprocessor.AbstractNode;
  -import org.apache.cocoon.util.StringUtils;
  +import org.apache.commons.lang.StringUtils;
   
   /**
    * @author <a href="mailto:unico@apache.org">Unico Hommes</a>
  
  
  
  1.6       +3 -3      cocoon-2.2/src/java/org/apache/cocoon/bean/helpers/BeanConfigurator.java
  
  Index: BeanConfigurator.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/bean/helpers/BeanConfigurator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BeanConfigurator.java	8 Mar 2004 13:57:39 -0000	1.5
  +++ BeanConfigurator.java	28 Mar 2004 21:01:21 -0000	1.6
  @@ -22,6 +22,7 @@
   
   import org.apache.cocoon.bean.OldCocoonBean;
   import org.apache.cocoon.bean.helpers.OutputStreamListener;
  +import org.apache.commons.lang.BooleanUtils;
   
   import org.w3c.dom.Document;
   import org.w3c.dom.NamedNodeMap;
  @@ -438,8 +439,7 @@
   
               if (attribute != null) {
                   String value = attribute.getNodeValue();
  -                return "yes".equals(value)
  -                        || "true".equals(value);
  +                return BooleanUtils.toBoolean(value);
               }
           }
           return false;
  
  
  
  1.19      +2 -2      cocoon-2.2/src/java/org/apache/cocoon/environment/ForwardRedirector.java
  
  Index: ForwardRedirector.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/environment/ForwardRedirector.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ForwardRedirector.java	8 Mar 2004 14:02:42 -0000	1.18
  +++ ForwardRedirector.java	28 Mar 2004 21:01:21 -0000	1.19
  @@ -97,7 +97,7 @@
           this.hasRedirected = true;
       }
   
  -    protected abstract void cocoonRedirect(String uri) throws IOException, ProcessingException;;
  +    protected abstract void cocoonRedirect(String uri) throws IOException, ProcessingException;
   
       /* (non-Javadoc)
        * @see org.apache.cocoon.environment.Redirector#hasRedirected()
  
  
  
  1.26      +4 -8      cocoon-2.2/src/java/org/apache/cocoon/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/Main.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Main.java	8 Mar 2004 13:57:35 -0000	1.25
  +++ Main.java	28 Mar 2004 21:01:21 -0000	1.26
  @@ -30,6 +30,7 @@
   import org.apache.commons.cli.Option;
   import org.apache.commons.cli.Options;
   import org.apache.commons.cli.PosixParser;
  +import org.apache.commons.lang.BooleanUtils;
   
   import org.w3c.dom.Document;
   
  @@ -286,10 +287,10 @@
               listener.setReportFile(line.getOptionValue(BROKEN_LINK_FILE_OPT));
           }
           if (line.hasOption(FOLLOW_LINKS_OPT)) {
  -            cocoon.setFollowLinks(yesno(line.getOptionValue(FOLLOW_LINKS_OPT)));
  +            cocoon.setFollowLinks(BooleanUtils.toBoolean(line.getOptionValue(FOLLOW_LINKS_OPT)));
           }
           if (line.hasOption(CONFIRM_EXTENSIONS_OPT)) {
  -            cocoon.setConfirmExtensions(yesno(line.getOptionValue(CONFIRM_EXTENSIONS_OPT,
"yes")));
  +            cocoon.setConfirmExtensions(BooleanUtils.toBoolean(line.getOptionValue(CONFIRM_EXTENSIONS_OPT,
"yes")));
           }
           if (line.hasOption(LOAD_CLASS_OPT)){
               cocoon.addLoadedClasses(Arrays.asList(line.getOptionValues(LOAD_CLASS_OPT)));
  @@ -308,13 +309,8 @@
   
           listener.complete();
   
  -
           int exitCode = (listener.isSuccessful() ? 0 : 1);
           System.exit(exitCode);
  -    }
  -
  -    private static boolean yesno(String in) {
  -        return "yes".equals(in) || "true".equals(in);
       }
   
       private static String processXConf(OldCocoonBean cocoon, String filename, String destDir,
String uriGroup) {
  
  
  
  1.11      +3 -3      cocoon-2.2/src/java/org/apache/cocoon/acting/AbstractValidatorAction.java
  
  Index: AbstractValidatorAction.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/java/org/apache/cocoon/acting/AbstractValidatorAction.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AbstractValidatorAction.java	16 Mar 2004 21:46:27 -0000	1.10
  +++ AbstractValidatorAction.java	28 Mar 2004 21:01:21 -0000	1.11
  @@ -33,7 +33,7 @@
   import org.apache.cocoon.environment.Redirector;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.sitemap.SitemapParameters;
  -import org.apache.cocoon.util.Tokenizer;
  +import org.apache.commons.lang.StringUtils;
   import org.apache.regexp.RE;
   import org.apache.regexp.RESyntaxException;
   
  @@ -948,7 +948,7 @@
           String[] rparams = null;
           Set set = new HashSet(20);
           if (!"*".equals(valstr.trim())) {
  -            rparams = Tokenizer.tokenize(valstr, ",", false);
  +            rparams = StringUtils.split(valstr, ",");
               if (rparams != null) {
                   for (int i = rparams.length - 1; i >= 0; i--) {
                       set.add(desc.get(rparams[i]));
  
  
  
  1.10      +2 -2      cocoon-2.2/src/test/org/apache/cocoon/environment/mock/MockRequest.java
  
  Index: MockRequest.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.2/src/test/org/apache/cocoon/environment/mock/MockRequest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MockRequest.java	8 Mar 2004 14:04:20 -0000	1.9
  +++ MockRequest.java	28 Mar 2004 21:01:21 -0000	1.10
  @@ -272,9 +272,9 @@
       public Session getSession(boolean create) {
           if ((session == null) && (create))
               this.session = new MockSession();
  -        else if ((session != null) && (!((MockSession) session).isValid()) &&
(create))
  +        else if ((session != null) && (!(session).isValid()) && (create))
               this.session = new MockSession();
  -        if ((session != null) && (((MockSession) session).isValid()))
  +        if ((session != null) && ((session).isValid()))
               return this.session;
           else
               return null;
  
  
  

Mime
View raw message