Search in sources :

Example 61 with Element

use of org.neo4j.ogm.domain.gh806.Element in project JMRI by JMRI.

the class SampleFactory method main.

// Main entry point for standalone run
public static void main(String[] args) {
    // dump a document to stdout
    Element root = getBasicSample();
    Document doc = new Document(root);
    try {
        org.jdom2.output.XMLOutputter fmt = new org.jdom2.output.XMLOutputter();
        fmt.setFormat(org.jdom2.output.Format.getPrettyFormat());
        fmt.output(doc, System.out);
    } catch (Exception e) {
        System.err.println("Exception writing file: " + e);
    }
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document)

Example 62 with Element

use of org.neo4j.ogm.domain.gh806.Element in project JMRI by JMRI.

the class AbstractNamedBeanManagerConfigXMLTest method testStoreNullProperty.

public void testStoreNullProperty() {
    // Create the manager to test
    AbstractNamedBeanManagerConfigXML x = new NamedBeanManagerConfigXMLTest();
    // create a NamedBean with two properties to store
    NamedBean from = new AbstractNamedBean("sys", "usr") {

        @Override
        public int getState() {
            return 0;
        }

        @Override
        public void setState(int i) {
        }

        @Override
        public String getBeanType() {
            return "";
        }
    };
    from.setProperty("foo", null);
    from.setProperty("biff", Boolean.valueOf(true));
    // create element for properties
    Element p = new Element("test");
    x.storeProperties(from, p);
    // create NamedBean to load
    NamedBean to = new AbstractNamedBean("sys", "usr") {

        @Override
        public int getState() {
            return 0;
        }

        @Override
        public void setState(int i) {
        }

        @Override
        public String getBeanType() {
            return "";
        }
    };
    x.loadProperties(to, p);
    // and test
    Assert.assertEquals(null, to.getProperty("foo"));
    Assert.assertEquals(Boolean.valueOf(true), to.getProperty("biff"));
}
Also used : AbstractNamedBean(jmri.implementation.AbstractNamedBean) AbstractNamedBean(jmri.implementation.AbstractNamedBean) NamedBean(jmri.NamedBean) Element(org.jdom2.Element)

Example 63 with Element

use of org.neo4j.ogm.domain.gh806.Element in project JMRI by JMRI.

the class LocaleSelectorTest method testFindPartialCode.

public void testFindPartialCode() {
    LocaleSelector.suffixes = new String[] { "kl_KL", "kl" };
    Namespace xml = Namespace.XML_NAMESPACE;
    Element el = new Element("foo").setAttribute("temp", "a").addContent(new Element("temp").setAttribute("lang", "aa_BB", xml).addContent("b")).addContent(new Element("temp").setAttribute("lang", "kl", xml).addContent("c")).addContent(new Element("temp").setAttribute("lang", "kl_AA", xml).addContent("d"));
    String result = LocaleSelector.getAttribute(el, "temp");
    Assert.assertEquals("find default", "c", result);
}
Also used : Element(org.jdom2.Element) Namespace(org.jdom2.Namespace)

Example 64 with Element

use of org.neo4j.ogm.domain.gh806.Element in project JMRI by JMRI.

the class LocaleSelectorTest method testFindFullCode.

public void testFindFullCode() {
    LocaleSelector.suffixes = new String[] { "kl_KL", "kl" };
    Namespace xml = Namespace.XML_NAMESPACE;
    Element el = new Element("foo").setAttribute("temp", "a").addContent(new Element("temp").setAttribute("lang", "aa_BB", xml).addContent("b")).addContent(new Element("temp").setAttribute("lang", "kl", xml).addContent("b")).addContent(new Element("temp").setAttribute("lang", "kl_KL", xml).addContent("c"));
    String result = LocaleSelector.getAttribute(el, "temp");
    Assert.assertEquals("find default", "c", result);
}
Also used : Element(org.jdom2.Element) Namespace(org.jdom2.Namespace)

Example 65 with Element

use of org.neo4j.ogm.domain.gh806.Element in project JMRI by JMRI.

the class SE8cSignalHeadXml method addTurnoutElement.

Element addTurnoutElement(NamedBeanHandle<Turnout> to, String which) {
    Element el = new Element("turnoutname");
    el.setAttribute("defines", which);
    el.addContent(to.getName());
    return el;
}
Also used : Element(org.jdom2.Element)

Aggregations

Element (org.jdom2.Element)3339 Document (org.jdom2.Document)508 Test (org.junit.Test)457 ArrayList (java.util.ArrayList)331 IOException (java.io.IOException)275 Attribute (org.jdom2.Attribute)213 JDOMException (org.jdom2.JDOMException)205 Element (org.osate.aadl2.Element)143 Namespace (org.jdom2.Namespace)140 List (java.util.List)135 Test (org.junit.jupiter.api.Test)131 File (java.io.File)128 SAXBuilder (org.jdom2.input.SAXBuilder)128 HashMap (java.util.HashMap)120 XMLOutputter (org.jdom2.output.XMLOutputter)105 XConfiguration (org.apache.oozie.util.XConfiguration)98 Configuration (org.apache.hadoop.conf.Configuration)96 NamedElement (org.osate.aadl2.NamedElement)77 StringReader (java.io.StringReader)67 Iterator (java.util.Iterator)63