com.espertech.esper.event
Class BaseConfigurableEventType

java.lang.Object
  extended by com.espertech.esper.event.BaseConfigurableEventType
All Implemented Interfaces:
EventType, EventTypeSPI
Direct Known Subclasses:
BaseXMLEventType

public abstract class BaseConfigurableEventType
extends java.lang.Object
implements EventTypeSPI

EventType than can be supplied with a preconfigured list of properties getters (aka. explicit properties).

Author:
pablo

Field Summary
protected  java.util.Map<java.lang.String,EventPropertyDescriptor> propertyDescriptorMap
          Descriptors for each known property.
protected  java.util.Map<java.lang.String,EventPropertyGetter> propertyGetters
          Getters for each known property.
 
Constructor Summary
protected BaseConfigurableEventType(EventAdapterService eventAdapterService, EventTypeMetadata metadata, int eventTypeId, java.lang.Class underlyngType)
          Ctor.
 
Method Summary
protected abstract  FragmentEventType doResolveFragmentType(java.lang.String property)
          Subclasses must implement this and return a fragment type for a property.
protected abstract  EventPropertyGetter doResolvePropertyGetter(java.lang.String property)
          Subclasses must implement this and supply a getter to a given property.
protected abstract  java.lang.Class doResolvePropertyType(java.lang.String property)
          Subclasses must implement this and return a type for a property.
 EventAdapterService getEventAdapterService()
          Returns the event adapter service.
 int getEventTypeId()
          Returns the event type id assigned to the event type.
 FragmentEventType getFragmentType(java.lang.String property)
          Returns the event type of the fragment that is the value of a property name or property expression.
 EventPropertyGetter getGetter(java.lang.String propertyExpression)
          Get the getter of an event property or property expression: Getters are useful when an application receives events of the same event type multiple times and requires fast access to an event property or nested, indexed or mapped property.
 EventPropertyGetterIndexed getGetterIndexed(java.lang.String indexedProperty)
          Get the getter of an event property that is a indexed event property: Getters are useful when an application receives events of the same event type multiple times and requires fast access to a indexed property.
 EventPropertyGetterMapped getGetterMapped(java.lang.String mappedProperty)
          Get the getter of an event property that is a mapped event property: Getters are useful when an application receives events of the same event type multiple times and requires fast access to a mapped property.
 EventTypeMetadata getMetadata()
          Returns the type metadata.
 java.lang.String getName()
          Returns the type name or null if no type name is assigned.
 EventPropertyDescriptor getPropertyDescriptor(java.lang.String propertyName)
          Get the property descriptor for a given property of the event, or null if a property by that name was not found.
 EventPropertyDescriptor[] getPropertyDescriptors()
          Get property descriptors for the event type.
 java.lang.String[] getPropertyNames()
          Get the property names for the event type.
 java.lang.Class getPropertyType(java.lang.String propertyExpression)
          Get the type of an event property.
 java.lang.Class getUnderlyingType()
          Get the class that represents the Java type of the event type.
protected  void initialize(java.util.List<ExplicitPropertyDescriptor> explicitProperties)
          Sets explicit properties using a map of event property name and getter instance for each property.
 boolean isProperty(java.lang.String property)
          Check that the given property name or property expression is valid for this event type, ie.
 
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.event.EventTypeSPI
equalsCompareType, getCopyMethod, getReader, getWritableProperty, getWriteableProperties, getWriter, getWriter
 
Methods inherited from interface com.espertech.esper.client.EventType
getDeepSuperTypes, getEndTimestampPropertyName, getStartTimestampPropertyName, getSuperTypes
 

Field Detail

propertyGetters

protected java.util.Map<java.lang.String,EventPropertyGetter> propertyGetters
Getters for each known property.


propertyDescriptorMap

protected java.util.Map<java.lang.String,EventPropertyDescriptor> propertyDescriptorMap
Descriptors for each known property.

Constructor Detail

BaseConfigurableEventType

protected BaseConfigurableEventType(EventAdapterService eventAdapterService,
                                    EventTypeMetadata metadata,
                                    int eventTypeId,
                                    java.lang.Class underlyngType)
Ctor.

Parameters:
underlyngType - is the underlying type returned by the event type
metadata - event type metadata
eventAdapterService - for dynamic event type creation
Method Detail

getEventTypeId

public int getEventTypeId()
Description copied from interface: EventType
Returns the event type id assigned to the event type.

Specified by:
getEventTypeId in interface EventType
Returns:
event type id

doResolvePropertyGetter

protected abstract EventPropertyGetter doResolvePropertyGetter(java.lang.String property)
Subclasses must implement this and supply a getter to a given property.

Parameters:
property - is the property expression
Returns:
getter for property

doResolvePropertyType

protected abstract java.lang.Class doResolvePropertyType(java.lang.String property)
Subclasses must implement this and return a type for a property.

Parameters:
property - is the property expression
Returns:
property type

doResolveFragmentType

protected abstract FragmentEventType doResolveFragmentType(java.lang.String property)
Subclasses must implement this and return a fragment type for a property.

Parameters:
property - is the property expression
Returns:
fragment property type

getName

public java.lang.String getName()
Description copied from interface: EventType
Returns the type name or null if no type name is assigned.

A type name is available for application-configured event types and for event types that represent events of a stream populated by insert-into.

No type name is available for anonymous statement-specific event type.

Specified by:
getName in interface EventType
Returns:
type name or null if none assigned

getEventAdapterService

public EventAdapterService getEventAdapterService()
Returns the event adapter service.

Returns:
event adapter service

initialize

protected void initialize(java.util.List<ExplicitPropertyDescriptor> explicitProperties)
Sets explicit properties using a map of event property name and getter instance for each property.

Parameters:
explicitProperties - property descriptors for explicit properties

getPropertyType

public java.lang.Class getPropertyType(java.lang.String propertyExpression)
Description copied from interface: EventType
Get the type of an event property.

Returns null if the property name or property expression is not valid against the event type. Can also return null if a select-clause selects a constant null value.

The method takes a property name or property expression as a parameter. Property expressions may include indexed properties via the syntax "name[index]", mapped properties via the syntax "name('key')", nested properties via the syntax "outer.inner" or combinations thereof.

Returns unboxed (such as 'int.class') as well as boxed (java.lang.Integer) type.

Specified by:
getPropertyType in interface EventType
Parameters:
propertyExpression - is the property name or property expression
Returns:
type of the property, the unboxed or the boxed type.

getUnderlyingType

public java.lang.Class getUnderlyingType()
Description copied from interface: EventType
Get the class that represents the Java type of the event type. Returns a Java bean event class if the schema represents a Java bean event type. Returns java.util.Map is the schema represents a collection of values in a Map.

Specified by:
getUnderlyingType in interface EventType
Returns:
type of the event object

getGetter

public EventPropertyGetter getGetter(java.lang.String propertyExpression)
Description copied from interface: EventType
Get the getter of an event property or property expression: Getters are useful when an application receives events of the same event type multiple times and requires fast access to an event property or nested, indexed or mapped property.

Returns null if the property name or property expression is not valid against the event type.

The method takes a property name or property expression as a parameter. Property expressions may include indexed properties via the syntax "name[index]", mapped properties via the syntax "name('key')", nested properties via the syntax "outer.inner" or combinations thereof.

Specified by:
getGetter in interface EventType
Parameters:
propertyExpression - is the property name or property expression
Returns:
a getter that can be used to obtain property values for event instances of the same event type

getGetterMapped

public EventPropertyGetterMapped getGetterMapped(java.lang.String mappedProperty)
Description copied from interface: EventType
Get the getter of an event property that is a mapped event property: Getters are useful when an application receives events of the same event type multiple times and requires fast access to a mapped property.

Returns null if the property name is not valid against the event type or the property is not a mapped property.

The method takes a mapped property name (and not a property expression) as a parameter.

Specified by:
getGetterMapped in interface EventType
Parameters:
mappedProperty - is the property name
Returns:
a getter that can be used to obtain property values for event instances of the same event type

getGetterIndexed

public EventPropertyGetterIndexed getGetterIndexed(java.lang.String indexedProperty)
Description copied from interface: EventType
Get the getter of an event property that is a indexed event property: Getters are useful when an application receives events of the same event type multiple times and requires fast access to a indexed property.

Returns null if the property name is not valid against the event type or the property is not an indexed property.

The method takes a indexed property name (and not a property expression) as a parameter.

Specified by:
getGetterIndexed in interface EventType
Parameters:
indexedProperty - is the property name
Returns:
a getter that can be used to obtain property values for event instances of the same event type

getFragmentType

public FragmentEventType getFragmentType(java.lang.String property)
Description copied from interface: EventType
Returns the event type of the fragment that is the value of a property name or property expression.

Returns null if the property name or property expression is not valid or does not return a fragment for the event type.

The EventPropertyDescriptor provides a flag that indicates which properties provide fragment events.

This is useful for navigating properties that are itself events or other well-defined types that the underlying event representation may represent as an event type. It is up to each event representation to determine what properties can be represented as event types themselves.

The method takes a property name or property expression as a parameter. Property expressions may include indexed properties via the syntax "name[index]", mapped properties via the syntax "name('key')", nested properties via the syntax "outer.inner" or combinations thereof.

The underlying event representation may not support providing fragments or therefore fragment event types for any or all properties, in which case the method returns null.

Use the EventType.getPropertyDescriptors() method to obtain a list of properties for which a fragment event type may be retrieved by this method.

Specified by:
getFragmentType in interface EventType
Parameters:
property - is the name of the property to return the fragment event type
Returns:
fragment event type of the property

getPropertyNames

public java.lang.String[] getPropertyNames()
Description copied from interface: EventType
Get the property names for the event type.

Note that properties do not have a defined order. Your application should not rely on the order of properties returned by this method.

The method does not return property names of inner or nested types.

Specified by:
getPropertyNames in interface EventType
Returns:
A string array containing the property names of this typed event data object.

isProperty

public boolean isProperty(java.lang.String property)
Description copied from interface: EventType
Check that the given property name or property expression is valid for this event type, ie. that the property exists on the event type.

The method takes a property name or property expression as a parameter. Property expressions may include indexed properties via the syntax "name[index]", mapped properties via the syntax "name('key')", nested properties via the syntax "outer.inner" or combinations thereof.

Specified by:
isProperty in interface EventType
Parameters:
property - is the property name or property expression to check
Returns:
true if exists, false if not

getPropertyDescriptors

public EventPropertyDescriptor[] getPropertyDescriptors()
Description copied from interface: EventType
Get property descriptors for the event type.

Note that properties do not have a defined order. Your application should not rely on the order of properties returned by this method.

The method does not return property information of inner or nested types.

Specified by:
getPropertyDescriptors in interface EventType
Returns:
descriptors for all known properties of the event type.

getMetadata

public EventTypeMetadata getMetadata()
Description copied from interface: EventTypeSPI
Returns the type metadata.

Specified by:
getMetadata in interface EventTypeSPI
Returns:
type metadata

getPropertyDescriptor

public EventPropertyDescriptor getPropertyDescriptor(java.lang.String propertyName)
Description copied from interface: EventType
Get the property descriptor for a given property of the event, or null if a property by that name was not found.

The property name parameter does accept a property expression. It therefore does not allow the indexed, mapped or nested property expression syntax and only returns the descriptor for the event type's known properties.

The method does not return property information of inner or nested types.

For returning a property descriptor for nested, indexed or mapped properties use EventTypeUtility.

Specified by:
getPropertyDescriptor in interface EventType
Parameters:
propertyName - property name
Returns:
descriptor for the named property

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