Class AbbrevLookup

  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
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


public AbbrevLookup()
Method Detail


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


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.

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


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.