public abstract class AbstractCompletion extends Object implements Completion
Completion
implementations can extend this class. It remembers the
CompletionProvider that returns this completion, and also implements
Comparable, allowing such completions to be compared
lexicographically (ignoring case).
This implementation assumes the input text and replacement text are the
same value. It also returns the input text from its toString()
method (which is what DefaultListCellRenderer uses to render
objects). Subclasses that wish to override any of this behavior can simply
override the corresponding method(s) needed to do so.
| Constructor and Description |
|---|
AbstractCompletion(CompletionProvider provider)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Completion c2)
Compares this completion to another one lexicographically, ignoring
case.
|
String |
getAlreadyEntered(JTextComponent comp)
Returns the portion of this completion that has already been entered
into the text component.
|
Icon |
getIcon()
The default implementation returns
null. |
String |
getInputText()
Returns the text the user has to (start) typing for this completion
to be offered.
|
CompletionProvider |
getProvider()
Returns the provider that returned this completion.
|
int |
getRelevance()
Returns the "relevance" of this completion.
|
String |
getToolTipText()
The default implementation returns
null. |
void |
setRelevance(int relevance)
Sets the relevance of this completion.
|
String |
toString()
Returns a string representation of this completion.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetReplacementText, getSummarypublic AbstractCompletion(CompletionProvider provider)
provider - The provider that created this completion.public int compareTo(Completion c2)
compareTo in interface Comparable<Completion>compareTo in interface Completionc2 - Another completion instance.public String getAlreadyEntered(JTextComponent comp)
This is a convenience method for:
getProvider().getAlreadyEnteredText(comp).
getAlreadyEntered in interface Completioncomp - The text component.public Icon getIcon()
null. Subclasses
who wish to display an icon can override this method.getIcon in interface Completionpublic String getInputText()
Completion.getReplacementText().getInputText in interface CompletionCompletion.getReplacementText()public CompletionProvider getProvider()
getProvider in interface Completionpublic int getRelevance()
By default, all completions have a relevance of 0. The
higher the value returned by this method, the higher up in the list
this completion will be; the lower the value returned, the lower it will
be. Completions with equal relevance values will be
sorted alphabetically.
getRelevance in interface Completionpublic String getToolTipText()
null. Subclasses
can override this method.getToolTipText in interface Completionpublic void setRelevance(int relevance)
relevance - The new relevance of this completion.getRelevance()public String toString()
getInputText().