예제 #1
0
 @Override
 public String getRawValueForArgument(Argument arg) {
   List values = argumentValues.get(arg);
   if (values == null || values.isEmpty()) {
     return arg.getDefaultValue();
   }
   return values.get(0).toString();
 }
예제 #2
0
  /*
  verifies that each of our registered parameters has a value, either given or default

  throws an exeption otherwise
   */
  private void verify() throws Exception {
    for (Argument parameter : parameters.values()) {
      if (parameter.getValue() == null && parameter.getDefaultValue() == null) {
        throw new Exception(
            String.format("Argument '%s' is required.  Please see usage.", parameter.name));
      }
    }
  }
예제 #3
0
 public Object getValue(String argumentName) {
   Object value = null;
   argumentName = argumentName.toLowerCase();
   if (parameters.containsKey(argumentName)) {
     Argument argument = parameters.get(argumentName);
     value = argument.getValue();
     if (value == null) {
       String defaultValue = argument.getDefaultValue();
       try {
         value = argument.getHandler().tryArgument(defaultValue);
       } catch (Exception e) {
       }
     }
   }
   return value;
 }