当前位置: 首页>>代码示例>>Java>>正文


Java UserInterruptException类代码示例

本文整理汇总了Java中org.jline.reader.UserInterruptException的典型用法代码示例。如果您正苦于以下问题:Java UserInterruptException类的具体用法?Java UserInterruptException怎么用?Java UserInterruptException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UserInterruptException类属于org.jline.reader包,在下文中一共展示了UserInterruptException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDoubleValue

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
protected Double getDoubleValue() {
  Double value = null;

  while (value == null) {
    String line;
    try {
      line = reader.readLine(prompt()).trim();
    } catch (EndOfFileException | UserInterruptException e) {
      break;
    }

    if (line.isEmpty()) {
      logger.info("no value entered");
      break;
    }
    try {
      value = Double.valueOf(line);
    } catch (NumberFormatException nfe) {
      PrintWriter writer = terminal.writer();
      writer.println("please enter a number");
    }
  }
  return value;
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:25,代码来源:AbstractDoubleConfigCommand.java

示例2: getIntValue

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
protected Integer getIntValue() {
  Integer value = null;

  while (value == null) {
    String line;
    try {
      line = reader.readLine(prompt()).trim();
    } catch (EndOfFileException | UserInterruptException e) {
      break;
    }

    if (line.isEmpty()) {
      logger.info("no value entered");
      break;
    }
    try {
      value = Integer.valueOf(line);
    } catch (NumberFormatException nfe) {
      terminal.writer().println("please enter an integer");
    }
  }
  return value;
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:24,代码来源:AbstractIntConfigCommand.java

示例3: login

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
private void login(String username, String code, Settings settings) {
    printBanner();

    LineReader reader = ShellUtils.lineReader(null, Optional.empty());
    try {
        if (username == null) {
            username = reader.readLine(getPrompt("Username"));
        }
        String password = reader.readLine(getPrompt("Password"), new Character('*'));
        postForTokenAndHandleResponse(username, password, code, settings, reader);
    }
    catch (EndOfFileException | UserInterruptException e) {
        log.error("Canceled!");
    }
    finally {
        ShellUtils.shutdown(reader);
    }
}
 
开发者ID:atomist-attic,项目名称:rug-cli,代码行数:19,代码来源:LoginCommand.java

示例4: readLine

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
/**
 * Attempt to read a logical line of input from the user. Can span multiple physical lines, as
 * long as all but the last end with '\\'.
 * @return The parsed, logical line.
 * @throws EndOfFileException If there is no more input available from the user.
 * @throws IOException If any other I/O error occurs.
 */
private String readLine() throws IOException {
  while (true) {
    try {
      String result = terminal.getLineReader().readLine();
      // A 'dumb' terminal (the kind used at runtime if a 'system' terminal isn't available) will
      // return null on EOF and user interrupt, instead of throwing the more fine-grained
      // exceptions. This null-check helps ensure that, upon encountering EOF, even a 'dumb'
      // terminal will be able to exit intelligently.
      if (result == null) {
        throw new EndOfFileException();
      } else {
        return result.trim();
      }
    } catch (UserInterruptException exception) {
      // User hit ctrl-C, just clear the current line and try again.
      terminal.writer().println("^C");
      terminal.flush();
    }
  }
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:28,代码来源:Cli.java

示例5: readLine

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
@Override
public String readLine() throws IOException {
    try {
        // Ignore the line that will be read, in order to process multiline commands in the client code.
        reader.readLine(InteractiveModeConstants.PROMPT);

        // Return the raw line.
        return reader.getParsedLine().line();
    } catch (UserInterruptException | EndOfFileException e) {
        return null;
    }
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:13,代码来源:JLineInteractiveModeConsole.java

示例6: getFwdRevDoubles

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
protected double[] getFwdRevDoubles() {
  terminal
      .writer()
      .println(Messages.bold("\nenter <forward>,<reverse> or a single number for both"));
  double[] values = null;
  while (values == null) {
    String line;
    try {
      line = reader.readLine(prompt()).trim();
    } catch (EndOfFileException | UserInterruptException e) {
      break;
    }

    if (line.isEmpty()) {
      logger.info("{}: no value entered", name());
      break;
    }

    List<String> entries = Arrays.asList(line.split(","));
    double[] doubles = new double[2];
    try {
      if (entries.size() > 0) {
        doubles[0] = Double.valueOf(entries.get(0));
      } else {
        help();
        continue;
      }
      if (entries.size() > 1) {
        doubles[1] = Double.valueOf(entries.get(1));
      } else {
        doubles[1] = doubles[0] * (flipReverse ? -1 : 1);
      }
    } catch (NumberFormatException nfe) {
      help();
      continue;
    }
    values = doubles;
  }
  return values;
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:41,代码来源:AbstractFwdRevDoubleConfigCommand.java

示例7: getBooleanValue

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
protected Boolean getBooleanValue() {
  Boolean value = null;

  while (value == null) {
    String line;
    try {
      line = reader.readLine(Messages.prompt("configure " + name() + " (Y/N)> ")).trim();
    } catch (EndOfFileException | UserInterruptException e) {
      break;
    }

    if (line.isEmpty()) {
      logger.info("no value entered");
      break;
    }
    boolean setpoint;
    if (line.equalsIgnoreCase("Y")) {
      setpoint = true;
    } else if (line.equalsIgnoreCase("N")) {
      setpoint = false;
    } else {
      terminal.writer().println(Messages.boldRed("enter <Y>, <N> or <enter> to go back"));
      continue;
    }
    value = setpoint;
  }
  return value;
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:29,代码来源:AbstractBooleanConfigCommand.java

示例8: perform

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
@Override
public void perform() {
  if (servoSet.getServo() == null) {
    terminal.writer().println(Messages.boldRed("no servo selected"));
    return;
  }
  terminal.writer().println(Messages.bold("Enter servo setpoint, press <enter> to go back"));
  while (true) {
    String line;
    try {
      line = reader.readLine(Messages.prompt("setpoint or <return> or b/B to exit> ")).trim();
    } catch (EndOfFileException | UserInterruptException e) {
      continue;
    }

    if (line.isEmpty() || line.equalsIgnoreCase("b")) {
      return;
    }
    double setpoint;
    try {
      setpoint = Double.valueOf(line);
    } catch (NumberFormatException nfe) {
      terminal.writer().println(Messages.boldRed("please enter a number"));
      continue;
    }
    terminal.writer().print(Messages.bold(String.format("setting servo to %.2f%n", setpoint)));
    servoSet.getServo().set(setpoint);
  }
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:30,代码来源:RunServoCommand.java

示例9: perform

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
@Override
public void perform() {
  if (dioSet.getDigitalOutput() == null) {
    terminal.writer().println(Messages.boldRed("no digital output selected selected"));
    return;
  }
  terminal.writer().println(Messages.bold("Enter duty cycle, press <enter> to go back"));
  while (true) {
    String line;
    try {
      line = reader.readLine(Messages.prompt("number or <return> to exit> ")).trim();
    } catch (EndOfFileException | UserInterruptException e) {
      continue;
    }

    if (line.isEmpty()) {
      return;
    }
    double setpoint;
    try {
      setpoint = Double.valueOf(line);
    } catch (NumberFormatException nfe) {
      help();
      continue;
    }
    terminal.writer().print(Messages.bold(String.format("pulsing for %.2f%n", setpoint)));
    DigitalOutput digitalOutput = dioSet.getDigitalOutput();
    digitalOutput.disablePWM();
    digitalOutput.enablePWM(setpoint);
  }
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:32,代码来源:PwmDigitalOutputCommand.java

示例10: perform

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
@Override
public void perform() {
  if (dioSet.getDigitalOutput() == null) {
    terminal.writer().println(Messages.boldRed("no digital output selected selected"));
    return;
  }
  terminal
      .writer()
      .println(Messages.bold("Enter 0 for off or 1 for on, press <enter> to go back"));
  while (true) {
    String line;
    try {
      line = reader.readLine(Messages.prompt("0/1 or <return> or b/B to exit> ")).trim();
    } catch (EndOfFileException | UserInterruptException e) {
      continue;
    }

    if (line.isEmpty() || line.equalsIgnoreCase("b")) {
      return;
    }
    int setpoint;
    try {
      setpoint = Integer.valueOf(line);
    } catch (NumberFormatException nfe) {
      help();
      continue;
    }
    if (setpoint != 0 && setpoint != 1) {
      help();
      continue;
    }
    terminal.writer().print(Messages.bold(String.format("setting dio to %d%n", setpoint)));
    dioSet.getDigitalOutput().set(setpoint == 1);
  }
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:36,代码来源:RunDigitalOutputCommand.java

示例11: perform

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
@Override
public void perform() {
  if (dioSet.getDigitalOutput() == null) {
    terminal.writer().println(Messages.boldRed("no digital output selected selected"));
    return;
  }
  terminal.writer().println(Messages.bold("Enter pulse length, press <enter> to go back"));
  while (true) {
    String line;
    try {
      line = reader.readLine(Messages.prompt("number or <return> to exit> ")).trim();
    } catch (EndOfFileException | UserInterruptException e) {
      continue;
    }

    if (line.isEmpty()) {
      return;
    }
    double setpoint;
    try {
      setpoint = Double.valueOf(line);
    } catch (NumberFormatException nfe) {
      help();
      continue;
    }
    terminal.writer().print(Messages.bold(String.format("pulsing for %.2f%n", setpoint)));
    dioSet.getDigitalOutput().pulse(setpoint);
  }
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:30,代码来源:PulseDigitalOutputCommand.java

示例12: readCommandLine

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
@Override
public String readCommandLine() {
    try {
        String prompt = toAnsi(getCommandPrompt());
        return commandReader.readLine(prompt);
    } catch (UserInterruptException e) {
        if (confirmQuit()) {
            throw new ConsoleTerminatedException();
        } else {
            return null;
        }
    }
}
 
开发者ID:aspectran,项目名称:aspectran,代码行数:14,代码来源:JLineConsole.java

示例13: readLine

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
@Override
public String readLine(String prompt) {
    try {
        return reader.readLine(prompt);
    } catch (UserInterruptException e) {
        throw new ConsoleTerminatedException();
    }
}
 
开发者ID:aspectran,项目名称:aspectran,代码行数:9,代码来源:JLineConsole.java

示例14: readPassword

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
@Override
public String readPassword(String prompt) {
    try {
        return reader.readLine(prompt, MASK_CHAR);
    } catch (UserInterruptException e) {
        throw new ConsoleTerminatedException();
    }
}
 
开发者ID:aspectran,项目名称:aspectran,代码行数:9,代码来源:JLineConsole.java

示例15: start

import org.jline.reader.UserInterruptException; //导入依赖的package包/类
public void start() {
    logger.log("\n" +
            "     \n" +
            "          ╓╖╓\n" +
            "        ╓▓▓▓▓▓M▌ ╟╜▀▓▌╗╥                                                        █\n" +
            "         ▓▓▓▓▓¼▓▓▓╗╬╢╬▓▓▓▌╗,        ,,         ,;          ,;;\n" +
            "       ╓▓▓╩╬▌╬▓▓▓▓╟▓▓▓▓▓▓▓▓▓▌   █▄▀╙└╙▀█▄   ▄▀▀└└\"▀█    ▄█▀┘└└▀▀▄      █▀       █\n" +
            "       ▓▓▌w╬▓▓▓▓▓╡▓▓▓▓▓▓▓▓▓▓▓M  █▌      █  █▀       █  █▀       \"█    █▀        █\n" +
            "      ▐▓▓▓,╟▓▓▓▓▓▓╟▓▓▓▓▓▓▓▓▓▓   █=      █  █▀▀▀▀▀▀▀▀▀  █         █⌐  █▀    ╓    █\n" +
            "      ▐▓▓▓▄,▓▓▓▓▓▓▓╬╬▓▓▓▓▓▓▌⌐   █=      █  ╙█          ╙█       ▄▀  █▀     █=   █\n" +
            "       ╟▓▓▓Ü ╟▓▌╬▓▓▓▓╬▌╝╬╬▓▌    ▀⌐      █   `▀Wæ▄æA▀     ▀▀æ▄æΦ▀└  ╝█≡≡≡≡≡≡█=   █\n" +
            "        ╚▓▓▌▌╬▓▓▓▓▌▀▓╜½╖▓▓M                                                █=   █\n" +
            "         `╚▓▓▓▓▓▓▓▓▓╟@╬▓▀                                                  ▀⌐╘≡▀└\n" +
            "           ▓▓▓▓▓▓▓▓▓╜╙`\n" +
            "            ╚▓▓▓▓▓▀\n" +
            "\n", AttributedStyle.BOLD.foreground(GREEN));

    AttributedStyle warningStyle = AttributedStyle.BOLD.blink().foreground(YELLOW);
    logger.log("");
    logger.log("Initializing session now...", AttributedStyle.DEFAULT.italic());
    session.init(this.getClass().getResourceAsStream("/exercises/dump.cypher"));
    logger.log("... done!", AttributedStyle.DEFAULT.italic());
    logger.log("");
    logger.log("Welcome to Devoxx France 2017 Hands on Neo4j!");
    logger.log("Available commands can be displayed with ':commands'");
    logger.log("");
    logger.log("Please make sure your Cypher statements end with a semicolon.", warningStyle);
    logger.log("Every exercise is independent, no changes are persisted against your database.", warningStyle);
    logger.log("Make sure to undo the insertions in the browser before using this REPL!", warningStyle);
    logger.log("");
    logger.log("Ask for help when needed and have fun!", AttributedStyle.BOLD.foreground(AttributedStyle.CYAN));
    while (true) {
        try {
            String statement = lineReader.readLine("(:Devoxx)-[:`<3`]-(:Cypher)> ");
            commandRegistry
                    .findFirst(statement)
                    .orElse(defaultCypherCommand)
                    .accept(session, statement);
        } catch (UserInterruptException ignored) {
        } catch (EndOfFileException e) {
            logger.log("Goodbye!");
            return;
        }
    }
}
 
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:46,代码来源:Console.java


注:本文中的org.jline.reader.UserInterruptException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。