/** * This snoops through the CCI and gets those methods that are not * in Java.lang.Object, are public and are not static. Note that this will * return all the unique names in the commands array. This method is not tasked * with dis-ambiguating them. * * @return java.lang.String[] */ public static String[] getCommandsNameList(Commands[] commands) { HashMap<String, Integer> names = new HashMap<String, Integer>(); // trick with the hash map to keep a running list of unique names, which are keys there. for(int i=0; i<commands.length ; i++){ Method[] CCIM = commands[i].getClass().getMethods(); for (int i0 = 0; i0 < CCIM.length; i0++) { if (!isJavaObjectMethod(CCIM[i0].getName(), CCIM[i0].getModifiers()) && hasRightSignature(CCIM[i0])) { names.put(CCIM[i0].getName(), 0); } } // end i0-loop } return names.keySet().toArray(new String[0]); }
for (int i = 0; i < getCLICommands().length; i++) { try { invokeMethod(commands[i], cmdS, cliAV); return OK_RC; // it worked }catch(InvocationTargetException itx){
protected void listCLIMethods() { say("Here are the commands available:"); String[] tempCCIN = CLIReflectionUtil.getCommandsNameList(getCLICommands()); for (int i = 0; i < tempCCIN.length; i++) { say(tempCCIN[i]); } say("To get more information on a command type\n"); say("command --help"); }