org.objectweb.cjdbc.controller.console
Class CommandCompletor

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.console.CommandCompletor
All Implemented Interfaces:
CommandCompletorInterface

public class CommandCompletor
extends java.lang.Object
implements CommandCompletorInterface

Command completor utility: allow to complete a String from a given list of keywords and from the file sytem.

This code has been inspired by the BeanShell Java Scripting project (http://www.beanshell.org/) by Patrick Niemeyer (pat@pat.net).

Version:
1.0
Author:
Mathieu Peltier

Field Summary
private  java.lang.String[] toBeFound
          List of keywords to look for.
 
Constructor Summary
CommandCompletor()
          Creates a new CommandCompletor instance with no list of keywords to look for.
CommandCompletor(java.lang.String[] keywords)
          Creates a new CommandCompletor instance with a given list of keywords to look for.
 
Method Summary
private  void addFileNames(java.util.List found, java.lang.String part)
          Adds the eventual file names corresponding to the given part to complete to the given list.
 java.lang.String[] complete(java.lang.String part)
          Returns an array containing a String element of the maximum unambiguous command completion or, if there is no common prefix, returns the list of ambiguous commands.
private  void searchFiles(java.util.List found, java.io.File dir, java.lang.String part)
          Searchs and adds to the given list the file names corresponding to the given part to complete.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

toBeFound

private java.lang.String[] toBeFound
List of keywords to look for.

Constructor Detail

CommandCompletor

public CommandCompletor()
Creates a new CommandCompletor instance with no list of keywords to look for.


CommandCompletor

public CommandCompletor(java.lang.String[] keywords)
Creates a new CommandCompletor instance with a given list of keywords to look for.

Parameters:
keywords - the given list of keywords.
Method Detail

complete

public java.lang.String[] complete(java.lang.String part)
Description copied from interface: CommandCompletorInterface
Returns an array containing a String element of the maximum unambiguous command completion or, if there is no common prefix, returns the list of ambiguous commands.

Specified by:
complete in interface CommandCompletorInterface
Parameters:
part - the String to complete.
Returns:
a String[] instance.
See Also:
CommandCompletorInterface.complete(java.lang.String)

addFileNames

private void addFileNames(java.util.List found,
                          java.lang.String part)
Adds the eventual file names corresponding to the given part to complete to the given list.

Parameters:
found - the List.
part - the String to complete.

searchFiles

private void searchFiles(java.util.List found,
                         java.io.File dir,
                         java.lang.String part)
Searchs and adds to the given list the file names corresponding to the given part to complete.

Parameters:
found - the completion List.
dir - the directory where to search the files.
part - the String to complete.


Copyright © 2002, 2003 - ObjectWeb Consortium - All Rights Reserved.