Class 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
    • 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:
        java.lang.IllegalArgumentException - If the completion's provider isn't this CompletionProvider.
        See Also:
        addCompletions(List), removeCompletion(Completion), clear()
      • addWordCompletions

        protected void addWordCompletions​(java.lang.String[] words)
        Adds simple completions for a list of words.
        Parameters:
        words - The words.
        See Also:
        BasicCompletion
      • checkProviderAndAdd

        protected void checkProviderAndAdd​(Completion c)
      • getCompletionByInputText

        public java.util.List<Completion> getCompletionByInputText​(java.lang.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 java.util.List<Completion> getCompletionsImpl​(javax.swing.text.JTextComponent comp)
        Description copied from class: CompletionProviderBase
        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)