Parsing Engine

danbikel.parser
Interface MutableEvent

All Superinterfaces:
Event, Serializable
All Known Subinterfaces:
Subcat
All Known Implementing Classes:
BrokenSubcatBag, SexpEvent, SexpSubcatEvent, SubcatBag, SubcatList

public interface MutableEvent
extends Event

Provides additional methods to those of Event that permit modification of the event object. For efficiency, it is recommended that implementations of this interface implement the optional ensureCapacity methods, which will allow efficient re-use of one MutableEvent object for lookups in a collection of Event objects.


Method Summary
 MutableEvent add(int type, Object obj)
          Adds the specified object of the specified type to this event.
 MutableEvent add(Object obj)
          Adds the specified object to this event.
 void clear()
          Clears all components from this event.
 void ensureCapacity(int size)
          Pre-allocates space for all abstract lists in this event (optional operation).
 void ensureCapacity(int type, int size)
          Pre-allocates space for the abstract list of the specified type (optional operation).
 
Methods inherited from interface danbikel.parser.Event
canonicalize, copy, equals, get, getClass, hashCode, numComponents, numComponents, numTypes, typeIndex
 

Method Detail

add

MutableEvent add(Object obj)
Adds the specified object to this event. The specified object must be of a type that this event is capable of collecting; that is,
 this.typeIndex(obj.getClass())
 
must not return -1.

If an implementation of this interface collects components that are primitive type values, then these values should be wrapped in their corresponding wrapper classes. For example, if an implementation of this interface accepts int values, they should be passed as Integer objects to this method. At present, an Event implementation cannot be designed accept both a primitive type and its associated wrapper class' type (this is, of course, not a serious limitation).

Returns:
this object
Throws:
ClassCastException - if this event does not support the run-time type of the specified object

add

MutableEvent add(int type,
                 Object obj)
Adds the specified object of the specified type to this event. The specified object must be of the type specified; that is, the expression
 this.typeIndex(obj.getClass()) == type
 
must be true.

If an implementation of this interface collects components that are primitive type values, then these values should be wrapped in their corresponding wrapper classes. For example, if an implementation of this interface accepts int values, they should be passed as an Integer objects to this method. At present, an Event implementation cannot be designed accept both a primitive type and its associated wrapper class' type (this is, of course, not a serious limitation).

Returns:
this object
Throws:
ClassCastException - if this event does not support the run-time type of the specified object or if the specified object is not of the specified type

ensureCapacity

void ensureCapacity(int size)
Pre-allocates space for all abstract lists in this event (optional operation).

Parameters:
size - the size to pre-allocate for all abstract lists of this event

ensureCapacity

void ensureCapacity(int type,
                    int size)
Pre-allocates space for the abstract list of the specified type (optional operation).

Parameters:
type - the type of underlying abstract list for which to pre-allocate space
size - the size to pre-allocate for the specified type of abstract list

clear

void clear()
Clears all components from this event.


Parsing Engine

Author: Dan Bikel.