Package org.dom4j

Examples of org.dom4j.Node


        throw new PluginException(missingMsg);
    }

    private static  String findMessageText(List<Document> messageCollectionList, String xpath, String missingMsg) {
        for (Document document : messageCollectionList) {
            Node node = document.selectSingleNode(xpath);
            if (node != null) {
                return node.getText().trim();
            }
        }
        return missingMsg;
    }
View Full Code Here


        }
        return missingMsg;
    }

    private static String getChildText(Node node, String childName) throws PluginException {
        Node child = node.selectSingleNode(childName);
        if (child == null) {
            throw new PluginException("Could not find child \"" + childName + "\" for node");
        }
        return child.getText();
    }
View Full Code Here

        try {
            if (fName.endsWith(".gz")) {
                in = new GZIPInputStream(in);
            }
            doc = reader.read(in);
            Node summary = doc.selectSingleNode("/BugCollection/FindBugsSummary");
            double cpu_seconds = Double.parseDouble(summary.valueOf("@cpu_seconds"));
            putStats("cpu_seconds", i, (int) (cpu_seconds * 1000));
            double gc_seconds = Double.parseDouble(summary.valueOf("@gc_seconds"));
            putStats("gc_seconds", i, (int) (gc_seconds * 1000));

            List<Node> profileNodes = XMLUtil.selectNodes(doc, "/BugCollection/FindBugsSummary/FindBugsProfile/ClassProfile");
            for(Node n : profileNodes) {
                String name = n.valueOf("@name");
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Object get(Object owner) throws HibernateException {
      Element ownerElement = (Element) owner;
      Node attribute = ownerElement.attribute(attributeName);
      return attribute==null ? null :
        super.propertyType.fromXMLNode(attribute, super.factory);
   
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Object get(Object owner) throws HibernateException {
      Element ownerElement = (Element) owner;
      Node element = ownerElement.element(elementName);
      return element==null ?
          null : super.propertyType.fromXMLNode(element, super.factory);
   
View Full Code Here

            Map uniqueLinks = new HashMap();
            Iterator linkIter = xpathResults.iterator();
            while (linkIter.hasNext())
            {
                Node node = (Node) linkIter.next();
                String href = node.getText();
                uniqueLinks.put(href, href);
            }

            Iterator iter = uniqueLinks.keySet().iterator();
            while (iter.hasNext())
View Full Code Here

    if (configuration!=null) {
      try {
        Element actionElement = DocumentHelper.parseText( "<action>"+configuration+"</action>" ).getRootElement();
        Iterator iter = new ArrayList( actionElement.content() ).iterator();
        while (iter.hasNext()) {
          Node node = (Node)iter.next();
          node.setParent(null);
          element.add( node );
        }
      } catch (DocumentException e) {
        log.error("couldn't create dom-tree for action configuration '"+configuration+"'", e);
      }
View Full Code Here

   */
  private static transient Logger log;
 
  private ExceptionMessageProvider() throws Exception {
    Document document = getConfiguration();   
    Node classNode = document.selectSingleNode("/exception-message-provider/source/@class");
    if(classNode != null){
      Class fileSourceClass = Class.forName(classNode.getText());
      Node sourceNode = document.selectSingleNode("/exception-message-provider/source");
      Constructor constructor = fileSourceClass.getConstructor(new Class[]{Node.class});
      source = (InquirableMessagesSource) constructor.newInstance(new Object[]{sourceNode});
    }
    else{
      throw new Exception("Unable to find MessagesSource class name");
View Full Code Here

  private static final long serialVersionUID = -5549563695772599153L;
  private transient Document document;

  public XmlMessagesSource(Node node) throws Exception {
    super(node);
    Node arg1 = node.selectSingleNode("xmlsource/@filename");
    if (arg1 != null) {
      document = getDocument(arg1.getText());
    } else {
      throw new DOMException(DOMException.NOT_FOUND_ERR, "Error reading configuration node, node is null.");
    }
  }
View Full Code Here

  public String getExceptionMessage(Object exceptionTypeKey, int exceptionErrorCode) throws Exception {
    StringBuffer sb = new StringBuffer();
    sb.append(getTypeDescription(exceptionTypeKey.toString()));
    sb.append(padString(Integer.toString(exceptionErrorCode), 3, '0', true));
    sb.append(" - ");
    Node node = document.selectSingleNode("/exception-types/type[@key=\"" + exceptionTypeKey.toString() + "\"]/exception[@errorcode=\""
        + exceptionErrorCode + "\"]/@message");
    if (node != null) {
      sb.append(node.getText());
    }
    return sb.toString();
  }
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.