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


Java ArgumentValidationException类代码示例

本文整理汇总了Java中com.lexicalscope.jewel.cli.ArgumentValidationException的典型用法代码示例。如果您正苦于以下问题:Java ArgumentValidationException类的具体用法?Java ArgumentValidationException怎么用?Java ArgumentValidationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: validateConvertMode

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
private static void validateConvertMode(DppInputParameters inputParameters) throws ArgumentValidationException {
    File metadataFile = inputParameters.getMetadataFile();
    if (metadataFile == null) {
        throw new ArgumentValidationException("Metadata.xml (--metadata) must be specified in 'convert' mode."
                + " Use 'metadata' mode (-m metadata) to generate a sample metadata.xml");
    }
    if (!metadataFile.isFile()) {
        throw new ArgumentValidationException(String.format(
                "Metadata file '%s' must be an existing file", metadataFile.getAbsolutePath()));

    }

    File audiomapFile = inputParameters.getAudiomapFile();
    // audiomap.xml may be null. in this case a default audiomap is created.
    if (audiomapFile != null && !audiomapFile.isFile()) {
        throw new ArgumentValidationException(String.format(
                "Audiomap file '%s' must be an existing file", audiomapFile.getAbsolutePath()));
    }
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:20,代码来源:DppInputParametersValidator.java

示例2: validateInputParameters

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
/**
 * Checks whether all input parameters needed for conversion are specified (such as CPL, IMP) are specified.
 * These parameters can be set either via command line arguments or in config.xml. So, the method must be called
 * after config.xml is processed.
 *
 * @param inputParameters the input to be validated
 * @throws ArgumentValidationException if some of the required command lines arguments are missing.
 */
public static void validateInputParameters(ImfUtilityInputParameters inputParameters) throws ArgumentValidationException {
    File impDirectory = inputParameters.getImpDirectoryFile();
    if (impDirectory == null) {
        throw new ArgumentValidationException("IMP directory must be specified either as a command line argument or in config.xml");
    }
    if (!impDirectory.isDirectory()) {
        throw new ArgumentValidationException(String.format(
                "IMP directory '%s' must be an existing folder", impDirectory.getAbsolutePath()));
    }

    File cplFile = inputParameters.getCplFile();
    if (cplFile == null) {
        throw new ArgumentValidationException("CPL file must be specified either as a command line argument or in config.xml");
    }
    if (!cplFile.isFile()) {
        throw new ArgumentValidationException(String.format(
                "CPL file '%s' must be an existing file", cplFile.getAbsolutePath()));
    }

    File workingDir = inputParameters.getWorkingDirFile();
    if (workingDir == null) {
        throw new ArgumentValidationException("Working directory must be specified either as a command line argument or in config.xml");
    }
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:33,代码来源:ImfUtilityInputParametersValidator.java

示例3: validateCmdLineArguments

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
/**
 * Checks whether all required parameters depending on the  mode are specified via command lines arguments.
 * Only iTunes-specific parameters are validated.
 *
 * @param inputParameters the input parameters to be validated.
 * @throws ArgumentValidationException if some of the parameters are missing
 */
public static void validateCmdLineArguments(ITunesInputParameters inputParameters) throws ArgumentValidationException {
    switch (inputParameters.getCmdLineArgs().getMode()) {
        case convert:
            validateConvertMode(inputParameters);
            break;
        case metadata:
            validateMetadataMode(inputParameters);
            break;
        case audiomap:
            validateAudiomapMode(inputParameters);
            break;
        case chapters:
            validateChaptersMode(inputParameters);
            break;
        default: // nothing
    }
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:25,代码来源:ITunesInputParametersValidator.java

示例4: validateConvertMode

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
private static void validateConvertMode(ITunesInputParameters inputParameters) throws ArgumentValidationException {
    validateVendorId(inputParameters.getCmdLineArgs().getVendorId());
    validateFallbackLocale(inputParameters.getCmdLineArgs().getFallbackLocale());

    // metadata.xml may be null. in this case a default metadata is created.
    validateFile(inputParameters.getMetadataFile(), "Metadata");
    // audiomap.xml may be null. in this case a default audiomap is created.
    validateFile(inputParameters.getAudiomapFile(), "Audiomap");
    // trailer may be null.
    validateFile(inputParameters.getTrailerFile(), "Trailer");
    // poster may be null.
    validateFile(inputParameters.getPosterFile(), "Poster");
    // chapters may be null. in this case a default chapters.xml is created.
    validateFile(inputParameters.getChaptersFile(), "Chapters");
    // cc may be null.
    validateFile(inputParameters.getCcFile(), "Closed captions");
    // subtitles may be null.
    validateFiles(inputParameters.getSubFiles(), "Subtitles");
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:20,代码来源:ITunesInputParametersValidator.java

示例5: main

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
public static void main(final String[] args)
        throws InterruptedException, ArgumentValidationException {
    CliOptions opts = CliFactory.parseArguments(CliOptions.class, args);
    try (UdpSimulinkConnection vehicleConnection = new UdpSimulinkConnection(
                opts.getRemoteSimulinkAddress().asInetSocketAddress(),
                opts.getLocalPortForSimulink());
            TcpServerConnection serverConnection = new TcpServerConnection(
                opts.getGrotrServerAddress().asInetSocketAddress());
        ) {
        GroTrClient client = new GroTrClient(serverConnection, vehicleConnection);
        client.start();
        client.awaitTermination(365, TimeUnit.DAYS);  // One year.
    } catch (IOException e) {
        logger.error("IO exception in client, terminating", e);
    }
}
 
开发者ID:alexvoronov,项目名称:itt-gt,代码行数:17,代码来源:GroTrClient.java

示例6: main

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
public static void main(String[] args) throws Exception {	

        //parse topology arguments:
        AvroWebLogTopologyOptions appOptions = null;
        try {
            appOptions = CliFactory.parseArguments(AvroWebLogTopologyOptions.class, args);
        }
        catch(ArgumentValidationException e)
        {
            System.out.println(e.getMessage());
            System.exit(-1);
        }
        System.out.println("appOptions.toString() = " + appOptions.toString());
        Config stormConfig = new Config();
        stormConfig.setNumWorkers(appOptions.getStormNumWorkers());

		StormSubmitter.submitTopology(appOptions.getTopologyName(), stormConfig, buildTopology(appOptions));
	}
 
开发者ID:Produban,项目名称:openbus,代码行数:19,代码来源:OpenbusProcessorTopology.java

示例7: main

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        //parse topology arguments:
        TopologyOptions appOptions = null;
        try {
            appOptions = CliFactory.parseArguments(TopologyOptions.class, args);
        }
        catch(ArgumentValidationException e)
        {
            System.out.println(e.getMessage());
            System.exit(-1);
        }

        Config stormConfig = new Config();
        stormConfig.setNumWorkers(appOptions.getStormNumWorkers());

        List<String> fields = new ArrayList<>();

        StormSubmitter.submitTopology(appOptions.getTopologyName(), stormConfig, buildTopology(appOptions));
    }
 
开发者ID:Produban,项目名称:openbus,代码行数:21,代码来源:RawLogTopology.java

示例8: main

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        //parse topology arguments:
        TweetsTopologyOptions appOptions = null;
        try {
            appOptions = CliFactory.parseArguments(TweetsTopologyOptions.class, args);
        }
        catch(ArgumentValidationException e)
        {
            System.out.println(e.getMessage());
            System.exit(-1);
        }

        Config stormConfig = new Config();
        stormConfig.setNumWorkers(appOptions.getStormNumWorkers());

        StormSubmitter.submitTopology(appOptions.getTopologyName(), stormConfig, buildTopology(appOptions));
    }
 
开发者ID:Produban,项目名称:openbus,代码行数:19,代码来源:TweetsTopology.java

示例9: main

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

    RunnerConfiguration config;
    try {
      RunnerArgs runnerArgs = CliFactory.parseArguments(RunnerArgs.class, args);
      config = buildConfiguration(runnerArgs);
    } catch (ArgumentValidationException ave) {
      printHelp(ave.getMessage());
      return;
    }

    final Runner runner = new Runner(config);
    runner.call();

    SignalManager.register(new Runnable() {
        @Override
        public void run() {
          runner.close();
        }
      }, SignalType.INT, SignalType.TERM);

    runner.await();
    runner.close();
  }
 
开发者ID:myrrix,项目名称:myrrix-recommender,代码行数:25,代码来源:Runner.java

示例10: build

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
static AllConfig build(String[] args) {

    AllUtilityArgs allArgs;
    try {
      allArgs = CliFactory.parseArguments(AllUtilityArgs.class, args);
    } catch (ArgumentValidationException ave) {
      System.out.println();
      System.out.println(ave.getMessage());
      System.out.println();
      return null;
    }

    String rescorerProviderClassNames = allArgs.getRescorerProviderClass();
    RescorerProvider rescorerProvider;
    if (rescorerProviderClassNames == null) {
      rescorerProvider = null;
    } else {
      rescorerProvider = AbstractRescorerProvider.loadRescorerProviders(rescorerProviderClassNames, null);
    }

    return new AllConfig(allArgs.getLocalInputDir(), 
                         allArgs.getOutFile(),
                         rescorerProvider, 
                         allArgs.getHowMany(), 
                         allArgs.isParallel());
  }
 
开发者ID:myrrix,项目名称:myrrix-recommender,代码行数:27,代码来源:AllConfig.java

示例11: validateCmdLineArguments

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
/**
 * Checks whether all required parameters depending on the  mode are specified via command lines arguments.
 * Only DPP-specific parameters are validated.
 *
 * @param inputParameters the input parameters to be validated.
 * @throws ArgumentValidationException if some of the parameters are missing
 */
public static void validateCmdLineArguments(DppInputParameters inputParameters) throws ArgumentValidationException {
    switch (inputParameters.getCmdLineArgs().getMode()) {
        case convert:
            validateConvertMode(inputParameters);
            break;
        case metadata:
            validateMetadataMode(inputParameters);
            break;
        case audiomap:
            validateAudiomapMode(inputParameters);
            break;
        default: // nothing
    }
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:22,代码来源:DppInputParametersValidator.java

示例12: testValidateConfigNotSpecified

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
@Test(expected = ArgumentValidationException.class)
public void testValidateConfigNotSpecified() throws Exception {
    String[] args = new String[]{};
    ImfUtilityInputParameters inputParameters = new FakeInputParameters(
            CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args),
            new FakeDefaultTools());

    ImfUtilityInputParametersValidator.validateCmdLineArguments(inputParameters);
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:10,代码来源:InputParametersTest.java

示例13: testValidateConfigNotExistentFile

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
@Test(expected = ArgumentValidationException.class)
public void testValidateConfigNotExistentFile() throws Exception {
    String[] args = new String[]{
            "-c", "someFile"
    };
    ImfUtilityInputParameters inputParameters = new FakeInputParameters(
            CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args),
            new FakeDefaultTools());

    ImfUtilityInputParametersValidator.validateCmdLineArguments(inputParameters);
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:12,代码来源:InputParametersTest.java

示例14: testValidateImpNotSpecified

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
@Test(expected = ArgumentValidationException.class)
public void testValidateImpNotSpecified() throws Exception {
    String[] args = new String[]{
            "--cpl", ImpUtils.getCorrectCpl().getName(),
            "-w", TemplateParameterContextCreator.getWorkingDir().getAbsolutePath()
    };
    ImfUtilityInputParameters inputParameters = new FakeInputParameters(
            CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args),
            new FakeDefaultTools());

    ImfUtilityInputParametersValidator.validateInputParameters(inputParameters);
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:13,代码来源:InputParametersTest.java

示例15: testValidateImpNotExistentFolder

import com.lexicalscope.jewel.cli.ArgumentValidationException; //导入依赖的package包/类
@Test(expected = ArgumentValidationException.class)
public void testValidateImpNotExistentFolder() throws Exception {
    String[] args = new String[]{
            "--imp", "someFolder",
            "--cpl", ImpUtils.getCorrectCpl().getName(),
            "-w", TemplateParameterContextCreator.getWorkingDir().getAbsolutePath()
    };
    ImfUtilityInputParameters inputParameters = new FakeInputParameters(
            CliFactory.parseArguments(ImfUtilityCmdLineArgs.class, args),
            new FakeDefaultTools());

    ImfUtilityInputParametersValidator.validateInputParameters(inputParameters);
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:14,代码来源:InputParametersTest.java


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