com.apama.event.parser
Class EventType

java.lang.Object
  extended by com.apama.event.parser.FieldType<Event>
      extended by com.apama.event.parser.EventType

public class EventType
extends FieldType<Event>

Represents the definition of an Apama event type, for which values are specified as Event objects. Each EventType consists of an event type name, and zero or more Field objects. Example usage can be found at the top level of this package.

Threading: The EventType class is not fully thread-safe, but once it has been initialized with all the required fields, it is safe to concurrently use it to parse and create event strings from any thread, provided fields are not added or removed from the event type (this would not happen in typical usage anyway).


Constructor Summary
EventType(java.lang.String name, Field<?>... fields)
          Create a new Event Type by specifying the name of the event and the FieldType of each of the event parameter.
 
Method Summary
 void addField(Field<?> field)
          Method to append extra field to the EventType.
<T> void
addField(java.lang.String name, FieldType<T> fieldType)
          Method to append extra field to the EventType.
 void assertAssignable(java.lang.Object c, java.lang.String fieldName)
          This method is intended for internal use only and may be removed at any time - do not use.
 boolean equals(java.lang.Object obj)
          equals if both objects has same field names/types
 boolean fieldExists(java.lang.String fieldName, FieldType<?> fieldType)
          Method to check if this EventType contains a field with name fieldName AND type fieldType.
 Field<?> getField(java.lang.String fieldName)
          Get a named field.
 java.lang.String[] getFieldNames()
          Method to retrieve the field names as String array for the event.
 int hashCode()
           
 Event parse(java.lang.String value)
          Convert a value of this type from the format used in Apama event strings, into an Event object.
 java.lang.String toString()
          Returns a String representation of the event type.
 
Methods inherited from class com.apama.event.parser.FieldType
format, getName, getTypeClass, newField
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventType

public EventType(java.lang.String name,
                 Field<?>... fields)
Create a new Event Type by specifying the name of the event and the FieldType of each of the event parameter.

Parameters:
name - The name of this type
fields - Array of field definitions for each event parameter
Method Detail

addField

public void addField(Field<?> field)
Method to append extra field to the EventType.

Parameters:
field - a new field to append to the eventType

addField

public <T> void addField(java.lang.String name,
                         FieldType<T> fieldType)
Method to append extra field to the EventType.

Parameters:
name - name of the field
fieldType - of the new field to be added

getFieldNames

public java.lang.String[] getFieldNames()
Method to retrieve the field names as String array for the event.

Returns:
fieldName array

getField

public Field<?> getField(java.lang.String fieldName)
Get a named field.

Parameters:
fieldName - The fieldName to check
Returns:
the Field object for the named field, or null if the name does not exist.

fieldExists

public boolean fieldExists(java.lang.String fieldName,
                           FieldType<?> fieldType)
Method to check if this EventType contains a field with name fieldName AND type fieldType.

Parameters:
fieldName - The fieldName to check
fieldType - The fieldType to match
Returns:
true if the fieldName exists with type fieldType. false otherwise.

assertAssignable

public void assertAssignable(java.lang.Object c,
                             java.lang.String fieldName)
Description copied from class: FieldType
This method is intended for internal use only and may be removed at any time - do not use.

Specified by:
assertAssignable in class FieldType<Event>

parse

public Event parse(java.lang.String value)
            throws ParserRuntimeException
Convert a value of this type from the format used in Apama event strings, into an Event object.

Overrides:
parse in class FieldType<Event>
Parameters:
value - the value to parse.
Returns:
an object specifying the value of the string that was parsed.
Throws:
ParserRuntimeException - If the specified value string cannot be parsed.

equals

public boolean equals(java.lang.Object obj)
equals if both objects has same field names/types

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a String representation of the event type. Note that this representation will use the Java toString() method to format the results, and is not valid monitorscript.

Overrides:
toString in class FieldType<Event>


Submit a bug or feature
Copyright (c) 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG