Package org.dom4j

Examples of org.dom4j.Node


   *
   * @param element
   * @return
   */
  public static String getElementPoint(Element element) {
    Node position = element.selectSingleNode("position");
    return ((Element)position).attributeValue("point");
  }
View Full Code Here


     * @throws Exception
     */
    public void assertXPathEquals( String xpath, String value, Node node )
        throws Exception
    {
        Node n = createXPath( xpath ).selectSingleNode( node );
       
        if ( n == null )
            fail("Couldn't select a valid node.");
       
        String value2 = n.getText().trim();
        assertEquals( value, value2 );
    }
View Full Code Here

            SAXReader reader = new SAXReader();
            org.dom4j.Document document = reader.read(inputFile);
            List nodes = document.selectNodes("/filelist/*");
            parentPath = inputFile.getParent();
            for (Iterator iter = nodes.iterator(); iter.hasNext();) {
                Node domNode = (Node) iter.next();
                String nodeName = domNode.getName();
                if (FILESET_NODE.equals(nodeName)) {
                    // found a fileset node
                    fileList.addAll(getFileNodesFromFileset(domNode, parentPath));
                } else if (FILE_NODE.equals(nodeName)) {
                    fileList.add(getPdfFileFromNode(domNode, null));
View Full Code Here

     * @return a list of PdfFile objects
     * @throws Exception
     */
    private List getFileNodesFromFileset(Node fileSetNode, String parentDir) throws Exception {
        String parentPath = null;
        Node useCurrentDir = fileSetNode.selectSingleNode("@usecurrentdir");
        Node dir = fileSetNode.selectSingleNode("@dir");
        if (dir != null && dir.getText().trim().length() > 0) {
            parentPath = dir.getText();
        } else {
            if (useCurrentDir != null && Boolean.valueOf(useCurrentDir.getText()).booleanValue()) {
                parentPath = parentDir;
            }
        }
View Full Code Here

     * @return list of PdfFile
     */
    private List getPdfFileListFromNode(List fileList, String parentPath) throws Exception {
        List retVal = new ArrayList();
        for (int i = 0; fileList != null && i < fileList.size(); i++) {
            Node pdfNode = (Node) fileList.get(i);
            retVal.add(getPdfFileFromNode(pdfNode, parentPath));
        }
        return retVal;
    }
View Full Code Here

    private PdfFile getPdfFileFromNode(Node pdfNode, String parentPath) throws Exception {
        PdfFile retVal = null;
        String pwd = null;
        String fileName = null;
        // get filename
        Node fileNode = pdfNode.selectSingleNode("@value");
        if (fileNode != null) {
            fileName = fileNode.getText().trim();
        } else {
            throw new ConcatException(ConcatException.ERR_READING_CSV_OR_XML, new String[] { "Empty file name." });
        }
        // get pwd value
        Node pwdNode = pdfNode.selectSingleNode("@password");
        if (pwdNode != null) {
            pwd = pwdNode.getText();
        }
        if (parentPath != null && parentPath.length() > 0) {
            retVal = new PdfFile(new File(parentPath, fileName), pwd);
        } else {
            retVal = new PdfFile(fileName, pwd);
View Full Code Here

    if(inputFile!=null){
      try{
        LOG.debug("Parsing xml transitions file "+inputFile.getAbsolutePath());   
        SAXReader reader = new SAXReader();
        Document document = reader.read(inputFile);
        Node rootNode = document.selectSingleNode("/transitions");
        if(rootNode != null){
          Node defType = rootNode.selectSingleNode("@defaulttype");
          Node defTransDur = rootNode.selectSingleNode("@defaulttduration");
          Node defDur = rootNode.selectSingleNode("@defaultduration");
          if(defType != null && defTransDur != null && defDur != null){
            if(transitions.getDefaultTransition() != null){
              throw new SlideShowException(SlideShowException.ERR_DEFAULT_TRANSITION_ALREADY_SET);
            }else{
              transitions.setDefaultTransition(new Transition(Transition.EVERY_PAGE, new Integer(defTransDur.getText().trim()).intValue(), defType.getText().trim(), new Integer(defDur.getText().trim()).intValue()));
            }
          }
          List transitionsList = document.selectNodes("/transitions/transition");
          for (int i = 0; transitionsList != null && i < transitionsList.size(); i++) {
            Node transitionNode = (Node) transitionsList.get(i);
            Node type = transitionNode.selectSingleNode("@type");
            Node transDuration = transitionNode.selectSingleNode("@tduration");
            Node duration = transitionNode.selectSingleNode("@duration");
            Node page = transitionNode.selectSingleNode("@pagenumber");
            if(type != null && transDuration != null && duration != null && page != null){             
              transitions.addTransition(new Transition(new Integer(page.getText().trim()).intValue(), new Integer(transDuration.getText().trim()).intValue(), type.getText().trim(), new Integer(duration.getText().trim()).intValue()));             
            }else{
              throw new SlideShowException(SlideShowException.ERR_READING_TRANSITION, new String[] {i+""});
            }
          }
        }else{
View Full Code Here

    }
   
    private void getDescendants(Branch node, List result) {
        List content = node.content();
        for (Iterator iter = content.iterator(); iter.hasNext();) {
            Node subnode = (Node) iter.next();
            if(subnode instanceof Element) {
                result.add(subnode);
                getDescendants(subnode, result);
            }
        }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public void loadJobNode(Node arg0) throws LoadJobException {
        try {
            Node fileDestination = (Node) arg0.selectSingleNode("destination/@value");
            if (fileDestination != null) {
                destinationTextField.setText(fileDestination.getText());
            }

            Node fileOverwrite = (Node) arg0.selectSingleNode("overwrite/@value");
            if (fileOverwrite != null) {
                overwriteCheckbox.setSelected(TRUE.equals(fileOverwrite.getText()));
            }

            Node mergeType = (Node) arg0.selectSingleNode("merge_type/@value");
            if (mergeType != null) {
                mergeTypeCheck.setSelected(TRUE.equals(mergeType.getText()));
            }

            List fileList = arg0.selectNodes("filelist/file");
            for (int i = 0; fileList != null && i < fileList.size(); i++) {
                Node fileNode = (Node) fileList.get(i);
                if (fileNode != null) {
                    Node fileName = (Node) fileNode.selectSingleNode("@name");
                    if (fileName != null && fileName.getText().length() > 0) {
                        Node pageSelection = (Node) fileNode.selectSingleNode("@pageselection");
                        Node filePwd = (Node) fileNode.selectSingleNode("@password");
                        selectionPanel.getLoader().addFile(new File(fileName.getText()),
                                (filePwd != null) ? filePwd.getText() : null,
                                (pageSelection != null) ? pageSelection.getText() : null);
                    }
                }
            }

            Node fileCompressed = (Node) arg0.selectSingleNode("compressed/@value");
            if (fileCompressed != null && TRUE.equals(fileCompressed.getText())) {
                outputCompressedCheck.doClick();
            }

            Node pdfVersion = (Node) arg0.selectSingleNode("pdfversion/@value");
            if (pdfVersion != null) {
                for (int i = 0; i < versionCombo.getItemCount(); i++) {
                    if (((StringItem) versionCombo.getItemAt(i)).getId().equals(pdfVersion.getText())) {
                        versionCombo.setSelectedIndex(i);
                        break;
                    }
                }
            }
View Full Code Here

      for (int i = 0; i < size; i++) {
        Object object = list.get(i);

        if (object instanceof Node) {
          Node node = (Node) object;
          Object expression = getCompareValue(node);
          sortValues.put(node, expression);
        }
      }
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.