git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131725 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2004-05-16 11:47:38 +00:00
parent 9522bd7085
commit f99d6d6d41
13 changed files with 81 additions and 33 deletions

View File

@ -27,7 +27,7 @@ import org.apache.commons.collections.Factory;
* use the prototype factory.
*
* @since Commons Collections 3.0
* @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -67,7 +67,9 @@ public class ConstantFactory implements Factory, Serializable {
}
/**
* Always return constant
* Always return constant.
*
* @return the stored constant value
*/
public Object create() {
return iConstant;
@ -75,6 +77,7 @@ public class ConstantFactory implements Factory, Serializable {
/**
* Gets the constant.
*
* @return the constant
* @since Commons Collections 3.1
*/

View File

@ -24,7 +24,7 @@ import org.apache.commons.collections.FunctorException;
* Closure implementation that always throws an exception.
*
* @since Commons Collections 3.0
* @version $Revision: 1.6 $ $Date: 2004/03/31 23:13:04 $
* @version $Revision: 1.7 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -56,8 +56,11 @@ public final class ExceptionClosure implements Closure, Serializable {
/**
* Always throw an exception.
*
* @param input the input object
* @throws FunctorException always
*/
public void execute(Object object) {
public void execute(Object input) {
throw new FunctorException("ExceptionClosure invoked");
}

View File

@ -24,7 +24,7 @@ import org.apache.commons.collections.FunctorException;
* Factory implementation that always throws an exception.
*
* @since Commons Collections 3.0
* @version $Revision: 1.6 $ $Date: 2004/03/31 23:13:04 $
* @version $Revision: 1.7 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -55,7 +55,10 @@ public final class ExceptionFactory implements Factory, Serializable {
}
/**
* Always throw an exception.
* Always throws an exception.
*
* @return never
* @throws FunctorException always
*/
public Object create() {
throw new FunctorException("ExceptionFactory invoked");

View File

@ -23,7 +23,7 @@ import org.apache.commons.collections.Closure;
* Closure implementation that calls another closure n times, like a for loop.
*
* @since Commons Collections 3.0
* @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -71,7 +71,9 @@ public class ForClosure implements Closure, Serializable {
}
/**
* Execute the closure count times.
* Executes the closure <code>count</code> times.
*
* @param input the input object
*/
public void execute(Object input) {
for (int i = 0; i < iCount; i++) {
@ -81,6 +83,7 @@ public class ForClosure implements Closure, Serializable {
/**
* Gets the closure.
*
* @return the closure
* @since Commons Collections 3.1
*/
@ -90,6 +93,7 @@ public class ForClosure implements Closure, Serializable {
/**
* Gets the count.
*
* @return the count
* @since Commons Collections 3.1
*/

View File

@ -26,7 +26,7 @@ import org.apache.commons.collections.Transformer;
* Internal utilities for functors.
*
* @since Commons Collections 3.0
* @version $Revision: 1.6 $ $Date: 2004/02/18 00:59:20 $
* @version $Revision: 1.7 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -36,6 +36,7 @@ class FunctorUtils {
* Restricted constructor.
*/
private FunctorUtils() {
super();
}
/**
@ -147,6 +148,7 @@ class FunctorUtils {
* Copy method
*
* @param transformers the transformers to copy
* @return a clone of the transformers
*/
static Transformer[] copy(Transformer[] transformers) {
if (transformers == null) {

View File

@ -25,7 +25,7 @@ import org.apache.commons.collections.Predicate;
* based on a predicate.
*
* @since Commons Collections 3.0
* @version $Revision: 1.5 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.6 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -76,7 +76,9 @@ public class IfClosure implements Closure, Serializable {
}
/**
* Execute the correct closure.
* Executes the true or false closure accoring to the result of the predicate.
*
* @param input the input object
*/
public void execute(Object input) {
if (iPredicate.evaluate(input) == true) {
@ -88,6 +90,7 @@ public class IfClosure implements Closure, Serializable {
/**
* Gets the predicate.
*
* @return the predicate
* @since Commons Collections 3.1
*/
@ -97,6 +100,7 @@ public class IfClosure implements Closure, Serializable {
/**
* Gets the closure called when true.
*
* @return the closure
* @since Commons Collections 3.1
*/
@ -106,6 +110,7 @@ public class IfClosure implements Closure, Serializable {
/**
* Gets the closure called when false.
*
* @return the closure
* @since Commons Collections 3.1
*/

View File

@ -26,7 +26,7 @@ import org.apache.commons.collections.FunctorException;
* Factory implementation that creates a new object instance by reflection.
*
* @since Commons Collections 3.0
* @version $Revision: 1.5 $ $Date: 2004/02/18 00:59:20 $
* @version $Revision: 1.6 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -50,6 +50,7 @@ public class InstantiateFactory implements Factory, Serializable {
* @param classToInstantiate the class to instantiate, not null
* @param paramTypes the constructor parameter types
* @param args the constructor arguments
* @return a new instantiate factory
*/
public static Factory getInstance(Class classToInstantiate, Class[] paramTypes, Object[] args) {
if (classToInstantiate == null) {
@ -113,7 +114,9 @@ public class InstantiateFactory implements Factory, Serializable {
}
/**
* Create the object using a constructor
* Creates an object using the stored constructor.
*
* @return the new object
*/
public Object create() {
// needed for post-serialization

View File

@ -23,7 +23,7 @@ import org.apache.commons.collections.Closure;
* Closure implementation that does nothing.
*
* @since Commons Collections 3.0
* @version $Revision: 1.5 $ $Date: 2004/03/31 23:13:04 $
* @version $Revision: 1.6 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -53,7 +53,9 @@ public class NOPClosure implements Closure, Serializable {
}
/**
* Do nothing
* Do nothing.
*
* @param input the input object
*/
public void execute(Object input) {
// do nothing

View File

@ -23,7 +23,7 @@ import org.apache.commons.collections.Predicate;
* Predicate implementation that returns true if the input is not null.
*
* @since Commons Collections 3.0
* @version $Revision: 1.5 $ $Date: 2004/03/31 23:13:04 $
* @version $Revision: 1.6 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -53,7 +53,10 @@ public final class NotNullPredicate implements Predicate, Serializable {
}
/**
* Return true if the object equals null.
* Evaluates the predicate returning true if the object does not equal null.
*
* @param object the object to evaluate
* @return true if not null
*/
public boolean evaluate(Object object) {
return (object != null);

View File

@ -31,7 +31,7 @@ import org.apache.commons.collections.FunctorException;
* Factory implementation that creates a new instance each time based on a prototype.
*
* @since Commons Collections 3.0
* @version $Revision: 1.6 $ $Date: 2004/02/18 00:59:20 $
* @version $Revision: 1.7 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -84,6 +84,7 @@ public class PrototypeFactory {
* Use <code>getInstance</code> if you want that.
*/
private PrototypeFactory() {
super();
}
// PrototypeCloneFactory
@ -123,7 +124,9 @@ public class PrototypeFactory {
}
/**
* Return clone of prototype
* Creates an object by calling the clone method.
*
* @return the new object
*/
public Object create() {
// needed for post-serialization
@ -164,7 +167,9 @@ public class PrototypeFactory {
}
/**
* Return clone of prototype by serialization
* Creates an object using serialization.
*
* @return the new object
*/
public Object create() {
ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
@ -186,13 +191,15 @@ public class PrototypeFactory {
if (bais != null) {
bais.close();
}
} catch (IOException ignored) {
} catch (IOException ex) {
// ignore
}
try {
if (baos != null) {
baos.close();
}
} catch (IOException ignored) {
} catch (IOException ex) {
// ignore
}
}
}

View File

@ -27,7 +27,7 @@ import org.apache.commons.collections.Predicate;
* like a switch statement.
*
* @since Commons Collections 3.0
* @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -127,7 +127,9 @@ public class SwitchClosure implements Closure, Serializable {
}
/**
* Execute the closure whose predicate returns true
* Executes the closure whose matching predicate returns true
*
* @param input the input object
*/
public void execute(Object input) {
for (int i = 0; i < iPredicates.length; i++) {
@ -141,6 +143,7 @@ public class SwitchClosure implements Closure, Serializable {
/**
* Gets the predicates, do not modify the array.
*
* @return the predicates
* @since Commons Collections 3.1
*/
@ -150,6 +153,7 @@ public class SwitchClosure implements Closure, Serializable {
/**
* Gets the closures, do not modify the array.
*
* @return the closures
* @since Commons Collections 3.1
*/
@ -159,6 +163,7 @@ public class SwitchClosure implements Closure, Serializable {
/**
* Gets the default closure.
*
* @return the default closure
* @since Commons Collections 3.1
*/

View File

@ -25,7 +25,7 @@ import org.apache.commons.collections.Transformer;
* and ignore the result.
*
* @since Commons Collections 3.0
* @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -64,7 +64,9 @@ public class TransformerClosure implements Closure, Serializable {
}
/**
* Call the transformer.
* Executes the closure by calling the decorated transformer.
*
* @param input the input object
*/
public void execute(Object input) {
iTransformer.transform(input);
@ -72,6 +74,7 @@ public class TransformerClosure implements Closure, Serializable {
/**
* Gets the transformer.
*
* @return the transformer
* @since Commons Collections 3.1
*/

View File

@ -25,7 +25,7 @@ import org.apache.commons.collections.Predicate;
* like a do-while or while loop.
*
* @since Commons Collections 3.0
* @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:47:38 $
*
* @author Stephen Colebourne
*/
@ -76,7 +76,9 @@ public class WhileClosure implements Closure, Serializable {
}
/**
* Execute the closure until the predicate is false.
* Executes the closure until the predicate is false.
*
* @param input the input object
*/
public void execute(Object input) {
if (iDoLoop) {
@ -89,6 +91,7 @@ public class WhileClosure implements Closure, Serializable {
/**
* Gets the predicate in use.
*
* @return the predicate
* @since Commons Collections 3.1
*/
@ -98,6 +101,7 @@ public class WhileClosure implements Closure, Serializable {
/**
* Gets the closure.
*
* @return the closure
* @since Commons Collections 3.1
*/
@ -107,6 +111,7 @@ public class WhileClosure implements Closure, Serializable {
/**
* Is the loop a do-while loop.
*
* @return true is do-while, false if while
* @since Commons Collections 3.1
*/