本文整理汇总了Java中jline.console.ConsoleReader.println方法的典型用法代码示例。如果您正苦于以下问题:Java ConsoleReader.println方法的具体用法?Java ConsoleReader.println怎么用?Java ConsoleReader.println使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jline.console.ConsoleReader
的用法示例。
在下文中一共展示了ConsoleReader.println方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: increasePop
import jline.console.ConsoleReader; //导入方法依赖的package包/类
/**
* Raise population of hippopotamus amphibius within console.
* @param console
*/
public static void increasePop(ConsoleReader console) {
HippopotamusFactory builder = HippopotamusFactory.builder();
if (System.getenv("HIPPO_SIZE") != null) {
int hippoSize = Integer.parseInt(System.getenv("HIPPO_SIZE"));
builder.size(hippoSize);
}
Hippopotamus hippo = builder.build();
try {
for (double i = 0; i < Math.PI; i += 0.1) {
console.println(hippo.toString().replaceAll("^|\n", "\n" + StringUtils.repeat(" ", (int) (Math.sin(i) * 100))));
console.flush();
Thread.sleep(100);
}
} catch (IOException | InterruptedException e) {
System.err.println("Supercalafrajilistichippopotamusexception");
}
hippo.submerge();
console.setPrompt(hippo.toString());
}
示例2: promptMongoVerified
import jline.console.ConsoleReader; //导入方法依赖的package包/类
/**
* Prompt the user asking them if they are sure they would like to do the
* install.
*
* @param instanceName - The Rya instance name. (not null)
* @param installConfig - The configuration that will be presented to the user. (not null)
* @return The value they entered.
* @throws IOException There was a problem reading the value.
*/
private boolean promptMongoVerified(final String instanceName, final InstallConfiguration installConfig) throws IOException {
requireNonNull(instanceName);
requireNonNull(installConfig);
final ConsoleReader reader = getReader();
reader.println();
reader.println("A Rya instance will be installed using the following values:");
reader.println(" Instance Name: " + instanceName);
reader.println(" Use Free Text Indexing: " + installConfig.isFreeTextIndexEnabled());
reader.println(" Use Temporal Indexing: " + installConfig.isTemporalIndexEnabled());
reader.println(" Use PCJ Indexing: " + installConfig.isPcjIndexEnabled());
reader.println("");
return promptBoolean("Continue with the install? (y/n) ", Optional.absent());
}
示例3: printLine
import jline.console.ConsoleReader; //导入方法依赖的package包/类
public static void printLine(ConsoleReader console, String author, String message) {
try {
CursorBuffer stashed = stashLine(console);
console.println(author + " > " + message);
unstashLine(console, stashed);
console.flush();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例4: getSparql
import jline.console.ConsoleReader; //导入方法依赖的package包/类
@Override
public Optional<String> getSparql() throws IOException {
final ConsoleReader reader = getReader();
reader.setCopyPasteDetection(true); // disable tab completion from activating
reader.setHistoryEnabled(false); // don't store SPARQL fragments in the command history
try {
reader.println("Enter a SPARQL Query.");
reader.println("Type '" + EXECUTE_COMMAND + "' to execute the current query.");
reader.println("Type '" + CLEAR_COMMAND + "' to clear the current query.");
reader.flush();
final StringBuilder sb = new StringBuilder();
String line = reader.readLine("SPARQL> ");
while (!line.endsWith(CLEAR_COMMAND) && !line.endsWith(EXECUTE_COMMAND)) {
sb.append(line).append("\n");
line = reader.readLine(" -> ");
}
if (line.endsWith(EXECUTE_COMMAND)) {
sb.append(line.substring(0, line.length() - EXECUTE_COMMAND.length()));
return Optional.of(sb.toString());
}
return Optional.absent();
} finally {
reader.setHistoryEnabled(true); // restore the ConsoleReader's settings
reader.setCopyPasteDetection(false); // restore tab completion
}
}
示例5: promptBoolean
import jline.console.ConsoleReader; //导入方法依赖的package包/类
/**
* Prompts a user for a boolean value. The prompt will be repeated until
* a value true/false string has been submitted. If a default value is
* provided, then it will be used if the user doens't enter anything.
*
* @param prompt - The prompt for the input. (not null)
* @param defaultValue - The default value for the input if one is provided. (not null)
* @return The value the user entered.
* @throws IOException There was a problem reading values from the user.
*/
protected boolean promptBoolean(final String prompt, final Optional<Boolean> defaultValue) throws IOException {
requireNonNull(prompt);
requireNonNull(defaultValue);
final ConsoleReader reader = getReader();
reader.setPrompt(prompt);
Boolean value = null;
boolean prompting = true;
while(prompting) {
// An empty input means to use the default value.
final String input = reader.readLine();
if(input.isEmpty() && defaultValue.isPresent()) {
value = defaultValue.get();
prompting = false;
}
// Check if it is one of the affirmative answers.
if(isAffirmative(input)) {
value = true;
prompting = false;
}
// Check if it is one of the negative answers.
if(isNegative(input)) {
value = false;
prompting = false;
}
// If we are still prompting, the input was invalid.
if(prompting) {
reader.println("Invalid response (true/false)");
}
}
return value;
}
示例6: promptString
import jline.console.ConsoleReader; //导入方法依赖的package包/类
/**
* Prompts a user for a String value. The prompt will be repeated until a
* value has been submitted. If a default value is provided, then it will be
* used if the user doesn't enter anything.
*
* @param prompt - The prompt for the input. (not null)
* @param defaultValue - The default value for the input if one is provided. (not null)
* @return The value the user entered.
* @throws IOException There was a problem reading values from the user.
*/
protected String promptString(final String prompt, final Optional<String> defaultValue) throws IOException {
requireNonNull(prompt);
requireNonNull(defaultValue);
final ConsoleReader reader = getReader();
reader.setPrompt(prompt);
String value = null;
boolean prompting = true;
while(prompting) {
// Read a line of input.
final String input = reader.readLine();
if(!input.isEmpty()) {
// If a value was provided, return it.
value = input;
prompting = false;
} else {
// Otherwise, if a default value was provided, return it;
if(defaultValue.isPresent()) {
value = defaultValue.get();
prompting = false;
} else {
// Otherwise, the user must provide a value.
reader.println("Invalid response. Must provide a value.");
}
}
}
return value;
}
示例7: promptAccumuloVerified
import jline.console.ConsoleReader; //导入方法依赖的package包/类
/**
* Prompt the user asking them if they are sure they would like to do the
* install.
*
* @param instanceName - The Rya instance name. (not null)
* @param installConfig - The configuration that will be presented to the user. (not null)
* @return The value they entered.
* @throws IOException There was a problem reading the value.
*/
private boolean promptAccumuloVerified(final String instanceName, final InstallConfiguration installConfig) throws IOException {
requireNonNull(instanceName);
requireNonNull(installConfig);
final ConsoleReader reader = getReader();
reader.println();
reader.println("A Rya instance will be installed using the following values:");
reader.println(" Instance Name: " + instanceName);
reader.println(" Use Shard Balancing: " + installConfig.isTableHashPrefixEnabled());
reader.println(" Use Entity Centric Indexing: " + installConfig.isEntityCentrixIndexEnabled());
reader.println(" Use Free Text Indexing: " + installConfig.isFreeTextIndexEnabled());
// RYA-215 reader.println(" Use Geospatial Indexing: " + installConfig.isGeoIndexEnabled());
reader.println(" Use Temporal Indexing: " + installConfig.isTemporalIndexEnabled());
reader.println(" Use Precomputed Join Indexing: " + installConfig.isPcjIndexEnabled());
if(installConfig.isPcjIndexEnabled()) {
if(installConfig.getFluoPcjAppName().isPresent()) {
reader.println(" PCJ Updater Fluo Application Name: " + installConfig.getFluoPcjAppName().get());
} else {
reader.println(" Not using a PCJ Updater Fluo Application");
}
}
reader.println("");
return promptBoolean("Continue with the install? (y/n) ", Optional.absent());
}
示例8: main
import jline.console.ConsoleReader; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// Connect to the sever
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", PORT).usePlaintext(true).build();
ReactorChatGrpc.ReactorChatStub stub = ReactorChatGrpc.newReactorStub(channel);
CountDownLatch done = new CountDownLatch(1);
ConsoleReader console = new ConsoleReader();
// Prompt the user for their name
console.println("Press ctrl+D to quit");
String author = console.readLine("Who are you? > ");
stub.postMessage(toMessage(author, author + " joined.")).subscribe();
// Subscribe to incoming messages
Disposable chatSubscription = stub.getMessages(Mono.just(Empty.getDefaultInstance())).subscribe(
message -> {
// Don't re-print our own messages
if (!message.getAuthor().equals(author)) {
printLine(console, message.getAuthor(), message.getMessage());
}
},
throwable -> {
printLine(console, "ERROR", throwable.getMessage());
done.countDown();
},
done::countDown
);
// Publish outgoing messages
Flux.fromIterable(new ConsoleIterator(console, author + " > "))
.map(msg -> toMessage(author, msg))
.flatMap(stub::postMessage)
.subscribe(
empty -> { },
throwable -> {
printLine(console, "ERROR", throwable.getMessage());
done.countDown();
},
done::countDown
);
// Wait for a signal to exit, then clean up
done.await();
stub.postMessage(toMessage(author, author + " left.")).subscribe();
chatSubscription.dispose();
channel.shutdown();
channel.awaitTermination(1, TimeUnit.SECONDS);
console.getTerminal().restore();
}
示例9: printLine
import jline.console.ConsoleReader; //导入方法依赖的package包/类
public static void printLine(ConsoleReader console, String author, String message) throws IOException {
CursorBuffer stashed = stashLine(console);
console.println(author + " > " + message);
unstashLine(console, stashed);
console.flush();
}
示例10: main
import jline.console.ConsoleReader; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// Connect to the sever
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", PORT).usePlaintext(true).build();
RxChatGrpc.RxChatStub stub = RxChatGrpc.newRxStub(channel);
CountDownLatch done = new CountDownLatch(1);
ConsoleReader console = new ConsoleReader();
// Prompt the user for their name
console.println("Press ctrl+D to quit");
String author = console.readLine("Who are you? > ");
stub.postMessage(toMessage(author, author + " joined.")).subscribe();
// Subscribe to incoming messages
Disposable chatSubscription = stub.getMessages(Single.just(Empty.getDefaultInstance())).subscribe(
message -> {
// Don't re-print our own messages
if (!message.getAuthor().equals(author)) {
printLine(console, message.getAuthor(), message.getMessage());
}
},
throwable -> {
printLine(console, "ERROR", throwable.getMessage());
done.countDown();
},
done::countDown
);
// Publish outgoing messages
Observable.fromIterable(new ConsoleIterator(console, author + " > "))
.map(msg -> toMessage(author, msg))
.flatMapSingle(stub::postMessage)
.subscribe(
empty -> { },
throwable -> {
printLine(console, "ERROR", throwable.getMessage());
done.countDown();
},
done::countDown
);
// Wait for a signal to exit, then clean up
done.await();
stub.postMessage(toMessage(author, author + " left.")).subscribe();
chatSubscription.dispose();
channel.shutdown();
channel.awaitTermination(1, TimeUnit.SECONDS);
console.getTerminal().restore();
}
示例11: printCandidates
import jline.console.ConsoleReader; //导入方法依赖的package包/类
public static void printCandidates(ConsoleReader reader, Collection<CharSequence> candidates) throws IOException {
HashSet distinct = new HashSet(candidates);
if(distinct.size() > reader.getAutoprintThreshold()) {
reader.print(Messages.DISPLAY_CANDIDATES.format(candidates.size()));
reader.flush();
String i$ = Messages.DISPLAY_CANDIDATES_NO.format();
String next = Messages.DISPLAY_CANDIDATES_YES.format();
char[] allowed = new char[]{next.charAt(0), i$.charAt(0)};
int copy;
while((copy = reader.readCharacter(allowed)) != -1){
String tmp = new String(new char[]{(char) copy});
if(i$.startsWith(tmp)) {
reader.println();
return;
}
if(next.startsWith(tmp)) {
break;
}
reader.beep();
}
}
if(distinct.size() != candidates.size()) {
ArrayList copy1 = new ArrayList();
Iterator i$1 = ((Collection) candidates).iterator();
while(i$1.hasNext()){
CharSequence next1 = (CharSequence) i$1.next();
if(!copy1.contains(next1)) {
copy1.add(next1);
}
}
candidates = copy1;
}
reader.println();
// clear candidates
Collection<CharSequence> clearedCandidates = new ArrayList<>();
for(CharSequence candidate : candidates) {
String str = candidate + "";
String[] spl = str.split(" ");
if(spl.length != 1) {
str = spl[spl.length - 1];
}
clearedCandidates.add(str);
}
reader.printColumns(clearedCandidates);
}