Package org.jdom

Examples of org.jdom.Element


    try {
      XmlDocumentReader xmlReader = new XmlDocumentReader();
      inDoc =
          xmlReader.initializeDocument(new ByteArrayInputStream(textMsg.getText().getBytes()),
                                       false);
      Element eControlArea = getControlArea(inDoc.getRootElement());
      Element eMessageId =
        eControlArea.getChild("Sender").getChild("MessageId");
      String senderAppId = eMessageId.getChild("SenderAppId").getText();
      String producerId = eMessageId.getChild("ProducerId").getText();
      String messageSeq = eMessageId.getChild("MessageSeq").getText();
      return senderAppId + "-" + producerId + "-" + messageSeq;
    }
    catch (XmlDocumentReaderException e) {
      logger.fatal("Error creating document from message passed in");
      logger.fatal(e.getMessage(), e);
View Full Code Here


   * @return          Element the ControlArea element (may be ControlAreaRequest,
   *                  ControlAreaReply or ControlAreaSync depending on the doc)
   */
  private Element getControlArea(Element root) {
    java.util.List cList = root.getChildren();
    Element retElem = null;
    for (int i = 0; i < cList.size(); i++) {
      Element current = (Element)cList.get(i);
      if (current.getName().indexOf("ControlArea") != -1) {
        retElem = current;
      }
    }
    return retElem;
  }
View Full Code Here

    logger.debug("Element returned: ");
    logger.debug("  - " + eCommand.getName());
    logger.debug("  - " + getName());

    Element eConfiguration = eCommand.getChild("Configuration");
    if (eConfiguration != null) {
      AppConfig aConfig = new AppConfig();
      aConfig.setName(getName());
      aConfig.setAppName(getAppName());
      aConfig.init(eConfiguration);
      setAppConfig(aConfig);
    }

    Element eMsgComponents = eCommand.getChild("MessagingComponents");
    if (eMsgComponents != null) {
      java.util.List lMsgComponents = eMsgComponents.getChildren();
      for (int i=0; i<lMsgComponents.size(); i++) {
        Element eMsgComponent = (Element)lMsgComponents.get(i);    // Applications, MessageGateways etc.
        java.util.List lComponents = eMsgComponent.getChildren();
        logger.debug(eMsgComponent.getName() + " has " + lComponents.size() + " children.");
        for (int j=0; j<lComponents.size(); j++) {
          Element eComponent = (Element)lComponents.get(j);        // Application, MessageGateway etc.
          String id = eComponent.getAttribute("id").getValue();
          logger.info("Adding MessageComponent named " + id);
          addMsgComponent(id, eComponent);
        }
      }
    }

    java.util.List lProps = eCommand.getChildren("Property");
    for (int i=0; i<lProps.size(); i++) {
      Element eProp = (Element)lProps.get(i);
      String key = eProp.getChild("PropertyName").getText();
      String value = eProp.getChild("PropertyValue").getText();
      addProperty(key, value);
    }
  }
View Full Code Here

   * then it calls the init(Element) method which actually initializes the CommandConfig
   * with the information found in the configuration element.
   *
   */
  private void init() throws EnterpriseConfigurationObjectException {
    Element rootElement = getConfigDoc().getRootElement();
    logger.debug("RootElement is: " + rootElement.getName());
    // Find the element specified by producerName in the document
    Element configElement = getConfigElementByAttributeValue(getName(), "name");
    init(configElement);
  }
View Full Code Here

  public final Element getElementByAttributeNameValue(Element e, String attrName, String attrValue) {
    // Drills down the element (e) until it finds a child named "name"
    logger.debug("Looking for Element with an attribute named: " + attrName + " and value of: " + attrValue);
    java.util.List eChildren1 = e.getChildren();
    for (int i=0; i<eChildren1.size(); i++) {
      Element e1 = (Element)eChildren1.get(i);
      java.util.List aChildren = e1.getAttributes();
      for (int j=0; j<aChildren.size(); j++) {
        Attribute a1 = (Attribute)aChildren.get(j);
        if (a1.getName().equals(attrName)) {
          if (a1.getValue() != null && a1.getValue().trim().equals(attrValue)) {
            return e1;
          }
        }
      }
      Element e2 = matchItByAttributeNameValue(e1,attrName,attrValue);
      if (e2 != null) {
        return e2;
      }
    }
    return null;
View Full Code Here

  }
  private Element matchItByAttributeNameValue(Element e, String attrName, String attrValue) {
    if (e.getContentSize()>0) {
      java.util.List ec = e.getChildren();
      for (int i=0; i<ec.size(); i++) {
        Element e1 = (Element)ec.get(i);
        java.util.List ac = e1.getAttributes();
        for (int j=0; j<ac.size(); j++) {
          Attribute a1 = (Attribute)ac.get(j);
          if (a1.getName().equals(attrName)) {
            if (a1.getValue() != null && a1.getValue().trim().equals(attrValue)) {
              return e1;
            }
          }
        }
        Element e2 = matchItByAttributeNameValue(e1,attrName,attrValue);
        if (e2 == null) {
          return null;
        }
        if (e2 != null) {
          java.util.List ac2 = e2.getAttributes();
          for (int j=0; j<ac2.size(); j++) {
            Attribute a2 = (Attribute)ac2.get(j);
            if (a2.getName().equals(attrName)) {
              if (a2.getValue() != null && a2.getValue().trim().equals(attrValue)) {
                return e2;
View Full Code Here

  public final Element getElementByAttributeNameValueRecursive(Element e, String attrName, String attrValue) {
    // Drills down the element (e) until it finds a child named "name"
    logger.debug("Looking for Element with an attribute named: " + attrName + " and value of: " + attrValue);
    java.util.List eChildren1 = e.getChildren();
    for (int i=0; i<eChildren1.size(); i++) {
      Element e1 = (Element)eChildren1.get(i);
      java.util.List aChildren = e1.getAttributes();
      for (int j=0; j<aChildren.size(); j++) {
        Attribute a1 = (Attribute)aChildren.get(j);
        if (a1.getName().equals(attrName)) {
          if (a1.getValue() != null && a1.getValue().trim().equalsIgnoreCase(attrValue)) {
            return e1;
          }
        }
      }
      Element e2 = matchItByAttributeNameValueRecursive(e1,attrName,attrValue);
      if (e2 != null) {
        return e2;
      }
    }
    return null;
View Full Code Here

  }
  private Element matchItByAttributeNameValueRecursive(Element e, String attrName, String attrValue) {
    if (e.getContentSize()>0) {
      java.util.List ec = e.getChildren();
      for (int i=0; i<ec.size(); i++) {
        Element e1 = (Element)ec.get(i);
        java.util.List ac = e1.getAttributes();
        for (int j=0; j<ac.size(); j++) {
          Attribute a1 = (Attribute)ac.get(j);
          if (a1.getName().equals(attrName)) {
            if (a1.getValue() != null && a1.getValue().trim().equalsIgnoreCase(attrValue)) {
              return e1;
            }
          }
        }
        Element e2 = matchItByAttributeNameValueRecursive(e1,attrName,attrValue);
        if (e2 != null) {
          java.util.List ac2 = e2.getAttributes();
          for (int j=0; j<ac2.size(); j++) {
            Attribute a2 = (Attribute)ac2.get(j);
            if (a2.getName().equals(attrName)) {
              if (a2.getValue() != null && a2.getValue().trim().equalsIgnoreCase(attrValue)) {
                return e2;
View Full Code Here

  */
  public final Element getElementByAttributeValue(Element e, String attrValue) {
    // Drills down the element (e) until it finds a child named "name"
    java.util.List eChildren1 = e.getChildren();
    for (int i=0; i<eChildren1.size(); i++) {
      Element e1 = (Element)eChildren1.get(i);
      java.util.List aChildren = e1.getAttributes();
      for (int j=0; j<aChildren.size(); j++) {
        Attribute a1 = (Attribute)aChildren.get(j);
        if (a1.getValue() != null && a1.getValue().trim().equals(attrValue)) {
          return e1;
        }
      }
      Element e2 = matchItByAttributeValue(e1, attrValue);
      if (e2 != null) {
        return e2;
      }
    }
    return null;
View Full Code Here

  }
  private Element matchItByAttributeValue(Element e, String attrValue) {
    if (e.getContentSize()>0) {
      java.util.List ec = e.getChildren();
      for (int i=0; i<ec.size(); i++) {
        Element e1 = (Element)ec.get(i);
        java.util.List ac = e1.getAttributes();
        for (int j=0; j<ac.size(); j++) {
          Attribute a1 = (Attribute)ac.get(j);
          if (a1.getValue() != null && a1.getValue().trim().equals(attrValue)) {
            return e1;
          }
        }
        Element e2 = matchItByAttributeValue(e1,attrValue);
        if (e2 == null) {
          return null;
        }
        java.util.List ac2 = e2.getAttributes();
        for (int j=0; j<ac2.size(); j++) {
          Attribute a2 = (Attribute)ac2.get(j);
          if (a2.getValue() != null && a2.getValue().trim().equals(attrValue)) {
            return e2;
          }
View Full Code Here

TOP

Related Classes of org.jdom.Element

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.