Source:
private String parseParamsForSystemInformation(ParameterSet params, JSONObject obj) throws Exception { String subselector = "status"; if (params.toArray().length < 1) { return "Incorrect number of arguments to @Trace (expects as least 1, received " + params.toArray().length + ")"; } if (params.toArray().length >= 1) { Object first = params.toArray()[0]; if (!(first instanceof String)) { return "First argument to @Trace must be a valid STRING selector, instead was " + first; } subselector = (String)first; if (!(subselector.equalsIgnoreCase("enable") || subselector.equalsIgnoreCase("disable") || subselector.equalsIgnoreCase("status") || subselector.equalsIgnoreCase("dump"))) { return "Invalid @Trace selector " + subselector; } } if (subselector.equalsIgnoreCase("status") || subselector.equalsIgnoreCase("dump")) { if (params.toArray().length != 1) { return "Incorrect number of arguments to @Trace (expected: 1, received: " + params.toArray().length + ")"; } obj.put("subselector", subselector); obj.put("interval", false); return null; } if (subselector.equalsIgnoreCase("enable") || subselector.equalsIgnoreCase("disable")) { if (params.toArray().length != 2) { return "Incorrect number of arguments to @Trace (expected: 2, received: " + params.toArray().length + ")"; } String categoryItem = params.toArray()[1].toString(); for (VoltTrace.Category cat : VoltTrace.Category.values()) { if (cat.toString().equalsIgnoreCase(categoryItem)) { obj.put("subselector", subselector); obj.put("categories", params.toArray()[1]); obj.put("interval", false); return null; } } return "Second argument to @Trace must be a valid STRING category, instead was " + categoryItem; } return "Invalid argument list to @Trace"; }

Target:
private String parseParamsForSystemInformation(ParameterSet params, JSONObject obj) throws Exception { String subselector = "status"; Object[] paramsArray = params.toArray(); int numOfParams = paramsArray.length; if (numOfParams < 1) { return "Incorrect number of arguments to @Trace (expects as least 1, received " + numOfParams + ")"; } Object first = paramsArray[0]; if (!(first instanceof String)) { return "First argument to @Trace must be a valid STRING selector, instead was " + first; } subselector = (String)first; if ("status".equalsIgnoreCase(subselector) || "dump".equalsIgnoreCase(subselector)) { if (numOfParams != 1) { return "Incorrect number of arguments to @Trace " + subselector + " (expected: 1, received: " + numOfParams + ")"; } obj.put("subselector", subselector); obj.put("interval", false); return null; } if ("enable".equalsIgnoreCase(subselector) || "disable".equalsIgnoreCase(subselector)) { if (numOfParams != 2) { return "Incorrect number of arguments to @Trace " + subselector + " (expected: 2, received: " + numOfParams + ")"; } String categoryItem = paramsArray[1].toString(); for (VoltTrace.Category cat : VoltTrace.Category.values()) { if (cat.toString().equalsIgnoreCase(categoryItem)) { obj.put("subselector", subselector); obj.put("categories", params.toArray()[1]); obj.put("interval", false); return null; } } return "Second argument to @Trace " + subselector + " must be a valid STRING category, instead was " + categoryItem; } return "Invalid @Trace selector " + subselector; }