Java 类org.apache.commons.configuration.HierarchicalConfiguration.Node 实例源码

项目:KernelHive    文件:EngineGraphConfiguration.java   
private Node createGraphNodeForEngine(final EngineGraphNodeDecorator node)
        throws ConfigurationException {
    try {
        final Node configNode = createNodeForEngine(node);
        final Node sendToNode = createSendToSubNode(node.getGraphNode());
        final Node childrenNode = createChildrenSubNode(node.getGraphNode());
        final Node propertiesNode = createPropertiesSubNode(node
                .getGraphNode());
        final Node sourcesNode = createKernelsSubNode(node);
        configNode.addChild(childrenNode);
        configNode.addChild(sendToNode);
        configNode.addChild(propertiesNode);
        configNode.addChild(sourcesNode);
        return configNode;
    } catch (final NullPointerException e) {
        throw new ConfigurationException(e);
    }
}
项目:KernelHive    文件:EngineGraphConfiguration.java   
@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);
    }
}
项目:KernelHive    文件:GUIGraphConfiguration.java   
private Node createGraphNodeForGUI(GUIGraphNodeDecorator node, File file)
        throws ConfigurationException {
    try {
        Node configNode = createNodeForGUI(node);
        Node sendToNode = createSendToSubNode(node.getGraphNode());
        Node childrenNode = createChildrenSubNode(node.getGraphNode());
        Node propertiesNode = createPropertiesSubNode(node.getGraphNode());
        Node sourcesNode = createSourceFilesSubNode(node, file);
        configNode.addChild(childrenNode);
        configNode.addChild(sendToNode);
        configNode.addChild(propertiesNode);
        configNode.addChild(sourcesNode);
        return configNode;
    } catch (NullPointerException e) {
        throw new ConfigurationException(e);
    }
}
项目:KernelHive    文件:AbstractGraphConfiguration.java   
protected Node createNode(final IGraphNode node)
        throws ConfigurationException {
    final Node configNode = new Node(NODE);
    final Node idAttr = new Node(NODE_ID_ATTRIBUTE, node.getNodeId());
    idAttr.setAttribute(true);
    final Node hashAttr = new Node(NODE_HASH_ATTRIBUTE, node.hashCode());
    hashAttr.setAttribute(true);
    final Node parentAttr = new Node(NODE_PARENT_ID_ATTRIBUTE,
            node.getParentNode() != null ? node.getParentNode().getNodeId()
                    : "");
    parentAttr.setAttribute(true);
    final Node nameAttr = new Node(NODE_NAME_ATTRIBUTE, node.getName());
    nameAttr.setAttribute(true);
    final Node typeAttr = new Node(NODE_TYPE_ATTRIBUTE, node.getType()
            .toString());
    typeAttr.setAttribute(true);
    configNode.addAttribute(idAttr);
    configNode.addAttribute(parentAttr);
    configNode.addAttribute(hashAttr);
    configNode.addAttribute(nameAttr);
    configNode.addAttribute(typeAttr);
    return configNode;
}
项目:KernelHive    文件:AbstractGraphConfiguration.java   
protected Node createPropertiesSubNode(final IGraphNode node)
        throws ConfigurationException {
    final Node propertiesNode = new Node(PROPERTIES_NODE);
    final Set<String> keySet = node.getProperties().keySet();
    for (final String key : keySet) {
        final Node propertyNode = new Node(PROPERTY_NODE);
        final Node keyAttr = new Node(PROPERTY_NODE_KEY_ATTRIBUTE, key);
        keyAttr.setAttribute(true);
        final Node valueAttr = new Node(PROPERTY_NODE_VALUE_ATTRIBUTE, node
                .getProperties().get(key));
        valueAttr.setAttribute(true);
        propertyNode.addAttribute(keyAttr);
        propertyNode.addAttribute(valueAttr);
        propertiesNode.addChild(propertyNode);
    }
    return propertiesNode;
}
项目:openNaEF    文件:NmsCorePseudoWireConfiguration.java   
@Override
protected boolean loadExtraConfigration() throws IOException {
    try {
        XMLConfiguration config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());

        for (Object obj : config.getRootNode().getChildren()) {
            Node node = (Node) obj;
            if (node.getName().equals(KEY_RELATED_LSP_FIELD_NAME)) {
                setRelatedRsvplspFieldName((String) node.getValue());
                return true;
            }
        }
    } catch (ConfigurationException e) {
        log.error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + getConfigFile());
    }
    return false;
}
项目:openNaEF    文件:NmsCoreRsvpLspConfiguration.java   
@Override
protected boolean loadExtraConfigration() throws IOException {
    try {
        XMLConfiguration config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());

        for (Object obj : config.getRootNode().getChildren()) {
            Node node = (Node) obj;
            if (node.getName().equals(KEY_HOP_IP_PATH_FIELD_NAME)) {
                List<String> values = new ArrayList<String>();

                for (Object value : node.getChildren()) {
                    values.add((String) ((Node) value).getValue());
                }
                setHopIpPathFieldsName(values);
                return true;
            }
        }
    } catch (ConfigurationException e) {
        log.error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + getConfigFile());
    }
    return false;
}
项目:KernelHive    文件:EngineGraphConfiguration.java   
private Node createKernelsSubNode(final EngineGraphNodeDecorator node)
        throws ConfigurationException {
    final Node sourcesNode = new Node(NODE_KERNELS);
    for (final IKernelString s : node.getKernels()) {
        final Node sourceNode = new Node(KERNEL);
        final Node srcAttr = new Node(KERNEL_SRC_ATTRIBUTE, s.getKernel());
        final Node srcIdAttr = new Node(KERNEL_ID_ATTRIBUTE, s.getId());
        srcIdAttr.setAttribute(true);
        srcAttr.setAttribute(true);
        sourceNode.addAttribute(srcIdAttr);
        sourceNode.addAttribute(srcAttr);
        final Set<String> srcKeySet = s.getProperties().keySet();
        for (final String key : srcKeySet) {
            final Object val = s.getProperties().get(key);
            final Node propNode = new Node(KERNEL_PROPERTY_NODE);
            final Node keyNode = new Node(
                    KERNEL_PROPERTY_NODE_KEY_ATTRIBUTE);
            keyNode.setAttribute(true);
            keyNode.setValue(key);
            final Node valNode = new Node(
                    KERNEL_PROPERTY_NODE_VALUE_ATTRIBUTE);
            valNode.setAttribute(true);
            valNode.setValue(val);
            propNode.addAttribute(keyNode);
            propNode.addAttribute(valNode);
            sourceNode.addChild(propNode);
        }
        sourcesNode.addChild(sourceNode);
    }
    return sourcesNode;
}
项目:KernelHive    文件:GUIGraphConfiguration.java   
private Node createNodeForGUI(GUIGraphNodeDecorator node)
        throws ConfigurationException {
    Node configNode = createNode(node.getGraphNode());
    Node xAttr = new Node(NODE_X_ATTRIBUTE, node.getX());
    xAttr.setAttribute(true);
    Node yAttr = new Node(NODE_Y_ATTRIBUTE, node.getY());
    yAttr.setAttribute(true);
    configNode.addAttribute(xAttr);
    configNode.addAttribute(yAttr);
    return configNode;
}
项目:KernelHive    文件:GUIGraphConfiguration.java   
private Node createSourceFilesSubNode(GUIGraphNodeDecorator node, File file)
        throws ConfigurationException {
    Node sourcesNode = new Node(NODE_SOURCE_FILES);
    for (IKernelFile f : node.getSourceFiles()) {
        Node sourceNode = new Node(SOURCE_FILE);
        Node srcAttr = new Node(
                SOURCE_FILE_SRC_ATTRIBUTE,
                (new File(FileUtils.translateAbsoluteToRelativePath(
                        file.getParentFile().getAbsolutePath(), f.getFile().getAbsolutePath()))));
        Node srcIdAttr = new Node(SOURCE_FILE_ID_ATTRIBUTE, f.getId());
        srcIdAttr.setAttribute(true);
        srcAttr.setAttribute(true);
        sourceNode.addAttribute(srcIdAttr);
        sourceNode.addAttribute(srcAttr);
        Set<String> srcKeySet = f.getProperties().keySet();
        for (String key : srcKeySet) {
            Object val = f.getProperties().get(key);
            Node propNode = new Node(SOURCE_FILE_PROPERTY_NODE);
            Node keyNode = new Node(SOURCE_FILE_PROPERTY_NODE_KEY_ATTRIBUTE);
            keyNode.setAttribute(true);
            keyNode.setValue(key);
            Node valNode = new Node(
                    SOURCE_FILE_PROPERTY_NODE_VALUE_ATTRIBUTE);
            valNode.setAttribute(true);
            valNode.setValue(val);
            propNode.addAttribute(keyNode);
            propNode.addAttribute(valNode);
            sourceNode.addChild(propNode);
        }
        sourcesNode.addChild(sourceNode);
    }
    return sourcesNode;
}
项目:KernelHive    文件:AbstractGraphConfiguration.java   
protected Node createChildrenSubNode(final IGraphNode node)
        throws ConfigurationException {
    final Node childrenNode = new Node(FIRST_CHILDREN_NODE);
    for (final IGraphNode wfNode : node.getChildrenNodes()) {
        if (wfNode.getPreviousNodes().size() == 0) {
            final Node childNode = new Node(CHILD_NODE);
            final Node childIdAttr = new Node(CHILD_NODE_ID_ATTRIBUTE,
                    wfNode.getNodeId());
            childIdAttr.setAttribute(true);
            childNode.addAttribute(childIdAttr);
            childrenNode.addChild(childNode);
        }
    }
    return childrenNode;
}
项目:KernelHive    文件:AbstractGraphConfiguration.java   
protected Node createGraphNode(final IGraphNode node)
        throws ConfigurationException {
    try {
        final Node configNode = createNode(node);
        final Node sendToNode = createSendToSubNode(node);
        final Node childrenNode = createChildrenSubNode(node);
        final Node propertiesNode = createPropertiesSubNode(node);
        configNode.addChild(sendToNode);
        configNode.addChild(childrenNode);
        configNode.addChild(propertiesNode);
        return configNode;
    } catch (final NullPointerException e) {
        throw new ConfigurationException(e);
    }
}
项目:KernelHive    文件:AbstractGraphConfiguration.java   
protected Node createSendToSubNode(final IGraphNode node)
        throws ConfigurationException {
    final Node sendToNode = new Node(SEND_TO_NODE);
    for (final IGraphNode wfNode : node.getFollowingNodes()) {
        final Node followingNode = new Node(FOLLOWING_NODE);
        final Node followingIdAttr = new Node(FOLLOWING_NODE_ID_ATTRIBUTE,
                wfNode.getNodeId());
        followingIdAttr.setAttribute(true);
        followingNode.addAttribute(followingIdAttr);
        sendToNode.addChild(followingNode);
    }
    return sendToNode;
}
项目:KernelHive    文件:AbstractGraphConfiguration.java   
@Override
public void setProjectName(final String name) throws ConfigurationException {
    final List<ConfigurationNode> attributes = config.getRoot()
            .getAttributes(ROOT_NODE_NAME_ATTRIBUTE);
    if (attributes.size() > 0) {
        attributes.get(0).setValue(name);
    } else {
        final Node attr = new Node(ROOT_NODE_NAME_ATTRIBUTE);
        attr.setAttribute(true);
        attr.setValue(name);
        config.getRoot().addAttribute(attr);
    }
}
项目:openNaEF    文件:NmsCoreCommonConfiguration.java   
@Override
protected void reloadConfigurationInner() throws IOException {
    try {
        XMLConfiguration config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());

        log.debug("loading config:" + getConfigName());

        for (Object obj : config.getRootNode().getChildren()) {
            Node node = (Node) obj;

            if (node.getName().equals(KEY_DISPATCHER_IP_ADDRESS)) {
                List<String> values = new ArrayList<String>();

                for (Object value : node.getChildren()) {
                    values.add((String) ((Node) value).getValue());
                }
                setDispatcherIpAddress(values);
            } else {
                log.info("unknown node:" + node.getName());
            }

        }
    } catch (ConfigurationException e) {
        log.error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + getConfigFile());
    }

}
项目:qaf    文件:XMLScenarioFactory.java   
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 });
        }
    }
}
项目:qaf    文件:XMLScenarioFactory.java   
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;
}
项目:qaf    文件:XMLScenarioFactory.java   
private String getAttribute(Node node, String attrName, String defValue) {
    List<?> attribute = node.getAttributes(attrName);
    if (attribute.size() > 0) {
        return (String) ((Node) attribute.get(0)).getValue();
    }

    if (null == defValue) {
        throw new RuntimeException("Missing attribute " + attrName + " in " + node.getName() + " xml element");
    }
    return defValue;

}
项目:KernelHive    文件:EngineGraphConfiguration.java   
private Node createNodeForEngine(final EngineGraphNodeDecorator node)
        throws ConfigurationException {
    final Node configNode = createNode(node.getGraphNode());
    return configNode;
}
项目:James    文件:FetchMail.java   
/**
 * Method configure parses and validates the Configuration data and creates
 * a new <code>ParsedConfiguration</code>, an <code>Account</code> for each
 * configured static account and a
 * <code>ParsedDynamicAccountParameters</code> for each dynamic account.
 * 
 * @see org.apache.james.lifecycle.api.Configurable#configure(HierarchicalConfiguration)
 */
@SuppressWarnings("unchecked")
public void configure(HierarchicalConfiguration configuration) throws ConfigurationException {
    // Set any Session parameters passed in the Configuration
    setSessionParameters(configuration);

    // Create the ParsedConfiguration used in the delegation chain
    ParsedConfiguration parsedConfiguration = new ParsedConfiguration(configuration, logger, getLocalUsers(), getDNSService(), getDomainList(), getMailQueue());

    setParsedConfiguration(parsedConfiguration);

    // Setup the Accounts
    List<HierarchicalConfiguration> allAccounts = configuration.configurationsAt("accounts");
    if (allAccounts.size() < 1)
        throw new ConfigurationException("Missing <accounts> section.");
    if (allAccounts.size() > 1)
        throw new ConfigurationException("Too many <accounts> sections, there must be exactly one");
    HierarchicalConfiguration accounts = allAccounts.get(0);

    if (accounts.getKeys().hasNext() == false)
        throw new ConfigurationException("Missing <account> section.");

    List<Node> accountsChildren = accounts.getRoot().getChildren();
    int i = 0;

    // Create an Account for every configured account
    for (Node accountsChild : accountsChildren) {

        String accountsChildName = accountsChild.getName();

        List<HierarchicalConfiguration> accountsChildConfig = accounts.configurationsAt(accountsChildName);
        HierarchicalConfiguration conf = accountsChildConfig.get(i);

        if ("alllocal".equals(accountsChildName)) {
            // <allLocal> is dynamic, save the parameters for accounts to
            // be created when the task is triggered
            getParsedDynamicAccountParameters().add(new ParsedDynamicAccountParameters(i, conf));
            continue;
        }

        if ("account".equals(accountsChildName)) {
            // Create an Account for the named user and
            // add it to the list of static accounts
            getStaticAccounts().add(new Account(i, parsedConfiguration, conf.getString("[@user]"), conf.getString("[@password]"), conf.getString("[@recipient]"), conf.getBoolean("[@ignorercpt-header]"), conf.getString("[@customrcpt-header]", ""), getSession()));
            continue;
        }

        throw new ConfigurationException("Illegal token: <" + accountsChildName + "> in <accounts>");
    }
    i++;
}