org.fife.ui.autocomplete
Class AbstractCompletionProvider

java.lang.Object
  extended by org.fife.ui.autocomplete.CompletionProviderBase
      extended by org.fife.ui.autocomplete.AbstractCompletionProvider
All Implemented Interfaces:
CompletionProvider
Direct Known Subclasses:
DefaultCompletionProvider

public abstract class AbstractCompletionProvider
extends CompletionProviderBase

A base class for completion providers. Completions are kept in a sorted list. To get the list of completions that match a given input, a binary search is done to find the first matching completion, then all succeeding completions that also match are also returned.

Version:
1.0
Author:
Robert Futrell

Field Summary
protected  Comparator comparator
          Compares a Completion against a String.
protected  List completions
          The completions this provider is aware of.
 
Fields inherited from class org.fife.ui.autocomplete.CompletionProviderBase
EMPTY_STRING
 
Constructor Summary
AbstractCompletionProvider()
          Constructor.
 
Method Summary
 void addCompletion(Completion c)
          Adds a single completion to this provider.
 void addCompletions(List completions)
          Adds Completions to this provider.
protected  void addWordCompletions(String[] words)
          Adds simple completions for a list of words.
protected  void checkProviderAndAdd(Completion c)
           
 void clear()
          Removes all completions from this provider.
 List getCompletionByInputText(String inputText)
          Returns a list of Completions in this provider with the specified input text.
protected  List getCompletionsImpl(JTextComponent comp)
          Does the dirty work of creating a list of completions.
 boolean removeCompletion(Completion c)
          Removes the specified completion from this provider.
 
Methods inherited from class org.fife.ui.autocomplete.CompletionProviderBase
clearParameterizedCompletionParams, getCompletions, getListCellRenderer, getParameterChoicesProvider, getParameterListEnd, getParameterListSeparator, getParameterListStart, getParent, isAutoActivateOkay, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParameterizedCompletionParams, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.fife.ui.autocomplete.CompletionProvider
getAlreadyEnteredText, getCompletionsAt, getParameterizedCompletions
 

Field Detail

completions

protected List completions
The completions this provider is aware of. Subclasses should ensure that this list is sorted alphabetically (case-insensitively).


comparator

protected Comparator comparator
Compares a Completion against a String.

Constructor Detail

AbstractCompletionProvider

public AbstractCompletionProvider()
Constructor.

Method Detail

addCompletion

public void addCompletion(Completion c)
Adds a single completion to this provider. If you are adding multiple completions to this provider, for efficiency reasons please consider using addCompletions(List) instead.

Parameters:
c - The completion to add.
Throws:
IllegalArgumentException - If the completion's provider isn't this CompletionProvider.
See Also:
addCompletions(List), removeCompletion(Completion), clear()

addCompletions

public void addCompletions(List completions)
Adds Completions to this provider.

Parameters:
completions - The completions to add. This cannot be null.
Throws:
IllegalArgumentException - If a completion's provider isn't this CompletionProvider.
See Also:
addCompletion(Completion), removeCompletion(Completion), clear()

addWordCompletions

protected void addWordCompletions(String[] words)
Adds simple completions for a list of words.

Parameters:
words - The words.
See Also:
BasicCompletion

checkProviderAndAdd

protected void checkProviderAndAdd(Completion c)

clear

public void clear()
Removes all completions from this provider. This does not affect the parent CompletionProvider, if there is one.

See Also:
addCompletion(Completion), addCompletions(List), removeCompletion(Completion)

getCompletionByInputText

public List getCompletionByInputText(String inputText)
Returns a list of Completions in this provider with the specified input text.

Parameters:
inputText - The input text to search for.
Returns:
A list of Completions, or null if there are no matching Completions.

getCompletionsImpl

protected List getCompletionsImpl(JTextComponent comp)
Does the dirty work of creating a list of completions.

Specified by:
getCompletionsImpl in class CompletionProviderBase
Parameters:
comp - The text component to look in.
Returns:
The list of possible completions, or an empty list if there are none.

removeCompletion

public boolean removeCompletion(Completion c)
Removes the specified completion from this provider. This method will not remove completions from the parent provider, if there is one.

Parameters:
c - The completion to remove.
Returns:
true if this provider contained the specified completion.
See Also:
clear(), addCompletion(Completion), addCompletions(List)


Copyright © 2003-2011. All Rights Reserved.