本文整理汇总了Java中org.apache.commons.configuration.tree.ConfigurationNode.getAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationNode.getAttributes方法的具体用法?Java ConfigurationNode.getAttributes怎么用?Java ConfigurationNode.getAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.configuration.tree.ConfigurationNode
的用法示例。
在下文中一共展示了ConfigurationNode.getAttributes方法的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;
}
示例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);
}
示例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);
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: loadGraphNode
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
protected IGraphNode loadGraphNode(final ConfigurationNode node)
throws ConfigurationException {
String id = null, name = null;
GraphNodeType type = null;
final List<ConfigurationNode> idAttrList = node
.getAttributes(NODE_ID_ATTRIBUTE);
final List<ConfigurationNode> nameAttrList = node
.getAttributes(NODE_NAME_ATTRIBUTE);
final List<ConfigurationNode> typeAttrList = node
.getAttributes(NODE_TYPE_ATTRIBUTE);
if (idAttrList.size() > 0)
id = (String) idAttrList.get(0).getValue();
if (nameAttrList.size() > 0)
name = (String) nameAttrList.get(0).getValue();
if (typeAttrList.size() > 0)
type = GraphNodeType.getType((String) typeAttrList.get(0)
.getValue());
IGraphNode graphNode;
final IGraphNodeBuilder gnBuilder = new GraphNodeBuilder();
try {
graphNode = gnBuilder.setType(type).setId(id).setName(name).build();
} catch (final GraphNodeBuilderException e) {
e.printStackTrace();
throw new ConfigurationException(e);
}
return graphNode;
}
示例11: 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;
}
示例12: getEntryForGraphNodeType
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
@Override
public IKernelRepositoryEntry getEntryForGraphNodeType(
final GraphNodeType type) throws KernelRepositoryException {
try {
resource = repoConfig
.getKernelRepositoryDescriptorFileURL(jarFileLocation);
config.load(resource);
final List<ConfigurationNode> entryNodes = config.getRootNode()
.getChildren(ENTRY_NODE);
for (final ConfigurationNode node : entryNodes) {
final List<ConfigurationNode> typeAttrList = node
.getAttributes(ENTRY_NODE_TYPE_ATTRIBUTE);
if (typeAttrList.size() > 0) {
final 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;
} catch (final ConfigurationException e) {
throw new KernelRepositoryException(e);
}
}
示例13: getEntryFromConfigurationNode
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private IKernelRepositoryEntry getEntryFromConfigurationNode(
final ConfigurationNode node) throws ConfigurationException {
final List<ConfigurationNode> typeAttrList = node
.getAttributes(ENTRY_NODE_TYPE_ATTRIBUTE);
final 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();
}
final List<IKernelPathEntry> kernelPathEntries = getKernelPathEntries(node);
Map<String, Object> kernelProperties = getKernelProperties(node);
return new KernelRepositoryEntry(GraphNodeType.getType(typeStr), desc,
kernelPathEntries, kernelProperties);
}
示例14: 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;
}
示例15: getMetaData
import org.apache.commons.configuration.tree.ConfigurationNode; //导入方法依赖的package包/类
private Map<?, ?> getMetaData(ConfigurationNode defination) {
Map<String, Object> metaData = new HashMap<String, Object>();
for (Object obj : defination.getAttributes()) {
Node node = (Node) obj;
metaData.put(node.getName(), toObject((String) node.getValue()));
}
return metaData;
}