本文整理汇总了Java中org.apache.commons.configuration.tree.ConfigurationNode.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationNode.getChildren方法的具体用法?Java ConfigurationNode.getChildren怎么用?Java ConfigurationNode.getChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.configuration.tree.ConfigurationNode
的用法示例。
在下文中一共展示了ConfigurationNode.getChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: makeElement
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private Element makeElement(ConfigurationNode node)
{
Element element = new Element(node.getName());
Object value = node.getValue();
if (value != null)
element.setText(value.toString());
List<ConfigurationNode> attributes = node.getAttributes();
for (ConfigurationNode attribute: attributes)
{
element.setAttribute(new Attribute(attribute.getName(),attribute.getValue().toString()));
}
List<ConfigurationNode> children = node.getChildren();
for (ConfigurationNode child: children)
{
element.addContent(makeElement(child));
}
return element;
}
示例3: getKernelPathEntries
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private List<KernelPathEntry> getKernelPathEntries(ConfigurationNode node) throws ConfigurationException{
List<ConfigurationNode> kernelsList = node.getChildren(KERNEL_NODE);
List<KernelPathEntry> list = new ArrayList<KernelPathEntry>(kernelsList.size());
for(ConfigurationNode kNode : kernelsList){
String name;
URL src;
String id;
List<ConfigurationNode> idAttrList = kNode.getAttributes(KERNEL_NODE_ID_ATTRIBUTE);
List<ConfigurationNode> nameAttrList = kNode.getAttributes(KERNEL_NODE_NAME_ATTRIBUTE);
List<ConfigurationNode> srcAttrList = kNode.getAttributes(KERNEL_NODE_SRC_ATTRIBUTE);
if(nameAttrList.size()>0){
name = (String) nameAttrList.get(0).getValue();
} else{
throw new ConfigurationException("KH: no required '"+KERNEL_NODE_NAME_ATTRIBUTE+"' attribute in "+KERNEL_NODE+" node");
}
if(srcAttrList.size()>0){
src = KernelRepository.class.getResource((String) srcAttrList.get(0).getValue());
if(src==null){
throw new ConfigurationException("KH: the resource path: '"+srcAttrList.get(0).getValue()+"' cound not be found");
}
} else{
throw new ConfigurationException("KH: no required '"+KERNEL_NODE_SRC_ATTRIBUTE+"' attribute in "+KERNEL_NODE+" node");
}
if(idAttrList.size()>0){
id = (String) idAttrList.get(0).getValue();
} else{
throw new ConfigurationException("KH: no required '"+KERNEL_NODE_ID_ATTRIBUTE+"' attribute in "+KERNEL_NODE+" node");
}
Map<String, Object> properties = getKernelProperties(kNode);
list.add(new KernelPathEntry(id, name, src, properties));
}
return list;
}
示例4: getKernelProperties
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private Map<String, Object> getKernelProperties(ConfigurationNode node) throws ConfigurationException{
List<ConfigurationNode> propertiesNodeList = node.getChildren(KERNEL_PROPERTY_NODE);
Map<String, Object> properties = new HashMap<String, Object>(propertiesNodeList.size());
for(ConfigurationNode pNode : propertiesNodeList){
String key;
Object value;
List<ConfigurationNode> keyAttrList = pNode.getAttributes(KERNEL_PROPERTY_NODE_KEY_ATTRIBUTE);
List<ConfigurationNode> valueAttrList = pNode.getAttributes(KERNEL_PROPERTY_NODE_VALUE_ATTRIBUTE);
if(keyAttrList.size()>0){
key = (String) keyAttrList.get(0).getValue();
} else{
throw new ConfigurationException("KH: no required '"+KERNEL_PROPERTY_NODE_KEY_ATTRIBUTE+"' attribute in "+KERNEL_PROPERTY_NODE+" node");
}
if(valueAttrList.size()>0){
value = valueAttrList.get(0).getValue();
} else{
throw new ConfigurationException("KH: no required '"+KERNEL_PROPERTY_NODE_VALUE_ATTRIBUTE+"' attribute in "+KERNEL_PROPERTY_NODE+" node");
}
properties.put(key, value);
}
return properties;
}
示例5: loadKernelProperties
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private Map<String, Object> loadKernelProperties(
final ConfigurationNode node) throws ConfigurationException {
final List<ConfigurationNode> propList = node
.getChildren(KERNEL_PROPERTY_NODE);
final Map<String, Object> properties = new HashMap<String, Object>();
for (final ConfigurationNode propNode : propList) {
String key;
Object value;
final List<ConfigurationNode> keyAttrList = propNode
.getAttributes(KERNEL_PROPERTY_NODE_KEY_ATTRIBUTE);
if (keyAttrList.size() > 0) {
key = (String) keyAttrList.get(0).getValue();
} else {
throw new ConfigurationException("KH: no required attribute '"
+ KERNEL_PROPERTY_NODE_KEY_ATTRIBUTE + "' in "
+ KERNEL_PROPERTY_NODE + " node");
}
final List<ConfigurationNode> valueAttrList = propNode
.getAttributes(KERNEL_PROPERTY_NODE_VALUE_ATTRIBUTE);
if (valueAttrList.size() > 0) {
value = valueAttrList.get(0).getValue();
} else {
throw new ConfigurationException("KH: no required attribute '"
+ KERNEL_PROPERTY_NODE_VALUE_ATTRIBUTE + "' in "
+ KERNEL_PROPERTY_NODE + " node");
}
properties.put(key, value);
}
return properties;
}
示例6: loadKernels
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private List<IKernelString> loadKernels(final ConfigurationNode node)
throws ConfigurationException {
final List<IKernelString> kernels = new ArrayList<IKernelString>();
List<ConfigurationNode> kernelNodes = node.getChildren(NODE_KERNELS);
if (kernelNodes.size() > 0) {
final ConfigurationNode kernelNode = kernelNodes.get(0);
kernelNodes = kernelNode.getChildren(KERNEL);
for (final ConfigurationNode n : kernelNodes) {
kernels.add(loadKernel(n));
}
}
return kernels;
}
示例7: loadSourceFileProperties
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private Map<String, Object> loadSourceFileProperties(ConfigurationNode node)
throws ConfigurationException {
List<ConfigurationNode> propList = node
.getChildren(SOURCE_FILE_PROPERTY_NODE);
Map<String, Object> properties = new HashMap<String, Object>();
for (ConfigurationNode propNode : propList) {
String key;
Object value;
List<ConfigurationNode> keyAttrList = propNode
.getAttributes(SOURCE_FILE_PROPERTY_NODE_KEY_ATTRIBUTE);
if (keyAttrList.size() > 0) {
key = (String) keyAttrList.get(0).getValue();
} else {
throw new ConfigurationException("KH: no required attribute '"
+ SOURCE_FILE_PROPERTY_NODE_KEY_ATTRIBUTE + "' in "
+ SOURCE_FILE_PROPERTY_NODE + " node");
}
List<ConfigurationNode> valueAttrList = propNode
.getAttributes(SOURCE_FILE_PROPERTY_NODE_VALUE_ATTRIBUTE);
if (valueAttrList.size() > 0) {
value = valueAttrList.get(0).getValue();
} else {
throw new ConfigurationException("KH: no required attribute '"
+ SOURCE_FILE_PROPERTY_NODE_VALUE_ATTRIBUTE + "' in "
+ SOURCE_FILE_PROPERTY_NODE + " node");
}
properties.put(key, value);
}
return properties;
}
示例8: loadSourceFiles
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private List<IKernelFile> loadSourceFiles(ConfigurationNode node)
throws ConfigurationException {
List<IKernelFile> sourceFiles = new ArrayList<IKernelFile>();
List<ConfigurationNode> sourceFilesList = node
.getChildren(NODE_SOURCE_FILES);
if (sourceFilesList.size() > 0) {
ConfigurationNode sourcesNode = sourceFilesList.get(0);
sourceFilesList = sourcesNode.getChildren(SOURCE_FILE);
for (ConfigurationNode src : sourceFilesList) {
sourceFiles.add(loadSourceFile(src));
}
}
return sourceFiles;
}
示例9: loadGraphNodeProperties
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
protected Map<String, Object> loadGraphNodeProperties(
final ConfigurationNode node) throws ConfigurationException {
final Map<String, Object> props = new HashMap<String, Object>();
List<ConfigurationNode> propertiesList = node
.getChildren(PROPERTIES_NODE);
if (propertiesList.size() > 0) {
final ConfigurationNode propsNode = propertiesList.get(0);
propertiesList = propsNode.getChildren(PROPERTY_NODE);
for (final ConfigurationNode prop : propertiesList) {
String key;
Object value;
final List<ConfigurationNode> keyAttrList = prop
.getAttributes(PROPERTY_NODE_KEY_ATTRIBUTE);
final List<ConfigurationNode> valueAttrList = prop
.getAttributes(PROPERTY_NODE_VALUE_ATTRIBUTE);
if (keyAttrList.size() > 0) {
key = (String) keyAttrList.get(0).getValue();
} else {
throw new ConfigurationException(
"KH: no required 'key' attribute in "
+ PROPERTY_NODE + " node");
}
if (valueAttrList.size() > 0) {
value = valueAttrList.get(0).getValue();
} else {
throw new ConfigurationException(
"KH: no required 'value' attribute in "
+ PROPERTY_NODE + " node");
}
props.put(key, value);
}
}
return props;
}
示例10: getKernelProperties
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private Map<String, Object> getKernelProperties(final ConfigurationNode node)
throws ConfigurationException {
final List<ConfigurationNode> propertiesNodeList = node
.getChildren(KERNEL_PROPERTY_NODE);
final Map<String, Object> properties = new HashMap<String, Object>(
propertiesNodeList.size());
for (final ConfigurationNode pNode : propertiesNodeList) {
String key;
Object value;
final List<ConfigurationNode> keyAttrList = pNode
.getAttributes(KERNEL_PROPERTY_NODE_KEY_ATTRIBUTE);
final List<ConfigurationNode> valueAttrList = pNode
.getAttributes(KERNEL_PROPERTY_NODE_VALUE_ATTRIBUTE);
if (keyAttrList.size() > 0) {
key = (String) keyAttrList.get(0).getValue();
} else {
throw new ConfigurationException("KH: no required '"
+ KERNEL_PROPERTY_NODE_KEY_ATTRIBUTE
+ "' attribute in " + KERNEL_PROPERTY_NODE + " node");
}
if (valueAttrList.size() > 0) {
value = valueAttrList.get(0).getValue();
} else {
throw new ConfigurationException("KH: no required '"
+ KERNEL_PROPERTY_NODE_VALUE_ATTRIBUTE
+ "' attribute in " + KERNEL_PROPERTY_NODE + " node");
}
properties.put(key, value);
}
return properties;
}
示例11: addSteps
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private void addSteps(ConfigurationNode defination, ArrayList<Object[]> statements) {
for (Object o : defination.getChildren()) {
Node stepNode = (Node) o;
if (stepNode.getName().equalsIgnoreCase("STEP")) {
String name = getAttribute(stepNode, "name", null);
String inParams = getAttribute(stepNode, "params", "[]");
if (!inParams.startsWith("[")) {
Object[] params = new Object[] { toObject(inParams) };
inParams = gson.toJson(params);
}
String outParams = getAttribute(stepNode, "result", "");
statements.add(new String[] { name, inParams, outParams });
}
}
}
示例12: getStringValue
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private String getStringValue(String name, String d) {
List<ConfigurationNode> properties = getRootNode().getChildren();
if (properties == null || properties.size() == 0) {
return d;
}
for (ConfigurationNode p : properties) {
if (p.getChildren("name") != null && p.getChildren("name").size() > 0
&& name.equals(p.getChildren("name").get(0).getValue())) {
return (String) p.getChildren("value").get(0).getValue();
}
}
return d;
}
示例13: getIntValue
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private int getIntValue(String name, int d) {
List<ConfigurationNode> properties = getRootNode().getChildren();
if (properties == null || properties.size() == 0) {
return d;
}
for (ConfigurationNode p : properties) {
if (p.getChildren("name") != null && p.getChildren("name").size() > 0
&& name.equals(p.getChildren("name").get(0).getValue())) {
return Integer.parseInt((String) p.getChildren("value").get(0).getValue());
}
}
return d;
}
示例14: getLongValue
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private long getLongValue(String name, long d) {
List<ConfigurationNode> properties = getRootNode().getChildren();
if (properties == null || properties.size() == 0) {
return d;
}
for (ConfigurationNode p : properties) {
if (p.getChildren("name") != null && p.getChildren("name").size() > 0
&& name.equals(p.getChildren("name").get(0).getValue())) {
return Long.parseLong((String) p.getChildren("value").get(0).getValue());
}
}
return d;
}
示例15: getFloatValue
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private float getFloatValue(String name, float d) {
List<ConfigurationNode> properties = getRootNode().getChildren();
if (properties == null || properties.size() == 0) {
return d;
}
for (ConfigurationNode p : properties) {
if (p.getChildren("name") != null && p.getChildren("name").size() > 0
&& name.equals(p.getChildren("name").get(0).getValue())) {
return Float.parseFloat((String) p.getChildren("value").get(0).getValue());
}
}
return d;
}