Package org.crsh.cli.spi

Examples of org.crsh.cli.spi.Completer


   * @param line the original command line arguments
   * @return the completions
   */
  public final CompletionMatch complete(RuntimeContext context, String line) throws CommandException {
    CompletionMatcher matcher = getDescriptor().completer();
    Completer completer = getCompleter(context);
    try {
      return matcher.match(completer, line);
    }
    catch (CompletionException e) {
      // command.log.log(Level.SEVERE, "Error during completion of line " + line, e);
View Full Code Here


  public CompletionMatch complete() throws CompletionException {

    //
    Class<? extends Completer> completerType = parameter.getCompleterType();
    Completer completer = null;
    if (completerType != EmptyCompleter.class) {

      // If the provided completer instance matches the parameter completer type
      // then we use it
      if (completerType.isInstance(this.completer)) {
        completer = this.completer;
      } else {
        // Otherwise we instantiate it
        Constructor<? extends Completer> ctor;
        try {
          ctor = completerType.getDeclaredConstructor();
        }
        catch (NoSuchMethodException ignore) {
          throw new CompletionException("The completer " + completerType.getName() + " does not provide a no arg constructor");
        }
        if (Modifier.isPublic(ctor.getModifiers())) {
          try {
            completer = ctor.newInstance();
          }
          catch (InstantiationException e) {
            throw new CompletionException("The completer " + completerType.getName() + " cannot be abstract");
          }
          catch (InvocationTargetException e) {
            throw new CompletionException(e.getCause());
          }
          catch (Exception e) {
            throw new CompletionException(e);
          }
        } else {
          throw new CompletionException("The completer " + completerType.getName() + " constructor must be public");
        }
      }
    }

    //
    if (completer != null) {
      try {
        return new CompletionMatch(delimiter, completer.complete(parameter, prefix));
      }
      catch (Exception e) {
        throw new CompletionException(e);
      }
    } else {
View Full Code Here

TOP

Related Classes of org.crsh.cli.spi.Completer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.