edu.rice.cs.drjava.ui.predictive
Class PredictiveInputModel.RegExStrategy<X extends Comparable<? super X>>

java.lang.Object
  extended by edu.rice.cs.drjava.ui.predictive.PredictiveInputModel.RegExStrategy<X>
All Implemented Interfaces:
PredictiveInputModel.MatchingStrategy<X>
Enclosing class:
PredictiveInputModel<T extends Comparable<? super T>>

public static class PredictiveInputModel.RegExStrategy<X extends Comparable<? super X>>
extends Object
implements PredictiveInputModel.MatchingStrategy<X>

Matching based on string regular expressions.


Constructor Summary
PredictiveInputModel.RegExStrategy()
           
 
Method Summary
 int compare(X item1, X item2, PredictiveInputModel<X> pim)
          Compare the two items and return -1, 0, or 1 if item1 is less than, equal to, or greater than item2.
 boolean equivalent(X item1, X item2, PredictiveInputModel<X> pim)
          Returns true if the two items are equivalent under this matching strategy.
 String force(X item, String mask)
          Force the mask to fit this entry.
 String getExtendedSharedMask(List<X> items, PredictiveInputModel<X> pim)
          Returns the mask extended by the shared extension.
 X getLongestMatch(X item, List<X> items, PredictiveInputModel<X> pim)
          Returns the item from the list that is the longest match.
 String getSharedMaskExtension(List<X> items, PredictiveInputModel<X> pim)
          Returns the shared mask extension for the list of items.
 boolean isMatch(X item, PredictiveInputModel<X> pim)
          Returns true if the item is a match.
 boolean isPerfectMatch(X item, PredictiveInputModel<X> pim)
          Returns true if the item is perfect a match.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PredictiveInputModel.RegExStrategy

public PredictiveInputModel.RegExStrategy()
Method Detail

toString

public String toString()
Overrides:
toString in class Object

isMatch

public boolean isMatch(X item,
                       PredictiveInputModel<X> pim)
Description copied from interface: PredictiveInputModel.MatchingStrategy
Returns true if the item is a match.

Specified by:
isMatch in interface PredictiveInputModel.MatchingStrategy<X extends Comparable<? super X>>
Parameters:
item - item to check
pim - predictive input model
Returns:
true if the item is a match

isPerfectMatch

public boolean isPerfectMatch(X item,
                              PredictiveInputModel<X> pim)
Description copied from interface: PredictiveInputModel.MatchingStrategy
Returns true if the item is perfect a match.

Specified by:
isPerfectMatch in interface PredictiveInputModel.MatchingStrategy<X extends Comparable<? super X>>
Parameters:
item - item to check
pim - predictive input model
Returns:
true if the item is a match

equivalent

public boolean equivalent(X item1,
                          X item2,
                          PredictiveInputModel<X> pim)
Description copied from interface: PredictiveInputModel.MatchingStrategy
Returns true if the two items are equivalent under this matching strategy.

Specified by:
equivalent in interface PredictiveInputModel.MatchingStrategy<X extends Comparable<? super X>>
Parameters:
item1 - first item
item2 - second item
pim - predictive input model
Returns:
true if equivalent

compare

public int compare(X item1,
                   X item2,
                   PredictiveInputModel<X> pim)
Description copied from interface: PredictiveInputModel.MatchingStrategy
Compare the two items and return -1, 0, or 1 if item1 is less than, equal to, or greater than item2.

Specified by:
compare in interface PredictiveInputModel.MatchingStrategy<X extends Comparable<? super X>>
Parameters:
item1 - first item
item2 - second item
pim - predictive input model
Returns:
-1, 0, or 1

getLongestMatch

public X getLongestMatch(X item,
                         List<X> items,
                         PredictiveInputModel<X> pim)
Description copied from interface: PredictiveInputModel.MatchingStrategy
Returns the item from the list that is the longest match.

Specified by:
getLongestMatch in interface PredictiveInputModel.MatchingStrategy<X extends Comparable<? super X>>
Parameters:
item - target item
items - list with items
pim - predictive input model
Returns:
longest match

getSharedMaskExtension

public String getSharedMaskExtension(List<X> items,
                                     PredictiveInputModel<X> pim)
Description copied from interface: PredictiveInputModel.MatchingStrategy
Returns the shared mask extension for the list of items.

Specified by:
getSharedMaskExtension in interface PredictiveInputModel.MatchingStrategy<X extends Comparable<? super X>>
Parameters:
items - items for which the mask extension should be generated
pim - predictive input model
Returns:
the shared mask extension

getExtendedSharedMask

public String getExtendedSharedMask(List<X> items,
                                    PredictiveInputModel<X> pim)
Description copied from interface: PredictiveInputModel.MatchingStrategy
Returns the mask extended by the shared extension.

Specified by:
getExtendedSharedMask in interface PredictiveInputModel.MatchingStrategy<X extends Comparable<? super X>>
Parameters:
items - items for which the mask extension should be generated
pim - predictive input model
Returns:
the extended shared mask

force

public String force(X item,
                    String mask)
Description copied from interface: PredictiveInputModel.MatchingStrategy
Force the mask to fit this entry. The matching strategies that accept line numbers can combine the current item with the line number. Other strategies just return the current item.

Specified by:
force in interface PredictiveInputModel.MatchingStrategy<X extends Comparable<? super X>>
Returns:
forced string