net.esper.core
Class EPStatementImpl

java.lang.Object
  extended by net.esper.core.EPStatementImpl
All Implemented Interfaces:
EPIterable, EPListenable, EPStatement, EPStatementSPI

public class EPStatementImpl
extends Object
implements EPStatementSPI

Statement implementation for EQL statements.


Constructor Summary
EPStatementImpl(EPServiceProvider epServiceProvider, String statementId, String statementName, String expressionText, boolean isPattern, DispatchService dispatchService, StatementLifecycleSvc statementLifecycleSvc, long timeLastStateChange, boolean isBlockingDispatch, long msecBlockingTimeout)
          Ctor.
 
Method Summary
 void addListener(StatementAwareUpdateListener listener)
          Add a statement-aware listener that observes events.
 void addListener(UpdateListener listener)
          Add a listener to the statement.
 void destroy()
          Destroy the statement releasing all statement resources.
 EventType getEventType()
          Returns the type of events the iterable returns.
 EPStatementListenerSet getListenerSet()
          Returns the set of listeners to the statement.
 String getName()
          Returns the statement name.
 EPStatementState getState()
          Returns the statement's current state.
 Iterator<StatementAwareUpdateListener> getStatementAwareListeners()
          Returns an iterator of statement-aware update listeners.
 String getStatementId()
          Returns the statement id.
 String getText()
          Returns the underlying expression text.
 long getTimeLastStateChange()
          Returns the system time in milliseconds of when the statement last change state.
 Iterator<UpdateListener> getUpdateListeners()
          Returns an iterator of update listeners.
 boolean isDestroyed()
          Returns true if the statement state is destroyed.
 boolean isStarted()
          Returns true if the statement state is started.
 boolean isStopped()
          Returns true if the statement state is stopped.
 Iterator<EventBean> iterator()
          Returns an iterator over events.
 void removeAllListeners()
          Remove all listeners to a statement.
 void removeListener(StatementAwareUpdateListener listener)
          Remove a statement-aware listener that observes events.
 void removeListener(UpdateListener listener)
          Remove a listeners to a statement.
 void setCurrentState(EPStatementState currentState, long timeLastStateChange)
          Set statement state.
 void setListeners(EPStatementListenerSet listenerSet)
          Sets the statement listeners.
 void setParentView(Viewable viewable)
          Sets the parent view.
 void start()
          Start the statement.
 void stop()
          Stop the statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EPStatementImpl

public EPStatementImpl(EPServiceProvider epServiceProvider,
                       String statementId,
                       String statementName,
                       String expressionText,
                       boolean isPattern,
                       DispatchService dispatchService,
                       StatementLifecycleSvc statementLifecycleSvc,
                       long timeLastStateChange,
                       boolean isBlockingDispatch,
                       long msecBlockingTimeout)
Ctor.

Parameters:
statementId - is a unique ID assigned by the engine for the statement
statementName - is the statement name assigned during creation, or the statement id if none was assigned
expressionText - is the EQL and/or pattern expression
isPattern - is true to indicate this is a pure pattern expression
dispatchService - for dispatching events to listeners to the statement
statementLifecycleSvc - handles lifecycle transitions for the statement
isBlockingDispatch - is true if the dispatch to listeners should block to preserve event generation order
msecBlockingTimeout - is the max number of milliseconds of block time
epServiceProvider - is the engine instance to provide to statement-aware update listeners
timeLastStateChange - the timestamp the statement was created and started
Method Detail

getStatementId

public String getStatementId()
Description copied from interface: EPStatementSPI
Returns the statement id.

Specified by:
getStatementId in interface EPStatementSPI
Returns:
statement id

start

public void start()
Description copied from interface: EPStatement
Start the statement.

Specified by:
start in interface EPStatement

stop

public void stop()
Description copied from interface: EPStatement
Stop the statement.

Specified by:
stop in interface EPStatement

destroy

public void destroy()
Description copied from interface: EPStatement
Destroy the statement releasing all statement resources.

A destroyed statement cannot be started again.

Specified by:
destroy in interface EPStatement

getState

public EPStatementState getState()
Description copied from interface: EPStatement
Returns the statement's current state.

Specified by:
getState in interface EPStatement
Returns:
state enum

setCurrentState

public void setCurrentState(EPStatementState currentState,
                            long timeLastStateChange)
Description copied from interface: EPStatementSPI
Set statement state.

Specified by:
setCurrentState in interface EPStatementSPI
Parameters:
currentState - new current state
timeLastStateChange - the timestamp the statement changed state

setParentView

public void setParentView(Viewable viewable)
Description copied from interface: EPStatementSPI
Sets the parent view.

Specified by:
setParentView in interface EPStatementSPI
Parameters:
viewable - is the statement viewable

getText

public String getText()
Description copied from interface: EPStatement
Returns the underlying expression text.

Specified by:
getText in interface EPStatement
Returns:
expression text

getName

public String getName()
Description copied from interface: EPStatement
Returns the statement name.

Specified by:
getName in interface EPStatement
Returns:
statement name

iterator

public Iterator<EventBean> iterator()
Description copied from interface: EPIterable
Returns an iterator over events.

Specified by:
iterator in interface EPIterable
Returns:
event iterator

getEventType

public EventType getEventType()
Description copied from interface: EPIterable
Returns the type of events the iterable returns.

Specified by:
getEventType in interface EPIterable
Returns:
event type of events the iterator returns

getListenerSet

public EPStatementListenerSet getListenerSet()
Returns the set of listeners to the statement.

Specified by:
getListenerSet in interface EPStatementSPI
Returns:
statement listeners

setListeners

public void setListeners(EPStatementListenerSet listenerSet)
Description copied from interface: EPStatementSPI
Sets the statement listeners.

Care must be taken in the use of this method as unsynchronized modification to the listeners of a statement can yield problems.

Specified by:
setListeners in interface EPStatementSPI
Parameters:
listenerSet - set

addListener

public void addListener(UpdateListener listener)
Add a listener to the statement.

Specified by:
addListener in interface EPListenable
Parameters:
listener - to add

removeListener

public void removeListener(UpdateListener listener)
Remove a listeners to a statement.

Specified by:
removeListener in interface EPListenable
Parameters:
listener - to remove

removeAllListeners

public void removeAllListeners()
Remove all listeners to a statement.

Specified by:
removeAllListeners in interface EPListenable

addListener

public void addListener(StatementAwareUpdateListener listener)
Description copied from interface: EPListenable
Add a statement-aware listener that observes events.

Specified by:
addListener in interface EPListenable
Parameters:
listener - to add

removeListener

public void removeListener(StatementAwareUpdateListener listener)
Description copied from interface: EPListenable
Remove a statement-aware listener that observes events.

Specified by:
removeListener in interface EPListenable
Parameters:
listener - to remove

getStatementAwareListeners

public Iterator<StatementAwareUpdateListener> getStatementAwareListeners()
Description copied from interface: EPListenable
Returns an iterator of statement-aware update listeners.

The returned iterator does not allow the remove operation.

Specified by:
getStatementAwareListeners in interface EPListenable
Returns:
iterator of statement-aware update listeners

getUpdateListeners

public Iterator<UpdateListener> getUpdateListeners()
Description copied from interface: EPListenable
Returns an iterator of update listeners.

The returned iterator does not allow the remove operation.

Specified by:
getUpdateListeners in interface EPListenable
Returns:
iterator of update listeners

getTimeLastStateChange

public long getTimeLastStateChange()
Description copied from interface: EPStatement
Returns the system time in milliseconds of when the statement last change state.

Specified by:
getTimeLastStateChange in interface EPStatement
Returns:
time in milliseconds of last statement state change

isStarted

public boolean isStarted()
Description copied from interface: EPStatement
Returns true if the statement state is started.

Specified by:
isStarted in interface EPStatement
Returns:
true for started statements, false for stopped or destroyed statements.

isStopped

public boolean isStopped()
Description copied from interface: EPStatement
Returns true if the statement state is stopped.

Specified by:
isStopped in interface EPStatement
Returns:
true for stopped statements, false for started or destroyed statements.

isDestroyed

public boolean isDestroyed()
Description copied from interface: EPStatement
Returns true if the statement state is destroyed.

Specified by:
isDestroyed in interface EPStatement
Returns:
true for destroyed statements, false for started or stopped statements.