org.lwes.db
Class EventTemplateDB

java.lang.Object
  extended by org.lwes.db.EventTemplateDB

public class EventTemplateDB
extends java.lang.Object

Provides type checking for the event system. Also provides a place for globally accessible information.

Author:
Anthony Molinaro, Michael P. Lum

Constructor Summary
EventTemplateDB()
          This is the EventTemplateDB constructor.
 
Method Summary
 boolean addEvent(java.lang.String anEventName)
          Add an Event to the EventTemplateDB
 boolean addEventAttribute(java.lang.String anEventName, java.lang.String anAttributeName, java.lang.String anAttributeType)
          Add an attribute to an Event in the EventTemplateDB
 boolean checkForAttribute(java.lang.String anEventName, java.lang.String anAttributeName)
          Checks to see if an attribute anAttributeName exists for the event anEventName
 boolean checkForEvent(java.lang.String anEventName)
          Checks to see if an Event exists in the EventTemplateDB
 boolean checkForType(java.lang.String aTypeName)
          Returns true if the type given by aTypeName is a valid type in the DB.
 boolean checkTypeForAttribute(java.lang.String anEventName, java.lang.String anAttributeName, java.lang.Object anAttributeValue)
          Checks to see if the type of an attribute is proper.
 boolean checkTypeForAttribute(java.lang.String anEventName, java.lang.String anAttributeName, java.lang.String anAttributeType)
          Checks to see if the type of an attribute is proper.
 BaseType getBaseTypeForObjectAttribute(java.lang.String eventName, java.lang.String attributeName, java.lang.Object attributeValue)
          Given an Object which is the attribute value of the attribute attributeName of event eventName, return the internal representation (i.e.
 java.util.Map<java.lang.String,BaseType> getBaseTypesForEvent(java.lang.String eventName)
          Returns the base types for this event
 java.io.File getESFFile()
          Gets the ESF file, in case you want to look at it
 java.io.InputStream getESFInputStream()
          Ges the ESF InputStream
 java.util.Enumeration<java.lang.String> getEventNames()
          Returns an enumeration of all defined events
 boolean initialize()
          Initializes the EventTemplateDB, assumes that setESFFile() has been called.
 java.lang.Object parseAttribute(java.lang.String anEventName, java.lang.String anAttributeName, java.lang.String stringAttributeValue)
          Parses the string representation of an event attribute into the appropriate objectt.
 void setESFFile(java.io.File anEsfFile)
          Sets the Event Specification file for this system
 void setESFInputStream(java.io.InputStream esfInputStream)
          Sets the Event Specification file as an InputStream
 java.lang.String toHtmlString()
          Returns a HTML rendering of the EventTemplateDB
 java.lang.String toString()
          Returns a rather long string Representation of the EventTemplateDB
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventTemplateDB

public EventTemplateDB()
This is the EventTemplateDB constructor.

Method Detail

setESFFile

public void setESFFile(java.io.File anEsfFile)
Sets the Event Specification file for this system

Parameters:
anEsfFile - the ESF file for this system.

getESFFile

public java.io.File getESFFile()
Gets the ESF file, in case you want to look at it

Returns:
the ESF file used in this system.

setESFInputStream

public void setESFInputStream(java.io.InputStream esfInputStream)
Sets the Event Specification file as an InputStream

Parameters:
esfInputStream - the InputStream representing an ESF file

getESFInputStream

public java.io.InputStream getESFInputStream()
Ges the ESF InputStream

Returns:
the ESF InputStream used in the system

initialize

public boolean initialize()
Initializes the EventTemplateDB, assumes that setESFFile() has been called.

Returns:
true if the EventTemplateDB initializes correctly; false if it does not. false means the event system is unable to perform validation

addEvent

public boolean addEvent(java.lang.String anEventName)
Add an Event to the EventTemplateDB

Parameters:
anEventName - the name of the Event to add
Returns:
true if the event was added, false if it was not

addEventAttribute

public boolean addEventAttribute(java.lang.String anEventName,
                                 java.lang.String anAttributeName,
                                 java.lang.String anAttributeType)
Add an attribute to an Event in the EventTemplateDB

Parameters:
anEventName - the name of the event to add this attribute to
anAttributeName - the name of the attribute to add
anAttributeType - the type of the attribute, should be the name of the type given in the ESF Specification.
Returns:
true if the attribute can be added, false if it can not.

getEventNames

public java.util.Enumeration<java.lang.String> getEventNames()
Returns an enumeration of all defined events

Returns:
an enumeration of all defined events

checkForType

public boolean checkForType(java.lang.String aTypeName)
Returns true if the type given by aTypeName is a valid type in the DB.

Parameters:
aTypeName - a type name according to the ESF Specification
Returns:
true if the type exists in the DB, false otherwise

checkForEvent

public boolean checkForEvent(java.lang.String anEventName)
Checks to see if an Event exists in the EventTemplateDB

Parameters:
anEventName - the name of the event to check the existence of
Returns:
true if the event with the name anEventName exists in the EventTemplateDB, false otherwise.

checkForAttribute

public boolean checkForAttribute(java.lang.String anEventName,
                                 java.lang.String anAttributeName)
Checks to see if an attribute anAttributeName exists for the event anEventName

Parameters:
anEventName - the name of an Event
anAttributeName - the name of an attribute of Event to check
Returns:
true if the attribute exists as a member of event, false otherwise

checkTypeForAttribute

public boolean checkTypeForAttribute(java.lang.String anEventName,
                                     java.lang.String anAttributeName,
                                     java.lang.Object anAttributeValue)
Checks to see if the type of an attribute is proper. (i.e. if the given attribute of the given event has the same type assigned to it as the type of the given objects value)

Parameters:
anEventName - the name of an Event.
anAttributeName - the name of the attribute whose type is being checked
anAttributeValue - the Object containing the possible value of the attribute.
Returns:
true if the event and attribute exist and if the type of the attribute matches the type assigned to this attribute in the EventTemplateDB, false otherwise.

checkTypeForAttribute

public boolean checkTypeForAttribute(java.lang.String anEventName,
                                     java.lang.String anAttributeName,
                                     java.lang.String anAttributeType)
Checks to see if the type of an attribute is proper. (i.e. if the given attribute of the given event has the same type assigned to it as the type given)

Parameters:
anEventName - the name of an Event.
anAttributeName - the name of the attribute whose type is being checked
anAttributeType - the String containing the possible type value of the attribute.
Returns:
true if the event and attribute exist and if the type of the attribute matches the type assigned to this attribute in the EventTemplateDB, false otherwise.

getBaseTypeForObjectAttribute

public BaseType getBaseTypeForObjectAttribute(java.lang.String eventName,
                                              java.lang.String attributeName,
                                              java.lang.Object attributeValue)
Given an Object which is the attribute value of the attribute attributeName of event eventName, return the internal representation (i.e. BaseType) of this Object

Parameters:
eventName - the name of an Event.
attributeName - the name of an attribute of eventName
attributeValue - the value of the attribute
Returns:
the BaseType representation of attributeValue

getBaseTypesForEvent

public java.util.Map<java.lang.String,BaseType> getBaseTypesForEvent(java.lang.String eventName)
Returns the base types for this event

Parameters:
eventName -
Returns:
a map of event fields to base types

parseAttribute

public java.lang.Object parseAttribute(java.lang.String anEventName,
                                       java.lang.String anAttributeName,
                                       java.lang.String stringAttributeValue)
Parses the string representation of an event attribute into the appropriate objectt.

Parameters:
anEventName - the name of an Event.
anAttributeName - the name of the attribute we are parsing
stringAttributeValue - a string representation of the value of the attribute given by anAttributeName.
Returns:
the object represented by the string stringAttributeValue

toHtmlString

public java.lang.String toHtmlString()
Returns a HTML rendering of the EventTemplateDB

Returns:
HTML string of the EventTemplateDB

toString

public java.lang.String toString()
Returns a rather long string Representation of the EventTemplateDB

Overrides:
toString in class java.lang.Object
Returns:
a string Representation of the EventTemplateDB