My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package nl.rintcius.groovy

public class ExpandoBuilder extends BuilderSupport {

private static final String NAME_PROP = "name"
private static final String VALUE_PROP = "value"

public ExpandoBuilder() {
super()
setCurrent(new Expando())
}

protected void setParent(Object parent, Object child) {
String childName = child.getProperty(NAME_PROP)
parent.setProperty(childName, child)
}

protected Object createNode(Object name) {
createNode(name, null, null)
}

protected Object createNode(Object name, Object value) {
createNode(name, null, value)
}

protected Object createNode(Object name, Map attributes) {
createNode(name, attributes, null)
}

protected Object createNode(Object name, Map attributes, Object value) {
Expando e = new Expando()
e.setProperty(NAME_PROP, name)
e.setProperty(VALUE_PROP, value)
attributes.each() { k, v ->
e.setProperty(k,v)
}
return e
}

protected Object postNodeCompletion(Object parent, Object node) {
return parent
}
}

Change log

r3 by rintcius on Sep 23, 2009   Diff
Initial version of ExpandoBuilder and
ExpandoDsl
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1042 bytes, 43 lines
Powered by Google Project Hosting