Example usage for org.dom4j DocumentFactory getInstance

List of usage examples for org.dom4j DocumentFactory getInstance

Introduction

In this page you can find the example usage for org.dom4j DocumentFactory getInstance.

Prototype

public static synchronized DocumentFactory getInstance() 

Source Link

Document

Access to singleton implementation of DocumentFactory which is used if no DocumentFactory is specified when building using the standard builders.

Usage

From source file:cz.muni.stanse.checker.CheckerErrorTrace.java

License:GNU General Public License

public Element xmlDump() {
    Element result = DocumentFactory.getInstance().createElement("trace");
    result.addElement("description").addText(getDescription());
    Element locs = result.addElement("locations");
    for (final CheckerErrorTraceLocation location : getLocations())
        locs.add(location.xmlDump());//from w  w w  .  j  a va 2  s.  c  o m
    return result;
}

From source file:cz.muni.stanse.checker.CheckerErrorTraceLocation.java

License:GNU General Public License

public Element xmlDump() {
    Element result = DocumentFactory.getInstance().createElement("location");
    result.addElement("unit").addText(getUnitName());
    result.addElement("line").addText(Integer.toString(getLineNumber()));
    result.addElement("column").addText(Integer.toString(getColumnNumber()));
    result.addElement("description").addText(getDescription());
    return result;
}

From source file:cz.muni.stanse.statistics.BasicEvaluationStatistic.java

License:GNU General Public License

private static Element xmlDump(String elName, final Vector<Triple<String, Double, Double>> container,
        final String type) {
    Element result = DocumentFactory.getInstance().createElement(elName);
    for (final Triple<String, Double, Double> data : container) {
        Element typeEl = result.addElement(type);
        typeEl.addElement("name").addText(data.getFirst());
        typeEl.addElement("time").addText(Double.toString(data.getSecond()));
        typeEl.addElement("space").addText(Double.toString(data.getThird()));
    }//from  w w w  . java2 s.c  om
    return result;
}

From source file:cz.muni.stanse.statistics.BasicEvaluationStatistic.java

License:GNU General Public License

private static Element xmlDump(final String elName, final String type,
        final Vector<Triple<String, String, String>> container) {
    final Element result = DocumentFactory.getInstance().createElement(elName);
    for (final Triple<String, String, String> data : container) {
        final Element item = result.addElement(type);
        item.addElement("checker").addText(data.getFirst());
        item.addElement("what").addText(data.getSecond());
        item.addElement("where").addText(data.getThird());
    }/*  ww  w . j  ava 2 s  .c  o  m*/
    return result;
}

From source file:datasource.Settings.java

License:Open Source License

public Settings() {
    try {//from  ww w . j  a  va2s .  co  m
        doc = XMLTools.readXML(getSettingsFileName());
    } catch (Exception x) {
        doc = DocumentFactory.getInstance().createDocument();
        Element e = doc.addElement("programs");
        e = e.addElement("program");
        e.addAttribute("name", System.getProperty("ant.project.name", "none"));
        shallSave = true;
    }
}

From source file:de.ailis.wlandsuite.utils.XmlUtils.java

License:Open Source License

/**
 * Returns a new XML element within the wlandsuite namespace.
 * /* www . ja  va2s  . co m*/
 * @param name
 *            The element name
 * @return The new XML element
 */

public static Element createElement(String name) {
    return DocumentFactory.getInstance().createElement(name, namespace);
}

From source file:de.hasait.eclipse.common.xml.XDocument.java

License:Apache License

/**
 * /* w  w  w .ja v  a2  s .  c om*/
 */
public XDocument(final String encoding, final String rootElementName) {
    super();

    DocumentFactory df = DocumentFactory.getInstance();
    _document = df.createDocument(encoding);
    _document.setRootElement(df.createElement(rootElementName));
}

From source file:de.hasait.eclipse.common.xml.XElement.java

License:Apache License

/**
 * @param name
 */
public XElement(final String name) {
    this(DocumentFactory.getInstance().createElement(name));
}

From source file:de.innovationgate.utils.WGUtils.java

License:Apache License

/**
 * Creates a directory link file pointing to a target path
 * @param parentDir The directory to contain the link file
 * @param target The target path that the directory link should point to
 * @throws IOException//w w w.jav  a 2s  .com
 */
public static void createDirLink(File parentDir, String target) throws IOException {
    File link = new File(parentDir, DIRLINK_FILE);
    Document doc = DocumentFactory.getInstance().createDocument();
    Element dirlink = doc.addElement("dirlink");
    Element path = dirlink.addElement("path");
    path.addAttribute("location", target);
    XMLWriter writer = new XMLWriter(OutputFormat.createPrettyPrint());
    writer.setOutputStream(new FileOutputStream(link));
    writer.write(doc);
    writer.close();
}

From source file:de.innovationgate.wga.common.WGAXML.java

License:Apache License

/**
 * add a default domain element to the given parentElement (<domains>)
 * @param parent/*w w w.  ja va  2 s .co  m*/
 * @param domainName
 * @return the created domain element
 */
public static Element addDomain(Element parent, String domainName) {
    Element domain = DocumentFactory.getInstance().createElement("domain");
    domain.addAttribute("name", domainName);
    domain.addAttribute("loginattempts", "5");
    Element login = domain.addElement("login");
    login.addAttribute("mode", "user");
    login.addAttribute("username", "");
    login.addAttribute("password", "");
    domain.addElement("defaultdboptions");
    domain.addElement("defaultpublisheroptions");
    Element errorPage = domain.addElement("errorpage");
    errorPage.addAttribute("enabled", "false");
    parent.add(domain);
    return domain;
}