org.fife.ui.autocomplete
Class AbstractCompletion

java.lang.Object
  extended byorg.fife.ui.autocomplete.AbstractCompletion
All Implemented Interfaces:
java.lang.Comparable, Completion
Direct Known Subclasses:
BasicCompletion, MarkupTagCompletion

public abstract class AbstractCompletion
extends java.lang.Object
implements Completion, java.lang.Comparable

Base class for possible completions. Most, if not all, 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.

Version:
1.0
Author:
Robert Futrell

Constructor Summary
AbstractCompletion(CompletionProvider provider)
          Constructor.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this completion to another one lexicographically, ignoring case.
 java.lang.String getAlreadyEntered(javax.swing.text.JTextComponent comp)
          Returns the portion of this completion that has already been entered into the text component. The match is case-insensitive.

This is a convenience method for: getProvider().getAlreadyEnteredText(comp).

 java.lang.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.
 java.lang.String getToolTipText()
          The default implementation returns null.
 java.lang.String toString()
          Returns a string representation of this completion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.fife.ui.autocomplete.Completion
getReplacementText, getSummary
 

Constructor Detail

AbstractCompletion

public AbstractCompletion(CompletionProvider provider)
Constructor.

Parameters:
provider - The provider that created this completion.
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Compares this completion to another one lexicographically, ignoring case.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Another completion instance.
Returns:
How this completion compares to the other one.

getAlreadyEntered

public java.lang.String getAlreadyEntered(javax.swing.text.JTextComponent comp)
Returns the portion of this completion that has already been entered into the text component. The match is case-insensitive.

This is a convenience method for: getProvider().getAlreadyEnteredText(comp).

Specified by:
getAlreadyEntered in interface Completion
Parameters:
comp - The text component.
Returns:
The already-entered portion of this completion.

getInputText

public java.lang.String getInputText()
Returns the text the user has to (start) typing for this completion to be offered. The default implementation simply returns Completion.getReplacementText().

Specified by:
getInputText in interface Completion
Returns:
The text the user has to (start) typing for this completion.
See Also:
Completion.getReplacementText()

getProvider

public CompletionProvider getProvider()
Returns the provider that returned this completion.

Specified by:
getProvider in interface Completion
Returns:
The provider.

getToolTipText

public java.lang.String getToolTipText()
The default implementation returns null. Subclasses can override this method.

Specified by:
getToolTipText in interface Completion
Returns:
The tool tip text.

toString

public java.lang.String toString()
Returns a string representation of this completion. The default implementation returns getInputText().

Returns:
A string representation of this completion.