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


Java ConfigurationNode类代码示例

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


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

示例1: getEntryForGraphNodeType

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
@Override
public KernelRepositoryEntry getEntryForGraphNodeType(GraphNodeType type)
		throws ConfigurationException {
	config.load(resource);
	
	List<ConfigurationNode> entryNodes = config.getRootNode().getChildren(ENTRY_NODE);
	for(ConfigurationNode node : entryNodes){
		List<ConfigurationNode> typeAttrList = node.getAttributes(ENTRY_NODE_TYPE_ATTRIBUTE);
		
		if(typeAttrList.size()>0){
			String val = (String) typeAttrList.get(0).getValue();
			
			if(type.equals(GraphNodeType.getType(val))){
				return getEntryFromConfigurationNode(node);
			}
		} else{
			throw new ConfigurationException("KH: no required '"+ENTRY_NODE_TYPE_ATTRIBUTE+"' attribute in "+ENTRY_NODE+" node");
		}
	}
	
	return null;
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:23,代码来源:KernelRepository.java

示例2: getEntryFromConfigurationNode

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
private KernelRepositoryEntry getEntryFromConfigurationNode(ConfigurationNode node) throws ConfigurationException{
	List<ConfigurationNode> typeAttrList = node.getAttributes(ENTRY_NODE_TYPE_ATTRIBUTE);
	List<ConfigurationNode> descAttrList = node.getAttributes(ENTRY_NODE_DESCRIPTION_ATTRIBUTE);
	String typeStr;
	String desc = null;
	
	if(typeAttrList.size()>0){
		typeStr = (String) typeAttrList.get(0).getValue();
	} else{
		throw new ConfigurationException("KH: no required '"+ENTRY_NODE_TYPE_ATTRIBUTE+"' attribute in "+ENTRY_NODE+" node");
	}
	
	if(descAttrList.size()>0){
		desc = (String) descAttrList.get(0).getValue();
	}
	
	List<KernelPathEntry> kernelPathEntries = getKernelPathEntries(node);
	Map<String, Object> kernelProperties = getKernelProperties(node);

	return new KernelRepositoryEntry(GraphNodeType.getType(typeStr), desc, kernelPathEntries, kernelProperties);
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:22,代码来源:KernelRepository.java

示例3: loadKernel

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
private IKernelString loadKernel(final ConfigurationNode node)
		throws ConfigurationException {
	String src;
	String srcId;

	final List<ConfigurationNode> idSourceAttrs = node
			.getAttributes(KERNEL_ID_ATTRIBUTE);
	if (idSourceAttrs.size() > 0) {
		srcId = (String) idSourceAttrs.get(0).getValue();
	} else {
		throw new ConfigurationException("KH: no required attribute '"
				+ KERNEL_ID_ATTRIBUTE + "' found in " + KERNEL + " node");
	}

	final List<ConfigurationNode> srcAttrs = node
			.getAttributes(KERNEL_SRC_ATTRIBUTE);
	if (srcAttrs.size() > 0) {
		src = (String) srcAttrs.get(0).getValue();
	} else {
		throw new ConfigurationException(
				"KH: no required attribute 'src' in " + KERNEL + " node");
	}

	final Map<String, Object> properties = loadKernelProperties(node);
	return new KernelString(srcId, src, properties);
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:27,代码来源:EngineGraphConfiguration.java

示例4: saveGraphForEngine

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
@Override
public void saveGraphForEngine(
		final List<EngineGraphNodeDecorator> graphNodes, final File file)
		throws ConfigurationException {
	final XMLConfiguration tempConfig = (XMLConfiguration) config.clone();
	try {
		config.clear();
		config.setRootNode(tempConfig.getRootNode());
		config.getRootNode().removeChildren();
		final List<ConfigurationNode> inputDataURLNodes = tempConfig
				.getRootNode().getChildren(INPUT_DATA_NODE);
		for (final ConfigurationNode node : inputDataURLNodes) {
			config.getRootNode().addChild(node);
		}
		for (final EngineGraphNodeDecorator engineNode : graphNodes) {
			config.getRoot().addChild(createGraphNodeForEngine(engineNode));
		}
		config.save(file);
	} catch (final ConfigurationException e) {
		config = tempConfig;
		config.save(file);
		throw e;
	}

}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:26,代码来源:EngineGraphConfiguration.java

示例5: setInputDataURL

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
@Override
public void setInputDataURL(final String inputDataUrl)
		throws ConfigurationException {
	final List<ConfigurationNode> dataNodes = config.getRoot().getChildren(
			INPUT_DATA_NODE);
	if (dataNodes.size() > 0) {
		final List<ConfigurationNode> attrList = dataNodes.get(0)
				.getChildren(INPUT_DATA_NODE_URL_ATTRIBUTE);
		if (attrList.size() > 0) {
			attrList.get(0).setValue(inputDataUrl);
		}
	} else {
		final Node data = new Node(INPUT_DATA_NODE);
		final Node url = new Node(INPUT_DATA_NODE_URL_ATTRIBUTE);
		url.setAttribute(true);
		url.setValue(inputDataUrl);
		data.addAttribute(url);
		config.getRoot().addChild(data);
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:21,代码来源:EngineGraphConfiguration.java

示例6: loadGraphNodeForGUI

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
private GUIGraphNodeDecorator loadGraphNodeForGUI(ConfigurationNode node)
		throws ConfigurationException {

	IGraphNode graphNode = loadGraphNode(node);
	int x = -1, y = -1;

	List<ConfigurationNode> xAttrList = node
			.getAttributes(NODE_X_ATTRIBUTE);
	List<ConfigurationNode> yAttrList = node
			.getAttributes(NODE_Y_ATTRIBUTE);
	if (xAttrList.size() > 0) {
		x = Integer.parseInt((String) xAttrList.get(0).getValue());
	}
	if (yAttrList.size() > 0) {
		y = Integer.parseInt((String) yAttrList.get(0).getValue());
	}

	GUIGraphNodeDecorator guiNode = new GUIGraphNodeDecorator(graphNode);
	guiNode.setX(x);
	guiNode.setY(y);

	return guiNode;
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:24,代码来源:GUIGraphConfiguration.java

示例7: getEntries

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
@Override
public List<IKernelRepositoryEntry> getEntries()
		throws KernelRepositoryException {
	try {
		resource = repoConfig
				.getKernelRepositoryDescriptorFileURL(jarFileLocation);
		config.load(resource);

		final List<IKernelRepositoryEntry> entries = new ArrayList<IKernelRepositoryEntry>();

		final List<ConfigurationNode> entryNodes = config.getRoot()
				.getChildren(ENTRY_NODE);
		for (final ConfigurationNode node : entryNodes) {
			entries.add(getEntryFromConfigurationNode(node));
		}
		return entries;
	} catch (final ConfigurationException e) {
		throw new KernelRepositoryException(e);
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:21,代码来源:KernelRepository.java

示例8: constructHierarchy

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
/**
 * Constructs the internal configuration nodes hierarchy.
 *
 * @param node The configuration node that is the root of the current configuration section.
 * @param map The map with the yaml configurations nodes, i.e. String -> Object.
 */
@SuppressWarnings("unchecked")
private void constructHierarchy(ConfigurationNode node, Map<String, Object> map)
{
    for (Map.Entry<String, Object> entry : map.entrySet())
    {
        String key = entry.getKey();
        Object value = entry.getValue();
        if (value instanceof Map)
        {
            ConfigurationNode treeNode = createNode(key);
            constructHierarchy(treeNode, (Map) value);
            node.addChild(treeNode);
        }
        else
        {
            ConfigurationNode leaveNode = createNode(key);
            leaveNode.setValue(value);
            node.addChild(leaveNode);
        }
    }
}
 
开发者ID:mbredel,项目名称:configurations-yaml,代码行数:28,代码来源:YAMLConfiguration.java

示例9: constructMap

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
/**
 * Constructs a YAML map, i.e. String -> Object from a given
 * configuration node.
 *
 * @param node The configuration node to create a map from.
 * @return A Map that contains the configuration node information.
 */
public Map<String, Object> constructMap(ConfigurationNode node)
{
    Map<String, Object> map = new HashMap<>(node.getChildrenCount());
    for (ConfigurationNode cNode : node.getChildren())
    {
        if (cNode.getChildren().isEmpty())
        {
            map.put(cNode.getName(), cNode.getValue());
        }
        else
        {
            map.put(cNode.getName(), constructMap(cNode));
        }
    }
    return map;
}
 
开发者ID:mbredel,项目名称:configurations-yaml,代码行数:24,代码来源:YAMLConfiguration.java

示例10: traverseTreeAndLoad

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
/**
 * Process a node in the object tree, and store it with its parent node in the Config tree.
 * <p>
 * This method recursively calls itself to walk an object tree.
 *
 * @param parent   Parent of the current node, as represented in the Config tree.
 * @param path     Path.
 * @param includes Includes encountered.
 * @param node     Node to process.
 */
void traverseTreeAndLoad(ConfigurationNode parent, String path, List<IncludeReference> includes, Object node) {
    if (node instanceof IncludeReference) {
        IncludeReference include = (IncludeReference) node;
        include.setConfigPath(path);
        includes.add(include);
    } else if (node instanceof Map<?, ?>) {
        // It is not feasible for this class to check this cast, but it is guaranteed by the
        // yaml.load() call that it is a Map<String, Object>.
        @SuppressWarnings("unchecked")
        Map<String, Object> map = (Map<String, Object>) node;

        for (Map.Entry<String, Object> entry : map.entrySet()) {
            String key = entry.getKey();
            HierarchicalConfiguration.Node child = new HierarchicalConfiguration.Node(key);
            child.setReference(entry);
            // Walk the complete tree.
            traverseTreeAndLoad(child, combineConfigKeyPath(path, key), includes, entry.getValue());
            parent.addChild(child);
        }
    } else {
        // This works for both primitives and lists.
        parent.setValue(node);
    }
}
 
开发者ID:LableOrg,项目名称:java-dynamicconfig,代码行数:35,代码来源:YamlDeserializer.java

示例11: processMqscFiles

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
private void processMqscFiles(XMLConfiguration config, List<File> mqscFiles, String releaseFolder) {
	
	if(CollectionUtils.isNotEmpty(mqscFiles)){
		List<ConfigurationNode> allMQSCEnvironments = config.getRootNode().getChildren();
		if(CollectionUtils.isNotEmpty(allMQSCEnvironments)){
			MultiValuedMap<String,String> allMQSCForEnvironment = new ArrayListValuedHashMap<>();
			
			processMQSCForAllEnvironments(config, mqscFiles,
					allMQSCEnvironments, allMQSCForEnvironment);
			
			for(String key: allMQSCForEnvironment.keySet()){
				List<String> mqscContentList = (List<String>)allMQSCForEnvironment.get(key);
				generateMQSCContent(config, mqscContentList, key, releaseFolder);
			}
		}
	}
}
 
开发者ID:anair-it,项目名称:wmq-mqsc-mojo,代码行数:18,代码来源:MqscMojo.java

示例12: processMQSCForAllEnvironments

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
private void processMQSCForAllEnvironments(XMLConfiguration config,
		List<File> allMqscFiles,
		List<ConfigurationNode> allMQSCEnvironments,
		MultiValuedMap<String,String> allMQSCForEnvironment) {
	for(ConfigurationNode rootConfigNode: allMQSCEnvironments){
		String environment = rootConfigNode.getName();
		
		for(File mqscFile: allMqscFiles){
			try {
				String originalfileContent = FileUtils.readFileToString(mqscFile, Charset.defaultCharset());
				allMQSCForEnvironment.put(environment, originalfileContent);
			} catch (IOException e) {
				LOG.error(e.getMessage(), e);
			}
		}
	}
}
 
开发者ID:anair-it,项目名称:wmq-mqsc-mojo,代码行数:18,代码来源:MqscMojo.java

示例13: saveComponentConfigurationsTo

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
private void saveComponentConfigurationsTo(HierarchicalConfiguration config)
		throws MEaterConfigurationException {
	// create a collection to hold the components section
	Collection<ConfigurationNode> configNodes = new LinkedList<ConfigurationNode>();

	// save all of our components to the section
	for (I c : this.configUnits) {
		// create a configuration for the component + save it, add it
		HierarchicalConfiguration cc = new HierarchicalConfiguration();
		c.saveConfigurationTo(cc);
		cc.getRootNode().setName(c.getRegisteredTypeName());
		configNodes.add(cc.getRootNode());
	}

	// add components section to config
	config.addNodes(CKEY_INSTANCES, configNodes);
}
 
开发者ID:rmachedo,项目名称:MEater,代码行数:18,代码来源:InstanceConfigContainer.java

示例14: saveModulesTo

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
private void saveModulesTo(HierarchicalConfiguration config)
		throws MEaterConfigurationException {
	// create a collection to hold the modules section
	Collection<ConfigurationNode> moduleNodes = new LinkedList<ConfigurationNode>();

	// save all of our modules to the section
	for (ConfigModule m : this.modules.values()) {
		// create a configuration for the module + save it, add it
		HierarchicalConfiguration mc = new HierarchicalConfiguration();
		m.saveConfigurationTo(mc);
		mc.getRootNode().setName(m.getModuleName());
		moduleNodes.add(mc.getRootNode());
	}

	// add modules section to config
	config.addNodes(CKEY_MODULES, moduleNodes);
}
 
开发者ID:rmachedo,项目名称:MEater,代码行数:18,代码来源:MEaterConfig.java

示例15: getProperty

import org.apache.commons.configuration.tree.ConfigurationNode; //导入依赖的package包/类
/**
 * Fetches the specified property. This task is delegated to the associated
 * expression engine.
 *
 * @param key the key to be looked up
 * @return the found value
 */
@Override
public List<Object> getProperty(String key) {
    List<?> nodes = fetchNodeList(key);

    if (nodes.size() == 0) {
        return null;
    } else {
        List<Object> list = new ArrayList<>();
        for (Object node : nodes) {
            ConfigurationNode configurationNode = (ConfigurationNode) node;
            if (configurationNode.getValue() != null) {
                list.add(configurationNode.getValue());
            }
        }

        if (list.size() < 1) {
            return null;
        } else {
            return list;
        }
    }
}
 
开发者ID:qspin,项目名称:qtaste,代码行数:30,代码来源:XMLConfiguration.java


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