org.jline.terminal.Terminal.writer()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(226)

本文整理了Java中org.jline.terminal.Terminal.writer()方法的一些代码示例,展示了Terminal.writer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Terminal.writer()方法的具体详情如下:
包路径:org.jline.terminal.Terminal
类名称:Terminal
方法名:writer

Terminal.writer介绍

[英]Retrieve the Writer for this terminal. This is the standard way to write to this terminal.
[中]检索此终端的Writer。这是写入此终端的标准方式。

代码示例

代码示例来源:origin: confluentinc/ksql

@Override
public PrintWriter writer() {
 return terminal.writer();
}

代码示例来源:origin: apache/flink

private void callHelp() {
  terminal.writer().println(CliStrings.MESSAGE_HELP);
  terminal.flush();
}

代码示例来源:origin: apache/flink

public void clearTerminal() {
  if (isPlainTerminal()) {
    for (int i = 0; i < 200; i++) { // large number of empty lines
      terminal.writer().println();
    }
  } else {
    terminal.puts(InfoCmp.Capability.clear_screen);
  }
}

代码示例来源:origin: apache/flink

private void printException(String message, Throwable t) {
  LOG.warn(message, t);
  terminal.writer().println(CliStrings.messageError(message, t).toAnsi());
  terminal.flush();
}

代码示例来源:origin: apache/flink

private void callShowTables() {
  final List<String> tables;
  try {
    tables = executor.listTables(context);
  } catch (SqlExecutionException e) {
    printExecutionException(e);
    return;
  }
  if (tables.isEmpty()) {
    terminal.writer().println(CliStrings.messageInfo(CliStrings.MESSAGE_EMPTY).toAnsi());
  } else {
    tables.forEach((v) -> terminal.writer().println(v));
  }
  terminal.flush();
}

代码示例来源:origin: apache/flink

private void callShowFunctions() {
  final List<String> functions;
  try {
    functions = executor.listUserDefinedFunctions(context);
  } catch (SqlExecutionException e) {
    printExecutionException(e);
    return;
  }
  if (functions.isEmpty()) {
    terminal.writer().println(CliStrings.messageInfo(CliStrings.MESSAGE_EMPTY).toAnsi());
  } else {
    functions.forEach((v) -> terminal.writer().println(v));
  }
  terminal.flush();
}

代码示例来源:origin: apache/flink

private void callExplain(SqlCommandCall cmdCall) {
  final String explanation;
  try {
    explanation = executor.explainStatement(context, cmdCall.operands[0]);
  } catch (SqlExecutionException e) {
    printExecutionException(e);
    return;
  }
  terminal.writer().println(explanation);
  terminal.flush();
}

代码示例来源:origin: apache/flink

private void printInfo(String message) {
    terminal.writer().println(CliStrings.messageInfo(message).toAnsi());
    terminal.flush();
  }
}

代码示例来源:origin: apache/flink

private void printExecutionError(String message) {
  terminal.writer().println(CliStrings.messageError(CliStrings.MESSAGE_SQL_EXECUTION_ERROR, message).toAnsi());
  terminal.flush();
}

代码示例来源:origin: apache/flink

private void printError(String message) {
  terminal.writer().println(CliStrings.messageError(message).toAnsi());
  terminal.flush();
}

代码示例来源:origin: confluentinc/ksql

private void addToHistory(final String line) {
 try {
  history.add(line);
  history.save();
 } catch (final IOException e) {
  LOGGER.error("Error saving history file", e);
  terminal.writer()
    .println("Error saving history file:" + ErrorMessageUtil.buildErrorMessage(e));
 }
}

代码示例来源:origin: apache/flink

private void callSet(SqlCommandCall cmdCall) {
  // show all properties
  if (cmdCall.operands.length == 0) {
    final Map<String, String> properties;
    try {
      properties = executor.getSessionProperties(context);
    } catch (SqlExecutionException e) {
      printExecutionException(e);
      return;
    }
    if (properties.isEmpty()) {
      terminal.writer().println(CliStrings.messageInfo(CliStrings.MESSAGE_EMPTY).toAnsi());
    } else {
      properties
        .entrySet()
        .stream()
        .map((e) -> e.getKey() + "=" + e.getValue())
        .sorted()
        .forEach((p) -> terminal.writer().println(p));
    }
  }
  // set a property
  else {
    context.setSessionProperty(cmdCall.operands[0], cmdCall.operands[1]);
    terminal.writer().println(CliStrings.messageInfo(CliStrings.MESSAGE_SET).toAnsi());
  }
  terminal.flush();
}

代码示例来源:origin: apache/flink

terminal.writer().append(CliStrings.MESSAGE_WELCOME);
  terminal.writer().append("\n");
  terminal.flush();

代码示例来源:origin: apache/flink

private boolean callInsertInto(SqlCommandCall cmdCall) {
  printInfo(CliStrings.MESSAGE_SUBMITTING_STATEMENT);
  try {
    final ProgramTargetDescriptor programTarget = executor.executeUpdate(context, cmdCall.operands[0]);
    terminal.writer().println(CliStrings.messageInfo(CliStrings.MESSAGE_STATEMENT_SUBMITTED).toAnsi());
    terminal.writer().println(programTarget.toString());
    terminal.flush();
  } catch (SqlExecutionException e) {
    printExecutionException(e);
    return false;
  }
  return true;
}

代码示例来源:origin: apache/flink

private void callDescribe(SqlCommandCall cmdCall) {
  final TableSchema schema;
  try {
    schema = executor.getTableSchema(context, cmdCall.operands[0]);
  } catch (SqlExecutionException e) {
    printExecutionException(e);
    return;
  }
  terminal.writer().println(schema.toString());
  terminal.flush();
}

代码示例来源:origin: apache/flink

private void callSource(SqlCommandCall cmdCall) {
  final String pathString = cmdCall.operands[0];
  // load file
  final String stmt;
  try {
    final Path path = Paths.get(pathString);
    byte[] encoded = Files.readAllBytes(path);
    stmt = new String(encoded, Charset.defaultCharset());
  } catch (IOException e) {
    printExecutionException(e);
    return;
  }
  // limit the output a bit
  if (stmt.length() > SOURCE_MAX_SIZE) {
    printExecutionError(CliStrings.MESSAGE_MAX_SIZE_EXCEEDED);
    return;
  }
  terminal.writer().println(CliStrings.messageInfo(CliStrings.MESSAGE_WILL_EXECUTE).toAnsi());
  terminal.writer().println(new AttributedString(stmt).toString());
  terminal.flush();
  // try to run it
  final Optional<SqlCommandCall> call = parseCommand(stmt);
  call.ifPresent(this::callCommand);
}

代码示例来源:origin: apache/flink

/**
 * Submits a SQL update statement and prints status information and/or errors on the terminal.
 *
 * @param statement SQL update statement
 * @return flag to indicate if the submission was successful or not
 */
public boolean submitUpdate(String statement) {
  terminal.writer().println(CliStrings.messageInfo(CliStrings.MESSAGE_WILL_EXECUTE).toAnsi());
  terminal.writer().println(new AttributedString(statement).toString());
  terminal.flush();
  final Optional<SqlCommandCall> parsedStatement = parseCommand(statement);
  // only support INSERT INTO
  return parsedStatement.map(cmdCall -> {
    switch (cmdCall.command) {
      case INSERT_INTO:
        return callInsertInto(cmdCall);
      default:
        printError(CliStrings.MESSAGE_UNSUPPORTED_SQL);
        return false;
    }
  }).orElse(false);
}

代码示例来源:origin: apache/flink

client.getTerminal().writer().println(computeTitleLine().toAnsi());
headerLines.forEach(l -> client.getTerminal().writer().println(l.toAnsi()));
  if (offsetX < l.length()) {
    final AttributedString windowX = l.substring(offsetX, Math.min(l.length(), offsetX + width));
    client.getTerminal().writer().println(windowX.toAnsi());
  } else {
    client.getTerminal().writer().println(); // nothing to show for this line
  windowedMainLines.size() - mainHeaderLines.size() - footerLines.size();
IntStream.range(0, emptyHeight).forEach(i -> client.getTerminal().writer().println());
    client.getTerminal().writer().print(l.toAnsi());
  } else {
    client.getTerminal().writer().println(l.toAnsi());

代码示例来源:origin: remkop/picocli

public void setReader(LineReader reader){            
  this.reader = (LineReaderImpl)reader;
  out = reader.getTerminal().writer();
}

代码示例来源:origin: apache/flink

.build();
  terminal.writer().println();
  terminal.writer().flush();
} catch (IOException e) {
  throw new SqlClientException("Error opening command line interface.", e);

相关文章