Search in sources :

Example 11 with Element

use of com.zhan_dui.utils.m3u8.Element in project gocd by gocd.

the class ProjectStatus method ccTrayXmlElement.

public Element ccTrayXmlElement(String fullContextPath) {
    Element element = new Element("Project");
    element.setAttribute("name", name);
    element.setAttribute("activity", activity);
    element.setAttribute("lastBuildStatus", lastBuildStatus);
    element.setAttribute("lastBuildLabel", lastBuildLabel);
    element.setAttribute("lastBuildTime", DateUtils.formatIso8601ForCCTray(lastBuildTime));
    element.setAttribute("webUrl", fullContextPath + "/" + webUrl);
    if (!breakers.isEmpty()) {
        addBreakers(element);
    }
    return element;
}
Also used : Element(org.jdom2.Element)

Example 12 with Element

use of com.zhan_dui.utils.m3u8.Element in project gocd by gocd.

the class GoConfigFieldTest method shouldValidateAndConvertOnlyIfAppropriate.

@Test(expected = RuntimeException.class)
public void shouldValidateAndConvertOnlyIfAppropriate() throws NoSuchFieldException {
    final Foo object = new Foo();
    final GoConfigFieldWriter field = new GoConfigFieldWriter(Foo.class.getDeclaredField("number"), object, configCache, null);
    final Element element = new Element("foo");
    element.setAttribute("number", "anything");
    field.setValueIfNotNull(element, object);
}
Also used : Element(org.jdom2.Element) Test(org.junit.Test)

Example 13 with Element

use of com.zhan_dui.utils.m3u8.Element in project gocd by gocd.

the class GoConfigFieldTest method shouldConvertFromXmlToJavaObjectCorrectly.

@Test
public void shouldConvertFromXmlToJavaObjectCorrectly() throws Exception {
    final Foo object = new Foo();
    final GoConfigFieldWriter field = new GoConfigFieldWriter(Foo.class.getDeclaredField("number"), object, configCache, null);
    final Element element = new Element("foo");
    element.setAttribute("number", "100");
    field.setValueIfNotNull(element, object);
    assertThat(object.number, is(100L));
}
Also used : Element(org.jdom2.Element) Test(org.junit.Test)

Example 14 with Element

use of com.zhan_dui.utils.m3u8.Element in project gocd by gocd.

the class StageCctrayPresentationModel method createProjectElement.

private void createProjectElement(Element parent, String name, String activity, String lastBuildStatus, String lastBuildLabel, String lastBuildTime, String webUrl) {
    Element project = new Element("Project");
    project.setAttribute("name", name);
    project.setAttribute("activity", activity);
    project.setAttribute("lastBuildStatus", lastBuildStatus);
    project.setAttribute("lastBuildLabel", lastBuildLabel);
    project.setAttribute("lastBuildTime", lastBuildTime);
    project.setAttribute("webUrl", webUrl);
    parent.addContent(project);
}
Also used : Element(org.jdom2.Element)

Example 15 with Element

use of com.zhan_dui.utils.m3u8.Element in project gocd by gocd.

the class GoConfigFieldWriter method parseCollection.

@SuppressWarnings("unchecked")
private Collection parseCollection(Element e, Class<?> collectionType) {
    ConfigCollection collection = collectionType.getAnnotation(ConfigCollection.class);
    Class<?> type = collection.value();
    Object o = newInstance(collectionType);
    bombUnless(o instanceof Collection, "Must be some sort of list. Was: " + collectionType.getName());
    Collection baseCollection = (Collection) o;
    for (Element childElement : (List<Element>) e.getChildren()) {
        if (isInCollection(childElement, type)) {
            baseCollection.add(parseType(childElement, type));
        }
    }
    bombIf(baseCollection.size() < collection.minimum(), "Required at least " + collection.minimum() + " subelements to '" + e.getName() + "'. " + "Found " + baseCollection.size() + ".");
    return baseCollection;
}
Also used : Element(org.jdom2.Element) Collection(java.util.Collection) List(java.util.List)

Aggregations

Element (org.jdom2.Element)673 Attribute (org.jdom2.Attribute)73 Document (org.jdom2.Document)58 File (java.io.File)49 ArrayList (java.util.ArrayList)36 NamedIcon (jmri.jmrit.catalog.NamedIcon)27 IOException (java.io.IOException)26 JDOMException (org.jdom2.JDOMException)26 XmlFile (jmri.jmrit.XmlFile)24 Test (org.junit.Test)24 Turnout (jmri.Turnout)20 DataConversionException (org.jdom2.DataConversionException)20 DocType (org.jdom2.DocType)19 Editor (jmri.jmrit.display.Editor)18 Point (java.awt.Point)15 HashMap (java.util.HashMap)15 Dimension (java.awt.Dimension)14 FileNotFoundException (java.io.FileNotFoundException)13 SignalHead (jmri.SignalHead)13 List (java.util.List)12