public static String getString(final String name) { return getString(name, null); }
/** * @since 2.6 */ public static long getLong(final String name, final long defaultValue) { String str = getString(name); if (str == null) { return defaultValue; } return Long.parseLong(str); }
/** * @since 2.6 */ public static int getInteger(final String name, final int defaultValue) { String str = getString(name); if (str == null) { return defaultValue; } return Integer.parseInt(str); }
public static boolean getBoolean(final String name, final boolean defaultValue) { String value = getString(name); if (value == null) { return defaultValue; } return value.length() == 0 || value.equalsIgnoreCase("1") || value.equalsIgnoreCase("on") || value.equalsIgnoreCase("true"); }
/** * Retrieve the URL for the inputrc configuration file in effect. Intended * use is for instantiating ConsoleKeys, to read inputrc variables. */ public static URL getInputRc() throws IOException { String path = Configuration.getString(JLINE_INPUTRC); if (path == null) { File f = new File(Configuration.getUserHome(), INPUT_RC); if (!f.exists()) { f = new File(DEFAULT_INPUT_RC); } return f.toURI().toURL(); } else { return Urls.create(path); } }
/** * Get the default encoding. Will first look at the LC_ALL, LC_CTYPE, and LANG environment variables, then the input.encoding * system property, then the default charset according to the JVM. * * @return The default encoding to use when none is specified. */ public static String getEncoding() { // Check for standard locale environment variables, in order of precedence, first. // See http://www.gnu.org/s/libc/manual/html_node/Locale-Categories.html for (String envOption : new String[]{"LC_ALL", "LC_CTYPE", "LANG"}) { String envEncoding = extractEncodingFromCtype(System.getenv(envOption)); if (envEncoding != null) { try { if (Charset.isSupported(envEncoding)) { return envEncoding; } } catch (IllegalCharsetNameException e) { continue; } } } return getString("input.encoding", Charset.defaultCharset().name()); }
private TerminalLineSettings(String ttyDevice, boolean unused) throws IOException, InterruptedException { checkNotNull(ttyDevice); this.sttyCommand = Configuration.getString(JLINE_STTY, DEFAULT_STTY); this.shCommand = Configuration.getString(JLINE_SH, DEFAULT_SH); this.ttyDevice = ttyDevice; this.useRedirect = SUPPORTS_REDIRECT && DEFAULT_TTY.equals(ttyDevice); this.initialConfig = get("-g").trim(); this.config = get("-a"); this.configLastFetched = System.currentTimeMillis(); Log.debug("Config: ", config); // sanity check if (config.length() == 0) { throw new IOException(MessageFormat.format("Unrecognized stty code: {0}", config)); } }
String type = Configuration.getString(JLINE_TERMINAL, defaultType);
public static String getString(final String name) { return getString(name, null); }
/** * @since 2.6 */ public static int getInteger(final String name, final int defaultValue) { String str = getString(name); if (str == null) { return defaultValue; } return Integer.parseInt(str); }
/** * @since 2.6 */ public static long getLong(final String name, final long defaultValue) { String str = getString(name); if (str == null) { return defaultValue; } return Long.parseLong(str); }
public static boolean getBoolean(final String name, final boolean defaultValue) { String value = getString(name); if (value == null) { return defaultValue; } return value.length() == 0 || value.equalsIgnoreCase("1") || value.equalsIgnoreCase("on") || value.equalsIgnoreCase("true"); }
private static URL getInputRc() throws IOException { String path = Configuration.getString(JLINE_INPUTRC); if (path == null) { File f = new File(Configuration.getUserHome(), INPUT_RC); if (!f.exists()) { f = new File(DEFAULT_INPUT_RC); } return f.toURI().toURL(); } else { return Urls.create(path); } }
/** * Get the default encoding. Will first look at the LC_ALL, LC_CTYPE, and LANG environment variables, then the input.encoding * system property, then the default charset according to the JVM. * * @return The default encoding to use when none is specified. */ public static String getEncoding() { // Check for standard locale environment variables, in order of precedence, first. // See http://www.gnu.org/s/libc/manual/html_node/Locale-Categories.html for (String envOption : new String[]{"LC_ALL", "LC_CTYPE", "LANG"}) { String envEncoding = extractEncodingFromCtype(System.getenv(envOption)); if (envEncoding != null) { try { if (Charset.isSupported(envEncoding)) { return envEncoding; } } catch (IllegalCharsetNameException e) { continue; } } } return getString("input.encoding", Charset.defaultCharset().name()); }
private TerminalLineSettings(String ttyDevice, boolean unused) throws IOException, InterruptedException { checkNotNull(ttyDevice); this.sttyCommand = Configuration.getString(JLINE_STTY, DEFAULT_STTY); this.shCommand = Configuration.getString(JLINE_SH, DEFAULT_SH); this.ttyDevice = ttyDevice; this.useRedirect = SUPPORTS_REDIRECT && DEFAULT_TTY.equals(ttyDevice); this.initialConfig = get("-g").trim(); this.config = get("-a"); this.configLastFetched = System.currentTimeMillis(); Log.debug("Config: ", config); // sanity check if (config.length() == 0) { throw new IOException(MessageFormat.format("Unrecognized stty code: {0}", config)); } }
String type = Configuration.getString(JLINE_TERMINAL); if (type == null) { type = AUTO;
@Override public void start(Environment environment) throws IOException { errorPrintStream = new PrintStream(errorStream, true); String user = environment.getEnv().get(Environment.ENV_USER); if (Strings.isNullOrEmpty(user)) { user = "unknown"; } try { // Use our RemoteTerminal which does not depends on the platform. terminal = new RemoteTerminal(true); terminal.init(); } catch (Exception e) { LOGGER.warn("Error during terminal detection, falling back to unsupported terminal"); LOGGER.debug(DETAILS_MESSAGE, e); terminal = new UnsupportedTerminal(); } consoleReader = new ConsoleReader(inputStream, outputStream, terminal); // Disable jline shutdownhook to avoid exception at application shutdown jline.internal.Configuration.getString("jline.shutdownhook", "false"); consoleReader.addCompleter(new StringsCompleter(commandRegistry.getCommandList())); consoleReader.setCompletionHandler(new CandidateListCompletionHandler()); consoleReader.setPrompt(user + "@" + application.getId() + "$ "); consoleReader.setHandleUserInterrupt(false); consoleReader.setHistoryEnabled(true); ses = new SubjectAwareExecutorService(Executors.newSingleThreadExecutor()); ses.submit(this); }
@Override public void start(Environment environment) throws IOException { errorPrintStream = new PrintStream(errorStream, true); String user = environment.getEnv().get(Environment.ENV_USER); if (Strings.isNullOrEmpty(user)) { user = "unknown"; } try { // Use our RemoteTerminal which does not depends on the platform. terminal = new RemoteTerminal(true); terminal.init(); } catch (Exception e) { LOGGER.warn("Error during terminal detection, falling back to unsupported terminal"); LOGGER.debug(DETAILS_MESSAGE, e); terminal = new UnsupportedTerminal(); } consoleReader = new ConsoleReader(inputStream, outputStream, terminal); // Disable jline shutdownhook to avoid exception at application shutdown jline.internal.Configuration.getString("jline.shutdownhook", "false"); consoleReader.addCompleter(new StringsCompleter(commandRegistry.getCommandList())); consoleReader.setCompletionHandler(new CandidateListCompletionHandler()); consoleReader.setPrompt(user + "@" + application.getId() + "$ "); consoleReader.setHandleUserInterrupt(false); consoleReader.setHistoryEnabled(true); ses = new SubjectAwareExecutorService(Executors.newSingleThreadExecutor()); ses.submit(this); }