]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/generator/DefaultRunnableDataNode.java
Minimal Hello World execution module
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / generator / DefaultRunnableDataNode.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.argeo.slc.core.execution.generator;
18
19 import java.util.ArrayList;
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.Map;
23
24 /**
25 * Default implementation of <code>RunnableDataNode</code>
26 *
27 */
28 public class DefaultRunnableDataNode implements RunnableDataNode {
29
30 private List<RunnableDataNode> children = new ArrayList<RunnableDataNode>();
31
32 private RunnableDataNode parent;
33
34 /**
35 * Data of the RunnableDataNode. Does not contain
36 * parent data.
37 */
38 private Map<String, Object> properData = new HashMap<String, Object>();
39
40 private String path;
41
42 private String beanName;
43
44 public boolean isLeaf() {
45 return children.size() == 0;
46 }
47
48 public List<RunnableDataNode> getChildren() {
49 return children;
50 }
51
52 public void addChild(RunnableDataNode child) {
53 child.setParent(this);
54 children.add(child);
55 }
56
57 public Map<String, Object> getData() {
58 Map<String, Object> data = new HashMap<String, Object>();
59 if(parent != null) {
60 Map<String, Object> parentData = parent.getData();
61 if(parentData != null) {
62 data.putAll(parentData);
63 }
64 }
65 // entries defined in parentData can be overridden
66 // in properData
67 if(properData != null) {
68 data.putAll(properData);
69 }
70 return data;
71 }
72
73 public Map<String, Object> getProperData() {
74 return properData;
75 }
76
77 public void setProperData(Map<String, Object> properData) {
78 this.properData = properData;
79 }
80
81 public String getPath() {
82 return path;
83 }
84
85 public void setPath(String path) {
86 this.path = path;
87 }
88
89 public String getBeanName() {
90 return beanName;
91 }
92
93 public void setBeanName(String beanName) {
94 this.beanName = beanName;
95 }
96
97 public void setParent(RunnableDataNode parent) {
98 this.parent = parent;
99 }
100
101 public RunnableDataNode getParent() {
102 return parent;
103 }
104
105 }