|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.esper.view.ViewSupport
net.esper.view.stat.WeightedAverageView
public final class WeightedAverageView
View for computing a weighted average. The view uses 2 fields within the parent view to compute the weighted average. The X field and weight field. In a price-volume example it calculates the volume-weighted average price as (sum(price * volume) / sum(volume)). Example: weighted_avg("price", "volume")
Field Summary |
---|
Fields inherited from class net.esper.view.ViewSupport |
---|
parent |
Constructor Summary | |
---|---|
WeightedAverageView()
Default constructor - required by all views to adhere to the Java bean specification. |
|
WeightedAverageView(String fieldNameX,
String fieldNameWeight)
Constructor requires the name of the field to use in the parent view to compute the weighted average on, as well as the name of the field in the parent view to get the weight from. |
Method Summary | |
---|---|
protected static EventType |
createEventType(ViewServiceContext viewServiceContext)
Creates the event type for this view. |
EventType |
getEventType()
Provides metadata information about the type of object the event collection contains. |
String |
getFieldNameWeight()
Returns the name of the field supplying the weight values. |
String |
getFieldNameX()
Returns the name of the field supplying the X values. |
ViewServiceContext |
getViewServiceContext()
Returns the context instances used by the view. |
Iterator<EventBean> |
iterator()
Allows iteration through all elements in this event collection. |
void |
setFieldNameWeight(String fieldNameWeight)
Sets the name of the field supplying the weight values. |
void |
setFieldNameX(String fieldNameX)
Sets the name of the field supplying the X values. |
void |
setParent(Viewable parent)
Called when the View is added to a Viewable object. |
void |
setViewServiceContext(ViewServiceContext viewServiceContext)
Set the services context containing service handles. |
String |
toString()
|
void |
update(EventBean[] newData,
EventBean[] oldData)
Notify that data has been added or removed from the Viewable parent. |
Methods inherited from class net.esper.view.ViewSupport |
---|
addView, dumpChildViews, dumpUpdateParams, findDescendent, getParent, getViews, hasViews, removeView, shallowCopyView, updateChildren, updateChildren |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WeightedAverageView()
public WeightedAverageView(String fieldNameX, String fieldNameWeight)
fieldNameX
- is the name of the field within the parent view to use to get numeric data points for this view to
compute the average for.fieldNameWeight
- is the field name for the weight to apply to each data pointMethod Detail |
---|
public ViewServiceContext getViewServiceContext()
ContextAwareView
getViewServiceContext
in interface ContextAwareView
public void setViewServiceContext(ViewServiceContext viewServiceContext)
ContextAwareView
setViewServiceContext
in interface ContextAwareView
viewServiceContext
- with service handlespublic void setParent(Viewable parent)
View
setParent
in interface View
setParent
in class ViewSupport
parent
- is the parent that this view is a child ofpublic final String getFieldNameX()
public final void setFieldNameX(String fieldNameX)
fieldNameX
- field name supplying X data pointspublic final String getFieldNameWeight()
public final void setFieldNameWeight(String fieldNameWeight)
fieldNameWeight
- field name supplying weightpublic final void update(EventBean[] newData, EventBean[] oldData)
View
update
in interface View
newData
- is the new data that has been added to the parent viewoldData
- is the old data that has been removed from the parent viewpublic final EventType getEventType()
EventCollection
getEventType
in interface EventCollection
public final Iterator<EventBean> iterator()
EventCollection
iterator
in interface Iterable<EventBean>
iterator
in interface EventCollection
public final String toString()
toString
in class Object
protected static EventType createEventType(ViewServiceContext viewServiceContext)
viewServiceContext
- is the event adapter service
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |