当前位置: 首页>>代码示例>>Java>>正文


Java Parameters.size方法代码示例

本文整理汇总了Java中org.kohsuke.args4j.spi.Parameters.size方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.size方法的具体用法?Java Parameters.size怎么用?Java Parameters.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kohsuke.args4j.spi.Parameters的用法示例。


在下文中一共展示了Parameters.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
/**
 * Tries to parse {@code String[]} argument from {@link Parameters}.
 */
@Override
public int parseArguments(Parameters params) throws CmdLineException
{
	int counter = 0;
	for (; counter < params.size(); counter++)
	{
		String param = params.getParameter(counter);

		boolean nextAlpha = false;

		if (param.length() > 1 && Character.isAlphabetic(param.charAt(1)))
			nextAlpha = true;

		if (param.startsWith("-") && nextAlpha)
			break;

		setter.addValue(param);
	}

	return counter;
}
 
开发者ID:verivital,项目名称:hyst,代码行数:25,代码来源:StringWithSpacesArrayOptionHandler.java

示例2: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
    String name = params.getParameter(0);
    CliCommand handler = getHandler(name);

    if (handler == null) throw new CmdLineException(
            owner, "Command \"" + name + "\" not found"
    );

    setter.addValue(handler);

    // Collect subcommand arguments
    int paramCount = params.size();
    String[] subCommandParams = new String[paramCount - 1];
    for (int i = 1; i < paramCount; i++) {
        subCommandParams[i - 1] = params.getParameter(i);
    }
    new CmdLineParser(handler).parseArgument(subCommandParams);

    return params.size(); // All arguments consumed
}
 
开发者ID:olivergondza,项目名称:dumpling,代码行数:22,代码来源:CliCommandOptionHandler.java

示例3: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
  int counter = 0;
  boolean hasValues = false;

  while (counter < params.size()) {
    String param = params.getParameter(counter);
    if (!param.isEmpty() && param.charAt(0) == '-') {
      break;
    }
    hasValues = true;
    builder.add(param);
    counter++;
  }

  Preconditions.checkArgument(hasValues, "Option \"%s\" takes one or more operands", option);
  return counter;
}
 
开发者ID:facebook,项目名称:buck,代码行数:19,代码来源:StringSetOptionHandler.java

示例4: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
/** Tries to parse {@code String[]} argument from {@link Parameters}. */
@Override
public int parseArguments(Parameters params) throws CmdLineException {
  int counter = 0;
  for (; counter < params.size(); counter++) {
    String param = params.getParameter(counter);

    // Special case the -- separator
    if (param.startsWith("-") && !param.equals(QueryCommand.SET_SEPARATOR)) {
      break;
    }

    setter.addValue(param);
  }

  return counter;
}
 
开发者ID:facebook,项目名称:buck,代码行数:18,代码来源:QueryMultiSetOptionHandler.java

示例5: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
    ArrayList<String> genArgs = new ArrayList<>();
    for (int ix = 0; ix < params.size(); ix++) {
        genArgs.add(params.getParameter(ix));
    }
    this.setter.addValue(new GeneratorArgs(params));
    return params.size();
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:10,代码来源:PrologChecker.java

示例6: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
@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;
}
 
开发者ID:RJMillerLab,项目名称:ibench,代码行数:10,代码来源:Log4jLevelOptionHandler.java

示例7: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
/**
 * Tries to parse {@code String[]} argument from {@link Parameters}.
 */
@SuppressWarnings("deprecation")
@Override
public int parseArguments(Parameters params) throws CmdLineException
{
	int counter = 0;
	for (; counter < params.size(); counter += 2)
	{
		String param1 = params.getParameter(counter);

		if (param1.startsWith("-"))
		{
			if (counter == 0)
			{
				// deprecated: we don't have proper locale support in Hyst
				throw new CmdLineException(owner,
						"No arguments found after a flag which requires arguments: "
								+ option.toString());
			}

			break;
		}

		if (counter + 1 == params.size())
		{
			// deprecated: we don't have proper locale support in Hyst
			throw new CmdLineException(owner,
					"Excepted pairs of arguments for option '" + option.toString() + "'.");
		}

		String param2 = params.getParameter(counter + 1);

		setter.addValue(param1);
		setter.addValue(param2);
	}

	return counter;
}
 
开发者ID:verivital,项目名称:hyst,代码行数:41,代码来源:StringPairsWithSpacesArrayOptionHandler.java

示例8: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
/**
 * Tries to parse {@code Double[]} argument from {@link Parameters}.
 */
@SuppressWarnings("deprecation") // we don't have proper locale support in
									// Hyst
@Override
public int parseArguments(Parameters params) throws CmdLineException
{
	int counter = 0;

	for (; counter < params.size(); counter++)
	{
		String param = params.getParameter(counter);

		// negative numbers should be okay, but we should break if it's a
		// flag
		if (param.startsWith("-")
				&& (param.length() < 2 || !Character.isDigit(param.charAt(1))))
			break;

		try
		{
			setter.addValue(Double.parseDouble(param));
		}
		catch (NumberFormatException e)
		{
			// deprecated: we don't have proper locale support in Hyst
			throw new CmdLineException(owner,
					"Error parsing argument as number: '" + param + "'");
		}
	}

	return counter;
}
 
开发者ID:verivital,项目名称:hyst,代码行数:35,代码来源:DoubleArrayOptionHandler.java

示例9: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
/**
 * Tries to parse {@code Expression[]} argument from {@link Parameters}.
 */
@SuppressWarnings("deprecation") // we don't have proper locale support in
									// Hyst
@Override
public int parseArguments(Parameters params) throws CmdLineException
{
	int counter = 0;

	for (; counter < params.size(); counter++)
	{
		String param = params.getParameter(counter);

		// negative numbers should be okay, but we should break if it's a
		// flag
		// use parenthesis around -varName expressions to resolve ambiguity
		if (param.startsWith("-")
				&& (param.length() < 2 || !Character.isDigit(param.charAt(1))))
			break;

		try
		{
			setter.addValue(FormulaParser.parseValue(param));
		}
		catch (AutomatonExportException e)
		{
			// deprecated: we don't have proper locale support in Hyst
			throw new CmdLineException(owner, "Error parsing argument as value expression: '"
					+ param + "': " + e.toString());
		}
	}

	return counter;
}
 
开发者ID:verivital,项目名称:hyst,代码行数:36,代码来源:ExpressionValueArrayOptionHandler.java

示例10: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
/**
 * Tries to parse {@code Double[]} argument from {@link Parameters}.
 */
@SuppressWarnings("deprecation") // we don't have proper locale support in
									// Hyst
@Override
public int parseArguments(Parameters params) throws CmdLineException
{
	int counter = 0;

	for (; counter < params.size(); counter += 2)
	{
		String param1 = params.getParameter(counter);

		if (param1.startsWith("-"))
		{
			if (counter == 0)
			{
				// deprecated: we don't have proper locale support in Hyst
				throw new CmdLineException(owner,
						"No arguments found after a flag which requires arguments: "
								+ option.toString());
			}

			break;
		}

		if (counter + 1 == params.size())
		{
			// deprecated: we don't have proper locale support in Hyst
			throw new CmdLineException(owner,
					"Excepted pairs of arguments. Argument missing after option '"
							+ option.toString() + "'.");
		}

		String param2 = params.getParameter(counter + 1);

		setter.addValue(new String[] { param1, param2 });
	}

	return counter;
}
 
开发者ID:verivital,项目名称:hyst,代码行数:43,代码来源:PairStringOptionHandler.java

示例11: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
  final int paramsSize = params.size();
  for (int i = 0; i < paramsSize; i++) {
    String param = params.getParameter(i);
    if (param.startsWith("-")) {
      return i;
    }

    setter.addValue(param);
  }
  return paramsSize;
}
 
开发者ID:angular,项目名称:clutz,代码行数:14,代码来源:Options.java

示例12: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
@Override
public int parseArguments(Parameters parameters) throws CmdLineException {
  int index;
  for (index = 0; index < parameters.size(); index++) {
    String parameter = parameters.getParameter(index);
    if (parameter.charAt(0) == '-') {
      break;
    }
    labels.put(ordinal.getAndIncrement(), LabelSelector.fromString(parameter));
  }
  return index;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:13,代码来源:TestLabelOptions.java

示例13: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
  int counter = 0;
  boolean hasValues = false;

  while (counter < params.size()) {
    String param = params.getParameter(counter);
    if (param.charAt(0) == '-') {
      break;
    }
    Iterator<String> values = Splitter.on(' ')
        .trimResults()
        .omitEmptyStrings()
        .split(param)
        .iterator();
    if (values.hasNext()) {
      hasValues = true;
      builder.addAll(values);
    }

    counter++;
  }

  Preconditions.checkArgument(
      hasValues, "Option \"%s\" takes one or more operands", option);
  return counter;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:28,代码来源:StringSetOptionHandler.java

示例14: parseArguments

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
@Override
public int parseArguments(Parameters params) throws CmdLineException {
  for (int idx = 0; idx < params.size(); idx += 1) {
    setter.addValue(params.getParameter(idx));
  }
  return params.size();
}
 
开发者ID:facebook,项目名称:buck,代码行数:8,代码来源:ConsumeAllOptionsHandler.java

示例15: GeneratorArgs

import org.kohsuke.args4j.spi.Parameters; //导入方法依赖的package包/类
GeneratorArgs(Parameters params) throws CmdLineException {
    this.args = new ArrayList<>();
    for (int ix = 0; ix < params.size(); ix++) {
        this.args.add(params.getParameter(ix));
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:7,代码来源:PrologChecker.java


注:本文中的org.kohsuke.args4j.spi.Parameters.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。