/** * Check to see if all arguments, including flag arguments, were consumed. * * @param scoped the argument scope * @throws UnconsumedParameterException thrown if parameters were not consumed */ private void checkUnconsumed(ContextArgumentStack scoped) throws UnconsumedParameterException { CommandContext context = scoped.getContext(); String unconsumed; String unconsumedFlags = getUnusedFlags(context); if ((unconsumed = scoped.getUnconsumed()) != null) { throw new UnconsumedParameterException(unconsumed + " " + unconsumedFlags); } if (unconsumedFlags != null) { throw new UnconsumedParameterException(unconsumedFlags); } }
/** * Get the default value for a parameter. * * @param i the index of the parameter * @param scoped the scoped context * @return a value * @throws ParameterException on an error * @throws CommandException on an error */ private Object getDefaultValue(int i, ContextArgumentStack scoped) throws ParameterException, CommandException, InvocationTargetException { CommandContext context = scoped.getContext(); ParameterData parameter = parameters[i]; String[] defaultValue = parameter.getDefaultValue(); if (defaultValue != null) { try { return parameter.getBinding().bind(parameter, new StringArgumentStack(context, defaultValue, false), false); } catch (MissingParameterException e) { throw new ParametricException( "The default value of the parameter using the binding " + parameter.getBinding().getClass() + " in the method\n" + method.toGenericString() + "\nis invalid"); } } return null; }
CommandContext context = scoped.getContext(); ParameterData parameter = parameters[i];