org.xnap.commons.gui.completion
Interface CompletionModel
- All Superinterfaces:
- ComboBoxModel, ListModel, MutableComboBoxModel
- All Known Implementing Classes:
- DefaultCompletionModel, FileCompletionModel
public interface CompletionModel
- extends MutableComboBoxModel
Defines the requirements for classes implementing a CompletionModel.
The completion model can be queried for possible completions of a given
prefix
. There are two methods a CompletionModel has to
implement:
- complete - Find all possible completions for a given prefix and add
them as a side effect to the MutableComboboxModel using
MutableComboBoxModel.addElement(Object)
.
- completeUniquePrefix - Find the largest common prefix of all possible
completions and return it.
The completion model interface inherits MutableComoboxModel so that
possible CompletionModes
can use it as the model for
a comobobox.
- Author:
- Felix Berger
complete
boolean complete(String prefix)
- Finds possible completions for a prefix.
As a side effect the completions are added to the
MutableComboBoxModel
. Use ListModel.getSize()
to get the number of
completions found and retrieve them with ListModel.getElementAt(int)
.
- Parameters:
prefix
- the prefix being matched
- Returns:
- true, if completion was successful, i.e. the prefix matches
at least one item in the model
completeUniquePrefix
String completeUniquePrefix(String prefix)
- Returns largest common prefix of all possible completions for the given
prefix.
- Parameters:
prefix
- the prefix being matched
- Returns:
- the largest common prefix of all possible matches, the prefix
given if no longer prefix can be found
Copyright © 2004-2007 XNap Commons Team. All Rights Reserved.