private static String[] getPresentationString(TestableGfsh shell) { Map<String, Object> result = shell.getCommandOutput(); StringBuffer presentationStr = new StringBuffer(); StringBuffer errStr = new StringBuffer(); for (Object key: result.keySet()) { Object value = result.get(key); // Log.getLogWriter().info("key class is " + key.getClass().getName() + ", key is " + key + " value is class " + // value.getClass().getName() + ", value is " + value + "\n"); if (value instanceof CommandResult) { CommandResult cr = (CommandResult)value; cr.resetToFirstLine(); while (cr.hasNextLine()) { String line = cr.nextLine(); presentationStr.append(line).append("\n"); //errStr.append(checkForRightPadding(line)); } } } return new String[] {presentationStr.toString(), errStr.toString()}; }
protected String commandResultToString(final CommandResult commandResult) { assertNotNull(commandResult); commandResult.resetToFirstLine(); StringBuilder buffer = new StringBuilder(commandResult.getHeader()); while (commandResult.hasNextLine()) { buffer.append(commandResult.nextLine()); } buffer.append(commandResult.getFooter()); return buffer.toString(); }
private String getHelpPresentationString(Map<String, Object> commandOutput) { Log.getLogWriter().info("getHelpPresentationString-Start"); StringBuilder strBldr = new StringBuilder(); for (Object key : commandOutput.keySet()) { Object value = commandOutput.get(key); if (value instanceof CommandResult) { CommandResult cr = (CommandResult) value; cr.resetToFirstLine(); while (cr.hasNextLine()) { String line = cr.nextLine(); //Log.getLogWriter().info("getHelpPresentationString-line=" + line); strBldr.append(splitAndTrim(line)); } } } return strBldr.toString().trim(); }
/** Get the output from the shell and return a String equivalent to what *should* be * displayed to the user in gfsh. * * @return [0] The String that should be a representation of the text presented to the gfsh * user. The word "should" means that we build the presentable string here and we * hope it is the same string built by gfsh. * [1] An error string is any erros were detected. */ private String[] getPresentationString(Map<String, Object> commandOutput) { Log.getLogWriter().info("getPresentationString-Start"); StringBuilder strBldr = new StringBuilder(); String presentationStr = new String(); StringBuilder whiteSpaceErrors = new StringBuilder(); for (Object key : commandOutput.keySet()) { Object value = commandOutput.get(key); if (value instanceof CommandResult) { CommandResult cr = (CommandResult) value; cr.resetToFirstLine(); while (cr.hasNextLine()) { String line = cr.nextLine(); line = line.replaceAll("\r",""); // saj hook2 strBldr.append(line).append("\n"); whiteSpaceErrors.append(checkForRightPadding(line)); } } } presentationStr = strBldr.toString(); return new String[] { presentationStr, whiteSpaceErrors.toString() }; }
private static void printCommandOutput(CommandResult cmdResult) { assertNotNull(cmdResult); Log.getLogWriter().info("Command Output : "); StringBuilder sb = new StringBuilder(); cmdResult.resetToFirstLine(); while (cmdResult.hasNextLine()) { sb.append(cmdResult.nextLine()).append(DataCommandRequest.NEW_LINE); } Log.getLogWriter().info(sb.toString()); Log.getLogWriter().info(""); }
CommandResult cr = (CommandResult) value; cr.resetToFirstLine(); while (cr.hasNextLine()) { String[] lines = cr.nextLine().split("\n"); for (String line : lines) {
private static boolean hasResultObject(TestableGfsh shell) { for (Object value: shell.getCommandOutput().values()) { if (value instanceof CommandResult) { CommandResult cr = (CommandResult) value; try { Log.getLogWriter().info("TestableGfsh saw ResultObject as follows: " + cr.getContent().toString()); Log.getLogWriter().info(" size: " + cr.getContent().size()); Log.getLogWriter().info(" toString: " + cr.getContent().toString()); Log.getLogWriter().info(" class: " + cr.getContent().getClass().getName()); if(cr.getContent().size()==0) { return false; } else { StringBuffer checkForOutput = new StringBuffer(); while (cr.hasNextLine()) { String line = cr.nextLine(); checkForOutput.append(line); } String tmpStr = checkForOutput.toString(); if(tmpStr.trim().length() == 0) { return false; } else { return true; } } } catch(Exception ex) {} return true; } } return false; }
CommandResult commandResult = CLIMultiStepHelper.getDisplayResultFromArgs(args); Gfsh.println(); while (commandResult.hasNextLine()) { Gfsh.println(commandResult.nextLine());
CommandResult commandResult = CLIMultiStepHelper.getDisplayResultFromArgs(args); Gfsh.println(); while (commandResult.hasNextLine()) { Gfsh.println(commandResult.nextLine());