Example usage for org.dom4j Node getText

List of usage examples for org.dom4j Node getText

Introduction

In this page you can find the example usage for org.dom4j Node getText.

Prototype

String getText();

Source Link

Document

Returns the text of this node.

Usage

From source file:darks.orm.core.config.sqlmap.DMLConfigReader.java

License:Apache License

private void parseSqlTag(AbstractTag parent, Element el, String namesp) throws Exception {
    AbstractTag prevTag = null;//ww w .j a  v a2s . c o m
    List<Node> list = el.content();
    Iterator<Node> it = list.iterator();
    while (it.hasNext()) {
        Node node = it.next();
        switch (node.getNodeType()) {
        case Node.ELEMENT_NODE:
            Element childEl = (Element) node;
            prevTag = parseElementTag(parent, node, childEl, namesp, prevTag);
            break;
        case Node.CDATA_SECTION_NODE:
        case Node.TEXT_NODE:
            String text = node.getText().replaceAll("\n|\t", " ").trim();
            if (!"".equals(text)) {
                TextTag tag = new TextTag(text, prevTag);
                parent.addChild(tag);
                prevTag = tag;
            }
            break;
        }
    }
}

From source file:data.BookshareWS.java

@Override
public void parse(String tekst) throws Exception {
    try {// w  w w.j  av a2 s . co  m
        //List<Book> lista=new ArrayList<>();
        Document document = DocumentHelper.parseText(tekst);

        List list = document.selectNodes("//result");
        //System.out.println("Velicina liste "+list.size());
        if (list == null || list.size() == 0) {
            System.out.println("Lista je null");
            kraj = true;
        } else {
            System.out.println("Trenutni broj strana " + trenutnaStrana);
            for (int i = 0; i < list.size(); i++) {
                Book b = new Book();
                b.setUri(URIGenerator.generateUri(b));
                Node node = (Node) list.get(i);
                b.setTitle(node.selectSingleNode("title").getText());

                Node isbn = node.selectSingleNode("isbn13");
                if (isbn != null) {
                    b.setIsbn(isbn.getText());
                }
                List autori = node.selectNodes("author");

                for (int j = 0; j < autori.size(); j++) {
                    Person p = new Person();
                    p.setUri(URIGenerator.generateUri(p));
                    p.setName(((Node) autori.get(j)).getText());
                    b.getAuthors().add(p);
                }

                Organization o = new Organization();
                o.setUri(URIGenerator.generateUri(o));
                Node publisher = node.selectSingleNode("publisher");
                if (publisher != null) {
                    o.setName(publisher.getText());
                }
                b.setPublisher(o);

                Node description = node.selectSingleNode("brief-synopsis");
                if (description != null) {
                    b.setDescription(description.getText());
                }
                lista.add(b);

            }
            trenutnaStrana++;
            //kraj=true;
        }

    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
}

From source file:datasource.Settings.java

License:Open Source License

public String get(String Program, String Module, String Option) {
    String resultStr = "";
    String XPath = "//program[@name='" + Program + "']/module[@name='" + Module + "']/option[@name='" + Option
            + "']";

    Node n = doc.selectSingleNode(XPath);
    if (n != null) {
        resultStr = n.getText();
    }/*from ww  w .  j  a  v a  2s.co  m*/
    return resultStr;
}

From source file:datasource.Settings.java

License:Open Source License

public void set(String Program, String Module, String Setting, String Value) {
    Node n = getSetting(Program, Module, Setting);
    if (!Value.equals(n.getText())) {
        shallSave = true;//from ww w  . ja v a2  s .com
        n.setText(Value);
    }
}

From source file:datasource.Settings.java

License:Open Source License

public void set(String Program, String Module, String Setting, boolean Value) {
    Node n = getSetting(Program, Module, Setting);
    boolean previousValue = (n.getText().equals("true"));

    if (Value != previousValue) {
        shallSave = true;/* ww  w.  java  2 s. c  om*/

        if (Value) {
            n.setText("true");
        } else {
            n.setText("false");
        }
    }
}

From source file:de.decoit.siemgui.service.converter.NeustaCorrelationRuleConverter.java

License:Open Source License

/**
 * Parse the rule description from a rule XML document.
 * The XML document must contain the XML structure that defines a correlation rule.
 *
 * @param xml Rule XML document//from  ww w.jav a 2 s  .c o m
 * @return Description string
 */
private String parseRuleDescriptionFromXml(Document xml) {
    Node node = xml.selectSingleNode("//rule/description");

    String description = null;
    if (node != null) {
        description = node.getText();
    }

    return description;
}

From source file:de.decoit.siemgui.service.converter.NeustaCorrelationRuleConverter.java

License:Open Source License

/**
 * Parse the rule condition from a rule XML document.
 * The XML document must contain the XML structure that defines a correlation rule.
 *
 * @param xml Rule XML document// w  ww.jav  a 2s  . c o m
 * @return Rule condition object
 */
private CorrelationRuleCondition parseRuleConditionFromXml(Document xml) {
    Node node = xml.selectSingleNode("//rule/condition/query");

    String query = null;
    if (node != null) {
        query = node.getText();
    }

    CorrelationRuleCondition cond = new CorrelationRuleCondition();
    cond.setQuery(query);

    return cond;
}

From source file:de.decoit.siemgui.service.converter.NeustaCorrelationRuleConverter.java

License:Open Source License

/**
 * Parse the rule action from a rule XML document.
 * The XML document must contain the XML structure that defines a correlation rule.
 *
 * @param xml Rule XML document//from www .j  a v  a  2 s .co  m
 * @return Rule condition object
 */
private CorrelationRuleAction parseRuleActionFromXml(Document xml) {
    Node incNameNode = xml.selectSingleNode("//rule/action/incidentname");

    String incName = null;
    if (incNameNode != null) {
        incName = incNameNode.getText();
    }

    Node incRiskNode = xml.selectSingleNode("//rule/action/risk");
    String incRisk = null;
    if (incRiskNode != null) {
        incRisk = incRiskNode.getText();
    }

    List<Node> queryNodeList = xml.selectNodes("//rule/action/query");
    List<String> queryList = queryNodeList.stream().map(Node::getText).collect(Collectors.toList());

    List<Node> updateQueryNodeList = xml.selectNodes("//rule/action/updatequery");
    List<String> updateQueryList = updateQueryNodeList.stream().map(Node::getText).collect(Collectors.toList());

    List<Node> recNodeList = xml.selectNodes("//rule/action/recommendation");
    List<String> recList = recNodeList.stream().map(Node::getText).collect(Collectors.toList());

    List<Node> explNodeList = xml.selectNodes("//rule/action/explanation");
    List<String> explList = explNodeList.stream().map(Node::getText).collect(Collectors.toList());

    CorrelationRuleAction cra = new CorrelationRuleAction();

    cra.setIncidentName(incName);
    cra.setRisk(incRisk);
    cra.setQuery(queryList);
    cra.setUpdateQuery(updateQueryList);
    cra.setRecommendation(recList);
    cra.setExplanation(explList);

    return cra;
}

From source file:de.drippinger.serviceExtractor.metaModel.NdfDeflector.java

License:Apache License

DataType deflectParser(Document document, File ndfFile) {
    Node node = document.selectSingleNode("//value[@name='node_type']");
    if (node == null) {
        log.warn("NodeType is null for file: {}", ndfFile.getAbsolutePath());
        return DataType.NONE;
    }/*from   ww  w  .  j a  v a2 s .  c om*/
    switch (node.getText()) {
    case "interface":
        return DataType.NONE;
    case "record":
        return DataType.DOCUMENT;
    case "flow":
        return DataType.SERVICE;
    }

    log.warn("Unknown node type: {}", node.getText());
    return DataType.NONE;
}

From source file:de.fct.companian.analyze.mvn.helper.PomHelper.java

License:Apache License

public PomInfo extractPomInfo() throws DocumentException {
    Node groupIdNode = this.selectSingleNode("/mvn:project/mvn:groupId");
    Node artifactIdNode = this.selectSingleNode("/mvn:project/mvn:artifactId");
    Node versionNode = this.selectSingleNode("/mvn:project/mvn:version");

    PomInfo pomInfo = null;/*w  ww.j  av  a 2  s .  com*/
    if (groupIdNode != null && artifactIdNode != null && versionNode != null) {
        String groupId = groupIdNode.getText();
        String artifactId = artifactIdNode.getText();
        String version = versionNode.getText();
        if (groupId != null && artifactId != null && version != null) {
            String jarName = this.pomFile.getName().replace(".pom", ".jar");
            pomInfo = new PomInfo(jarName, groupId, artifactId, version);
        }
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("extractPomInfo() no PomInfo found - perhaps a parent POM exists");
        }
        if (artifactIdNode != null) {
            String artifactId = artifactIdNode.getText();
            if (logger.isDebugEnabled()) {
                logger.debug("extractPomInfo() found artifactId " + artifactId + " and look for parent POM");
            }
            pomInfo = this.extractParentPom();
            if (pomInfo != null) {
                pomInfo.setArtifactId(artifactId);
            }
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("extractPomInfo() no artifactId found - no use to look for parent POM");
            }
        }
    }

    if (logger.isInfoEnabled()) {
        logger.info("extractPomInfo() extracted " + pomInfo + " from " + this.pomFile.getName());
    }
    return pomInfo;
}