Class 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

      Constructors 
      Constructor Description
      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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      Event defaultValue()
      Get the default value for Event field type.
      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 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>
      • defaultValue

        public Event defaultValue()
        Get the default value for Event field type.
        Specified by:
        defaultValue in class FieldType<Event>
        Returns:
        An empty event