Class EventParser


  • public class EventParser
    extends java.lang.Object
    Provides the functionality to parse String objects into Apama Event objects, for any EventType registered with the parser.

    Threading: The EventParser is thread-safe.

    See the EventType documentation for an example of how event strings may be parsed using this class.

    • Constructor Detail

      • EventParser

        public EventParser​(EventType... types)
        Constructor to create an EventParser.
        Parameters:
        types - Optional parameter for automatically registering a set of initial event types with the parser.
    • Method Detail

      • getDefaultParser

        @Deprecated
        public static EventParser getDefaultParser()
        Deprecated.
        This method is deprecated - create a new EventParser instance using EventParser(params EventType[]) instead")
        Returns:
        the singleton EventParser instance.
      • registerEventType

        public void registerEventType​(EventType type)
        Register the given event type as being a valid type this parser recognizes.
        Parameters:
        type - the event type to parse
      • getType

        public FieldType<?> getType​(java.lang.String typeName)
        Retrieve a Type by name.
        Parameters:
        typeName - The name of the Type
        Returns:
        type or null if unknown
      • registerType

        public void registerType​(FieldType<?> fieldType)
        Register the given field type as being a valid type this parser recognizes.
        Parameters:
        type - the field type to register
      • deregisterEventType

        public void deregisterEventType​(EventType type)
        Deregister the given event type from being a valid type this parser. recognizes.
        Parameters:
        type - the event type to parse
      • getEventType

        public EventType getEventType​(java.lang.String name)
        Retrieve an Event Type by name.
        Parameters:
        name - the name of the EventType
        Returns:
        the EventType or null if unknown
      • parse

        public Event parse​(java.lang.String eventString)
                    throws ParserRuntimeException
        Parse an event string.
        Parameters:
        eventString - the string representation of the event
        Returns:
        The resulting Event object
        Throws:
        ParserRuntimeException - if the event string is invalid, or if the EventType of the specified event has not been registered with this EventParser.
      • getTypeName

        public static java.lang.String getTypeName​(java.lang.String eventString)
        Method to extract and return the event type name from an event string. Note that this method will NOT parse the entire event, only the name will be extracted from the eventString.
        Parameters:
        eventString - the event string to process
        Returns:
        the type name or null if the name cannot be extracted