net.sf.fikin.sql.core
Class SqlsCounter

java.lang.Object
  extended by net.sf.fikin.sql.SQLPipeElement
      extended by net.sf.fikin.sql.core.SqlsCounter

public class SqlsCounter
extends SQLPipeElement

Counter of the sql commands

One can query the current counter from before of after in the pipe chain.

Counter is incremented even in case of SQLException during sql command execution.

It provides with built-in functionality to execute sql commands in the range of start-stop i.e. one can instantiate the element with start=5 and stop=10 which would result that all sql commands before 5 and after 10 will be ignored i.e. it will return from execute() without passing it to the next in the pipe.

created on Dec 16, 2006

Since:
Version:
$Revision: 1.5 $
Author:
fiykov

Constructor Summary
SqlsCounter()
          create an element without any start-stop filtering
SqlsCounter(int start)
          create an element where it will pass sql commands after start
SqlsCounter(int start, int stop)
          create an element where it will pass sql commands in between start-stop
 
Method Summary
 void execute(java.lang.String cmd)
          increment the sql command counter and pass it to the next in the pipe if current command is <start or >stop it will not pass it and simply return from the method
 int getCurrent()
          get current sql command counter
 void setStart(int start)
          assign start-from sql command
 void setStop(int stop)
          assign stop-to sql command
 
Methods inherited from class net.sf.fikin.sql.SQLPipeElement
getBaseClassName, getId, getNext, getPipe, setNext, setPipe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlsCounter

public SqlsCounter()
create an element without any start-stop filtering


SqlsCounter

public SqlsCounter(int start)
create an element where it will pass sql commands after start

Parameters:
start -

SqlsCounter

public SqlsCounter(int start,
                   int stop)
create an element where it will pass sql commands in between start-stop

Parameters:
start -
stop -
Method Detail

setStart

public void setStart(int start)
assign start-from sql command

Parameters:
start -

setStop

public void setStop(int stop)
assign stop-to sql command

Parameters:
stop -

execute

public void execute(java.lang.String cmd)
             throws java.sql.SQLException
increment the sql command counter and pass it to the next in the pipe if current command is <start or >stop it will not pass it and simply return from the method

Specified by:
execute in class SQLPipeElement
Parameters:
cmd - to execute
Throws:
java.sql.SQLException - in case of error

getCurrent

public int getCurrent()
get current sql command counter

Returns:
current sql command count


Copyright © 2003-2007 Nikolay Fiykov. All Rights Reserved.