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


Java HierarchicalConfiguration.getString方法代码示例

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


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

示例1: parseBalancer

import org.apache.commons.configuration2.HierarchicalConfiguration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <E extends VMwareBalancer<?>> E parseBalancer(
        HierarchicalConfiguration parent, Class<E> targetClass,
        Class<? extends E> defaultBalancer,
        VMwareDatacenterInventory inventory) throws Exception {

    String balancerClass = parent.getString("balancer[@class]");
    Class<?> loadedClass = null;
    if (balancerClass != null) {
        loadedClass = this.getClass().getClassLoader()
                .loadClass(balancerClass);
        if (!targetClass.isAssignableFrom(loadedClass)) {
            loadedClass = null;
            logger.warn("The configured balancer '" + balancerClass
                    + "' is not of type " + targetClass.getSimpleName());
        }
    }
    if (loadedClass == null) {
        balancerClass = defaultBalancer.getName();
        parent.addProperty("balancer[@class]", balancerClass);
        loadedClass = defaultBalancer;
    }
    HierarchicalConfiguration balancerConfig = parent
            .configurationAt(ELEMENT_BALANCER);
    E balancer = (E) loadedClass.newInstance();
    balancer.setConfiguration(balancerConfig);
    balancer.setInventory(inventory);
    return balancer;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:30,代码来源:LoadBalancerConfiguration.java

示例2: setConfiguration

import org.apache.commons.configuration2.HierarchicalConfiguration; //导入方法依赖的package包/类
@Override
public void setConfiguration(HierarchicalConfiguration config) {
    if (config != null) {
        String storages = config.getString("[@storage]");
        if (storages == null || storages.trim().length() == 0) {
            throw new IllegalArgumentException(
                    "No storage reference defined for balancer");
        }
        String[] elms = storages.split(",");
        for (String x : elms) {
            datastoreNames.add(x.toString().trim());
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:15,代码来源:StorageBalancer.java

示例3: setConfiguration

import org.apache.commons.configuration2.HierarchicalConfiguration; //导入方法依赖的package包/类
@Override
public void setConfiguration(HierarchicalConfiguration xmlConfig) {
    if (xmlConfig != null) {
        String hosts = xmlConfig.getString("[@hosts]");
        if (hosts != null) {
            String[] elms = hosts.split(",");
            for (String x : elms) {
                hostNames.add(x.toString().trim());
            }
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:13,代码来源:HostBalancer.java

示例4: testPseudonymizationSettings

import org.apache.commons.configuration2.HierarchicalConfiguration; //导入方法依赖的package包/类
private static void testPseudonymizationSettings(final XMLConfiguration config) throws ConfigurationException, IllegalArgumentException, ClassNotFoundException {
    List<HierarchicalConfiguration<ImmutableNode>> fields = config.configurationsAt("fields.field");
    for (HierarchicalConfiguration field : fields) {
        // Test the name of the field.
        final String constraint = field.getString("constraint");
        final String fieldName = field.getString("name");
        final String algorithmName = field.getString("algorithm.name");
        if ( (fieldName == null) || (constraint == null) || (algorithmName == null) )
            throw new NoSuchElementException("Name of the field, constraint and algoritm needs to be set for each field.");
        // Test the constraint.
        if (!Constraints.CONSTRAINT_MAP.containsKey(field.getString("constraint"))) {
            throw new ConfigurationException(field.getString("constraint") + "should be defined in constraints list (Constraints.java)");
        }
        // TODO PEF-78: Test if the fieldName matches with the context.
        // TODO PEF-79: No expression support.
        // Test if the algorithm is part of the configured algorithms.
        List<HierarchicalConfiguration> parameters = field.childConfigurationsAt("algorithm.params");
        List<AlgorithmParameter> parameterList = new ArrayList<>();

        //TODO PEF-81: Create here a specific parameter type.
        for (HierarchicalConfiguration parameter : parameters) {
            parameterList.add(new AlgorithmParameter(parameter.getString("name"), parameter.getString("value"), Class.forName(parameter.getString("type"))));
        }
        final StringBuilder buffer = new StringBuilder();
        if (!testParseValueTransformerConfiguration(TransformerId.valueOf(algorithmName), parameterList, buffer)) {
            throw new ConfigurationException("Error in configuration for algorithm "+ algorithmName + " " + buffer.toString());
        }
    }
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:30,代码来源:LiveCapture.java

示例5: phase

import org.apache.commons.configuration2.HierarchicalConfiguration; //导入方法依赖的package包/类
private LanguageSpecBuildPhase phase(HierarchicalConfiguration<ImmutableNode> config) {
    final String phaseStr = config.getString("phase");
    try {
        return phaseStr != null ? LanguageSpecBuildPhase.valueOf(phaseStr) : defaultPhase;
    } catch(IllegalArgumentException e) {
        logger.warn("Language specification build phase with name {} does not exist, defaulting to {}", e, phaseStr,
            defaultPhase);
        return defaultPhase;
    }
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:11,代码来源:SpoofaxLanguageSpecConfig.java


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