Package org.crsh.cli.impl

Examples of org.crsh.cli.impl.SyntaxException


      Object value = parameterMatch != null ? parameterMatch.computeValue() : null;
      if (value == null) {
        if (parameter.getDeclaredType().isPrimitive() || parameter.isRequired()) {
          if (parameter instanceof ArgumentDescriptor) {
            ArgumentDescriptor argument = (ArgumentDescriptor)parameter;
            throw new SyntaxException("Missing argument " + argument.getName());
          } else {
            OptionDescriptor option = (OptionDescriptor)parameter;
            throw new SyntaxException("Missing option " + option.getNames());
          }
        }
      } else {
        ((Binding)parameter).set(target, args, value);
      }
View Full Code Here


            if (v != null) {
              mArgs[i] = v;
            }
          }
          if (mArgs[i] == null && parameterType.isPrimitive()) {
            throw new SyntaxException("Method argument at position " + i + " of " + m + " is missing");
          }
        }

        // Perform method invocation
        try {
View Full Code Here

  @Override
  public Object parse(List<String> values) throws SyntaxException {
    if (arity == 0) {
      if (values.size() > 0) {
        throw new SyntaxException("Too many values " + values + " for option " + names.get(0));
      }
      // It's a boolean and it is true
      return Boolean.TRUE;
    } else {
      if (getMultiplicity() == Multiplicity.SINGLE) {
        if (values.size() > 1) {
          throw new SyntaxException("Too many values " + values + " for option " + names.get(0));
        }
        if (values.size() == 0) {
          throw new SyntaxException("Missing option " + names.get(0) + " value");
        }
        String value = values.get(0);
        try {
          return parse(value);
        } catch (Exception e) {
          throw new SyntaxException("Could not parse value <" + value + "> for option " + names.get(0));
        }
      } else {
        List<Object> v = new ArrayList<Object>(values.size());
        for (String value : values) {
          try {
            v.add(parse(value));
          } catch (Exception e) {
            throw new SyntaxException("Could not parse value <" + value + "> for option " + names.get(0));
          }
        }
        return v;
      }
    }
View Full Code Here

  @Override
  public Object parse(List<String> values) throws SyntaxException {
    if (getMultiplicity() == Multiplicity.SINGLE) {
      if (values.size() > 1) {
        throw new SyntaxException("Too many option values " + values);
      }
      String value = values.get(0);
      try {
        return parse(value);
      } catch (Exception e) {
        throw new SyntaxException("Could not parse " + value);
      }
    } else {
      List<Object> v = new ArrayList<Object>(values.size());
      for (String value : values) {
        try {
          v.add(parse(value));
        } catch (Exception e) {
          throw new SyntaxException("Could not parse " + value);
        }
      }
      return v;
    }
  }
View Full Code Here

TOP

Related Classes of org.crsh.cli.impl.SyntaxException

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.