Example usage for org.dom4j Node selectNodes

List of usage examples for org.dom4j Node selectNodes

Introduction

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

Prototype

List<Node> selectNodes(String xpathExpression);

Source Link

Document

selectNodes evaluates an XPath expression and returns the result as a List of Node instances or String instances depending on the XPath expression.

Usage

From source file:io.mashin.oep.hpdl.XMLReadUtils.java

License:Open Source License

public static PropertyElementCollection textCollectionFrom(Node element, String xpath,
        PropertyElementCollection pec) {
    @SuppressWarnings("unchecked")
    List<Node> nodes = element.selectNodes(xpath);
    if (nodes != null) {
        for (Node node : nodes) {
            TextPropertyElement tpe = (TextPropertyElement) pec.createAndAdd();
            String value = node.getText();
            if (value != null) {
                tpe.setStringValue(value);
            }// ww w  .j  a  v a  2 s.co  m
        }
    }
    return pec;
}

From source file:io.mashin.oep.hpdl.XMLReadUtils.java

License:Open Source License

public static void initFSDeleteCollectionFrom(PropertyElementCollection pec, Node node, String xpath) {
    @SuppressWarnings("unchecked")
    List<Node> subNodes = node.selectNodes(xpath);
    if (subNodes != null) {
        for (Node subNode : subNodes) {
            FSActionNode.FSOperationDelete delete = (FSActionNode.FSOperationDelete) pec.createAndAdd();
            initTextPropertyFrom(delete.path, subNode, "@path");
        }/*from ww  w.ja v  a2s. c  o m*/
    }
}

From source file:io.mashin.oep.hpdl.XMLReadUtils.java

License:Open Source License

public static void initFSMkdirCollectionFrom(PropertyElementCollection pec, Node node, String xpath) {
    @SuppressWarnings("unchecked")
    List<Node> subNodes = node.selectNodes(xpath);
    if (subNodes != null) {
        for (Node subNode : subNodes) {
            FSActionNode.FSOperationMkdir mkdir = (FSActionNode.FSOperationMkdir) pec.createAndAdd();
            initTextPropertyFrom(mkdir.path, subNode, "@path");
        }//w  w w .j a  v  a2s  .  com
    }
}

From source file:io.mashin.oep.hpdl.XMLReadUtils.java

License:Open Source License

public static void initFSMoveCollectionFrom(PropertyElementCollection pec, Node node, String xpath) {
    @SuppressWarnings("unchecked")
    List<Node> subNodes = node.selectNodes(xpath);
    if (subNodes != null) {
        for (Node subNode : subNodes) {
            FSActionNode.FSOperationMove move = (FSActionNode.FSOperationMove) pec.createAndAdd();
            initTextPropertyFrom(move.source, subNode, "@source");
            initTextPropertyFrom(move.target, subNode, "@target");
        }/* ww  w.ja va2 s .  c  o  m*/
    }
}

From source file:io.mashin.oep.hpdl.XMLReadUtils.java

License:Open Source License

public static void initFSChmodCollectionFrom(PropertyElementCollection pec, Node node, String xpath) {
    @SuppressWarnings("unchecked")
    List<Node> subNodes = node.selectNodes(xpath);
    if (subNodes != null) {
        for (Node subNode : subNodes) {
            FSActionNode.FSOperationChmod chmod = (FSActionNode.FSOperationChmod) pec.createAndAdd();
            initCheckPropertyFrom(chmod.recursive, subNode, "./recursive");
            initTextPropertyFrom(chmod.path, subNode, "@path");
            initTextPropertyFrom(chmod.permissions, subNode, "@permissions");
            initTextPropertyFrom(chmod.dirFiles, subNode, "@dir-files");
        }//from  w w  w  .  ja va 2s.  c  o  m
    }
}

From source file:io.mashin.oep.hpdl.XMLReadUtils.java

License:Open Source License

public static void initFSTouchzCollectionFrom(PropertyElementCollection pec, Node node, String xpath) {
    @SuppressWarnings("unchecked")
    List<Node> subNodes = node.selectNodes(xpath);
    if (subNodes != null) {
        for (Node subNode : subNodes) {
            FSActionNode.FSOperationTouchz touchz = (FSActionNode.FSOperationTouchz) pec.createAndAdd();
            initTextPropertyFrom(touchz.path, subNode, "@path");
        }/* w  w w .  j a v  a  2  s. c  o m*/
    }
}

From source file:io.mashin.oep.hpdl.XMLReadUtils.java

License:Open Source License

public static void initFSChgrpCollectionFrom(PropertyElementCollection pec, Node node, String xpath) {
    @SuppressWarnings("unchecked")
    List<Node> subNodes = node.selectNodes(xpath);
    if (subNodes != null) {
        for (Node subNode : subNodes) {
            FSActionNode.FSOperationChgrp chgrp = (FSActionNode.FSOperationChgrp) pec.createAndAdd();
            initCheckPropertyFrom(chgrp.recursive, subNode, "./recursive");
            initTextPropertyFrom(chgrp.path, subNode, "@path");
            initTextPropertyFrom(chgrp.group, subNode, "@group");
            initTextPropertyFrom(chgrp.dirFiles, subNode, "@dir-files");
        }//from www.j ava  2  s .c  om
    }
}

From source file:it.eng.qbe.datasource.configuration.dao.fileimpl.CalculatedFieldsDAOFileImpl.java

License:Mozilla Public License

private List<ModelCalculatedField.Slot> loadSlots(Node calculatedFieldNode) {

    List<ModelCalculatedField.Slot> slots = new ArrayList<ModelCalculatedField.Slot>();

    Node slotBlock = calculatedFieldNode.selectSingleNode(SLOTS_TAG);
    if (slotBlock != null) {
        List<Node> slotNodes = slotBlock.selectNodes(SLOT_TAG);

        for (Node slotNode : slotNodes) {
            ModelCalculatedField.Slot slot = loadSlot(slotNode);
            slots.add(slot);//from  ww  w.  j  a  v a2  s .  c o m
        }
    }

    return slots;
}

From source file:it.eng.qbe.datasource.configuration.dao.fileimpl.CalculatedFieldsDAOFileImpl.java

License:Mozilla Public License

private ModelCalculatedField.Slot loadSlot(Node slotNode) {
    ModelCalculatedField.Slot slot;//from   www  .  java2 s .c o  m

    String slotValue = slotNode.valueOf("@value");
    slot = new ModelCalculatedField.Slot(slotValue);

    List<Node> mappedValues = slotNode.selectNodes(VALUESET_TAG);
    for (Node mappedValuesNode : mappedValues) {
        ModelCalculatedField.Slot.IMappedValuesDescriptor descriptor = loadDescriptor(mappedValuesNode);
        slot.addMappedValuesDescriptors(descriptor);
    }

    return slot;
}

From source file:it.eng.qbe.datasource.configuration.dao.fileimpl.CalculatedFieldsDAOFileImpl.java

License:Mozilla Public License

private ModelCalculatedField.Slot.MappedValuesPunctualDescriptor loadPunctualDescriptor(Node mappedValuesNode) {
    ModelCalculatedField.Slot.MappedValuesPunctualDescriptor punctualDescriptor;

    punctualDescriptor = new ModelCalculatedField.Slot.MappedValuesPunctualDescriptor();
    List<Node> punctualValueNodes = mappedValuesNode.selectNodes(VALUE_TAG);
    for (Node punctualValueNode : punctualValueNodes) {
        String punctualValue = punctualValueNode.valueOf("@value");
        punctualDescriptor.addValue(punctualValue);
    }/*from  w w w .  ja  v  a2  s .com*/

    return punctualDescriptor;
}