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

java.lang.Object
  extended by edu.rice.cs.drjava.ui.predictive.PredictiveInputModel<T>

public class PredictiveInputModel<T extends Comparable<? super T>>
extends Object

Model class for predictive string input.


Nested Class Summary
static class PredictiveInputModel.FragmentLineNumStrategy<X extends Comparable<? super X>>
          Matching based on string fragments, supporting line numbers.
static class PredictiveInputModel.FragmentStrategy<X extends Comparable<? super X>>
          Matching based on string fragments.
static interface PredictiveInputModel.MatchingStrategy<X extends Comparable<? super X>>
          Strategy used for matching and mask extension.
static class PredictiveInputModel.PrefixLineNumStrategy<X extends Comparable<? super X>>
          Matching based on string prefix, supporting line numbers separated by :.
static class PredictiveInputModel.PrefixStrategy<X extends Comparable<? super X>>
          Matching based on string prefix.
static class PredictiveInputModel.RegExLineNumStrategy<X extends Comparable<? super X>>
          Matching based on string regular expressions, supporting line numbers.
static class PredictiveInputModel.RegExStrategy<X extends Comparable<? super X>>
          Matching based on string regular expressions.
 
Constructor Summary
PredictiveInputModel(boolean ignoreCase, PredictiveInputModel.MatchingStrategy<T> strategy, List<T> items)
          Create a new predictive input model.
PredictiveInputModel(boolean ignoreCase, PredictiveInputModel.MatchingStrategy<T> strategy, T... items)
          Create a new predictive input model.
PredictiveInputModel(boolean ignoreCase, PredictiveInputModel<T> pim)
          Create a new predictive input model.
 
Method Summary
 void extendMask(String extension)
          Extends the mask.
 void extendSharedMask()
          Extends the mask by the shared string.
 T getCurrentItem()
          Get currently selected item.
 List<T> getList()
          Returns a copy of the list of items.
 String getMask()
          Return the current mask.
 List<T> getMatchingItems()
          Get matching items.
 String getSharedMaskExtension()
          Returns the shared mask extension.
 void setCurrentItem(T item)
          Set currently selected item.
 void setList(List<T> items)
          Sets the list.
 void setList(PredictiveInputModel<T> pim)
          Sets the list.
 void setList(T... items)
          Sets the list
 void setMask(String mask)
          Set the current mask.
 void setStrategy(PredictiveInputModel.MatchingStrategy<T> strategy)
          Sets the strategy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PredictiveInputModel

public PredictiveInputModel(boolean ignoreCase,
                            PredictiveInputModel<T> pim)
Create a new predictive input model.

Parameters:
ignoreCase - true if case should be ignored
pim - other predictive input model

PredictiveInputModel

public PredictiveInputModel(boolean ignoreCase,
                            PredictiveInputModel.MatchingStrategy<T> strategy,
                            List<T> items)
Create a new predictive input model.

Parameters:
ignoreCase - true if case should be ignored
strategy - matching strategy to use
items - list of items

PredictiveInputModel

public PredictiveInputModel(boolean ignoreCase,
                            PredictiveInputModel.MatchingStrategy<T> strategy,
                            T... items)
Create a new predictive input model.

Parameters:
ignoreCase - true if case should be ignored
strategy - matching strategy to use
items - varargs/array of items
Method Detail

setStrategy

public void setStrategy(PredictiveInputModel.MatchingStrategy<T> strategy)
Sets the strategy


getList

public List<T> getList()
Returns a copy of the list of items.

Returns:
list of items

setList

public void setList(List<T> items)
Sets the list.

Parameters:
items - list of items

setList

public void setList(T... items)
Sets the list

Parameters:
items - varargs/array of items

setList

public void setList(PredictiveInputModel<T> pim)
Sets the list.

Parameters:
pim - other predictive input model

getMask

public String getMask()
Return the current mask.

Returns:
current mask

setMask

public void setMask(String mask)
Set the current mask.

Parameters:
mask - new mask

getCurrentItem

public T getCurrentItem()
Get currently selected item.

Returns:
currently selected item

setCurrentItem

public void setCurrentItem(T item)
Set currently selected item. Will select the item, or if the item does not match the mask, an item as closely preceding as possible.

Parameters:
item - currently selected item

getMatchingItems

public List<T> getMatchingItems()
Get matching items.

Returns:
list of matching items

getSharedMaskExtension

public String getSharedMaskExtension()
Returns the shared mask extension. The shared mask extension is the string that can be added to the mask such that the list of matching strings does not change.

Returns:
shared mask extension

extendMask

public void extendMask(String extension)
Extends the mask. This operation can only narrow the list of matching strings and is thus faster than setting the mask.

Parameters:
extension - string to append to mask

extendSharedMask

public void extendSharedMask()
Extends the mask by the shared string.