You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2003/11/23 15:41:27 UTC

cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections TransformerUtils.java FunctorException.java PredicateUtils.java FactoryUtils.java ClosureUtils.java

scolebourne    2003/11/23 06:41:27

  Modified:    collections/src/test/org/apache/commons/collections
                        TestPredicateUtils.java TestFactoryUtils.java
                        TestClosureUtils.java TestCollectionUtils.java
                        TestTransformerUtils.java
               collections/src/java/org/apache/commons/collections
                        TransformerUtils.java FunctorException.java
                        PredicateUtils.java FactoryUtils.java
                        ClosureUtils.java
  Added:       collections/src/java/org/apache/commons/collections/functors
                        FunctorException.java
  Log:
  Add functors subpackage
  
  Revision  Changes    Path
  1.4       +4 -2      jakarta-commons/collections/src/test/org/apache/commons/collections/TestPredicateUtils.java
  
  Index: TestPredicateUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestPredicateUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestPredicateUtils.java	5 Oct 2003 21:23:21 -0000	1.3
  +++ TestPredicateUtils.java	23 Nov 2003 14:41:27 -0000	1.4
  @@ -62,6 +62,8 @@
   import java.util.Collections;
   import java.util.List;
   
  +import org.apache.commons.collections.functors.FunctorException;
  +
   import junit.framework.Test;
   import junit.framework.TestSuite;
   import junit.textui.TestRunner;
  
  
  
  1.6       +4 -2      jakarta-commons/collections/src/test/org/apache/commons/collections/TestFactoryUtils.java
  
  Index: TestFactoryUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestFactoryUtils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestFactoryUtils.java	5 Oct 2003 21:11:06 -0000	1.5
  +++ TestFactoryUtils.java	23 Nov 2003 14:41:27 -0000	1.6
  @@ -62,6 +62,8 @@
   import java.util.Date;
   import java.util.TimeZone;
   
  +import org.apache.commons.collections.functors.FunctorException;
  +
   import junit.framework.Test;
   import junit.framework.TestSuite;
   import junit.textui.TestRunner;
  
  
  
  1.4       +4 -2      jakarta-commons/collections/src/test/org/apache/commons/collections/TestClosureUtils.java
  
  Index: TestClosureUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestClosureUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestClosureUtils.java	5 Oct 2003 21:11:06 -0000	1.3
  +++ TestClosureUtils.java	23 Nov 2003 14:41:27 -0000	1.4
  @@ -67,6 +67,8 @@
   import junit.framework.TestSuite;
   import junit.textui.TestRunner;
   
  +import org.apache.commons.collections.functors.FunctorException;
  +
   /**
    * Tests the org.apache.commons.collections.ClosureUtils class.
    * 
  
  
  
  1.32      +3 -2      jakarta-commons/collections/src/test/org/apache/commons/collections/TestCollectionUtils.java
  
  Index: TestCollectionUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestCollectionUtils.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- TestCollectionUtils.java	16 Nov 2003 22:15:09 -0000	1.31
  +++ TestCollectionUtils.java	23 Nov 2003 14:41:27 -0000	1.32
  @@ -80,6 +80,7 @@
   import org.apache.commons.collections.collection.SynchronizedCollection;
   import org.apache.commons.collections.collection.TransformedCollection;
   import org.apache.commons.collections.collection.UnmodifiableCollection;
  +import org.apache.commons.collections.functors.FunctorException;
   
   /**
    * Tests for CollectionUtils.
  
  
  
  1.5       +4 -2      jakarta-commons/collections/src/test/org/apache/commons/collections/TestTransformerUtils.java
  
  Index: TestTransformerUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestTransformerUtils.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestTransformerUtils.java	5 Oct 2003 21:23:21 -0000	1.4
  +++ TestTransformerUtils.java	23 Nov 2003 14:41:27 -0000	1.5
  @@ -68,6 +68,8 @@
   import junit.framework.TestSuite;
   import junit.textui.TestRunner;
   
  +import org.apache.commons.collections.functors.FunctorException;
  +
   /**
    * Tests the org.apache.commons.collections.TransformerUtils class.
    * 
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/functors/FunctorException.java
  
  Index: FunctorException.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/FunctorException.java,v 1.1 2003/11/23 14:41:27 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections.functors;
  
  import java.io.PrintStream;
  import java.io.PrintWriter;
  
  /**
   * Exception thrown from functors.
   * If required, a root cause error can be wrapped within this one.
   * 
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/11/23 14:41:27 $
   *
   * @author Stephen Colebourne
   */
  public class FunctorException extends RuntimeException {
      
      /**
       * Does JDK support nested exceptions
       */
      private static final boolean JDK_SUPPORTS_NESTED;
      
      static {
          boolean flag = false;
          try {
              Throwable.class.getDeclaredMethod("getCause", new Class[0]);
              flag = true;
          } catch (NoSuchMethodException ex) {
              flag = false;
          }
          JDK_SUPPORTS_NESTED = flag;
      }
      
      /**
       * Root cause of the exception
       */
      private final Throwable iThrowable;
  
      /**
       * Constructs a new <code>FunctorException</code> without specified
       * detail message.
       */
      public FunctorException() {
          super();
          iThrowable = null;
      }
  
      /**
       * Constructs a new <code>FunctorException</code> with specified
       * detail message.
       *
       * @param msg  the error message.
       */
      public FunctorException(String msg) {
          super(msg);
          iThrowable = null;
      }
  
      /**
       * Constructs a new <code>FunctorException</code> with specified
       * nested <code>Throwable</code> root cause.
       *
       * @param rootCause  the exception or error that caused this exception
       *                   to be thrown.
       */
      public FunctorException(Throwable rootCause) {
          super((rootCause == null ? null : rootCause.getMessage()));
          iThrowable = rootCause;
      }
  
      /**
       * Constructs a new <code>FunctorException</code> with specified
       * detail message and nested <code>Throwable</code> root cause.
       *
       * @param msg        the error message.
       * @param rootCause  the exception or error that caused this exception
       *                   to be thrown.
       */
      public FunctorException(String msg, Throwable rootCause) {
          super(msg);
          iThrowable = rootCause;
      }
  
      /**
       * Gets the cause of this throwable.
       * 
       * @return  the cause of this throwable, or <code>null</code>
       */
      public Throwable getCause() {
          return iThrowable;
      }
  
      /**
       * Prints the stack trace of this exception to the standard error stream.
       */
      public void printStackTrace() {
          printStackTrace(System.err);
      }
  
      /**
       * Prints the stack trace of this exception to the specified stream.
       *
       * @param out  the <code>PrintStream</code> to use for output
       */
      public void printStackTrace(PrintStream out) {
          synchronized (out) {
              PrintWriter pw = new PrintWriter(out, false);
              printStackTrace(pw);
              // Flush the PrintWriter before it's GC'ed.
              pw.flush();
          }
      }
  
      /**
       * Prints the stack trace of this exception to the specified writer.
       *
       * @param out  the <code>PrintWriter</code> to use for output
       */
      public void printStackTrace(PrintWriter out) {
          synchronized (out) {
              super.printStackTrace(out);
              if (iThrowable != null && JDK_SUPPORTS_NESTED == false) {
                  out.print("Caused by: ");
                  iThrowable.printStackTrace(out);
              }
          }
      }
  
  }
  
  
  
  1.6       +4 -2      jakarta-commons/collections/src/java/org/apache/commons/collections/TransformerUtils.java
  
  Index: TransformerUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/TransformerUtils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TransformerUtils.java	9 Oct 2003 20:58:52 -0000	1.5
  +++ TransformerUtils.java	23 Nov 2003 14:41:27 -0000	1.6
  @@ -64,6 +64,8 @@
   import java.util.Iterator;
   import java.util.Map;
   
  +import org.apache.commons.collections.functors.FunctorException;
  +
   /**
    * <code>TransformerUtils</code> provides reference implementations and 
    * utilities for the Transformer functor interface. The supplied transformers are:
  
  
  
  1.3       +6 -103    jakarta-commons/collections/src/java/org/apache/commons/collections/FunctorException.java
  
  Index: FunctorException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/FunctorException.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FunctorException.java	31 Aug 2003 17:26:43 -0000	1.2
  +++ FunctorException.java	23 Nov 2003 14:41:27 -0000	1.3
  @@ -57,129 +57,32 @@
    */
   package org.apache.commons.collections;
   
  -import java.io.PrintStream;
  -import java.io.PrintWriter;
  -
   /**
    * Exception thrown from functors.
    * If required, a root cause error can be wrapped within this one.
    * 
  + * @deprecated TO BE DELETED BEFORE v3.0
    * @since Commons Collections 3.0
    * @version $Revision$ $Date$
    *
    * @author Stephen Colebourne
    */
  -public class FunctorException extends RuntimeException {
  -    
  -    /**
  -     * Does JDK support nested exceptions
  -     */
  -    private static final boolean JDK_SUPPORTS_NESTED;
  -    
  -    static {
  -        boolean flag = false;
  -        try {
  -            Throwable.class.getDeclaredMethod("getCause", new Class[0]);
  -            flag = true;
  -        } catch (NoSuchMethodException ex) {
  -            flag = false;
  -        }
  -        JDK_SUPPORTS_NESTED = flag;
  -    }
  +public class FunctorException extends org.apache.commons.collections.functors.FunctorException {
       
  -    /**
  -     * Root cause of the exception
  -     */
  -    private final Throwable iThrowable;
  -
  -    /**
  -     * Constructs a new <code>FunctorException</code> without specified
  -     * detail message.
  -     */
       public FunctorException() {
           super();
  -        iThrowable = null;
       }
   
  -    /**
  -     * Constructs a new <code>FunctorException</code> with specified
  -     * detail message.
  -     *
  -     * @param msg  the error message.
  -     */
       public FunctorException(String msg) {
           super(msg);
  -        iThrowable = null;
       }
   
  -    /**
  -     * Constructs a new <code>FunctorException</code> with specified
  -     * nested <code>Throwable</code> root cause.
  -     *
  -     * @param rootCause  the exception or error that caused this exception
  -     *                   to be thrown.
  -     */
       public FunctorException(Throwable rootCause) {
  -        super((rootCause == null ? null : rootCause.getMessage()));
  -        iThrowable = rootCause;
  +        super(rootCause);
       }
   
  -    /**
  -     * Constructs a new <code>FunctorException</code> with specified
  -     * detail message and nested <code>Throwable</code> root cause.
  -     *
  -     * @param msg        the error message.
  -     * @param rootCause  the exception or error that caused this exception
  -     *                   to be thrown.
  -     */
       public FunctorException(String msg, Throwable rootCause) {
  -        super(msg);
  -        iThrowable = rootCause;
  -    }
  -
  -    /**
  -     * Gets the cause of this throwable.
  -     * 
  -     * @return  the cause of this throwable, or <code>null</code>
  -     */
  -    public Throwable getCause() {
  -        return iThrowable;
  -    }
  -
  -    /**
  -     * Prints the stack trace of this exception to the standard error stream.
  -     */
  -    public void printStackTrace() {
  -        printStackTrace(System.err);
  -    }
  -
  -    /**
  -     * Prints the stack trace of this exception to the specified stream.
  -     *
  -     * @param out  the <code>PrintStream</code> to use for output
  -     */
  -    public void printStackTrace(PrintStream out) {
  -        synchronized (out) {
  -            PrintWriter pw = new PrintWriter(out, false);
  -            printStackTrace(pw);
  -            // Flush the PrintWriter before it's GC'ed.
  -            pw.flush();
  -        }
  -    }
  -
  -    /**
  -     * Prints the stack trace of this exception to the specified writer.
  -     *
  -     * @param out  the <code>PrintWriter</code> to use for output
  -     */
  -    public void printStackTrace(PrintWriter out) {
  -        synchronized (out) {
  -            super.printStackTrace(out);
  -            if (iThrowable != null && JDK_SUPPORTS_NESTED == false) {
  -                out.print("Caused by: ");
  -                iThrowable.printStackTrace(out);
  -            }
  -        }
  +        super(msg, rootCause);
       }
   
   }
  
  
  
  1.11      +4 -2      jakarta-commons/collections/src/java/org/apache/commons/collections/PredicateUtils.java
  
  Index: PredicateUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/PredicateUtils.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PredicateUtils.java	29 Oct 2003 23:21:39 -0000	1.10
  +++ PredicateUtils.java	23 Nov 2003 14:41:27 -0000	1.11
  @@ -63,6 +63,8 @@
   import java.util.Iterator;
   import java.util.Set;
   
  +import org.apache.commons.collections.functors.FunctorException;
  +
   /**
    * <code>PredicateUtils</code> provides reference implementations and utilities
    * for the Predicate functor interface. The supplied predicates are:
  
  
  
  1.9       +4 -2      jakarta-commons/collections/src/java/org/apache/commons/collections/FactoryUtils.java
  
  Index: FactoryUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/FactoryUtils.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FactoryUtils.java	31 Aug 2003 17:26:43 -0000	1.8
  +++ FactoryUtils.java	23 Nov 2003 14:41:27 -0000	1.9
  @@ -67,6 +67,8 @@
   import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
   
  +import org.apache.commons.collections.functors.FunctorException;
  +
   /**
    * <code>FactoryUtils</code> provides reference implementations and utilities
    * for the Factory functor interface. The supplied factories are:
  
  
  
  1.4       +4 -2      jakarta-commons/collections/src/java/org/apache/commons/collections/ClosureUtils.java
  
  Index: ClosureUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/ClosureUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ClosureUtils.java	31 Aug 2003 17:26:44 -0000	1.3
  +++ ClosureUtils.java	23 Nov 2003 14:41:27 -0000	1.4
  @@ -62,6 +62,8 @@
   import java.util.Iterator;
   import java.util.Map;
   
  +import org.apache.commons.collections.functors.FunctorException;
  +
   /**
    * <code>ClosureUtils</code> provides reference implementations and utilities
    * for the Closure functor interface. The supplied closures are:
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org