@Override public int complete(String buffer, int cursor, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); delegate.getStrings().add("on"); delegate.getStrings().add("off"); return delegate.complete(buffer, cursor, candidates); } }
@Override public int complete(final String buffer, final int cursor, final List candidates) { StringsCompleter delegate = new StringsCompleter(kinds); return delegate.complete(buffer, cursor, candidates); } }
@Override public int complete(String buffer, int index, List<String> candidates) { delegate.getStrings().addAll(Arrays.asList(LOCAL_HOSTNAME, LOCAL_IP, PUBLIC_HOSTNAME, PUBLIC_IP, MANUAL_IP)); return delegate.complete(buffer, index, candidates); } }
public StringsCompleter(final Collection<String> strings, boolean caseSensitive) { this(caseSensitive); assert strings != null; getStrings().addAll(strings); }
@SuppressWarnings("rawtypes") public int complete(final String buffer, final int cursor, final List candidates) { return delegate.complete(buffer, cursor, candidates); }
private Completer getDefaultCompleter(CommandSession session, Field field) { Completer completer = null; Class<?> type = field.getType(); if (type.isAssignableFrom(File.class)) { completer = new FileCompleter(session); } else if (type.isAssignableFrom(Boolean.class) || type.isAssignableFrom(boolean.class)) { completer = new StringsCompleter(new String[] {"false", "true"}, false); } else if (type.isAssignableFrom(Enum.class)) { Set<String> values = new HashSet<>(); for (Object o : EnumSet.allOf((Class<Enum>) type)) { values.add(o.toString()); } completer = new StringsCompleter(values, false); } else { // TODO any other completers we can add? } return completer; }
@Override public int complete(String buffer, int index, List<String> candidates) { delegate.getStrings().addAll(Arrays.asList(LOCAL_HOSTNAME, LOCAL_IP, PUBLIC_HOSTNAME, PUBLIC_IP, MANUAL_IP)); return delegate.complete(buffer, index, candidates); } }
public StringsCompleter(final Collection<String> strings) { this(); assert strings != null; getStrings().addAll(strings); }
@Override public int complete(final String buffer, final int cursor, final List candidates) { StringsCompleter delegate = new StringsCompleter(mainClasses); return delegate.complete(buffer, cursor, candidates); } }
public int complete(final String buffer, final int cursor, final List candidates) { return delegate.complete(buffer, cursor, candidates); }
private Completer getDefaultCompleter(Field field) { Completer completer = null; Class<?> type = field.getType(); if (type.isAssignableFrom(File.class)) { completer = new FileCompleter(null); } else if (type.isAssignableFrom(Boolean.class) || type.isAssignableFrom(boolean.class)) { completer = new StringsCompleter(new String[] {"false", "true"}, false); } else if (type.isAssignableFrom(Enum.class)) { Set<String> values = new HashSet<>(); for (Object o : EnumSet.allOf((Class<Enum>) type)) { values.add(o.toString()); } completer = new StringsCompleter(values, false); } else { // TODO any other completers we can add? } return completer; }
/** * @param buffer * the beginning string typed by the user * @param cursor * the position of the cursor * @param candidates * the list of completions proposed to the user */ @Override public int complete(String buffer, int cursor, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); delegate.getStrings().add("ALLOW"); delegate.getStrings().add("BLOCK"); return delegate.complete(buffer, cursor, candidates); } }
@Override public int complete(String buffer, int cursor, List<String> candidates) { delegate.getStrings().clear(); for (String item : cache.values()) { if (buffer == null || item.startsWith(buffer)) { delegate.getStrings().add(item); } } return delegate.complete(buffer, cursor, candidates); }
public void configurationEvent(ConfigurationEvent configurationEvent) { String pid = configurationEvent.getPid(); if (configurationEvent.getType() == ConfigurationEvent.CM_DELETED) { delegate.getStrings().remove(pid); } else if (configurationEvent.getType() == ConfigurationEvent.CM_UPDATED) { delegate.getStrings().add(pid); } } }
public int complete(String buffer, int cursor, List<String> candidates) { if (session == null) { session = CommandSessionHolder.getSession(); } checkData(); int res = new StringsCompleter(commands).complete(buffer, cursor, candidates); Collections.sort(candidates); return res; }
@Override @SuppressWarnings("unchecked") public int complete(String buffer, int cursor, List candidates) { if (buffer == null) { return super.complete(null, cursor, candidates); } else { // support completing lower case as well with the toUpperCase() call return super.complete(buffer.toUpperCase(), cursor, candidates); } } }
this.function = function; commandCompleter = new StringsCompleter(getNames(session, command)); optionsCompleter = new StringsCompleter(options.keySet()); Object value = method.invoke(action); if (value instanceof String[]) { argCompleter = new StringsCompleter((String[]) value); } else if (value instanceof Collection) { argCompleter = new StringsCompleter((Collection<String>) value); } else { LOGGER.warn("Could not use value " + value + " as set of completions!"); argCompleter = new FileCompleter(session); } else if (type.isAssignableFrom(Boolean.class) || type.isAssignableFrom(boolean.class)) { argCompleter = new StringsCompleter(new String[] {"false", "true"}, false); } else if (type.isAssignableFrom(Enum.class)) { Set<String> values = new HashSet<>(); values.add(o.toString()); argCompleter = new StringsCompleter(values, false); } else {
@Override public int complete(String buffer, int cursor, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); try { for (String datasource : jdbcService.datasources()) { delegate.getStrings().add(datasource); } } catch (Exception e) { // nothing to do } return delegate.complete(buffer, cursor, candidates); }
@Override public int complete(String s, int i, List<String> strings) { delegate.getStrings().clear(); delegate.getStrings().add(runtimeProperties.getRuntimeIdentity()); return delegate.complete(s,i,strings); }
public void configurationEvent(ConfigurationEvent configurationEvent) { String pid = configurationEvent.getPid(); if (configurationEvent.getType() == ConfigurationEvent.CM_DELETED) { delegate.getStrings().remove(pid); } else if (configurationEvent.getType() == ConfigurationEvent.CM_UPDATED) { delegate.getStrings().add(pid); } } }