Package org.dom4j

Examples of org.dom4j.Node


        List<Dependency> pomDependeciesList = new ArrayList<Dependency>();
        readDependenciesListFromXmlNode(pomDependeciesList, dependenciesNode);

        int pomDependenciesIndex = pomDependeciesList.size() - 1;
        for (int i = dependenciesNode.nodeCount() - 1; i >= 0; i--) {
            Node dependecyNode = (Node) dependenciesNode.node(i);
            if (Node.ELEMENT_NODE == dependecyNode.getNodeType()) {
                if (pomDependenciesIndex < 0) {
                    throw new Exception("Unsynchronized dependencies list with XML on index: " + i);
                }
                Dependency dependency = pomDependeciesList.get(pomDependenciesIndex);
                if (-1 == dependencies.indexOf(dependency)) {
                    dependecyNode.detach();
                    pomDependeciesList.remove(pomDependenciesIndex);
                }
                pomDependenciesIndex--;
            }
        }
View Full Code Here


            final Map<String, List<String>> filesToDeploy) {
       
        final List copyNodes = configurationXmlDocument.selectNodes("/deployer/copy");
        if (null != copyNodes) {
            for (int i = 0; i < copyNodes.size(); i++) {
                Node copyNode = (Node)copyNodes.get(i);
                String path = XmlUtils.getAttributeValue(copyNode, "path");
                if (!filesToDeploy.containsKey(path)) {
                    filesToDeploy.put(path, new ArrayList<String>());
                }
                final List targetPaths = copyNode.selectNodes("./target");
                if (null != targetPaths) {
                    for (int j = 0; j < targetPaths.size(); j++) {
                        Node targetPath = (Node)targetPaths.get(j);
                        filesToDeploy.get(path).add(targetPath.getText());
                    }
                }
            }
        }
    }
View Full Code Here

   
    public static void loadSettingsSection(final String xPathString, final Object parent,
            final DeployerSettings deployerSettings) throws JaxenException {
       
        XPath xpath = new Dom4jXPath(xPathString);
        Node settings = (Node)xpath.selectSingleNode(parent);
       
        if (null != settings) {
            deployerSettings.useIndex = XmlUtils.getChildNodeBooleanValue(settings,
                    XmlConstants.USE_INDEX, deployerSettings.useIndex);
        }
View Full Code Here

        List projectsNodes = configurationXmlDocument.selectNodes("/deployer/project");
        if (null != projectsNodes) {
            for (int i = 0; i < projectsNodes.size(); i++) {
                DeployerProject project = new DeployerProject(globalSettings);
                loadSettingsSection("./settings", projectsNodes.get(i), project.settings);
                Node projectNode = (Node)projectsNodes.get(i);
               
                project.path = XmlUtils.getAttributeValue(projectNode, "path");
                JavaUtils.checkDirectoryExists(project.path);
               
                List sources = projectNode.selectNodes("./sources");
                if (null != sources) {
                    for (int j = 0; j < sources.size(); j++) {
                        DeployerSourcesInfo sourcesInfo = new DeployerSourcesInfo();
                        Node sourcesNode = (Node)sources.get(j);
                        sourcesInfo.path = XmlUtils.getAttributeValue(sourcesNode, "path")
                        sourcesInfo.binariesFolder = XmlUtils.getAttributeValue(sourcesNode, "output");
                        loadDeploymentPaths(sourcesInfo, sourcesNode, true);
                        project.sources.add(sourcesInfo);
                    }
                }
               
                List resources = projectNode.selectNodes("./resources");
                if (null != resources) {
                    for (int j = 0; j < resources.size(); j++) {
                        DeployerResourceInfo resourceInfo = new DeployerResourceInfo();
                        Node resourceNode = (Node)resources.get(j);
                        resourceInfo.path = XmlUtils.getAttributeValue(resourceNode, "path");
                        File resourcePath = new File(FilenameUtils.concat(project.path, resourceInfo.path));
                        if (!resourcePath.exists()) {
                            throw new ApplicationException("Resource path \"" + resourceInfo.path + "\" doesn't exists in the project \""
                                    + project.path + "\" ");
View Full Code Here

    private static void loadDeploymentPaths(final DeployerResourceInfo resourceInfo,
            final Node parent, final boolean mustBeFile) throws ApplicationException {
        List deploymentPaths = parent.selectNodes("./target");
        if (null != deploymentPaths) {
            for (int k = 0; k < deploymentPaths.size(); k++) {
                Node deploymentPath = (Node)deploymentPaths.get(k);
                final String path = deploymentPath.getText();
                resourceInfo.deploymentPaths.add(path);
                if (mustBeFile) {
                    if (!JavaUtils.isFile(path)) {
                        throw new ApplicationException("Target path \"" + path + "\" for resorce should be a file");
                    }
View Full Code Here

    public static void loadPostProcessCommands(final Document configurationXmlDocument,
            List<DeployerCommandInfo> postProcessCallCommands) {
        List commands = configurationXmlDocument.selectNodes("/deployer/command");
        if (null != commands) {
            for (int i = 0; i < commands.size(); i++) {
                Node command = (Node)commands.get(i);
                DeployerCommandInfo commandInfo = new DeployerCommandInfo();
                commandInfo.onUpdatedPath = XmlUtils.getAttributeValue(command, "updated_path");
                commandInfo.commandLine = XmlUtils.getAttributeValue(command, "run");
                postProcessCallCommands.add(commandInfo);
            }
View Full Code Here

    public static void loadPostProcessCallUrls(final Document configurationXmlDocument,
            List<String> postProcessCallUrls) {
        List callUrls = configurationXmlDocument.selectNodes("/deployer/call_url");
        if (null != callUrls) {
            for (int i = 0; i < callUrls.size(); i++) {
                Node callUrl = (Node)callUrls.get(i);
                postProcessCallUrls.add(callUrl.getText().trim());
            }
        }
    }
View Full Code Here

                    prefix += "default:";
                }
                XPath xpath = new Dom4jXPath(prefix + childName);
                xpath.setNamespaceContext(new SimpleNamespaceContext(map));

                Node child = (Node) xpath.selectSingleNode(parent);
                if (null != child) {
                    if (null != child.getText()) {
                        result = child.getText().trim();
                    }
                }
            }
            catch (JaxenException e) {
                e.printStackTrace();
View Full Code Here

    }
   
    public String getAttributeValue(final int index, final String attributeName) {
        validateIndex(index);
       
        Node node = (Node)document.getRootElement().elements().get(index);
        return XmlUtils.getAttributeValue(node, attributeName);
    }
View Full Code Here

    }
   
    public void delete(final int index) {
        validateIndex(index);
       
        Node node = (Node)document.getRootElement().elements().get(index);
        node.detach();
    }
View Full Code Here

TOP

Related Classes of org.dom4j.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.