|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Event
Provides the specification for arbitrary event types, to be used
when collecting counts for and computing probabilities of arbitrary
events. Event
objects have to satisfy the rather
conflicting design goals of providing an abstraction for events
composed of arbitrarily-typed components, efficiency of access,
efficiency of storage and notational felicity when composing an
event. Therefore, the general contract of Event
objects is that they provide the means to store sequences of
different types of components, such that two Event
s
are guaranteed to be equal if components of the same type have been
added in the same order and are pairwise equal. Put another way,
Event
objects can be thought of abstractly as a
set of lists, with one list for each type of object they are
capable of collecting, where two Event
objects
are equal if all of their corresponding lists are equal. This contract
achieves notational convenience when composing an event, because
MutableEvent.add(Object)
will add the specified object to the
appropriate list. For example, if two MutableEvent
objects
event1
and event2
are composed via the following
code
event1.add(new Integer(2)).add("foo").add(new Integer(3)); event2.add("foo").add(new Integer(2)).add(new Integer(3));it is guaranteed that
event1.equals(event2)
will return
true
.
Event
objects must explicitly publish the run-time types of
objects they are capable of collecting, and these types may include
Object
, as well as primitive types. This publishing is
accomplished via the method getClass(int)
, which maps integers
in the range [0,numTypes()
) to Class
objects.
Method Summary | |
---|---|
int |
canonicalize(Map canonical)
Since events are typically read-only, this method will allow for canonicalization (or "unique-ifying") of the information contained in this event. |
Event |
copy()
Returns a deep copy of this event of the same run-time type. |
boolean |
equals(Object obj)
Returns true if and only if the following three
conditions are met:
the specified object is an instance of Event
the specified object supports the same and only the same types
of components as this Event object
the abstract lists of each type for this object and the
specified object are of equal length and are pairwise equal in
their items |
Object |
get(int type,
int index)
Gets the index th component of the
specified type from this event. |
Class |
getClass(int type)
Maps the specified integer to a type that this Event is
capable of collecting. |
int |
hashCode()
Returns the hash code for this event. |
int |
numComponents()
Gets the total number of components of this event. |
int |
numComponents(int type)
Gets the number of components of this event of a particular type. |
int |
numTypes()
Returns the number of component types capable of being collected by this Event implementation. |
int |
typeIndex(Class cl)
Returns the integer constant associated with the specified event component type, or -1 if this event does not support the specified class. |
Method Detail |
---|
Class getClass(int type)
Event
is
capable of collecting. Type indices are required to fill
the range [0, numTypes()
) for all types supported by an
Event
implementation.
Class
) associated with the specified
type indexint typeIndex(Class cl)
int numTypes()
Event
implementation.
int numComponents()
int numComponents(int type)
Object get(int type, int index)
index
th component of the
specified type from this event. If an implementation of this
interface supports primitive type values, then these values
should be wrapped in their corresponding wrapper classes. For example,
if an implementation collects int
values, then
these values should be returned by this method wrapped in
Integer
objects.
IndexOutOfBoundsException
- if
type
< 0 or if
type >= numTypes()
or if
index < 0
or if
index >= numComponents(type)
Event copy()
int canonicalize(Map canonical)
canonical
- a reflexive map of objecs representing event
information: for each unique key-value pair, the value is a
reference to the key
canonical
) or
-1 if this event was not even eligible for canonicalizationint hashCode()
hashCode
in class Object
boolean equals(Object obj)
true
if and only if the following three
conditions are met:
Event
Event
object
|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |