Methods Summary |
---|
public void | addCmdMapping(java.lang.String name, java.lang.Class theClass)
if ( ! Cmd.class.isAssignableFrom( theClass ) )
{
throw new IllegalArgumentException( "Command " + theClass.getName() +
" must implement " + Cmd.class.getName() );
}
mCmds.put( name, theClass );
|
public Cmd | createCmd(java.lang.String name, CmdEnv env)
final String cmdString = name;
final Cmd cmd = instantiateCmd( cmdString, env );
return( cmd );
|
public java.lang.Class | getClass(java.lang.String cmdName)
final Class cmdClass = (Class)mCmds.get( cmdName );
return( cmdClass );
|
public java.lang.String[] | getNames(java.lang.Class theClass)
final ArrayList list = new ArrayList();
final Iterator keys = mCmds.keySet().iterator();
while( keys.hasNext() )
{
final String key = (String)keys.next();
final Class thisClass = (Class)mCmds.get( key );
if ( thisClass == theClass )
{
list.add( key );
}
}
final String [] names = new String [ list.size() ];
list.toArray( names );
return( names );
|
private Cmd | instantiateCmd(java.lang.String cmdName, CmdEnv env)
Class cmdClass = (Class)mCmds.get( cmdName );
if ( cmdClass == null )
{
// not found; see if there is a default registered
cmdClass = (Class)mCmds.get( DEFAULT_CMD_NAME );
}
if ( cmdClass == null )
{
return( null );
}
final Object [] args = new Object [] { env };
Cmd cmd = null;
try
{
cmd = (CmdBase)ClassUtil.InstantiateObject( cmdClass, args );
}
catch( Exception e )
{
p( e.getMessage() );
e.printStackTrace();
throw e;
}
return( cmd );
|
private static void | p(java.lang.Object o)
System.out.println( SmartStringifier.toString( o ) );
|
public void | removeCmdMapping(java.lang.String name)
mCmds.remove( name );
|