Package org.jdom

Examples of org.jdom.JDOMException


    }
    else {
      xpath = followXPath(parent, target).toString();

      if (xpath == null) {
        throw new JDOMException("the target element is not a descendant of the parent element");
      }
    }
   
    return xpath;
  }
View Full Code Here


      Element parent = findTarget(root, target);
      if (parent != null) {
        xpath = computeXPath(root, parent, target);
      }
      else {
        throw new JDOMException("the target object is not in the tree (" + target + ")");
      }
    }
   
    return xpath;
  }
View Full Code Here

   */
  private static StringBuffer targetXPath(Element parent, Object child) throws JDOMException {
    StringBuffer xpath;
   
    if (parent == null || child == null) {
      throw new JDOMException("can't use null parent or child");
    }
   
    if (child instanceof Element) {
      xpath = new StringBuffer();
      xpath.append("/").append(((Element)child).getQualifiedName());
View Full Code Here

  private static StringBuffer computeXPathToNode(Element root, Element node) throws JDOMException {
    StringBuffer xpath = new StringBuffer();
    Element n = node;
   
    if (root == null || node == null) {
      throw new JDOMException("can't use null root or node");
    }
   
    while (n != null) {
      Element p = null;
      if (n.getParent() != null && n.getParent() instanceof Element)
View Full Code Here

        pathPartStart = pathPartEnd + 1;
        atRoot = false;
      }
    }
    else {
      throw new JDOMException("xpath is not absolute (must begin with '/')");
    }

    return rslt;
  }
View Full Code Here

      Object x = getElement(root, parentXpath);
      if (x instanceof Element) {
        rslt = (Element)x;
      }
      else {
        throw new JDOMException("parent element should be type Element, not " + x.getClass().getName());
      }
    }
   
    return rslt;
  }
View Full Code Here

      String numStr = pathPart.substring(lbracket+1, rbracket);
      try {
        rslt = Integer.parseInt(numStr);
      }
      catch (NumberFormatException e) {
        throw new JDOMException("invalid index in \"" + pathPart + "\"");
      }
    }
    else {
      throw new JDOMException("index must be the last part of \"" + pathPart + "\"");
    }

    return rslt - 1;
  }
View Full Code Here

   */
  private static List<Element> getNamedChildren(Element parent, String name) throws JDOMException {
    List<Element> children = new ArrayList<Element>();
   
    if (parent == null) {
      throw new JDOMException("can't use null parent");
    }
   
    Iterator<?> it = parent.getChildren().iterator();
    while (it.hasNext()) {
      Object child = it.next();
View Full Code Here

   */
  private static int computeTwinIndex(Element parent, Element child) throws JDOMException {
    int index = -1;

    if (parent == null) {
      throw new JDOMException("can't use null parent");
    }
   
    List<Element> identicalTwins = getNamedChildren(parent, child.getQualifiedName());

    if (identicalTwins.size() > 1) {
      for (int j = 0; index < 0 && j < identicalTwins.size(); ++j) {
        if (identicalTwins.get(j) == child) {
          // Add 1 to convert to 1-origin index used by
          // Xpath.

          index = j + 1;
        }
      }

      if (index < 0) {
        // ??? Something is wrong. We didn't find child
        // among its parent's children.

        throw new JDOMException("error in tree: node is not listed among its parent's children");
      }
    }
   
    return index;
  }
View Full Code Here

   
    if (index < 0) {
      // ??? Something is wrong. We didn't find child
      // among its parent's children.

      throw new JDOMException("error in tree: object is not listed among its parent's children");
    }

    return index;
  }
View Full Code Here

TOP

Related Classes of org.jdom.JDOMException

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.