All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.testng.xml.XmlDefine Maven / Gradle / Ivy

There is a newer version: 7.10.2
Show newest version
package org.testng.xml;

import static org.testng.collections.CollectionUtils.hasElements;

import org.testng.collections.Lists;
import org.testng.reporters.XMLStringBuffer;
import org.testng.xml.dom.OnElement;

import java.util.List;

public class XmlDefine {

  private String m_name;

  public void setName(String name) {
    m_name = name;
  }

  public String getName() {
    return m_name;
  }

  public String toXml(String indent) {
    XMLStringBuffer xsb = new XMLStringBuffer(indent);
    boolean hasElements = hasElements(m_includes);
    if (hasElements) {
      xsb.push("define", "name", m_name);
    }
    for (String s : m_includes) {
      xsb.addEmptyElement("include", "name", s);
    }
    if (hasElements) {
      xsb.pop("define");
    }

    return xsb.toXML();
  }

  private List m_includes = Lists.newArrayList();

  @OnElement(tag = "include", attributes = "name")
  public void onElement(String name) {
    m_includes.add(name);
  }

  public List getIncludes() {
    return m_includes;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy