org.springframework.batch.repeat
Class ExitStatus

java.lang.Object
  extended by org.springframework.batch.repeat.ExitStatus
All Implemented Interfaces:
Serializable

public class ExitStatus
extends Object
implements Serializable

Value object used to carry information about the status of a RepeatOperations. ExitStatus is immutable and therefore thread-safe.

Author:
Dave Syer
See Also:
Serialized Form

Field Summary
static ExitStatus CONTINUABLE
          Convenient constant value representing unfinished processing.
static ExitStatus FAILED
          Convenient constant value representing finished processing with an error.
static ExitStatus FINISHED
          Convenient constant value representing finished processing.
static ExitStatus NOOP
          Convenient constant value representing job that did no processing (e.g.
static ExitStatus UNKNOWN
          Convenient constant value representing unknown state - assumed not continuable.
 
Constructor Summary
ExitStatus(boolean continuable)
           
ExitStatus(boolean continuable, String exitCode)
           
ExitStatus(boolean continuable, String exitCode, String exitDescription)
           
 
Method Summary
 ExitStatus addExitDescription(String description)
          Add an exit description to an existing ExitStatus.
 ExitStatus and(boolean continuable)
          Create a new ExitStatus with a logical combination of the continuable flag.
 ExitStatus and(ExitStatus status)
          Create a new ExitStatus with a logical combination of the continuable flag, and a concatenation of the descriptions.
 boolean equals(Object obj)
          Compare the fields one by one.
 String getExitCode()
          Getter for the exit code (defaults to blank).
 String getExitDescription()
          Getter for the exit description (defaults to blank)
 int hashCode()
          Compatible with the equals implementation.
 boolean isContinuable()
          Flag to signal that processing can continue.
 boolean isRunning()
          Check if this status represents a running process.
 ExitStatus replaceExitCode(String code)
          Add an exit code to an existing ExitStatus.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final ExitStatus UNKNOWN
Convenient constant value representing unknown state - assumed not continuable.


CONTINUABLE

public static final ExitStatus CONTINUABLE
Convenient constant value representing unfinished processing.


FINISHED

public static final ExitStatus FINISHED
Convenient constant value representing finished processing.


NOOP

public static final ExitStatus NOOP
Convenient constant value representing job that did no processing (e.g. because it was already complete).


FAILED

public static final ExitStatus FAILED
Convenient constant value representing finished processing with an error.

Constructor Detail

ExitStatus

public ExitStatus(boolean continuable)

ExitStatus

public ExitStatus(boolean continuable,
                  String exitCode)

ExitStatus

public ExitStatus(boolean continuable,
                  String exitCode,
                  String exitDescription)
Method Detail

isContinuable

public boolean isContinuable()
Flag to signal that processing can continue. This is distinct from any flag that might indicate that a batch is complete, or terminated, since a batch might be only a small part of a larger whole, which is still not finished.

Returns:
true if processing can continue.

getExitCode

public String getExitCode()
Getter for the exit code (defaults to blank).

Returns:
the exit code.

getExitDescription

public String getExitDescription()
Getter for the exit description (defaults to blank)


and

public ExitStatus and(boolean continuable)
Create a new ExitStatus with a logical combination of the continuable flag.

Parameters:
continuable - true if the caller thinks it is safe to continue.
Returns:
a new ExitStatus with isContinuable() the logical and of the current value and the argument provided.

and

public ExitStatus and(ExitStatus status)
Create a new ExitStatus with a logical combination of the continuable flag, and a concatenation of the descriptions. The exit code is only replaced if the result is continuable or the input is not continuable.
If the input is null just return this.

Parameters:
status - an ExitStatus to combine with this one.
Returns:
a new ExitStatus with isContinuable() the logical and of the current value and the argument provided.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Compare the fields one by one.

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Compatible with the equals implementation.

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

replaceExitCode

public ExitStatus replaceExitCode(String code)
Add an exit code to an existing ExitStatus. If there is already a code present tit will be replaced.

Parameters:
code - the code to add
Returns:
a new ExitStatus with the same properties but a new exit code.

isRunning

public boolean isRunning()
Check if this status represents a running process.

Returns:
true if the exit code is "RUNNING" or "UNKNOWN"

addExitDescription

public ExitStatus addExitDescription(String description)
Add an exit description to an existing ExitStatus. If there is already a description present the two will be concatenated with a semicolon.

Parameters:
description - the description to add
Returns:
a new ExitStatus with the same properties but a new exit description


Copyright © 2009 SpringSource. All Rights Reserved.