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


Java ConfigurationRuntimeException类代码示例

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


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

示例1: configure

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
/**
 * @param configuration
 *            The configuration of K-Fold cross validation. The XML labels
 *            supported are:
 *
 *            <ul>
 *            <li><b>stratify= boolean</b></li>
 *            <li><b>num-folds= int</b></li>
 *            </ul>
 */
@Override
public void configure(Configuration configuration) {
	super.configure(configuration);

	// Set stratify (default false)
	boolean stratifyValue = configuration.getBoolean("stratify", stratify);
	setStratify(stratifyValue);

	// num folds
	int numFols = configuration.getInt("num-folds", numFolds);
	if (numFols < 1) {
		throw new ConfigurationRuntimeException("\n<num-folds>" + numFols + "</num-folds>. " + "num-folds > 0");
	}
	setNumFolds(numFols);
}
 
开发者ID:ogreyesp,项目名称:JCLAL,代码行数:26,代码来源:kFoldCrossValidation.java

示例2: configure

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
/**
 * @param configuration
 *            The configuration of Hold Out.
 *
 *            The XML labels supported are:
 *
 *            <ul>
 *            <li><b>percentage-split= double</b></li>
 *            </ul>
 */
@Override
public void configure(Configuration configuration) {

	super.configure(configuration);

	// the percent of instances used to train
	double percentTrain = configuration.getDouble("percentage-split", percentageToSplit);

	String perc = "\n<percentage-split>" + percentTrain + "</percentage-split>";

	if (percentTrain <= 0) {
		throw new ConfigurationRuntimeException(perc + ". percentage-split > 0");
	}
	if (percentTrain >= 100) {
		throw new ConfigurationRuntimeException(perc + ". percentage-split < 100");
	}

	setPercentageToSplit(percentTrain);
}
 
开发者ID:ogreyesp,项目名称:JCLAL,代码行数:30,代码来源:HoldOut.java

示例3: getConfiguration

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
/**
 * Common method to load content of all configuration resources defined in
 * 'config-definition.xml'.
 * 
 * @param configDefFilePath
 *          the config def file path
 * @return Configuration
 */
public static Configuration getConfiguration(String configDefFilePath) {
  if (configurationsCache.containsKey(configDefFilePath)) {
    return configurationsCache.get(configDefFilePath);
  }
  CombinedConfiguration configuration = null;
  synchronized (configurationsCache) {
    if (configurationsCache.containsKey(configDefFilePath)) {
      return configurationsCache.get(configDefFilePath);
    }
    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
    String filePath = getConfigDefFilePath(configDefFilePath);
    LOGGER.info("loading from 'configDefFilePath' : {}", filePath);
    builder.setFile(new File(filePath));
    try {
      configuration = builder.getConfiguration(true);
      configurationsCache.put(filePath, configuration);
    } catch (ConfigurationException|ConfigurationRuntimeException e) {
      LOGGER.info("Exception in loading property files.", e);
    }
  }
  return configuration;
}
 
开发者ID:apache,项目名称:metron,代码行数:31,代码来源:ConfigurationManager.java

示例4: urlFromFile

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
/**
 * Helper method for converting a file to a URL.
 *
 * @param file the file
 * @return the corresponding URL
 * @throws ConfigurationRuntimeException if the URL cannot be constructed
 */
private static URL urlFromFile(File file)
{
    try
    {
        return file.toURI().toURL();
    }
    catch (MalformedURLException mex)
    {
        throw new ConfigurationRuntimeException(mex);
    }
}
 
开发者ID:mbredel,项目名称:configurations-yaml,代码行数:19,代码来源:ConfigurationAssert.java

示例5: configure

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
/**
 * @param configuration
 *            The configuration object for Abstract sampling.
 *            <p>
 *            <b>percentage-to-select= double</b>
 *            </p>
 */
@Override
public void configure(Configuration configuration) {

	double percentageInstancesToLabelledTemp = configuration.getDouble("percentage-to-select", 10);
	String perc = "\n<percentage-to-select>" + percentageInstancesToLabelledTemp + "</percentage-to-select>";
	if (percentageInstancesToLabelledTemp <= 0) {
		throw new ConfigurationRuntimeException(perc + ". percentage-to-select > 0");
	}
	if (percentageInstancesToLabelledTemp > 100) {
		throw new ConfigurationRuntimeException(perc + ". percentage-to-select <= 100");
	}
	setPercentageInstancesToLabelled(percentageInstancesToLabelledTemp);

}
 
开发者ID:ogreyesp,项目名称:JCLAL,代码行数:22,代码来源:AbstractSampling.java

示例6: configure

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
/**
 *
 * @param configuration
 *            The configuration of Abstract Batch Mode.
 *
 *            The XML labels supported are:
 *            <ul>
 *            <li>batch-size= int</li>
 *            </ul>
 */
@Override
public void configure(Configuration configuration) {

	// Set batchSize
	int batchT = configuration.getInt("batch-size", batchSize);
	if (batchT <= 0) {
		throw new ConfigurationRuntimeException(
				"\nIllegal batch size: <batch-size>" + batchT + "</batch-size>" + ". Batch size > 0");
	}
	setBatchSize(batchT);
}
 
开发者ID:ogreyesp,项目名称:JCLAL,代码行数:22,代码来源:AbstractBatchMode.java

示例7: createMongoClient

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
/**
 * Create a {@link MongoClient} that is connected to the configured database.
 *
 * @param mongoConf - Configures what will be connected to. (not null)
 * @throws ConfigurationRuntimeException An invalid port was provided by {@code mongoConf}.
 * @throws MongoException Couldn't connect to the MongoDB database.
 */
private static MongoClient createMongoClient(final MongoDBRdfConfiguration mongoConf) throws ConfigurationRuntimeException, MongoException {
    requireNonNull(mongoConf);
    requireNonNull(mongoConf.getMongoHostname());
    requireNonNull(mongoConf.getMongoPort());
    requireNonNull(mongoConf.getMongoDBName());

    // Connect to a running MongoDB server.
    final int port;
    try {
        port = Integer.parseInt( mongoConf.getMongoPort() );
    } catch(final NumberFormatException e) {
        throw new ConfigurationRuntimeException("Port '" + mongoConf.getMongoPort() + "' must be an integer.");
    }

    final ServerAddress server = new ServerAddress(mongoConf.getMongoHostname(), port);

    // Connect to a specific MongoDB Database if that information is provided.
    final String username = mongoConf.getMongoUser();
    final String database = mongoConf.getMongoDBName();
    final String password = mongoConf.getMongoPassword();
    if(username != null && password != null) {
        final MongoCredential cred = MongoCredential.createCredential(username, database, password.toCharArray());
        return new MongoClient(server, Arrays.asList(cred));
    } else {
        return new MongoClient(server);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:35,代码来源:RyaSailFactory.java

示例8: testBadConfig

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
@Test(expectedExceptions = ConfigurationRuntimeException.class)
public void testBadConfig()
    throws IOException {
  String quotaConfigStr = "{\"storage\":\"-1M\"}";
  QuotaConfig quotaConfig = new ObjectMapper().readValue(quotaConfigStr, QuotaConfig.class);
  quotaConfig.validate();
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:8,代码来源:QuotaConfigTest.java

示例9: setDataConfiguration

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
@Override
protected void setDataConfiguration(Configuration configuration) {
	// Set multiLabel flag
	boolean multi = configuration.getBoolean("multi-label", false);
	setMultiLabel(multi);

	// Set multiInstance flag
	boolean multiInstance = configuration.getBoolean("multi-instance", false);
	setMultiInstance(multiInstance);

	// Set the xml file, it is used in the case of a multi-label
	// dataset
	String xml = configuration.getString("file-xml", "");
	setXmlPath(xml);

	// the multi-label elements are verified
	if (multi && xml.isEmpty()) {
		throw new ConfigurationRuntimeException("\nThe multi-label flag is " + "enabled and the xml path is empty. "
				+ "<multi-label>true</multi-label>" + " <file-xml></file-xml>");
	}

	// Set file labeled
	String fileLabeled = configuration.getString("file-labeled", "");
	setFileLabeledDataset(fileLabeled);

	// Set file unlabeled
	String fileUnlabeled = configuration.getString("file-unlabeled", "");
	setFileUnlabeledDataset(fileUnlabeled);

	if (fileLabeled.isEmpty() || fileUnlabeled.isEmpty()) {
		throw new ConfigurationRuntimeException("\n <file-labeled> and <file-unlabeled> tags must be defined.");
	}

	// Set file test
	String fileTest = configuration.getString("file-test", "");

	if (fileTest.isEmpty()) {
		/*
		 * Logger.getLogger(RealScenario.class.getName()).log(Level.INFO,
		 * "The param <file-test> is empty, the active learning algorithm require this property "
		 * +
		 * "for evaluating the constructed model, but in real scenario is not really necessary. In this case, "
		 * + "we assign the <file-unlabeled> as <file-test>.");
		 */
		fileTest = fileUnlabeled;
	}

	setFileTestDataset(fileTest);

	// Set class attribute
	int classAttributeT = configuration.getInt("class-attribute", -1);

	setClassAttribute(classAttributeT);
}
 
开发者ID:ogreyesp,项目名称:JCLAL,代码行数:55,代码来源:RealScenario.java

示例10: init

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
        throws FloodlightModuleException {

    bgpRoutes = new ConcurrentInvertedRadixTree<>(
            new DefaultByteArrayNodeFactory());
    interfaceRoutes = new ConcurrentInvertedRadixTree<>(
            new DefaultByteArrayNodeFactory());
    externalNetworkSwitchPorts = new HashSet<SwitchPort>();

    ribUpdates = new LinkedBlockingQueue<>();

    // Register REST handler.
    restApi = context.getServiceImpl(IRestApiService.class);
    proxyArp = context.getServiceImpl(IProxyArpService.class);

    controllerRegistryService = context
            .getServiceImpl(IControllerRegistryService.class);
    pathRuntime = context.getServiceImpl(IPathCalcRuntimeService.class);
    linkDiscoveryService = context.getServiceImpl(ILinkDiscoveryService.class);

    intentIdGenerator = new IdBlockAllocatorBasedIntentIdGenerator(
            controllerRegistryService);

    // TODO: initialize intentService

    pushedRouteIntents = new ConcurrentHashMap<>();

    prefixesWaitingOnArp = Multimaps.synchronizedSetMultimap(
            HashMultimap.<InetAddress, RibUpdate>create());

    //flowCache = new FlowCache(floodlightProvider);

    bgpUpdatesExecutor = Executors.newSingleThreadExecutor(
            new ThreadFactoryBuilder().setNameFormat("bgp-updates-%d").build());

    // Read in config values
    bgpdRestIp = context.getConfigParams(this).get("BgpdRestIp");
    if (bgpdRestIp == null) {
        log.error("BgpdRestIp property not found in config file");
        throw new ConfigurationRuntimeException(
                "BgpdRestIp property not found in config file");
    } else {
        log.info("BgpdRestIp set to {}", bgpdRestIp);
    }

    routerId = context.getConfigParams(this).get("RouterId");
    if (routerId == null) {
        log.error("RouterId property not found in config file");
        throw new ConfigurationRuntimeException(
                "RouterId property not found in config file");
    } else {
        log.info("RouterId set to {}", routerId);
    }

    String configFilenameParameter = context.getConfigParams(this).get("configfile");
    if (configFilenameParameter != null) {
        currentConfigFilename = configFilenameParameter;
    }
    log.debug("Config file set to {}", currentConfigFilename);

    readConfiguration(currentConfigFilename);
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:64,代码来源:SdnIp.java

示例11: validate

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
public void validate() {
  if (_storage != null && DataSize.toBytes(_storage) < 0) {
    LOGGER.error("Failed to convert storage quota config: {} to bytes", _storage);
    throw new ConfigurationRuntimeException("Failed to convert storage quota config: " + _storage + " to bytes");
  }
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:7,代码来源:QuotaConfig.java

示例12: configure

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
/**
 *
 * @param configuration
 *            The configuration object for
 *            MultiLabel3DimensionalQueryStrategy
 *
 *            The XML labels supported are:
 *            <ul>
 *            <li>evidence-dimension: The possible values are [C, S]</li>
 *            <li>class-dimension: The possible values are [M, A, R]</li>
 *            <li>weight-dimension: The possible values are [N, M]</li>
 *            </ul>
 */
@Override
public void configure(Configuration configuration) {

	super.configure(configuration);

	evidenceDimension = configuration.getString("evidence-dimension", "C").toCharArray()[0];
	classDimension = configuration.getString("class-dimension", "M").toCharArray()[0];
	weightDimension = configuration.getString("weight-dimension", "N").toCharArray()[0];

	switch (evidenceDimension) {

	case 'C':

		setMaximal(false);

		break;

	case 'S':

		setMaximal(true);

		break;

	default:
		throw new ConfigurationRuntimeException("For the evidence dimension the options are C and S");
	}

	switch (classDimension) {

	case 'M':

		break;

	case 'A':

		break;

	case 'R':

		break;

	default:
		throw new ConfigurationRuntimeException("For the class dimension the options are M, A and R");
	}

	switch (weightDimension) {

	case 'N':

		break;

	case 'W':

		break;

	default:
		throw new ConfigurationRuntimeException("For the weight dimension the options are N and W");
	}

}
 
开发者ID:ogreyesp,项目名称:JCLAL,代码行数:74,代码来源:MultiLabel3DimensionalQueryStrategy.java

示例13: configure

import org.apache.commons.configuration.ConfigurationRuntimeException; //导入依赖的package包/类
/**
 * @param configuration
 *            The configuration of SenderEmail.
 *
 *            The XML labels supported are:
 *            <ul>
 *            <li>smtp-host= ip</li>
 *            <li>smtp-port= int</li>
 *            <li>to= email</li>
 *            <li>from= email</li>
 *            <li>attach-report-file=boolean</li>
 *            <li>user=String</li>
 *            <li>pass=String</li>
 *            </ul>
 */
@Override
public void configure(Configuration configuration) {

	String hostT = configuration.getString("smtp-host", "");
	if (hostT.isEmpty()) {
		throw new ConfigurationRuntimeException("\nThe tag <smtp-host></smtp-host> is empty.");
	}

	setHost(hostT);

	int portT = configuration.getInt("smtp-port", 21);

	setPort(portT);

	String fromT = configuration.getString("from", "");

	if (fromT.isEmpty()) {
		throw new ConfigurationRuntimeException("\nThe tag <from></from> is empty. ");
	}

	setFrom(fromT);

	// Number of defined recipients
	int numberRecipients = configuration.getList("to").size();

	if (numberRecipients == 0) {
		throw new ConfigurationRuntimeException("\nAt least one <to></to> tag must be defined. ");
	}

	// For each recipients in list
	for (int i = 0; i < numberRecipients; i++) {

		String header = "to(" + i + ")";

		// recipient
		String recipientName = configuration.getString(header, "");

		// Add this recipient
		toRecipients.append(recipientName).append(";");
	}

	toRecipients.deleteCharAt(toRecipients.length() - 1);

	boolean attach = configuration.getBoolean("attach-report-file", false);

	setAttachReporFile(attach);

	String userT = configuration.getString("user", "");

	if (userT.isEmpty()) {
		throw new ConfigurationRuntimeException("\nThe tag <user></user> is empty. ");
	}

	setUser(userT);

	String passT = configuration.getString("pass", "");

	if (passT.isEmpty()) {
		throw new ConfigurationRuntimeException("\nThe tag <pass></pass> is empty. ");
	}

	setPass(passT);
}
 
开发者ID:ogreyesp,项目名称:JCLAL,代码行数:79,代码来源:SenderEmail.java


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