|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdanbikel.lisp.Sexp
danbikel.lisp.SexpList
danbikel.parser.SubcatList
public class SubcatList
Implements subcats where requirements need to be met in the order in which they are added to this subcat (the strictest form of a subcat). The only loosening of restrictions in this implementation of a subcat is that nonterminals are stripped of any gap augmentations before added to this subcat frame.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class danbikel.lisp.SexpList |
---|
SexpList.HashCache |
Field Summary |
---|
Fields inherited from class danbikel.lisp.SexpList |
---|
emptyList |
Constructor Summary | |
---|---|
SubcatList()
Construct a new empty subcat list. |
|
SubcatList(SexpList list)
Constructs a new subcat list from the requirements in the specified SexpList . |
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. |
Subcat |
add(Symbol requirement)
Adds the specified requirement to this subcat list. |
boolean |
addAll(SexpList list)
Adds the requirements ( Symbol objects) of list
to this subcat list. |
void |
become(Subcat other)
Causes this subcat to be equal to the specified subcat by copying the specified subcat's data to this subcat. |
int |
canonicalize(Map canonical)
This method does nothing and returns -1, as no internal data to this class can be canonicalized. |
boolean |
contains(Symbol requirement)
Returns true if this subcat frame contains the
specified requirement. |
Event |
copy()
Returns a deep copy of this event of the same run-time type. |
boolean |
empty()
Returns true if all requirements of this subcat frame have
been met. |
void |
ensureCapacity(int type,
int size)
As Subcat objects only support requirements of a single
type (Symbol ), this method is an alias for
SexpList.ensureCapacity(int) . |
boolean |
equals(Object obj)
Returns true if and only if the specified object is an
instance of SubcatList whose underlying list is equal
to that of this object, as determined by SexpList.equals(Object) . |
Sexp |
get(int index)
Gets the Sexp at the specified index. |
Object |
get(int type,
int index)
An alias for SexpList.get(int) . |
Subcat |
getCanonical(boolean copyInto,
Map<Subcat,Subcat> map)
Returns a canonical instance of this object using the specified map (optional operation). |
Class |
getClass(int type)
This method returns the one class that Subcat objects
need to support: Symbol.class . |
int |
numComponents()
An alias for SexpList.size . |
int |
numComponents(int type)
An alias for SexpList.size . |
int |
numTypes()
Returns 1 ( Subcat objects only support Symbol
objects). |
void |
readExternal(ObjectInput in)
Reads this object from an ObjectInput instance. |
boolean |
remove(Symbol requirement)
Removes the specified requirement from this subcat list, if possible. |
Sexp |
toSexp()
Returns a list view of the information contained in this subcat, such that an equivalent subcat would result if a new Subcat object of this run-time type were constructed
and its Subcat.addAll(SexpList) method were invoked with the
list returned by this method. |
int |
typeIndex(Class cl)
Returns 0 if the specified class is equal to Symbol.class , -1 otherwise. |
protected boolean |
validRequirement(Symbol requirement)
A method to check if the specified requirement is valid. |
void |
writeExternal(ObjectOutput out)
Writes this object to an ObjectOutput instance. |
Methods inherited from class danbikel.lisp.SexpList |
---|
add, add, addAll, clear, contains, deepCopy, ensureCapacity, first, getCanonical, getChildLabel, hashCode, indexOf, isAllSymbols, isList, isSymbol, iterator, last, length, listAt, remove, reverse, set, setChildLabel, size, symbolAt, toString, trimToSize, trimToSizeRecursive |
Methods inherited from class danbikel.lisp.Sexp |
---|
getCanonical, list, main, read, read, read, symbol |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface danbikel.parser.Subcat |
---|
hashCode, iterator, size |
Methods inherited from interface danbikel.parser.MutableEvent |
---|
clear, ensureCapacity |
Constructor Detail |
---|
public SubcatList()
public SubcatList(SexpList list)
SexpList
.
list
- the list of requirements from which to construct this
subcat listMethod Detail |
---|
public MutableEvent add(Object obj)
MutableEvent
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).
add
in interface MutableEvent
public MutableEvent add(int type, Object obj)
MutableEvent
this.typeIndex(obj.getClass()) == typemust 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).
add
in interface MutableEvent
protected boolean validRequirement(Symbol requirement)
Training.gapAugmentation()
or a symbol for which
Training.isArgumentFast(Symbol)
returns true
.
A subclass may override this method to allow for new or different
valid requirements.
requirement
- the requirement to test
public Subcat add(Symbol requirement)
requirement
is a nonterminal containing a gap
augmentation, the augmentation is removed before the requirement is added.
Efficiency note: The requirement is added to the beginning
of the internal list of this object--an O(n) operation--so as to
make the running time of remove(Symbol)
O(1). The preferred
method of construction of this type of subcat is via the
addAll(SexpList)
method, which operates in time linear to
the size of the specified list.
add
in interface Subcat
requirement
- the requirement to add
Subcat
objectTraining.defaultArgAugmentation()
,
Training.gapAugmentation()
,
Training.isArgumentFast(Symbol)
public boolean addAll(SexpList list)
Symbol
objects) of list
to this subcat list. Functionally, the order of elements in
list
is preserved, in that its first element will be the
first requirement of this subcat (provided that this subcat is empty
when this method is invoked).
addAll
in interface Subcat
addAll
in class SexpList
list
- the elements to be added at the end of this list
public boolean remove(Symbol requirement)
remove
in interface Subcat
requirement
- the requirement to remove from this subcat list
true
if the specified requirement was the next
requirement in this subcat and was removed, false
otherwiseSubcat.contains(Symbol)
public boolean empty()
Subcat
true
if all requirements of this subcat frame have
been met. This method should return true
if and only if
size() == 0
.
empty
in interface Subcat
public boolean contains(Symbol requirement)
Subcat
true
if this subcat frame contains the
specified requirement.
contains
in interface Subcat
requirement
- the requirement for which membership in this
subcat is to be checked
true
if this subcat contains requirement
,
that is, returns true
if and only if Subcat.remove(Symbol)
would remove the specified symbol from this subcatpublic boolean equals(Object obj)
true
if and only if the specified object is an
instance of SubcatList
whose underlying list is equal
to that of this object, as determined by SexpList.equals(Object)
.
equals
in interface Event
equals
in interface Subcat
equals
in class SexpList
obj
- the object to test for equality with this list
AbstractList.equals(java.lang.Object)
public Event copy()
Event
copy
in interface Event
public Subcat getCanonical(boolean copyInto, Map<Subcat,Subcat> map)
Subcat
getCanonical
in interface Subcat
copyInto
- specifies whether to copy this subcat before inserting
into the canonical mapmap
- the reflexive map to use for canonicalization: the key-value
pair of (this, this
) should be added to map
if this object is not already a key in map
public Sexp get(int index)
SexpList
Sexp
at the specified index.
get
in class SexpList
index
- the index of the list element to be retrieved
Sexp
at the specified index.public Class getClass(int type)
Subcat
objects
need to support: Symbol.class
.
getClass
in interface Event
Class
) associated with the specified
type indexpublic int typeIndex(Class cl)
Symbol.class
, -1 otherwise.
typeIndex
in interface Event
public int numTypes()
Subcat
objects only support Symbol
objects).
numTypes
in interface Event
public int numComponents()
SexpList.size
.
numComponents
in interface Event
public int numComponents(int type)
SexpList.size
.
numComponents
in interface Event
public Object get(int type, int index)
SexpList.get(int)
.
get
in interface Event
public int canonicalize(Map canonical)
canonicalize
in interface Event
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 canonicalizationpublic void ensureCapacity(int type, int size)
Subcat
objects only support requirements of a single
type (Symbol
), this method is an alias for
SexpList.ensureCapacity(int)
.
ensureCapacity
in interface MutableEvent
type
- the type of underlying abstract list for which to pre-allocate
spacesize
- the size to pre-allocate for the specified type of abstract
listpublic Sexp toSexp()
Subcat
Subcat
object of this run-time type were constructed
and its Subcat.addAll(SexpList)
method were invoked with the
list returned by this method.
toSexp
in interface SexpConvertible
toSexp
in interface Subcat
public void become(Subcat other)
Subcat
become
in interface Subcat
other
- the subcat that this subcat is to becomepublic void writeExternal(ObjectOutput out) throws IOException
SexpList
ObjectOutput
instance.
writeExternal
in interface Externalizable
writeExternal
in class SexpList
out
- the object stream to which to write an object of this class
IOException
- if the underlying write operation throws an
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
SexpList
ObjectInput
instance.
readExternal
in interface Externalizable
readExternal
in class SexpList
in
- the object stream from which to read objects of this class
IOException
- if the underlying read operation throws an
IOException
ClassNotFoundException
- if the underlying read operation throws
an ClassNotFoundException
|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |