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


Java JSAPResult.success方法代码示例

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


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

示例1: getNextCommand

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
@Override
protected Command getNextCommand() throws Exception {
    String nextCommandAsString = reader.readLine();
    
    if (EXIT_COMMAND.equals(nextCommandAsString)) {
        hasMoreCommands = false;
        return null;
    }
    
    JSAPResult result = jsap.parse(nextCommandAsString);
    
    if (result.success()) {
        String databaseFolder = result.getString(DATABASE_FOLDER_OPTION);
        String commandName = result.getString(COMMAND_NAME_OPTION);
        Map<String, String> parameters = parseParameters(result.getString(PARAMETERS_OPTION, ""));
        
        return CommandBuilder
                .command(commandName)
                .usingDatabaseManager(databaseManager)
                .forDatabase(databaseFolder)
                .withParameters(parameters)
                .build();
    } else {
        throw new Exception("Wrong command syntax: " + nextCommandAsString);
    }
}
 
开发者ID:cyber-waste,项目名称:kuzoff,代码行数:27,代码来源:ShellManager.java

示例2: parseArguments

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
private boolean parseArguments(String[] args) {
	JSAPResult jsapConfig = jsap.parse(args);
	if (!jsapConfig.success()) {
		System.err.println();
		for (Iterator<?> errs = jsapConfig.getErrorMessageIterator(); errs.hasNext(); ) {
			System.err.println("Error: " + errs.next());
		}
		showUsage();
		return false;
	}
	String[] sources = jsapConfig.getStringArray("source");
	final File[] sourceFiles = new File[sources.length];
	for (int i = 0; i < sources.length; i++) {
		String path = sources[i];
		File sourceFile = FileLibrary.openFrom(path);
		sourceFiles[i] = sourceFile;
	}

	final URL[] classpath = JavaLibrary.classpathFrom(jsapConfig.getString("classpath"));

	this.nopolContext = new NopolContext(sourceFiles, classpath, jsapConfig.getStringArray("test"));

	nopolContext.setType(strToStatementType(jsapConfig.getString("type")));
	nopolContext.setMode(strToMode(jsapConfig.getString("mode")));
	nopolContext.setSynthesis(strToSynthesis(jsapConfig.getString("synthesis")));
	nopolContext.setOracle(strToOracle(jsapConfig.getString("oracle")));
	nopolContext.setSolver(strToSolver(jsapConfig.getString("solver")));
	if (jsapConfig.getString("solverPath") != null) {
		nopolContext.setSolverPath(jsapConfig.getString("solverPath"));
		SolverFactory.setSolver(nopolContext.getSolver(), nopolContext.getSolverPath());
	}
	nopolContext.setComplianceLevel(jsapConfig.getInt("complianceLevel", 7)); nopolContext.setMaxTimeInMinutes(jsapConfig.getInt("maxTime", nopolContext.getMaxTimeInMinutes()));
	nopolContext.setMaxTimeEachTypeOfFixInMinutes(jsapConfig.getInt("maxTimeType",5));

	nopolContext.setLocalizer(strToLocalizer(jsapConfig.getString("faultLocalization")));
	nopolContext.setOutputFolder(jsapConfig.getString("outputFolder"));
	nopolContext.setJson(jsapConfig.getBoolean("outputJson", false));
	return true;
}
 
开发者ID:SpoonLabs,项目名称:nopol,代码行数:40,代码来源:Main.java

示例3: Parameters

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public Parameters(String[] args) throws JSAPException {
	JSAP jsap = createJSAP();
	JSAPResult config = jsap.parse(args);
	if(!config.success()){
		exit(jsap);
	}
	
	input = config.getString(INPUT_OPT);
	output = config.getString(OUTPUT_OPT);
	model = config.getString(MODEL_OPT);
	train = config.getString(TRAIN_OPT);
	external = config.getString(EXTERNAL_OPT);
	trainSize = config.getInt(TRAINSIZE_OPT);
	iters = config.getInt(ITER_OPT);
	modelSize = config.getInt(MODEL_SIZE_OPT);
	repeats = config.getInt(REPEAT_OPT);
	rightMerge = config.getBoolean(RIGHT_MERGE_STRATEGY);
	implicitComplete = config.getBoolean(IMPLICIT_COMPLETE_STRATEGY);
	constrainedMerge = config.getBoolean(CONSTRAINED_MERGE_STRATEGY);
	fixedMweOnly = config.getBoolean(FIXED_MWE_ONLY);
	noSyntax = config.getBoolean(NO_SYNTACTIC_ANALYSIS);
	baseline = config.getBoolean(BASELINE);
	projective = config.getBoolean(PROJECTIVE_OPT);
	xconll = config.getBoolean(XCONLL_INPUT);
	
	if(!rightMerge && constrainedMerge){
		throw new IllegalStateException("The constrained merge strategy can only be applied with a right merge strategy!!");
	}
	if(iters <= 0){
		throw new IllegalStateException("number of training iterations should be positive");
	}
	if(modelSize <= 0){
		throw new IllegalStateException("number of feature identifiers should be positive");
	}
	
	if(repeats <= 0){
		throw new IllegalStateException("number of repeats should be positive");
	}
	
}
 
开发者ID:MathieuConstant,项目名称:lgtools,代码行数:41,代码来源:Parameters.java

示例4: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException,
		InterruptedException, JSAPException {
	JSAP jsap = new JSAP();
	jsap.registerParameter(new Switch(HEADERED_TABLES_ONLY).setLongFlag(
			HEADERED_TABLES_ONLY).setShortFlag('h'));
	jsap.registerParameter(new Switch(PREPROCESSING).setLongFlag(
			PREPROCESSING).setShortFlag('r'));
	jsap.registerParameter(new Switch(STORE_FULL_RESULT).setLongFlag(
			STORE_FULL_RESULT).setShortFlag('s'));
	jsap.registerParameter(new Switch(STORE_FULL_RESULT_IN_LEVELDB).setLongFlag(
			STORE_FULL_RESULT_IN_LEVELDB).setShortFlag('l'));
	jsap.registerParameter(new UnflaggedOption(CORPUS_PATH)
			.setRequired(true));
	jsap.registerParameter(new UnflaggedOption(OUTPUT_PATH)
			.setRequired(true));
	JSAPResult config = jsap.parse(args);

	if (!config.success()) {
		System.err.println();
		System.err.println("Usage: java " + Indexer.class.getName());
		System.err.println("                " + jsap.getUsage());
		System.err.println();
		System.exit(1);
	}

	Indexer fi = new Indexer(config);
	fi.iterate(config.getString(CORPUS_PATH));
}
 
开发者ID:JulianEberius,项目名称:dwtc-tools,代码行数:29,代码来源:Indexer.java

示例5: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    JSAP jsap = new JSAP();
    FlaggedOption targetIp = new FlaggedOption("targetIp")
            .setStringParser(JSAP.INETADDRESS_PARSER)
            .setRequired(true)
            .setShortFlag('d')
            .setLongFlag("destination");
    FlaggedOption relayIp = new FlaggedOption("relayIp")
            .setStringParser(JSAP.INETADDRESS_PARSER)
            .setRequired(true)
            .setShortFlag('r')
            .setLongFlag("relay");
    FlaggedOption relayPort = new FlaggedOption("relayPort")
            .setStringParser(JSAP.INTEGER_PARSER)
            .setRequired(false)
            .setDefault(String.valueOf(DEFAULT_PORT))
            .setShortFlag('p')
            .setLongFlag("port");
    FlaggedOption token = new FlaggedOption("token")
            .setRequired(true)
            .setShortFlag('t')
            .setLongFlag("token");
    FlaggedOption rules = new FlaggedOption("rules")
            .setRequired(false)
            .setLongFlag("rules");
    jsap.registerParameter(targetIp);
    jsap.registerParameter(relayIp);
    jsap.registerParameter(relayPort);
    jsap.registerParameter(token);
    jsap.registerParameter(rules);
    JSAPResult config = jsap.parse(args);
    if (!config.success()) {
        System.err.println();
        System.err.println("Usage: " + jsap.getUsage());
        System.err.println();
        System.exit(0);
    }
    InetSocketAddress natBypassServer = new InetSocketAddress(config.getInetAddress("relayIp"), config.getInt("relayPort"));
    NATHole hole = UDPHoleCreator.createHole(config.getString("token"), config.getInetAddress("targetIp"), natBypassServer);
    channelHandler = new ChannelHandler(hole.getSocket(), hole.getTarget());
    if (config.contains("rules")) {
        for (String rule : config.getString("rules").split(",")) {
            if (!rule.equals("")) {
                parseRule(rule);
            }
        }
    }
    channelHandler.start();
    BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in));
    while (true) {
        try {
            String line = userInput.readLine();
            if (line.equalsIgnoreCase("exit")) {
                System.exit(0);
            } else if (line.equalsIgnoreCase("show")) {
                channelHandler.showChannels();
            } else {
                parseRule(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:JoBa97,项目名称:UDPRelayClient,代码行数:65,代码来源:UDPClient.java

示例6: init

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void init(String[] args) throws Exception {
  // argument parser:
  JSAP jsap = new JSAP();

  jsap.registerParameter(new FlaggedOption("email").setStringParser(JSAP.STRING_PARSER).setRequired(false).setLongFlag("email"));

  jsap.registerParameter(new FlaggedOption("params").setStringParser(JSAP.STRING_PARSER).setRequired(true).setShortFlag('p'));

  jsap.registerParameter(new FlaggedOption("year").setStringParser(JSAP.INTEGER_PARSER).setRequired(false).setShortFlag('y'));

  jsap.registerParameter(new FlaggedOption("month").setStringParser(JSAP.INTEGER_PARSER).setRequired(false).setShortFlag('m'));

  jsap.registerParameter(
      new FlaggedOption("contract").setLongFlag("contract").setShortFlag('c').setStringParser(JSAP.INTEGER_PARSER).setRequired(false));

  jsap.registerParameter(new Switch("offline").setLongFlag("offline").setDefault("false"));

  jsap.registerParameter(new Switch("debug").setLongFlag("debug").setDefault("false"));

  jsap.registerParameter(new FlaggedOption("do").setStringParser(JSAP.STRING_PARSER).setRequired(false).setLongFlag("do"));

  JSAPResult config = jsap.parse(args);
  if (!config.success()) {
    for (@SuppressWarnings("rawtypes")
    java.util.Iterator errs = config.getErrorMessageIterator(); errs.hasNext();) {
      System.err.println("Error: " + errs.next());
    }
    System.out.println("Usage:\n\n\t" + jsap.getUsage() + "\n\n");

    System.exit(1);
  }

  File propFile = new File(config.getString("params"));
  if (!propFile.exists()) {
    String msg = "Cannot find property file: " + config.getString("params");
    System.out.println(msg);
    throw new Exception(msg);
  } else {}

  boolean connectToDB = !config.getBoolean("offline");

  FileInputStream in;
  Properties props = new Properties();
  ;
  try {
    in = new FileInputStream(propFile);
    props.load(in);
    in.close();
  } catch (Exception e) {
    logger.error(e);
    System.exit(0);
  }

  GlobalConstants.load(props);

  if (connectToDB) {
    DatabaseManager.initDatabaseManager(props.getProperty("host"), Integer.parseInt(props.getProperty("port")), props.getProperty("user"),
        props.getProperty("pass"), props.getProperty("db"), true);
  } else {
    System.out.println("WARNING: not connecting to DB");
  }

}
 
开发者ID:hugozaragoza,项目名称:SaaSMetrics4J,代码行数:64,代码来源:AgencyBilling.java


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