本文整理了Java中org.kohsuke.args4j.spi.Parameters
类的一些代码示例,展示了Parameters
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parameters
类的具体详情如下:
包路径:org.kohsuke.args4j.spi.Parameters
类名称:Parameters
[英]List of arguments.
Object of this interface is passed to OptionHandlers to make it easy/safe to parse additional parameters for options.
[中]参数列表。
该接口的对象被传递给OptionHandlers,以方便/安全地解析选项的其他参数。
代码示例来源:origin: jenkinsci/jenkins
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String param = params.getParameter(0);
Result v = fromString(param.replace('-', '_'));
if (v==null)
throw new CmdLineException(owner,"No such status '"+param+"'. Did you mean "+
EditDistance.findNearest(param.replace('-', '_').toUpperCase(), getNames()));
setter.addValue(v);
return 1;
}
代码示例来源:origin: kohsuke/args4j
public int parseArguments(Parameters parameters) throws CmdLineException {
for (int i=0; i<parameters.size(); i++)
setter.addValue(parameters.getParameter(i));
return parameters.size();
}
代码示例来源:origin: org.bitbucket.ibencher/vagabond
@Override
public int parseArguments(Parameters params) throws CmdLineException {
if (params.size() != 1)
throw new CmdLineException ("an option of type log level should have one parameter [trace,debug,info,warn,error,fatal,off]");
Level result = Level.toLevel(params.getParameter(0).toLowerCase());
setter.addValue(result);
log.debug("set log level " + result);
return 1;
}
代码示例来源:origin: args4j/args4j
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String macString = params.getParameter(0);
String[] macStringArray = null;
throw new CmdLineException(owner,
Messages.ILLEGAL_MAC_ADDRESS, macString);
setter.asFieldSetter().addValue(mac);
return 1;
代码示例来源:origin: jenkinsci/jenkins
@Override
public int parseArguments(Parameters params) throws CmdLineException {
setter.addValue(getView(params.getParameter(0)));
return 1;
}
代码示例来源:origin: com.madgag/org.eclipse.jgit.pgm
@Override
public int parseArguments(final Parameters params) throws CmdLineException {
String name = params.getParameter(0);
boolean interesting = true;
if (name.startsWith("^")) { //$NON-NLS-1$
name = name.substring(1);
interesting = false;
}
final int dot2 = name.indexOf(".."); //$NON-NLS-1$
if (dot2 != -1) {
if (!option.isMultiValued())
throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn
, option.metaVar(), name));
final String left = name.substring(0, dot2);
final String right = name.substring(dot2 + 2);
addOne(left, false);
addOne(right, true);
return 1;
}
addOne(name, interesting);
return 1;
}
代码示例来源:origin: kohsuke/args4j
@Override
public int parseArguments(Parameters params) throws CmdLineException {
FieldSetter fs = setter.asFieldSetter();
Map v = (Map)fs.getValue();
if (v==null) {
v = createNewCollection(fs.getType());
fs.addValue(v);
}
addToMap(params.getParameter(0),v);
return 1;
}
代码示例来源:origin: args4j/args4j
@Override
public String get(int index) {
try {
return params.getParameter(index+1);
} catch (CmdLineException e) {
// invalid index was accessed.
throw new IndexOutOfBoundsException();
}
}
代码示例来源:origin: kohsuke/args4j
@Override
public int size() {
return params.size()-1;
}
});
代码示例来源:origin: CoreMedia/jangaroo-tools
@Override
public int parseArguments(Parameters parameters) throws CmdLineException {
List<File> sourceFiles = new ArrayList<File>(parameters.size());
for(int i = 0; i<parameters.size(); i++) {
String sourcePath = parameters.getParameter(i);
// be tolerant, accept also '/' as file separator
File sourceFile = new File(sourcePath.replace('/', File.separatorChar));
if (!sourceFile.exists()) {
throw new CmdLineException(owner, "Source file does not exist: " + sourceFile.getAbsolutePath());
}
sourceFiles.add(sourceFile);
}
setter.addValue(sourceFiles);
return parameters.size();
}
代码示例来源:origin: kohsuke/args4j
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String macString = params.getParameter(0);
String[] macStringArray = null;
throw new CmdLineException(owner,
Messages.ILLEGAL_MAC_ADDRESS, macString);
setter.asFieldSetter().addValue(mac);
return 1;
代码示例来源:origin: jenkinsci/jenkins
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String nodeName = params.getParameter(0);
final Node node = Jenkins.get().getNode(nodeName);
if (node == null) throw new IllegalArgumentException("No such node '" + nodeName + "'");
setter.addValue(node);
return 1;
}
代码示例来源:origin: args4j/args4j
@Override
public int parseArguments(Parameters params) throws CmdLineException {
FieldSetter fs = setter.asFieldSetter();
Map v = (Map)fs.getValue();
if (v==null) {
v = createNewCollection(fs.getType());
fs.addValue(v);
}
addToMap(params.getParameter(0),v);
return 1;
}
代码示例来源:origin: kohsuke/args4j
@Override
public String get(int index) {
try {
return params.getParameter(index+1);
} catch (CmdLineException e) {
// invalid index was accessed.
throw new IndexOutOfBoundsException();
}
}
代码示例来源:origin: args4j/args4j
@Override
public int size() {
return params.size()-1;
}
});
代码示例来源:origin: kohsuke/args4j
@Override
public int parseArguments(Parameters params) throws CmdLineException {
String param = params.getParameter(0);
try {
setter.addValue(new URL(param));
return 1;
} catch (MalformedURLException e) {
throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND,
params.getParameter(-1), param);
}
}
代码示例来源:origin: args4j/args4j
public int parseArguments(Parameters parameters) throws CmdLineException {
for (int i=0; i<parameters.size(); i++)
setter.addValue(parameters.getParameter(i));
return parameters.size();
}
代码示例来源:origin: org.jacoco/org.jacoco.cli
@Override
public int parseArguments(final Parameters params) throws CmdLineException {
final String subCmd = params.getParameter(0);
for (final Command c : AllCommands.get()) {
if (c.name().equals(subCmd)) {
parseSubArguments(c, params);
setter.addValue(c);
return params.size(); // consume all the remaining tokens
}
}
throw new CmdLineException(owner,
Messages.ILLEGAL_OPERAND.format(option.toString(), subCmd));
}
代码示例来源:origin: Audiveris/audiveris
@Override
public int parseArguments (org.kohsuke.args4j.spi.Parameters params)
throws CmdLineException
{
String className = params.getParameter(0).trim();
if (!className.isEmpty()) {
try {
Class runClass = Class.forName(className);
FieldSetter fs = setter.asFieldSetter();
fs.addValue(runClass);
} catch (ClassNotFoundException ex) {
throw new CmdLineException(owner, ex);
}
}
return 1;
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override public int parseArguments(Parameters params) throws CmdLineException {
final Jenkins j = Jenkins.get();
final String src = params.getParameter(0);
T s = j.getItemByFullName(src, type());
if (s == null) {
final Authentication who = Jenkins.getAuthentication();
try (ACLContext acl = ACL.as(ACL.SYSTEM)) {
Item actual = j.getItemByFullName(src);
if (actual == null) {
LOGGER.log(Level.FINE, "really no item exists named {0}", src);
} else {
LOGGER.log(Level.WARNING, "running as {0} could not find {1} of {2}", new Object[] {who.getPrincipal(), actual, type()});
}
}
T nearest = Items.findNearest(type(), src, j);
if (nearest != null) {
throw new IllegalArgumentException("No such job '" + src + "'; perhaps you meant '" + nearest.getFullName() + "'?");
} else {
throw new IllegalArgumentException("No such job '" + src + "'");
}
}
setter.addValue(s);
return 1;
}
内容来源于网络,如有侵权,请联系作者删除!