Skip navigation links


oracle.idm.util.progress
Class ProgressReporter

java.lang.Object
  extended by oracle.idm.util.progress.ProgressReporter

Direct Known Subclasses:
ProgressProcessor

public class ProgressReporter
extends java.lang.Object

The ProgressReporter object is used to report progress in a flexible way, allowing for step reporting, percent reporting, or duration reporting. The methods in this class will automatically calculate values of properties that are not supplied by the event source, whenever possible.

For example, if step information is supplied by the event source, both percent and duration information will be calculated automatically by the ProgressReporter methods. If only percent information is specified by the event source, duration information will be calculated automatically. If no information is specified by the event source, only current duration will be calculated automatically. If total duration information is specified by the event source, percent information will be calculated automatically.


Constructor Summary
ProgressReporter()
          Creates an instance of a ProgressReporter.
ProgressReporter(ProgressManager manager)
          Creates an instance of a ProgressReporter.

 

Method Summary
 void clearTransient()
          This method clears all transient throwables.
 void continuing()
          Call this method when continuing onto the next step in you process.
 long getDuration()
          Getter for the duration property.
 int getErrorTotal()
          Getter for the errorTotal property.
static java.lang.Exception getException(java.lang.Throwable throwable)
          This method converts throwables to exceptions.
static java.lang.String getLocalizedMessage(java.lang.Throwable throwable)
          This method returns throwable message.
static java.util.Collection getLocalizedMessages(java.lang.Throwable throwable)
          Returns localized messages associated with the throwable and all of its causes.
static java.lang.String getMessage(java.lang.Throwable throwable)
          This method returns throwable message.
static java.util.Collection getMessages(java.lang.Throwable throwable)
          Returns messages associated with the throwable and all of its causes.
 ProgressManager getProgressManager()
          Getter method to return the ProgressManager.
static java.lang.RuntimeException getRuntimeException(java.lang.Throwable throwable)
          This method converts throwables to runtime exceptions.
 java.lang.String getStateCurrent()
          Getter for the stateCurrent property.
 long getStateTimeStamp()
          Getter for the stateTimeStamp property.
 long getTimeout()
          Getter for the timeout property.
 java.util.Set getTransient()
          This method returns all transient throwables.
 int getWarningTotal()
          Getter for the warningTotal property.
 boolean hasTimedout()
          Getter for the timedout property.
 boolean isStateCurrent(java.lang.String state)
          Checks if the current state equals the state parameter.
 boolean isTransient(java.lang.Throwable throwable)
          This method returns true if the throwable is transient.
 void markTransient(java.lang.Throwable throwable)
          This method marks the throwable as transient.
 void reset()
          This method resets the progress reporter, call when you want to reuse the same progress reporter to report progress on a new process.
 void resetDuration()
          Resetter for the duration property.
 void sendProgressEvent(ProgressEvent event)
          This method sends a progress event the progress listeners.
protected  void setErrorTotal(int total)
          Setter for the errorTotal property.
protected  void setProgressManager(ProgressManager manager)
          Setter method for the ProgressManager.
protected  void setStateCurrent(java.lang.String current)
          Setter for the stateCurrent property.
protected  void setStateTimeStamp(long timeStamp)
          Setter for the stateTimeStamp property.
 void setTimeout(long timeout)
          Setter for the timeout property.
protected  void setWarningTotal(int total)
          Setter for the warningTotal property.
 void throwErrorOrException(java.lang.Throwable throwable)
          This method throws throwables as exceptions.
 void throwErrorOrRuntimeException(java.lang.Throwable throwable)
          This method throws throwables as runtime exceptions.
 void throwException(java.lang.Throwable throwable)
          This method throws throwables as exceptions.
 void throwRuntimeException(java.lang.Throwable throwable)
          This method throws throwables as runtime exceptions.
 void unmarkTransient(java.lang.Throwable throwable)
          This method unmarks the transient throwable.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

ProgressReporter

public ProgressReporter()
Creates an instance of a ProgressReporter. Users of this API can also create instances of ProgressReporter via the getProgressReporter factory method in the ProgressManager class.
See Also:
ProgressManager.getProgressReporter()

ProgressReporter

public ProgressReporter(ProgressManager manager)
Creates an instance of a ProgressReporter. Users of this API can also create instances of ProgressReporter via the getProgressReporter factory method in the ProgressManager class.
Parameters:
manager - ProgressManager that manages this ProgressMonitor.
See Also:
ProgressManager.getProgressReporter()

Method Detail

getProgressManager

public ProgressManager getProgressManager()
Getter method to return the ProgressManager.

setProgressManager

protected void setProgressManager(ProgressManager manager)
Setter method for the ProgressManager.

getStateCurrent

public java.lang.String getStateCurrent()
Getter for the stateCurrent property.
Returns:
String representing the current state.

setStateCurrent

protected void setStateCurrent(java.lang.String current)
Setter for the stateCurrent property.
Parameters:
String - representing the current state.

isStateCurrent

public boolean isStateCurrent(java.lang.String state)
Checks if the current state equals the state parameter.

getErrorTotal

public int getErrorTotal()
Getter for the errorTotal property.
Returns:
total number of errors reported so far

setErrorTotal

protected void setErrorTotal(int total)
Setter for the errorTotal property.
Parameters:
total - number of errors reported so far

getWarningTotal

public int getWarningTotal()
Getter for the warningTotal property.
Returns:
total number of warnings reported so far

setWarningTotal

protected void setWarningTotal(int total)
Setter for the warningTotal property.
Parameters:
total - number of warnings reported so far

getStateTimeStamp

public long getStateTimeStamp()
Getter for the stateTimeStamp property.
Returns:
long representing the state time stamp

setStateTimeStamp

protected void setStateTimeStamp(long timeStamp)
Setter for the stateTimeStamp property.
Parameters:
long - representing the state time stamp

getDuration

public long getDuration()
Getter for the duration property.
Returns:
The duration of the current operation as of the last call to the sendProgressEvent() method.

resetDuration

public void resetDuration()
Resetter for the duration property.

getTimeout

public long getTimeout()
Getter for the timeout property. The timeout property is used when reporting events. A value of 0L indicates no timeout. The default value is 0L.
See Also:
ProgressReporter, TimeoutException

setTimeout

public void setTimeout(long timeout)
Setter for the timeout property.
Parameters:
timeout - The timeout after which APIs report TimeoutExceptions.
See Also:
getTimeout(), TimeoutException

hasTimedout

public boolean hasTimedout()
Getter for the timedout property.
Returns:
True if the current operation has timed out as of the last call to the sendProgressEvent() method.

sendProgressEvent

public void sendProgressEvent(ProgressEvent event)
This method sends a progress event the progress listeners.
Parameters:
event -
See Also:
ProgressReporter

continuing

public void continuing()
Call this method when continuing onto the next step in you process. This method calls clears all transient throwables and calls Thread.yield().

reset

public void reset()
This method resets the progress reporter, call when you want to reuse the same progress reporter to report progress on a new process.

getMessage

public static java.lang.String getMessage(java.lang.Throwable throwable)
This method returns throwable message. It first attempts to get the message, then it attempts to convert the throwable to string. If throwable is null, this method returns null.

getLocalizedMessage

public static java.lang.String getLocalizedMessage(java.lang.Throwable throwable)
This method returns throwable message. It first attempts to get the localized message, then it attemts to get the message, finally it attempts to convert the throwable to string. If throwable is null, this method returns null.

getMessages

public static java.util.Collection getMessages(java.lang.Throwable throwable)
Returns messages associated with the throwable and all of its causes.
Returns:
collection of messages, null if none were collected

getLocalizedMessages

public static java.util.Collection getLocalizedMessages(java.lang.Throwable throwable)
Returns localized messages associated with the throwable and all of its causes.
Returns:
collection of localized messages, null if none were collected

getException

public static java.lang.Exception getException(java.lang.Throwable throwable)
This method converts throwables to exceptions. If the throwable is already an exception, it will simply return the throwable cast to exception. Otherwise it will create a new exception with the message obtained by the getLocalizedMessage(Throwable) method and the throwable as the exception cause. If the throwable is null, this method returns null.

getRuntimeException

public static java.lang.RuntimeException getRuntimeException(java.lang.Throwable throwable)
This method converts throwables to runtime exceptions. If the throwable is already a runtime exception, it will simply return the throwable cast to runtime exception. Otherwise it will create a new runtime exception with the message obtained by the getLocalizedMessage(Throwable) method and the throwable as the runtime exception cause. If the throwable is null, this method returns null.

markTransient

public void markTransient(java.lang.Throwable throwable)
This method marks the throwable as transient. Mark throwables as transient so that your code will know not to report them to the progress listeners. There is only support for marking throwables in this class. Actual logic that decides what to do with transient throwables is up the the subclass or the user of this class.

unmarkTransient

public void unmarkTransient(java.lang.Throwable throwable)
This method unmarks the transient throwable.

isTransient

public boolean isTransient(java.lang.Throwable throwable)
This method returns true if the throwable is transient.

getTransient

public java.util.Set getTransient()
This method returns all transient throwables.

clearTransient

public void clearTransient()
This method clears all transient throwables.

throwException

public void throwException(java.lang.Throwable throwable)
                    throws java.lang.Exception
This method throws throwables as exceptions. Errors will also be converted to exceptions. Throwables will be thrown as exceptions obtained by the getException(Throwable) method. If the throwable is null, this method does nothing.
Throws:
java.lang.Exception

throwErrorOrException

public void throwErrorOrException(java.lang.Throwable throwable)
                           throws java.lang.Exception
This method throws throwables as exceptions. Errors will not be converted to exceptions, but simply thrown. All other throwables will be thrown as exceptions obtained by the getException(Throwable) method. If the throwable is null, this method does nothing.
Throws:
java.lang.Exception

throwRuntimeException

public void throwRuntimeException(java.lang.Throwable throwable)
This method throws throwables as runtime exceptions. Errors will also be converted to runtime exceptions. Throwables will be thrown as runtime exceptions obtained by the getRuntimeException(Throwable) method. If the throwable is null, this method does nothing.

throwErrorOrRuntimeException

public void throwErrorOrRuntimeException(java.lang.Throwable throwable)
This method throws throwables as runtime exceptions. Errors will not be converted to runtime exceptions, but simply thrown. All other throwables will be thrown as runtime exceptions obtained by the getRuntimeException(Throwable) method. If the throwable is null, this method does nothing.

Skip navigation links