net.esper.view
Class ViewServiceHelper

java.lang.Object
  extended by net.esper.view.ViewServiceHelper

public class ViewServiceHelper
extends java.lang.Object

Utility methods to deal with chains of views, and for merge/group-by views.


Constructor Summary
ViewServiceHelper()
           
 
Method Summary
protected static void addMergeViews(java.util.List<ViewSpec> specifications)
          Add merge views for any views in the chain requiring a merge (group view).
protected static java.util.List<View> instantiateChain(java.util.List<View> existingParentViews, Viewable parentViewable, java.util.List<ViewSpec> specifications, ViewServiceContext context)
          Instantiate a chain of views.
protected static Pair<Viewable,java.util.List<View>> matchExistingViews(Viewable rootViewable, java.util.Map<View,ViewSpec> specificationRepository, java.util.List<ViewSpec> specifications)
          Match the views under the stream to the list of view specications passed in.
protected static java.util.List<View> removeChainLeafView(Viewable parentViewable, Viewable viewToRemove)
          Removes a view from a parent view returning the orphaned parent views in a list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewServiceHelper

public ViewServiceHelper()
Method Detail

addMergeViews

protected static void addMergeViews(java.util.List<ViewSpec> specifications)
Add merge views for any views in the chain requiring a merge (group view). Appends to the list of view specifications passed in one ore more new view specifications that represent merge views. Merge views have the same parameter list as the (group) view they merge data for.

Parameters:
specifications - is a list of view definitions defining the chain of views.

instantiateChain

protected static java.util.List<View> instantiateChain(java.util.List<View> existingParentViews,
                                                       Viewable parentViewable,
                                                       java.util.List<ViewSpec> specifications,
                                                       ViewServiceContext context)
                                                throws ViewProcessingException
Instantiate a chain of views.

Parameters:
existingParentViews - - parent views
parentViewable - - parent view to add the chain to
specifications - - view specification, one for each chain element
context - - dependent services
Returns:
chain of views instantiated
Throws:
ViewProcessingException - is throw to indicate an error instantiating the chain

removeChainLeafView

protected static java.util.List<View> removeChainLeafView(Viewable parentViewable,
                                                          Viewable viewToRemove)
Removes a view from a parent view returning the orphaned parent views in a list.

Parameters:
parentViewable - - parent to remove view from
viewToRemove - - view to remove
Returns:
chain of orphaned views

matchExistingViews

protected static Pair<Viewable,java.util.List<View>> matchExistingViews(Viewable rootViewable,
                                                                        java.util.Map<View,ViewSpec> specificationRepository,
                                                                        java.util.List<ViewSpec> specifications)
                                                                 throws ViewProcessingException
Match the views under the stream to the list of view specications passed in. The method changes the view specifications list passed in and removes those specifications for which matcing views have been found. If none of the views under the stream matches the first view specification passed in, the method returns the stream itself and leaves the view specification list unchanged. If one view under the stream matches, the view's specification is removed from the list. The method will then attempt to determine if any child views of that view also match specifications.

Parameters:
rootViewable - is the top rootViewable event stream to which all views are attached as child views
specificationRepository - is a map of view and specification that enables view specification comparison
specifications - is the non-empty list of specifications describing the new chain of views to create. This parameter is changed by this method, ie. specifications are removed if they match existing views.
Returns:
a pair of (A) the stream if no views matched, or the last child view that matched (B) the full list of parent views
Throws:
ViewProcessingException - to indicate an error finding matching views