Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java @ 109:ab646e0f5569
Improved the ProtocolUtils - there are new functions to append a current state and the reachable states to a root node.
artifacts/trunk@1298 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 07 Feb 2011 11:24:07 +0000 |
parents | 39d9391059bd |
children | 435631e07da2 |
comparison
equal
deleted
inserted
replaced
108:9ece61d918b1 | 109:ab646e0f5569 |
---|---|
5 * Read the file LGPL.txt coming with the software for details | 5 * Read the file LGPL.txt coming with the software for details |
6 * or visit http://www.gnu.org/licenses/ if it does not exist. | 6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
7 */ | 7 */ |
8 package de.intevation.artifactdatabase; | 8 package de.intevation.artifactdatabase; |
9 | 9 |
10 import org.apache.log4j.Logger; | 10 import java.util.List; |
11 | 11 |
12 import org.w3c.dom.Element; | 12 import org.w3c.dom.Element; |
13 import org.w3c.dom.Node; | |
14 | 13 |
15 import de.intevation.artifacts.common.utils.XMLUtils; | 14 import de.intevation.artifacts.common.utils.XMLUtils; |
15 | |
16 import de.intevation.artifactdatabase.state.State; | |
16 | 17 |
17 | 18 |
18 /** | 19 /** |
19 * This class provides methods that help creating the artifact protocol | 20 * This class provides methods that help creating the artifact protocol |
20 * documents describe, feed, advance and out. | 21 * documents describe, feed, advance and out. |
100 creator, | 101 creator, |
101 "hash", | 102 "hash", |
102 new String[] {"value"}, | 103 new String[] {"value"}, |
103 new String[] {hash})); | 104 new String[] {hash})); |
104 } | 105 } |
106 | |
107 | |
108 /** | |
109 * This method appends a node that describes the current state to | |
110 * <i>root</i>. | |
111 * | |
112 * @param creator The ElementCreator used to create new elements. | |
113 * @param root The parent node for new elements. | |
114 * @param state The state to be appended. | |
115 */ | |
116 public static void appendState( | |
117 XMLUtils.ElementCreator creator, Element root, State state) | |
118 { | |
119 root.appendChild(createArtNode( | |
120 creator, "state", | |
121 new String[] { "description", "name" }, | |
122 new String[] { state.getDescription(), state.getID() })); | |
123 } | |
124 | |
125 | |
126 /** | |
127 * This method appends a node with reachable states to <i>root</i>. | |
128 * | |
129 * @param creator The ElementCreator used to create new elements. | |
130 * @param root The parent node for new elements. | |
131 * @param states The reachable states to be appended. | |
132 */ | |
133 public static void appendReachableStates( | |
134 XMLUtils.ElementCreator creator, | |
135 Element root, | |
136 List<State> states) | |
137 { | |
138 Element reachable = createArtNode( | |
139 creator, "reachable-states", null, null); | |
140 | |
141 for (State s: states) { | |
142 appendState(creator, reachable, s); | |
143 } | |
144 | |
145 root.appendChild(reachable); | |
146 } | |
105 } | 147 } |
106 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: | 148 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |