public class ForClosure extends java.lang.Object implements Closure, java.io.Serializable
WARNING: from v3.2.2 onwards this class will throw an
UnsupportedOperationException
when trying to serialize or
de-serialize an instance to prevent potential remote code execution exploits.
In order to re-enable serialization support for ForClosure
the following system property can be used (via -Dproperty=true):
org.apache.commons.collections.enableUnsafeSerialization
Modifier and Type | Field and Description |
---|---|
private Closure |
iClosure
The closure to call
|
private int |
iCount
The number of times to loop
|
private static long |
serialVersionUID
Serial version UID
|
Constructor and Description |
---|
ForClosure(int count,
Closure closure)
Constructor that performs no validation.
|
Modifier and Type | Method and Description |
---|---|
void |
execute(java.lang.Object input)
Executes the closure
count times. |
Closure |
getClosure()
Gets the closure.
|
int |
getCount()
Gets the count.
|
static Closure |
getInstance(int count,
Closure closure)
Factory method that performs validation.
|
private void |
readObject(java.io.ObjectInputStream is)
Overrides the default readObject implementation to prevent
de-serialization (see COLLECTIONS-580).
|
private void |
writeObject(java.io.ObjectOutputStream os)
Overrides the default writeObject implementation to prevent
serialization (see COLLECTIONS-580).
|
private static final long serialVersionUID
private final int iCount
private final Closure iClosure
public ForClosure(int count, Closure closure)
getInstance
if you want that.count
- the number of times to execute the closureclosure
- the closure to execute, not nullpublic static Closure getInstance(int count, Closure closure)
A null closure or zero count returns the NOPClosure
.
A count of one returns the specified closure.
count
- the number of times to execute the closureclosure
- the closure to execute, not nullfor
closurepublic void execute(java.lang.Object input)
count
times.public Closure getClosure()
public int getCount()
private void writeObject(java.io.ObjectOutputStream os) throws java.io.IOException
java.io.IOException
private void readObject(java.io.ObjectInputStream is) throws java.lang.ClassNotFoundException, java.io.IOException
java.lang.ClassNotFoundException
java.io.IOException