Package org.jdom

Examples of org.jdom.Element


   
    /**
     * Test valid constructor usages.
     */
    public void testValidContructorUsage() throws Exception {
        Element element;
        Document document;
        JDOMWriter jdomWriter = null;
       
        // valid
        jdomWriter = new JDOMWriter(STD_NAMESPACES);
        jdomWriter = new JDOMWriter(new String[] { EMPTY_NAMESPACE, XML_NAMESPACE, "urn:myNs1", "urn:myNs2" });
       
        document = new Document();
       
        // valid
        jdomWriter = new JDOMWriter(STD_NAMESPACES, document);
       
        element = new Element("element");
        document = new Document(element);
       
        // valid
        jdomWriter = new JDOMWriter(STD_NAMESPACES, document);
        jdomWriter = new JDOMWriter(STD_NAMESPACES, element);
View Full Code Here


            fail("expected NullPointerException");
        } catch(NullPointerException e) {}
       
        // invalid: Element has no parent Document
        try {
            jdomWriter = new JDOMWriter(STD_NAMESPACES, new Element("element"));
            fail("expected NullPointerException");
        } catch(NullPointerException e) {}
       
        assertNull(jdomWriter);
    }
View Full Code Here

    public void writeXMLDecl(String version, String encoding, String standalone) throws IOException {
        // do nothing
    }

    public void startTagOpen(int index, String name) throws IOException {
        Element newElement = new Element(name, getNamespace(index));
       
        if(this.currentElement == null) {
            this.document.setRootElement(newElement);
        } else {
            this.currentElement.addContent(newElement);
View Full Code Here

    }

    // Add all elements as 'Properties'
    java.util.List props = configElement.getChildren();
    for (int i=0; i<props.size(); i++) {
      Element aProp = (Element)props.get(i);
      if (aProp.getName().equals("LoggingProducer")) {
        try {
          setLoggingProducer(new PubSubProducer(new ProducerConfig(aProp)));
        }
        catch (Exception e) {
          logger.fatal(e.getMessage(), e);
        }
      }
      else {
        String key = aProp.getName();
        String value = aProp.getText();
        logger.debug("Adding " + key + " - " + value);
        addProperty(key, value);
      }
    }
    }
View Full Code Here

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

      // look for and set the 'refresh' Attribute (done in EnterpriseConfigurationObjectImpl)
      super.init(configElement);
      java.util.List props = configElement.getChildren();
      logger.debug("There are " + props.size() + " properties to add.");
      for (int i=0; i<props.size(); i++) {
        Element aProp = (Element)props.get(i);
        if (aProp.getName().equals("Property")) {
          String propName = aProp.getChild("PropertyName").getText();
          String propValue = aProp.getChild("PropertyValue").getText();
          logger.debug("Adding property " + propName + " - " + propValue);
          addProperty(propName, propValue);
        }
      }
    }
View Full Code Here

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

    }

    // Should be none, for now as everything is specified as attributes.
    java.util.List props = configElement.getChildren();
    for (int i=0; i<props.size(); i++) {
      Element aProp = (Element)props.get(i);
      String key = aProp.getName();
      String value = aProp.getText();
      logger.debug("Adding " + key + " - " + value);
      addProperty(key, value);
    }
  }
View Full Code Here

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

  }

  public final Element getConfigElementByAttributeValue(String value, String attributeName) {
    // Find the element "name" in the current document that matches the type
    // of "configType"
    Element root = getConfigDoc().getRootElement();
    // Get all MessagingComponents.
    // For each component, get its configuration Element.
    // For each configuration element, check its type.
    // If its type matches the type of this object, get the name associated to the configuration element.
    // If the name matches this object's name, then return that element.
    logger.debug("Looking for value: " + value);
    logger.debug("Looking for attribute named: " + attributeName);
//    java.util.List mComponents = root.getChild("MessagingComponents").getChildren();
    java.util.List mComponents = root.getChildren();
    for (int i=0; i<mComponents.size(); i++) {
      Element e = (Element)mComponents.get(i);
      java.util.List mComponentItems = e.getChildren();
      for (int h=0; h<mComponentItems.size(); h++) {
        Element eMComponent = (Element)mComponentItems.get(h);
        Element eConfig = eMComponent.getChild("Configuration");
        java.util.List lConfigs = eConfig.getChildren();
        for (int j=0; j<lConfigs.size(); j++) {
          Element eConfigGroup = (Element)lConfigs.get(j);
          java.util.List lConfigItems = eConfigGroup.getChildren();
          for (int k=0; k<lConfigItems.size(); k++) {
            Element eConfigItem = (Element)lConfigItems.get(k);
            if (eConfigItem.getName().equals(getType())) {
              if (eConfigItem.getAttribute(attributeName).getValue().equals(getName())) {
                // we have winner!
                return eConfigItem;
              }
            }
            else {
              // Here's where we need to go all the way down for each configuration item
              // and see if it contains a config object matching the one we're looking for.
              Element e1 = matchConfigByAttribute(eConfigItem, attributeName);
              if (e1 != null) {
                if (e1.getName().equals(getType())) {
                  if (e1.getAttribute(attributeName).getValue().equals(getName())) {
                    // we have winner!
                    return e1;
                  }
                }
              }
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.