6 public static class Attribute {
7 public final Name name;
8 public final String value;
10 public Attribute(Name name, String value) {
16 public static Attribute $(Name name, String value) {
17 return(new Attribute(name, value));
20 public static Attribute $(String name, String value) {
21 return($(new Name(name), value));
24 public static Attribute $(Namespace ns, String local, String value) {
25 return($(new Name(ns, local), value));
28 private static void populate0(Element el, Iterable<?> contents) {
29 for(Object ob : contents) {
31 } else if(ob instanceof Node) {
33 } else if(ob instanceof Attribute) {
34 el.set(((Attribute)ob).name, ((Attribute)ob).value);
35 } else if(ob instanceof Populous) {
36 ((Populous)ob).populate(el);
37 } else if(ob instanceof Object[]) {
38 populate0(el, Arrays.asList((Object[])ob));
39 } else if(ob instanceof Iterable) {
40 populate0(el, (Iterable<?>)ob);
41 } else if(ob instanceof String) {
42 el.add(new Text((String)ob));
44 el.add(new Text(ob.toString()));
49 public static Element populate(Element el, Object... contents) {
50 populate0(el, Arrays.asList(contents));