本文整理了Java中org.jline.reader.History.size()
方法的一些代码示例,展示了History.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。History.size()
方法的具体详情如下:
包路径:org.jline.reader.History
类名称:History
方法名:size
暂无
代码示例来源:origin: org.jline/jline
default boolean isEmpty() {
return size() == 0;
}
代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.core
public int last() {
return first() + history.size() - 1;
}
代码示例来源:origin: apache/karaf
public int last() {
return first() + history.size() - 1;
}
代码示例来源:origin: org.jline/jline
protected boolean viHistorySearchBackward() {
searchDir = -1;
searchIndex = history.size() - 1;
return getViSearchString() && viRepeatSearch();
}
代码示例来源:origin: org.springframework.shell/spring-shell-standard-commands
@ShellMethod(value = "Display or save the history of previously run commands")
public List<String> history(@ShellOption(help = "A file to save history to.", defaultValue = ShellOption.NULL) File file) throws IOException {
if (file == null) {
List<String> result = new ArrayList<>(jLineHistory.size());
jLineHistory.forEach(e -> result.add(e.line()));
return result;
} else {
try (FileWriter w = new FileWriter(file)) {
for (org.jline.reader.History.Entry entry : jLineHistory) {
w.append(entry.line()).append(System.lineSeparator());
}
}
return Collections.singletonList(String.format("Wrote %d entries to %s", jLineHistory.size(), file));
}
}
}
代码示例来源:origin: julianhyde/sqlline
private String calculateCommand(int currentOffset, Set<Integer> offsets) {
if (!offsets.add(currentOffset)) {
throw new IllegalArgumentException(
"Cycled rerun of commands from history " + offsets);
}
History history = sqlLine.getLineReader().getHistory();
Iterator<History.Entry> iterator = currentOffset > 0
? history.iterator(currentOffset - 1)
: history.reverseIterator(history.size() - 1 + currentOffset);
String command = iterator.next().line();
if (command.trim().startsWith("!/") || command.startsWith("!rerun")) {
String[] cmd = sqlLine.split(command);
if (cmd.length > 2 || (cmd.length == 2 && !cmd[1].matches("-?\\d+"))) {
return command;
}
int offset = cmd.length == 1 ? -1 : Integer.parseInt(cmd[1]);
if (history.size() < offset || history.size() - 1 < -offset) {
return command;
}
return calculateCommand(offset, offsets);
}
return command;
}
代码示例来源:origin: sqlline/sqlline
private String calculateCommand(int currentOffset, Set<Integer> offsets) {
if (!offsets.add(currentOffset)) {
throw new IllegalArgumentException(
"Cycled rerun of commands from history " + offsets);
}
History history = sqlLine.getLineReader().getHistory();
Iterator<History.Entry> iterator = currentOffset > 0
? history.iterator(currentOffset - 1)
: history.reverseIterator(history.size() - 1 + currentOffset);
String command = iterator.next().line();
if (command.trim().startsWith("!/") || command.startsWith("!rerun")) {
String[] cmd = sqlLine.split(command);
if (cmd.length > 2 || (cmd.length == 2 && !cmd[1].matches("-?\\d+"))) {
return command;
}
int offset = cmd.length == 1 ? -1 : Integer.parseInt(cmd[1]);
if (history.size() < offset || history.size() - 1 < -offset) {
return command;
}
return calculateCommand(offset, offsets);
}
return command;
}
代码示例来源:origin: org.jline/jline
switch (c) {
case '!':
if (history.size() == 0) {
throw new IllegalArgumentException("!!: event not found");
if (history.size() == 0) {
throw new IllegalArgumentException("!$: event not found");
throw new IllegalArgumentException((neg ? "!-" : "!") + line.substring(i1, i) + ": event not found");
if (neg && idx > 0 && idx <= history.size()) {
rep = history.get(history.index() - idx);
} else if (!neg && idx > history.index() - history.size() && idx <= history.index()) {
rep = history.get(idx - 1);
} else {
代码示例来源:origin: julianhyde/sqlline
public void rerun(String line, DispatchCallback callback) {
String[] cmd = sqlLine.split(line);
History history = sqlLine.getLineReader().getHistory();
int size = history.size();
if (cmd.length > 2 || (cmd.length == 2 && !cmd[1].matches("-?\\d+"))) {
if (size == 0) {
代码示例来源:origin: sqlline/sqlline
public void rerun(String line, DispatchCallback callback) {
String[] cmd = sqlLine.split(line);
History history = sqlLine.getLineReader().getHistory();
int size = history.size();
if (cmd.length > 2 || (cmd.length == 2 && !cmd[1].matches("-?\\d+"))) {
if (size == 0) {
内容来源于网络,如有侵权,请联系作者删除!