/** * Get ParamModel for short option name. */ private ParamModel lookupShortOption(char c) { // XXX - for now, fake it if no options if (options == null) return null; String sc = Character.toString(c); for (ParamModel od : options) { if (od.getParam().shortName().equals(sc)) return od; } return null; }
/** * Get ParamModel for short option name. */ private ParamModel lookupShortOption(char c) { // XXX - for now, fake it if no options if (options == null) return null; String sc = Character.toString(c); for (ParamModel od : options) { if (od.getParam().shortName().equals(sc)) return od; } return null; }
/** * Get ParamModel for long option name. */ private ParamModel lookupLongOption(String s) { if (s == null || s.length() == 0) return null; // XXX - for now, fake it if no options if (options == null) { // no valid options specified so everything is valid return new ParamModelData(s, String.class, true, null); } for (ParamModel od : options) { if (od.getParam().primary()) continue; if (s.equalsIgnoreCase(od.getName())) return od; if (s.equalsIgnoreCase(od.getParam().alias())) return od; } return null; }
/** * Get an option value, that might come from the command line * or from the environment. Return the default value for the * option if not otherwise specified. */ private String getOption(String name) { String val = options.getOne(name); if (val == null) val = getFromEnvironment(name); if (val == null) { // no value, find the default ParamModel opt = commandModel.getModelFor(name); // if no value was specified and there's a default value, return it if (opt != null) { String def = opt.getParam().defaultValue(); if (ok(def)) val = def; } } return val; }
/** * Get an option value, that might come from the command line * or from the environment. Return the default value for the * option if not otherwise specified. */ protected String getOption(String name) { String val = options.getOne(name); if (val == null) val = env.getStringOption(name); if (val == null) { // no value, find the default ParamModel opt = commandModel.getModelFor(name); // if no value was specified and there's a default value, return it if (opt != null) { String def = opt.getParam().defaultValue(); if (ok(def)) val = def; } } return val; }
/** * Get ParamModel for long option name. */ private ParamModel lookupLongOption(String s) { if (s == null || s.length() == 0) return null; // XXX - for now, fake it if no options if (options == null) { // no valid options specified so everything is valid return new ParamModelData(s, String.class, true, null); } for (ParamModel od : options) { if (od.getParam().primary()) continue; if (s.equalsIgnoreCase(od.getName())) return od; if (s.equalsIgnoreCase(od.getParam().alias())) return od; } return null; }
/** * Get an option value, that might come from the command line * or from the environment. Return the default value for the * option if not otherwise specified. */ private String getOption(String name) { String val = options.getOne(name); if (val == null) val = getFromEnvironment(name); if (val == null) { // no value, find the default ParamModel opt = commandModel.getModelFor(name); // if no value was specified and there's a default value, return it if (opt != null) { String def = opt.getParam().defaultValue(); if (ok(def)) val = def; } } return val; }
@Override public boolean isOptional(AnnotatedElement element, Param annotation) { String name = CommandModel.getParamName(annotation, element); CommandModel.ParamModel param = model.getModelFor(name); return param.getParam().optional(); }
@Override public boolean isOptional(AnnotatedElement element, Param annotation) { String name = CommandModel.getParamName(annotation, element); CommandModel.ParamModel param = model.getModelFor(name); return param.getParam().optional(); }
@Override public boolean isOptional(AnnotatedElement element, Param annotation) { String name = CommandModel.getParamName(annotation, element); CommandModel.ParamModel param = model.getModelFor(name); return param.getParam().optional(); }
/** * Get the ParamModel that corresponds to the operand * (primary parameter). Return null if none. */ protected ParamModel getOperandModel() { for (ParamModel pm : commandModel.getParameters()) { if (pm.getParam().primary()) return pm; } return null; }
/** * Get the ParamModel that corresponds to the operand * (primary parameter). Return null if none. */ private ParamModel getOperandModel() { for (ParamModel pm : commandModel.getParameters()) { if (pm.getParam().primary()) return pm; } return null; }
@Override public boolean isOptional(AnnotatedElement element, Param annotation) { String name = CommandModel.getParamName(annotation, element); CommandModel.ParamModel param = model.getModelFor(name); return param.getParam().optional(); }
/** * Get the ParamModel that corresponds to the operand * (primary parameter). Return null if none. */ private ParamModel getOperandModel() { for (ParamModel pm : commandModel.getParameters()) { if (pm.getParam().primary()) return pm; } return null; }
public void validatePassword(String password, ParamModel pwdOpt) throws CommandValidationException { // XXX - hack alert! the description is stored in the default value String description = pwdOpt.getParam().defaultValue(); if (!ok(description)) description = pwdOpt.getName(); if (password == null) throw new CommandValidationException( strings.get("PasswordMissing", description)); }
/** * Get the ParamModel that corresponds to the operand * (primary parameter). Return null if none. */ protected ParamModel getOperandModel() { for (ParamModel pm : commandModel.getParameters()) { if (pm.getParam().primary()) return pm; } return null; }
/** * Get the ParamModel that corresponds to the operand * (primary parameter). Return null if none. */ private ParamModel getOperandModel() { for (ParamModel pm : commandModel.getParameters()) { if (pm.getParam().primary()) return pm; } return null; }
@Override public boolean isOptional(AnnotatedElement element, Param annotation) { String name = CommandModel.getParamName(annotation, element); CommandModel.ParamModel param = model.getModelFor(name); return param.getParam().optional(); }