com.espertech.esper.view
Class ViewSupport

java.lang.Object
  extended by com.espertech.esper.view.ViewSupport
All Implemented Interfaces:
EventCollection, View, Viewable, java.lang.Iterable<EventBean>
Direct Known Subclasses:
AddPropertyValueView, BaseBivariateStatisticsView, BufferView, ContextMergeView, CreateVariableView, EPLSelectUpdateDispatchView, EPLSelectViewable, EventRowRegexNFAView, ExpressionViewBase, ExternallyTimedBatchView, ExternallyTimedWindowView, FilterExprView, FirstElementView, FirstLengthWindowView, FirstTimeView, FirstUniqueByPropertyView, GroupByViewImpl, GroupByViewReclaimAged, InternalRoutePreprocessView, IntersectAsymetricView, IntersectBatchView, IntersectView, KeepAllView, LastElementView, LastPostObserverView, LengthBatchView, LengthBatchViewRStream, LengthWindowView, LengthWindowViewRStream, MergeView, NamedWindowConsumerView, NamedWindowOnExprBaseView, NamedWindowRootViewInstance, NamedWindowTailViewInstance, OnSetVariableView, PatternRemoveDispatchView, PriorEventView, RankWindowView, RouteResultView, SingleStreamDispatchView, SizeView, SortWindowView, SubselectAggregatorViewBase, TableOnViewBase, TableStateViewableInternal, TableStateViewablePublic, TimeAccumView, TimeAccumViewRStream, TimeBatchView, TimeBatchViewRStream, TimeLengthBatchView, TimeOrderView, TimeWindowView, UnionAsymetricView, UnionView, UniqueByPropertyView, UnivariateStatisticsView, UpdateDispatchViewBase, VirtualDWViewImpl, WeightedAverageView

public abstract class ViewSupport
extends java.lang.Object
implements View

A helper class for View implementations that provides generic implementation for some of the methods. Methods that contain the actual logic of the view are not implemented in this class. A common implementation normally does not need to override any of the methods implemented here, their implementation is generic and should suffice. The class provides a convenience method for updateing it's children data updateChildren(Object[], Object[]). This method should be called from within the View.update(Object[], Object[]) methods in the subclasses.


Field Summary
static View[] EMPTY_VIEW_ARRAY
           
protected  Viewable parent
          Parent viewable to this view - directly accessible by subclasses.
 
Constructor Summary
protected ViewSupport()
          Constructor.
 
Method Summary
 View addView(View view)
          Add a view to the viewable object.
static View[] addView(View[] children, View view)
           
static void dumpChildViews(java.lang.String prefix, Viewable parentViewable)
          Convenience method for logging the child views of a Viewable.
static void dumpUpdateParams(java.lang.String prefix, java.lang.Object[] newData, java.lang.Object[] oldData)
          Convenience method for logging the parameters passed to the update method.
static void dumpUpdateParams(java.lang.String prefix, UniformPair<EventBean[]> result)
          Convenience method for logging the parameters passed to the update method.
static java.util.List<View> findDescendent(Viewable parentView, Viewable descendentView)
          Find the descendent view in the view tree under the parent view returning the list of view nodes between the parent view and the descendent view.
static int findViewIndex(View[] children, View view)
           
 Viewable getParent()
          Returns the View's parent Viewable.
 View[] getViews()
          Returns all added views.
 boolean hasViews()
          Test is there are any views to the Viewable.
 void removeAllViews()
          Remove all views.
 boolean removeView(View view)
          Remove a view.
static View[] removeView(View[] children, int index)
           
 void setParent(Viewable parent)
          Called when the View is added to a Viewable object.
protected static void updateChildren(java.util.Collection<View> childViews, EventBean[] newData, EventBean[] oldData)
          Updates all the children with new data.
 void updateChildren(EventBean[] newData, EventBean[] oldData)
          Updates all the children with new data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.espertech.esper.view.View
update
 
Methods inherited from interface com.espertech.esper.view.EventCollection
getEventType, iterator
 

Field Detail

EMPTY_VIEW_ARRAY

public static final View[] EMPTY_VIEW_ARRAY

parent

protected Viewable parent
Parent viewable to this view - directly accessible by subclasses.

Constructor Detail

ViewSupport

protected ViewSupport()
Constructor.

Method Detail

getParent

public Viewable getParent()
Description copied from interface: View
Returns the View's parent Viewable.

Specified by:
getParent in interface View
Returns:
viewable

setParent

public void setParent(Viewable parent)
Description copied from interface: View
Called when the View is added to a Viewable object.

Specified by:
setParent in interface View
Parameters:
parent - is the parent that this view is a child of

addView

public View addView(View view)
Description copied from interface: Viewable
Add a view to the viewable object.

Specified by:
addView in interface Viewable
Parameters:
view - to add
Returns:
view to add

removeView

public boolean removeView(View view)
Description copied from interface: Viewable
Remove a view.

Specified by:
removeView in interface Viewable
Parameters:
view - to remove
Returns:
true to indicate that the view to be removed existed within this view, false if the view to remove could not be found

removeAllViews

public void removeAllViews()
Description copied from interface: Viewable
Remove all views.

Specified by:
removeAllViews in interface Viewable

getViews

public View[] getViews()
Description copied from interface: Viewable
Returns all added views.

Specified by:
getViews in interface Viewable
Returns:
list of added views

hasViews

public boolean hasViews()
Description copied from interface: Viewable
Test is there are any views to the Viewable.

Specified by:
hasViews in interface Viewable
Returns:
true indicating there are child views, false indicating there are no child views

updateChildren

public void updateChildren(EventBean[] newData,
                           EventBean[] oldData)
Updates all the children with new data. Views may want to use the hasViews method on the Viewable interface to determine if there are any child views attached at all, and save the work of constructing the arrays and making the call to updateChildren() in case there aren't any children attached.

Parameters:
newData - is the array of new event data
oldData - is the array of old event data

updateChildren

protected static void updateChildren(java.util.Collection<View> childViews,
                                     EventBean[] newData,
                                     EventBean[] oldData)
Updates all the children with new data. Static convenience method that accepts the list of child views as a parameter.

Parameters:
childViews - is the list of child views to send the data to
newData - is the array of new event data
oldData - is the array of old event data

dumpUpdateParams

public static void dumpUpdateParams(java.lang.String prefix,
                                    UniformPair<EventBean[]> result)
Convenience method for logging the parameters passed to the update method. Only logs if debug is enabled.

Parameters:
prefix - is a prefix text to output for each line
result - is the data in an update call

dumpUpdateParams

public static void dumpUpdateParams(java.lang.String prefix,
                                    java.lang.Object[] newData,
                                    java.lang.Object[] oldData)
Convenience method for logging the parameters passed to the update method. Only logs if debug is enabled.

Parameters:
prefix - is a prefix text to output for each line
newData - is the new data in an update call
oldData - is the old data in an update call

dumpChildViews

public static void dumpChildViews(java.lang.String prefix,
                                  Viewable parentViewable)
Convenience method for logging the child views of a Viewable. Only logs if debug is enabled. This is a recursive method.

Parameters:
prefix - is a text to print for each view printed
parentViewable - is the parent for which the child views are displayed.

findDescendent

public static java.util.List<View> findDescendent(Viewable parentView,
                                                  Viewable descendentView)
Find the descendent view in the view tree under the parent view returning the list of view nodes between the parent view and the descendent view. Returns null if the descendent view is not found. Returns an empty list if the descendent view is a child view of the parent view.

Parameters:
parentView - is the view to start searching under
descendentView - is the view to find
Returns:
list of Viewable nodes between parent and descendent view.

addView

public static View[] addView(View[] children,
                             View view)

findViewIndex

public static int findViewIndex(View[] children,
                                View view)

removeView

public static View[] removeView(View[] children,
                                int index)

© 2006-2015 EsperTech Inc.
All rights reserved.
Visit us at espertech.com