@Override public void doComplete(CompletionInfo completions, String partial, int flags) { partial = partial.toLowerCase(); for (IBMPartitionTypes pt : IBMPartitionTypes.values()) { String code = Integer.toHexString(pt.getCode()); if (code.startsWith(partial)) { completions.addCompletion(code); } } }
@Override public void doComplete(final CompletionInfo completions, final String partial, final int flags) { try { // If 'partial' is a well-formed "file:" URL with no host, port, // user or query, do completion on the path component. URL url = new URL(partial); if (url.getProtocol().equals("file") && (url.getAuthority() == null || url.getAuthority().length() == 0) && (url.getQuery() == null || url.getQuery().length() == 0)) { // Use a FileArgument to do the work of completing the pathname, // capturing the results using our own CompletionInfo object. CompletionInfo myCompletion = new CommandCompletions(); new FileArgument(null, getFlags()).complete(myCompletion, url.getPath(), flags); // Then turn the completions back into "file:" URLs for (String c : myCompletion.getCompletions()) { // (Kludge - the 'true' argument prevents an extra space // character from being appended to the completions.) completions.addCompletion("file:" + c, true); } } } catch (MalformedURLException ex) { // No completion possible } }