本文整理汇总了Java中org.apache.commons.configuration.tree.ConfigurationNode.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationNode.getValue方法的具体用法?Java ConfigurationNode.getValue怎么用?Java ConfigurationNode.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.configuration.tree.ConfigurationNode
的用法示例。
在下文中一共展示了ConfigurationNode.getValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
}
示例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: traverseTreeAndEmit
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
/**
* Process a node in the Config tree, and store it with its parent node in an object tree.
* <p>
* This method recursively calls itself to walk a Config tree.
*
* @param parent Parent of the current node, as represented in the Config tree.
* @return An object tree.
*/
public static Object traverseTreeAndEmit(ConfigurationNode parent) {
if (parent.getChildrenCount() == 0) {
return parent.getValue();
} else {
Map<String, Object> map = new LinkedHashMap<>();
for (Object o : parent.getChildren()) {
ConfigurationNode child = (ConfigurationNode) o;
String nodeName = child.getName();
addToMap(map, nodeName, traverseTreeAndEmit(child));
}
return map;
}
}
示例4: visitBeforeChildren
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
@Override
public void visitBeforeChildren(ConfigurationNode node) {
mPrefixes.push(node.getName());
if (node.getValue() != null) {
String key = StringUtils.join(mPrefixes, ".");
if (mProperties.containsKey(key)) {
String value = mProperties.get(key);
mProperties.put(key, String.format("%s, %s", value, (String) node.getValue()));
} else {
mProperties.put(key, (String) node.getValue());
}
}
}