Methods Summary |
---|
java.util.Set | arrayToSet(java.lang.Object[] names)
final TreeSet theSet = new TreeSet();
for( int i = 0; i < names.length; ++i )
{
theSet.add( names[ i ] );
}
return( theSet );
|
static java.lang.String | convertToJavaRegex(java.lang.String input)
/*
We support only '*" in a simplified form.
*/
String converted = input;
if ( input != null )
{
// first run the tokenizer on it specifying no delimiters so as to eliminate any escape constructs
final String [] tokens = new TokenizerImpl( input, "", '\\", "*").getTokens();
assert( tokens.length == 1 );
// now any '\' or '*' characters are to be taken literally
final String unescapedInput = tokens[ 0 ];
final int length = unescapedInput.length();
final StringBuffer buf = new StringBuffer();
for( int i = 0; i < length; ++i )
{
final char theChar = unescapedInput.charAt( i );
if ( theChar == '." )
{
buf.append( "[.]" );
}
else if ( theChar == '*" )
{
buf.append( ".*" );
}
else if ( theChar == BACKSLASH )
{
buf.append( "" + BACKSLASH + BACKSLASH );
}
else
{
buf.append( theChar );
}
}
converted = buf.toString();
}
return( converted );
|
void | display(java.util.Set names)
println( IteratorStringifier.stringify( names.iterator(), "\n" ) );
|
void | executeInternal()
String [] targets = getOperands();
if ( targets.length == 0 )
{
targets = new String [] { "all" };
}
final boolean add = getBoolean( "add", Boolean.FALSE ).booleanValue();
final boolean remove = getBoolean( "remove", Boolean.FALSE ).booleanValue();
final boolean displayCurrent = getBoolean( "current", Boolean.FALSE ).booleanValue();
final String regex = getString( "regex", null );
final String javaregex = getString( "java-regex", null );
final Set currentSet = getCurrent();
if ( displayCurrent )
{
if ( currentSet == null || currentSet.size() == 0 )
{
println( "Nothing in current set." );
}
else
{
display( currentSet );
}
}
else
{
establishProxy();
final String actualRegex = (javaregex != null) ?
javaregex : convertToJavaRegex( regex );
ObjectName [] objectNames = getProxy().mbeanFind( targets, actualRegex);
final String [] objectStrings = objectNamesToStrings( objectNames );
Set resultSet = arrayToSet( objectStrings );
if ( currentSet != null )
{
if ( add )
{
currentSet.addAll( resultSet );
resultSet = currentSet;
}
else if ( remove )
{
currentSet.removeAll( resultSet );
resultSet = currentSet;
}
}
envPut( ENV_CURRENT_SET, resultSet, false );
if ( resultSet.size() == 0 )
{
println( "No objects match the targets " + SmartStringifier.toString( targets ) );
}
else
{
display( resultSet );
}
}
|
java.util.Set | getCurrent()
return( (Set)envGet( ENV_CURRENT_SET ) );
|
public static java.lang.String[] | getNames()
return( new String [] { "find", "f" } );
|
int | getNumRequiredOperands()
// require 1, by default
return( 0 );
|
ArgHelper.OptionsInfo | getOptionInfo()
return( new ArgHelperOptionsInfo( OPTIONS_INFO ) );
|
public java.lang.String | getUsage()
return( CmdStrings.FIND_HELP.toString() );
|
java.lang.String[] | objectNamesToStrings(javax.management.ObjectName[] objectNames)
// sorting doesn't work on returned array, so convert to Strings first,then sort
final String [] resultStrs = new String [ objectNames.length ];
for( int i = 0; i < resultStrs.length; ++i )
{
resultStrs[ i ] = objectNames[ i ].toString();
}
return( resultStrs );
|