/** * prints with the current indent and a linefeed. * * @param x */ protected void sayi(String x) { say(INDENT + x); }
/** * Returns the value if it is not empty of a placeholder if it is. * * @param x * @return */ protected String getValue(String x) { return isEmpty(x) ? getPlaceHolder() : x; }
/** * Creates the input prompt and shows the supplied default value. This returns the default if the default value is chosen * and the input value otherwise. If supplied the default value is a null, then this is shown too. * * @param prompt * @param defaultValue * @return */ protected String getInput(String prompt, String defaultValue) { sayi2(prompt + "[" + (defaultValue == null ? "(null)" : defaultValue) + "]:"); String inLine = readline(); if (isEmpty(inLine)) { // assumption is that the default value is required return defaultValue; // no input. User hit a return } return inLine; }
/** * Output a line without a linefeed and using the indent currently in force. * Generally this is used a part of a prompt and is followed by a call * to {@link #readline}. * * @param x */ protected void sayi2(String x) { say2(INDENT + x); }
protected String readline() { try { String x = getBufferedReader().readLine(); if (x.equals(EXIT_COMMAND)) { throw new ExitException(EXIT_COMMAND + " encountered"); } return x; } catch (IOException iox) { throw new GeneralException("Error, could not read the input line due to IOException", iox); } }
@Override protected void say(String x) { // suppress output if this is run from the command line. if (!isBatchMode()) { super.say(x); } }