Methods Summary |
---|
int | countOptions()
return( getArgHelper().countOptions( ) );
|
void | dm(java.lang.Object o)
// debug message
mOutput.println( mStringifier.stringify( o ) );
|
java.lang.Object | envGet(java.lang.String key)
return( mEnv.get( key ) );
|
java.lang.Object | envGet(java.lang.String key, java.lang.Object defaultValue)
Object value = envGet( key );
if ( value == null )
{
value = defaultValue;
}
return( value );
|
void | envPut(java.lang.String key, java.lang.Object value, boolean allowPersistence)
mEnv.put( key, value, allowPersistence);
|
void | envRemove(java.lang.String key)
mEnv.remove( key );
|
public final void | execute()
try
{
preExecute();
if ( getBoolean( "help", Boolean.FALSE ).booleanValue() ||
getBoolean( "h", Boolean.FALSE ).booleanValue() )
{
printUsage();
}
else
{
executeInternal( );
}
}
catch( Exception e )
{
handleException( e );
e.printStackTrace();
}
|
abstract void | executeInternal()
|
java.lang.String | getAlsoKnownAs(java.lang.Class theClass)
String aka = "";
try
{
aka = ArrayStringifier.stringify( getCmdNames( theClass ), " " );
}
catch( Exception e )
{
// Hmmm..
}
return( "Also known as: " + aka );
|
com.sun.cli.jmx.cmd.ArgHelper | getArgHelper()
assert( mArgHelper != null );
return( mArgHelper );
|
java.lang.Boolean | getBoolean(java.lang.String name, java.lang.Boolean defaultValue)
return( getArgHelper().getBoolean( name, defaultValue ) );
|
CmdFactory | getCmdFactory()
return( (CmdFactory)envGet( ENV_CMD_FACTORY ) );
|
java.lang.String | getCmdNameAsInvoked()
return( mTokens[ 0 ] );
|
public static java.lang.String[] | getCmdNames(java.lang.Class theClass)
String [] names = null;
final java.lang.reflect.Method m = theClass.getDeclaredMethod( "getNames", EMPTY_SIG );
names = (String [])m.invoke( theClass, EMPTY_ARGS);
return( names );
|
public boolean | getDebug()
boolean isDebug = false;
final String value = (String)envGet( ENV_DEBUG );
if ( value != null )
{
isDebug = value.equalsIgnoreCase( "true" ) ||
value.equalsIgnoreCase( "t" ) ||
value.equalsIgnoreCase( "yes" )||
value.equalsIgnoreCase( "y" );
}
return( isDebug );
|
java.util.Set | getEnvKeys()
return( mEnv.getKeys() );
|
java.util.Set | getEnvKeys(java.lang.String regExp)
final Iterator iter = getEnvKeys().iterator();
final java.util.Set filteredSet = new java.util.HashSet();
final Pattern pattern = Pattern.compile( regExp );
while ( iter.hasNext() )
{
final String key = (String)iter.next();
final Matcher m = pattern.matcher( key );
if ( m.matches() )
{
filteredSet.add( key );
}
}
return( filteredSet );
|
java.lang.Integer | getInteger(java.lang.String name)
return( getArgHelper().getInteger( name ) );
|
int | getNumRequiredOperands()
// require 1, by default
return( 1 );
|
java.lang.String[] | getOperands()
return( getArgHelper().getOperands( ) );
|
ArgHelper.OptionsInfo | getOptionInfo()
// default to none
return( new ArgHelperOptionsInfo( ) );
|
java.lang.String | getString(java.lang.String name, java.lang.String defaultValue)
return( getArgHelper().getString( name, defaultValue ) );
|
abstract java.lang.String | getUsage()
|
void | handleException(java.lang.Exception e)
if ( e instanceof WrongNumberOfOperandsException )
{
// already reported
}
else if ( e instanceof ArgHelper.IllegalOptionException )
{
printError( "ERROR: " + e.getMessage() );
printUsage();
}
else if ( e instanceof java.io.IOException)
{
printError( "ERROR: " + e.getMessage() );
}
else
{
printError( "ERROR: exception of type: " +
e.getClass().getName() + ", msg = " + e.getMessage() );
e.printStackTrace();
}
|
void | initArgHelper()
if ( mArgHelper == null )
{
final java.util.ListIterator iter =
Arrays.asList( mTokens ).listIterator( 1 );
final ArgHelper.OptionsInfo optionsInfo = getOptionInfo();
mArgHelper = new ArgHelperImpl( iter, new OptionsInfoWrapper( optionsInfo ) );
}
|
void | preExecute()
initArgHelper();
requireNumOperands( getNumRequiredOperands() );
|
public void | print(java.lang.Object o)
mOutput.print( o );
|
public void | printDebug(java.lang.Object o)
mOutput.printDebug( o );
|
public void | printError(java.lang.Object o)
mOutput.printError( o );
|
void | printUsage()
println( getUsage() );
println( getAlsoKnownAs( this.getClass() ) );
|
public void | println(java.lang.Object o)
mOutput.println( o );
|
void | requireNumOperands(int numRequiredOperands)
final String [] operands = getOperands();
if ( operands.length < numRequiredOperands )
{
requireNumOperandsFailed( operands.length, numRequiredOperands, null);
}
|
void | requireNumOperands(int numRequiredOperands, java.lang.String msg)
final String [] operands = getOperands();
if ( operands.length < numRequiredOperands )
{
requireNumOperandsFailed( operands.length, numRequiredOperands, msg);
}
|
void | requireNumOperandsFailed(int numSupplied, int numRequired, java.lang.String msg)
printError( "ERROR: " + numRequired + " arguments required, " + numSupplied + " supplied" );
if ( msg != null )
{
println( msg );
}
else
{
printUsage();
}
throw new WrongNumberOfOperandsException( "illlegal number of operands" );
|