|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjchrest.lib.Pattern
jchrest.lib.ListPattern
public class ListPattern
The ListPattern is the primary datatype used to represent compound patterns within Chrest. A ListPattern holds an ordered list of instances of other pattern types. The ListPattern may optionally indicate that it cannot be extended by setting the _finished flag. Note that once a pattern is 'finished', it cannot be added to. TODO: Think about if ListPatterns can be embedded within ListPatterns - would have to look inside ListPattern to make the match.
Constructor Summary | |
---|---|
ListPattern()
|
|
ListPattern(Modality modality)
|
Method Summary | |
---|---|
void |
add(PrimitivePattern pattern)
Used in constructing instances by Pattern class. |
ListPattern |
append(ListPattern pattern)
Return a new ListPattern formed from the contents of this list pattern and the contents of the given pattern appended to it. |
ListPattern |
append(PrimitivePattern pattern)
Return a new ListPattern formed from the contents of this list pattern and the given PrimitivePattern appended to it. |
ListPattern |
clone()
Construct a copy of this pattern, so that it can be modified without affecting the original. |
boolean |
contains(PrimitivePattern given)
|
boolean |
equals(ListPattern pattern)
Two patterns are equal if they contain the same items. |
ListPattern |
getFirstItem()
Construct a new pattern containing just the first item in this one. |
PrimitivePattern |
getItem(int index)
Retrieve the indexed item from the list pattern. |
Modality |
getModality()
Accessor to retrieve the modality of the pattern. |
java.lang.String |
getModalityString()
Convert the modality into a string. |
boolean |
isAction()
Accessor method to check action modality. |
boolean |
isEmpty()
Check if the list pattern is empty, holding no patterns. |
boolean |
isFinished()
Accessor method to _finished property. |
static boolean |
isSameModality(ListPattern pattern1,
ListPattern pattern2)
Class level method to check if two patterns have the same modality. |
boolean |
isSimilarTo(ListPattern pattern,
int k)
Compare this list pattern with a given list pattern, returning true if the two share k or more items. |
boolean |
isVerbal()
Accessor method to check verbal modality. |
boolean |
isVisual()
Accessor method to check visual modality. |
java.util.Iterator<PrimitivePattern> |
iterator()
Support iteration over the items of a list pattern. |
boolean |
matches(Pattern givenPattern)
Two patterns match if they are both ListPatterns and this ListPattern is a presequence of given pattern. |
ListPattern |
remove(ListPattern pattern)
Return a new ListPattern forming the parts of this pattern without the matching elements of the given pattern. |
void |
setFinished()
Set the _finished property to true. |
void |
setModality(Modality modality)
Mutator to change modality of pattern. |
void |
setNotFinished()
Set the _finished property to false. |
int |
size()
Return the number of patterns held inside the list pattern. |
ListPattern |
sort(java.util.Comparator<PrimitivePattern> comparator)
Return a new list pattern with the items sorted using the given comparator. |
java.lang.String |
toString()
Render the list pattern as a string. |
Methods inherited from class jchrest.lib.Pattern |
---|
makeActionList, makeNumber, makeString, makeVerbalList, makeVerbalList, makeVisualList, makeVisualList |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ListPattern()
public ListPattern(Modality modality)
Method Detail |
---|
public void add(PrimitivePattern pattern)
Pattern
class.
Add pattern to list, unless the pattern is 'finished'.
public ListPattern clone()
clone
in class java.lang.Object
public int size()
public boolean isEmpty()
public PrimitivePattern getItem(int index)
public boolean isFinished()
public static boolean isSameModality(ListPattern pattern1, ListPattern pattern2)
public Modality getModality()
public void setModality(Modality modality)
public boolean isVisual()
public boolean isVerbal()
public boolean isAction()
public java.lang.String getModalityString()
public void setFinished()
public void setNotFinished()
public boolean equals(ListPattern pattern)
public boolean matches(Pattern givenPattern)
matches
in class Pattern
public ListPattern remove(ListPattern pattern)
public ListPattern append(ListPattern pattern)
public ListPattern append(PrimitivePattern pattern)
public ListPattern getFirstItem()
public java.lang.String toString()
toString
in class Pattern
public boolean contains(PrimitivePattern given)
public boolean isSimilarTo(ListPattern pattern, int k)
public ListPattern sort(java.util.Comparator<PrimitivePattern> comparator)
public java.util.Iterator<PrimitivePattern> iterator()
iterator
in interface java.lang.Iterable<PrimitivePattern>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |