org.basex.core
Class Proc

java.lang.Object
  extended by org.basex.core.Proc
Direct Known Subclasses:
Builder, Command, IndexBuilder, Parser, QueryContext, QueryProcessor, Zip

public abstract class Proc
extends java.lang.Object

This class is implemented by all kinds of processes. It gives feedback on the current process. Moreover, it allows to interrupt the process by calling the stop() method.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
 InfoListener listen
          Listener, reacting on process information.
 boolean updating
          This flag indicates that a command may perform updates.
 
Constructor Summary
Proc()
           
 
Method Summary
protected  void abort()
          Aborts a failed or interrupted process.
 void checkStop()
          Checks if the process was interrupted; if yes, sends a runtime exception.
 void databases(LockResult lockResult)
          Adds the names of the databases that may be touched by the process.
protected  java.lang.String det()
          Returns short information on this process.
 java.lang.String detail()
          Returns detailed information on the current process or sub process.
 void listen(InfoListener il)
          Attaches the specified info listener.
protected
<P extends Proc>
P
proc(P proc)
          Sets a new sub process.
protected  double prog()
          Returns a progress value (0 - 1).
 double progress()
          Returns a progress value from the interval [0, 1].
 boolean registered()
          Checks if the process is registered.
 void registered(boolean reg)
          Sets the registered state.
 void startTimeout(long ms)
          Starts a timeout thread.
 void stop()
          Stops a process or sub process.
 void stopTimeout()
          Stops the timeout thread.
protected  java.lang.String tit()
          Returns short information on this process.
 java.lang.String title()
          Returns short information on the current process or sub process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listen

public InfoListener listen
Listener, reacting on process information.


updating

public boolean updating
This flag indicates that a command may perform updates.

Constructor Detail

Proc

public Proc()
Method Detail

title

public final java.lang.String title()
Returns short information on the current process or sub process.

Returns:
header information

detail

public final java.lang.String detail()
Returns detailed information on the current process or sub process. Can be overwritten to give more detailed information.

Returns:
information in detail

progress

public final double progress()
Returns a progress value from the interval [0, 1].

Returns:
header information

listen

public final void listen(InfoListener il)
Attaches the specified info listener.

Parameters:
il - info listener

proc

protected final <P extends Proc> P proc(P proc)
Sets a new sub process.

Type Parameters:
P - process type
Parameters:
proc - process
Returns:
passed on process reference

stop

public final void stop()
Stops a process or sub process.


checkStop

public final void checkStop()
Checks if the process was interrupted; if yes, sends a runtime exception.


abort

protected void abort()
Aborts a failed or interrupted process.


startTimeout

public final void startTimeout(long ms)
Starts a timeout thread.

Parameters:
ms - milliseconds to wait; deactivated if set to 0

stopTimeout

public final void stopTimeout()
Stops the timeout thread.


databases

public void databases(LockResult lockResult)
Adds the names of the databases that may be touched by the process.

Parameters:
lockResult - Container for lock result to pass around

registered

public final boolean registered()
Checks if the process is registered.

Returns:
result of check

registered

public final void registered(boolean reg)
Sets the registered state.

Parameters:
reg - registered flag

tit

protected java.lang.String tit()
Returns short information on this process. Can be overwritten to give more detailed information.

Returns:
header information

det

protected java.lang.String det()
Returns short information on this process.

Returns:
header information

prog

protected double prog()
Returns a progress value (0 - 1). Can be overwritten to give more detailed information.

Returns:
header information