com.espertech.esper.event
Class BaseNestableEventType

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

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

Implementation of the EventType interface for handling name value pairs.


Field Summary
protected  java.lang.String endTimestampPropertyName
           
protected  EventAdapterService eventAdapterService
           
protected  int eventTypeId
           
protected  EventTypeNestableGetterFactory getterFactory
           
protected  EventTypeMetadata metadata
           
protected  java.util.Map<java.lang.String,java.lang.Object> nestableTypes
           
protected  java.util.Set<EventType> optionalDeepSupertypes
           
protected  EventType[] optionalSuperTypes
           
protected  EventPropertyDescriptor[] propertyDescriptors
           
protected  java.util.Map<java.lang.String,EventPropertyGetter> propertyGetterCache
           
protected  java.util.Map<java.lang.String,PropertySetDescriptorItem> propertyItems
           
protected  java.lang.String[] propertyNames
           
protected  java.lang.String startTimestampPropertyName
           
protected  java.lang.String typeName
           
 
Constructor Summary
BaseNestableEventType(EventTypeMetadata metadata, java.lang.String typeName, int eventTypeId, EventAdapterService eventAdapterService, java.util.Map<java.lang.String,java.lang.Object> propertyTypes, EventType[] optionalSuperTypes, java.util.Set<EventType> optionalDeepSupertypes, ConfigurationEventTypeWithSupertype typeConfig, EventTypeNestableGetterFactory getterFactory)
          Constructor takes a type name, map of property names and types, for use with nestable Map events.
 
Method Summary
 void addAdditionalProperties(java.util.Map<java.lang.String,java.lang.Object> typeMap, EventAdapterService eventAdapterService)
          Adds additional properties that do not yet exist on the given type.
 boolean equalsCompareType(EventType otherEventType)
           
 java.util.Iterator<EventType> getDeepSuperTypes()
          Returns iterator over all super types to event type, going up the hierarchy and including all Java interfaces (and their extended interfaces) and superclasses as EventType instances.
 java.lang.String getEndTimestampPropertyName()
          Returns the property name of the property providing the end timestamp value.
 java.lang.String getEqualsMessage(EventType otherType)
          Returns a message if the type, compared to this type, is not compatible in regards to the property numbers and types.
 int getEventTypeId()
          Returns the event type id assigned to the event type.
 FragmentEventType getFragmentType(java.lang.String propertyName)
          Returns the event type of the fragment that is the value of a property name or property expression.
 EventPropertyGetter getGetter(java.lang.String propertyName)
          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 indexedPropertyName)
          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 mappedPropertyName)
          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 propertyName)
          Get the type of an event property.
 java.lang.String getStartTimestampPropertyName()
          Returns the property name of the property providing the start timestamp value.
 EventType[] getSuperTypes()
          Returns an array of event types that are super to this event type, from which this event type inherited event properties.
 java.util.Map<java.lang.String,java.lang.Object> getTypes()
          Returns the name-type map of map properties, each value in the map can be a Class or a Map (for nested maps).
static java.lang.String isDeepEqualsProperties(java.lang.String otherName, java.util.Map<java.lang.String,java.lang.Object> setOne, java.util.Map<java.lang.String,java.lang.Object> setTwo)
          Compares two sets of properties and determines if they are the same, allowing for boxed/unboxed types, and nested map types.
 boolean isProperty(java.lang.String propertyName)
          Check that the given property name or property expression is valid for this event type, ie.
protected abstract  void postUpdateNestableTypes()
           
 
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
getCopyMethod, getReader, getWritableProperty, getWriteableProperties, getWriter, getWriter
 
Methods inherited from interface com.espertech.esper.client.EventType
getUnderlyingType
 

Field Detail

metadata

protected final EventTypeMetadata metadata

typeName

protected final java.lang.String typeName

eventAdapterService

protected final EventAdapterService eventAdapterService

optionalSuperTypes

protected final EventType[] optionalSuperTypes

optionalDeepSupertypes

protected final java.util.Set<EventType> optionalDeepSupertypes

eventTypeId

protected final int eventTypeId

getterFactory

protected final EventTypeNestableGetterFactory getterFactory

propertyNames

protected java.lang.String[] propertyNames

propertyDescriptors

protected EventPropertyDescriptor[] propertyDescriptors

propertyItems

protected final java.util.Map<java.lang.String,PropertySetDescriptorItem> propertyItems

propertyGetterCache

protected java.util.Map<java.lang.String,EventPropertyGetter> propertyGetterCache

nestableTypes

protected java.util.Map<java.lang.String,java.lang.Object> nestableTypes

startTimestampPropertyName

protected java.lang.String startTimestampPropertyName

endTimestampPropertyName

protected java.lang.String endTimestampPropertyName
Constructor Detail

BaseNestableEventType

public BaseNestableEventType(EventTypeMetadata metadata,
                             java.lang.String typeName,
                             int eventTypeId,
                             EventAdapterService eventAdapterService,
                             java.util.Map<java.lang.String,java.lang.Object> propertyTypes,
                             EventType[] optionalSuperTypes,
                             java.util.Set<EventType> optionalDeepSupertypes,
                             ConfigurationEventTypeWithSupertype typeConfig,
                             EventTypeNestableGetterFactory getterFactory)
Constructor takes a type name, map of property names and types, for use with nestable Map events.

Parameters:
typeName - is the event type name used to distinquish map types that have the same property types, empty string for anonymous maps, or for insert-into statements generating map events the stream name
propertyTypes - is pairs of property name and type
eventAdapterService - is required for access to objects properties within map values
optionalSuperTypes - the supertypes to this type if any, or null if there are no supertypes
optionalDeepSupertypes - the deep supertypes to this type if any, or null if there are no deep supertypes
metadata - event type metadata
Method Detail

postUpdateNestableTypes

protected abstract void postUpdateNestableTypes()

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

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

getStartTimestampPropertyName

public java.lang.String getStartTimestampPropertyName()
Description copied from interface: EventType
Returns the property name of the property providing the start timestamp value.

Specified by:
getStartTimestampPropertyName in interface EventType
Returns:
start timestamp property name

getEndTimestampPropertyName

public java.lang.String getEndTimestampPropertyName()
Description copied from interface: EventType
Returns the property name of the property providing the end timestamp value.

Specified by:
getEndTimestampPropertyName in interface EventType
Returns:
end timestamp property name

getPropertyType

public final java.lang.Class getPropertyType(java.lang.String propertyName)
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:
propertyName - is the property name or property expression
Returns:
type of the property, the unboxed or the boxed type.

getGetter

public EventPropertyGetter getGetter(java.lang.String propertyName)
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:
propertyName - 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 mappedPropertyName)
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:
mappedPropertyName - 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 indexedPropertyName)
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:
indexedPropertyName - is the property name
Returns:
a getter that can be used to obtain property values for event instances of the same event type

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 propertyName)
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:
propertyName - is the property name or property expression to check
Returns:
true if exists, false if not

getSuperTypes

public EventType[] getSuperTypes()
Description copied from interface: EventType
Returns an array of event types that are super to this event type, from which this event type inherited event properties.

For Java bean instances underlying the event this method returns the event types for all superclasses extended by the Java bean and all interfaces implemented by the Java bean.

Specified by:
getSuperTypes in interface EventType
Returns:
an array of event types

getDeepSuperTypes

public java.util.Iterator<EventType> getDeepSuperTypes()
Description copied from interface: EventType
Returns iterator over all super types to event type, going up the hierarchy and including all Java interfaces (and their extended interfaces) and superclasses as EventType instances.

Specified by:
getDeepSuperTypes in interface EventType
Returns:
iterator of event types represeting all superclasses and implemented interfaces, all the way up to java.lang.Object but excluding java.lang.Object itself

getTypes

public java.util.Map<java.lang.String,java.lang.Object> getTypes()
Returns the name-type map of map properties, each value in the map can be a Class or a Map (for nested maps).

Returns:
is the property name and types

addAdditionalProperties

public void addAdditionalProperties(java.util.Map<java.lang.String,java.lang.Object> typeMap,
                                    EventAdapterService eventAdapterService)
Adds additional properties that do not yet exist on the given type.
Parameters:
typeMap - properties to add
eventAdapterService - for resolving further map event types that are property types

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.

isDeepEqualsProperties

public static java.lang.String isDeepEqualsProperties(java.lang.String otherName,
                                                      java.util.Map<java.lang.String,java.lang.Object> setOne,
                                                      java.util.Map<java.lang.String,java.lang.Object> setTwo)
Compares two sets of properties and determines if they are the same, allowing for boxed/unboxed types, and nested map types.

Parameters:
setOne - is the first set of properties
setTwo - is the second set of properties
otherName - name of the type compared to
Returns:
null if the property set is equivalent or message if not

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

getMetadata

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

Specified by:
getMetadata in interface EventTypeSPI
Returns:
type metadata

getFragmentType

public FragmentEventType getFragmentType(java.lang.String propertyName)
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:
propertyName - is the name of the property to return the fragment event type
Returns:
fragment event type of the property

getEqualsMessage

public java.lang.String getEqualsMessage(EventType otherType)
Returns a message if the type, compared to this type, is not compatible in regards to the property numbers and types.

Parameters:
otherType - to compare to
Returns:
message

equalsCompareType

public boolean equalsCompareType(EventType otherEventType)
Specified by:
equalsCompareType in interface EventTypeSPI

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