org.jline.reader.History.save()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(158)

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

History.save介绍

[英]Save history.
[中]保存历史。

代码示例

代码示例来源:origin: org.springframework.shell/spring-shell-core

@EventListener
  public void onContextClosedEvent(ContextClosedEvent event) throws IOException {
    history.save();
  }
}

代码示例来源:origin: com.github.fonimus/spring-boot-ssh-shell-starter

@EventListener
  public void onContextClosedEvent(ContextClosedEvent event) throws IOException {
    history.save();
  }
}

代码示例来源:origin: jiaqi/jmxterm

@Override
 public void run() {
  try {
   history.save();
  } catch (IOException e) {
   System.err.println("Failed to flush command history! " + e);
  }
 }
}));

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

public void close() {
  if (closed.compareAndSet(false, true)) {
    if (running) {
      try {
        reader.getHistory().save();
      } catch (IOException e) {
        // ignore
      }
    }
    running = false;
    if (thread != Thread.currentThread() && thread != null) {
      thread.interrupt();
    }
    if (closeCallback != null) {
      closeCallback.run();
    }
    if (terminal instanceof AutoCloseable) {
      try {
        ((AutoCloseable) terminal).close();
      } catch (Exception e) {
        // Ignore
      }
    }
    if (session != null)
      session.close();
  }
}

代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.core

public void close() {
  if (closed.compareAndSet(false, true)) {
    if (running) {
      try {
        reader.getHistory().save();
      } catch (IOException e) {
        // ignore
      }
    }
    running = false;
    if (thread != Thread.currentThread() && thread != null) {
      thread.interrupt();
    }
    if (closeCallback != null) {
      closeCallback.run();
    }
    if (terminal instanceof AutoCloseable) {
      try {
        ((AutoCloseable) terminal).close();
      } catch (Exception e) {
        // Ignore
      }
    }
    if (session != null)
      session.close();
  }
}

代码示例来源:origin: julianhyde/sqlline

private void setLineReaderHistoryIntVariable(
  String variableName, String value, SqlLineProperty property) {
 LineReader lineReader = sqlLine.getLineReader();
 if (lineReader == null) {
  return;
 }
 int currentValue = getInt(property);
 try {
  if (DEFAULT.equals(value)) {
   if (currentValue == (Integer) property.defaultValue()) {
    return;
   } else {
    lineReader.setVariable(variableName, property.defaultValue());
    lineReader.getHistory().save();
    propertiesMap.put(property, property.defaultValue());
    return;
   }
  }
  int parsedValue = Integer.parseInt(value);
  if (parsedValue == currentValue) {
   return;
  } else {
   lineReader.setVariable(variableName, parsedValue);
   lineReader.getHistory().save();
   propertiesMap.put(property, parsedValue);
  }
 } catch (Exception e) {
  sqlLine.handleException(e);
 }
}

代码示例来源:origin: sqlline/sqlline

private void setLineReaderHistoryIntVariable(
  String variableName, String value, SqlLineProperty property) {
 LineReader lineReader = sqlLine.getLineReader();
 if (lineReader == null) {
  return;
 }
 int currentValue = getInt(property);
 try {
  if (DEFAULT.equals(value)) {
   if (currentValue == (Integer) property.defaultValue()) {
    return;
   } else {
    lineReader.setVariable(variableName, property.defaultValue());
    lineReader.getHistory().save();
    propertiesMap.put(property, property.defaultValue());
    return;
   }
  }
  int parsedValue = Integer.parseInt(value);
  if (parsedValue == currentValue) {
   return;
  } else {
   lineReader.setVariable(variableName, parsedValue);
   lineReader.getHistory().save();
   propertiesMap.put(property, parsedValue);
  }
 } catch (Exception e) {
  sqlLine.handleException(e);
 }
}

代码示例来源:origin: batfish/batfish

private void runInteractive() {
 SignalHandler handler = signal -> _logger.debugf("Client: Ignoring signal: %s\n", signal);
 Signal.handle(new Signal("INT"), handler);
 try {
  while (!_exit) {
   try {
    String rawLine = _reader.readLine("batfish> ");
    if (rawLine == null) {
     break;
    }
    processCommand(rawLine);
   } catch (UserInterruptException e) {
    continue;
   }
  }
 } catch (EndOfFileException e) {
  // ignored
 } catch (Throwable t) {
  t.printStackTrace();
 } finally {
  try {
   _reader.getHistory().save();
  } catch (IOException e) {
   e.printStackTrace();
  }
 }
}

代码示例来源:origin: julianhyde/sqlline

public void setHistoryFile(String historyFile) {
 final String currentValue = get(HISTORY_FILE);
 if (Objects.equals(currentValue, historyFile)
   || Objects.equals(currentValue, Commands.expand(historyFile))) {
  return;
 }
 if (DEFAULT.equalsIgnoreCase(historyFile)) {
  set(HISTORY_FILE, DEFAULT);
 } else {
  propertiesMap.put(HISTORY_FILE, Commands.expand(historyFile));
 }
 if (sqlLine != null && sqlLine.getLineReader() != null) {
  History history = sqlLine.getLineReader().getHistory();
  if (history == null) {
   history = new DefaultHistory();
  } else {
   try {
    history.save();
   } catch (IOException e) {
    sqlLine.handleException(e);
   }
  }
  sqlLine.getLineReader()
    .setVariable(LineReader.HISTORY_FILE, get(HISTORY_FILE));
  history.attach(sqlLine.getLineReader());
 }
}

代码示例来源:origin: sqlline/sqlline

public void setHistoryFile(String historyFile) {
 final String currentValue = get(HISTORY_FILE);
 if (Objects.equals(currentValue, historyFile)
   || Objects.equals(currentValue, Commands.expand(historyFile))) {
  return;
 }
 if (DEFAULT.equalsIgnoreCase(historyFile)) {
  set(HISTORY_FILE, DEFAULT);
 } else {
  propertiesMap.put(HISTORY_FILE, Commands.expand(historyFile));
 }
 if (sqlLine != null && sqlLine.getLineReader() != null) {
  final History history = sqlLine.getLineReader().getHistory();
  if (history != null) {
   try {
    history.save();
   } catch (IOException e) {
    sqlLine.handleException(e);
   }
  }
  sqlLine.getLineReader()
    .setVariable(LineReader.HISTORY_FILE, get(HISTORY_FILE));
  new DefaultHistory().attach(sqlLine.getLineReader());
 }
}

代码示例来源:origin: apache/incubator-ratis

defaultHistory.save();
} catch (IOException e) {
 LOG.debug("Failed to save terminal history", e);

代码示例来源:origin: org.jline/jline

history.save();

代码示例来源:origin: org.jline/jline-builtins

history.save();

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

reader.getHistory().save();
} catch (IOException e1) {

代码示例来源:origin: julianhyde/sqlline

callback);
if (saveHistory) {
 fileHistory.save();

代码示例来源:origin: sqlline/sqlline

callback);
if (saveHistory) {
 fileHistory.save();

相关文章