
org.cyclopsgroup.jmxterm.io.JlineCommandInput Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmxterm Show documentation
Show all versions of jmxterm Show documentation
Command line based interactive JMX client
The newest version!
package org.cyclopsgroup.jmxterm.io;
import java.io.IOException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.jline.reader.impl.LineReaderImpl;
/**
* Implementation of input that reads command from jloin console input
*
* @author Jiaqi Guo
*/
public class JlineCommandInput extends CommandInput {
private final LineReaderImpl console;
private final String prompt;
/**
* @param console Jline console reader
* @param prompt Prompt string
*/
public JlineCommandInput(LineReaderImpl console, String prompt) {
Validate.notNull(console, "Jline console reader can't be NULL");
this.console = console;
this.prompt = StringUtils.trimToEmpty(prompt);
}
/** @return Jline console */
public final LineReaderImpl getConsole() {
return console;
}
@Override
public String readLine() throws IOException {
return console.readLine(prompt);
}
@Override
public String readMaskedString(String prompt) throws IOException {
return console.readLine(prompt, '*');
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy