SystemTimeInterruptMonitor

Inheritance: java.lang.Object, com.aspose.cells.AbstractInterruptMonitor

public class SystemTimeInterruptMonitor extends AbstractInterruptMonitor

Simple implementation of AbstractInterruptMonitor by checking and comparing current system time with user specified limit.

Remarks

This implementation is just a simple solution for simple scenarios. It needs to frequently retrieve and check the system time so itself may have a negative impact on performance to some extent.

Example

The following example shows how to monitor the load and save procedure with specified time limit:

         SystemTimeInterruptMonitor monitor = new SystemTimeInterruptMonitor(false);
         LoadOptions lopts = new LoadOptions();
         lopts.setInterruptMonitor(monitor);
         monitor.startMonitor(1000); //time limit is 1 second
         Workbook wb = new Workbook("Large.xlsx", lopts);
         //if the time cost of loading the template file exceeds one second, interruption will be required and exception will be thrown here
         //otherwise starts to monitor the save procedure
         monitor.startMonitor(1500); //time limit is 1.5 seconds
         wb.save("result.xlsx");

Constructors

ConstructorDescription
SystemTimeInterruptMonitor(boolean terminateWithoutException)Constructs one interruption monitor.

Methods

MethodDescription
equals(Object arg0)
getClass()
getTerminateWithoutException()See AbstractInterruptMonitor.getTerminateWithoutException().
hashCode()
isInterruptionRequested()This implementation just checks whether the time cost(from the time when starting this monitor to now) is greater than user specified limit.
notify()
notifyAll()
startMonitor(int msLimit)Starts the monitor with the specified time limit.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

SystemTimeInterruptMonitor(boolean terminateWithoutException)

public SystemTimeInterruptMonitor(boolean terminateWithoutException)

Constructs one interruption monitor.

Parameters:

ParameterTypeDescription
terminateWithoutExceptionbooleanAbstractInterruptMonitor.getTerminateWithoutException()

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getTerminateWithoutException()

public boolean getTerminateWithoutException()

See AbstractInterruptMonitor.getTerminateWithoutException(). This property is specified by user when constructing this monitor instance.

Returns: boolean

hashCode()

public native int hashCode()

Returns: int

isInterruptionRequested()

public boolean isInterruptionRequested()

This implementation just checks whether the time cost(from the time when starting this monitor to now) is greater than user specified limit.

Returns: boolean

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

startMonitor(int msLimit)

public void startMonitor(int msLimit)

Starts the monitor with the specified time limit. The start time to calculate time cost is just when this method is called, so the procedure which needs to be monitored should be started just after this call.

Parameters:

ParameterTypeDescription
msLimitinttime limit(ms) to require the interruption.

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int