001    /**
002     *      jline - Java console input library
003     *      Copyright (c) 2002-2006, Marc Prud'hommeaux <mwp1@cornell.edu>
004     *      All rights reserved.
005     *
006     *      Redistribution and use in source and binary forms, with or
007     *      without modification, are permitted provided that the following
008     *      conditions are met:
009     *
010     *      Redistributions of source code must retain the above copyright
011     *      notice, this list of conditions and the following disclaimer.
012     *
013     *      Redistributions in binary form must reproduce the above copyright
014     *      notice, this list of conditions and the following disclaimer
015     *      in the documentation and/or other materials provided with
016     *      the distribution.
017     *
018     *      Neither the name of JLine nor the names of its contributors
019     *      may be used to endorse or promote products derived from this
020     *      software without specific prior written permission.
021     *
022     *      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
023     *      "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024     *      BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
025     *      AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
026     *      EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
027     *      FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
028     *      OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
029     *      PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
030     *      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
031     *      AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
032     *      LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
033     *      IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
034     *      OF THE POSSIBILITY OF SUCH DAMAGE.
035     */
036    package jline;
037    
038    import java.util.*;
039    
040    /**
041     *  A Completor is the mechanism by which tab-completion candidates
042     *  will be resolved.
043     *  <p>
044     *  <strong>TODO:</strong>
045     *  <ul>
046     *      <li>handle quotes and escaped quotes</li>
047     *      <li>enable automatic escaping of whitespace</li>
048     *  </ul>
049     *
050     *  @author  <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
051     */
052    public interface Completor
053    {
054            /**
055             *  Populates <i>candidates</i> with a list of possible
056             *  completions for the <i>buffer</i>. The <i>candidates</i>
057             *  list will not be sorted before being displayed to the
058             *  user: thus, the complete method should sort the
059             *  {@link List} before returning.
060             *
061             *
062             *  @param  buffer              the buffer
063             *  @param  candidates  the {@link List} of candidates to populate
064             *  @return                             the index of the <i>buffer</i> for which
065             *                                      the completion will be relative
066             */
067            int complete (String buffer, int cursor, List candidates);
068    }