com.raelity.jvi
Class AbbrevLookup

java.lang.Object
  extended by com.raelity.jvi.AbbrevLookup

public class AbbrevLookup
extends Object

This is a lookup table where the key can be abbreviated. It is convenient for words that are entered by users.


Nested Class Summary
static class AbbrevLookup.CommandElement
          A registered command is represented by this class.
 
Constructor Summary
AbbrevLookup()
           
 
Method Summary
 void add(String abbrev, String name, Object value)
          Register a command; the abbrev must be unique.
 List getList()
          This method returns a read-only copy of the list.
 AbbrevLookup.CommandElement lookupCommand(String command)
          Search the list for the command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbbrevLookup

public AbbrevLookup()
Method Detail

getList

public List getList()
This method returns a read-only copy of the list. The elements of the list are AbbrevLookup.CommandElement.


add

public void add(String abbrev,
                String name,
                Object value)
Register a command; the abbrev must be unique. The abbrev is the "key" for the command, for example since "s" is the abbreviation for "substitue" and "se" is the abbreviation for "set" then "substitute" sorts earlier than "set" because "s" sorts earlier than "se". Consider this when adding commands, since unique prefix has nothing to do with how commands are recognized.

Throws:
IllegalArgumentException - this is thrown if the abbreviation and/or the name already exist in the list or there's a null argument.

lookupCommand

public AbbrevLookup.CommandElement lookupCommand(String command)
Search the list for the command. Sequentially search a list starting with the list that start with the first letter of the input command.