1
2
3
4
5
6
7
8 package net.kwfgrid.gworkflowdl.structure;
9
10 import org.jdom.Attribute;
11 import org.jdom.Element;
12
13 /***
14 * User: hans
15 * Date: 05.04.2006
16 * Time: 13:02:10
17 */
18 public class OperationCandidateJdom {
19 private OperationCandidateJdom() {
20 }
21
22 public static Element java2element(OperationCandidate clo) {
23 final Element cloe = new Element("operationCandidate", JdomString.ocSpace);
24
25
26 final String type = clo.getType();
27 if (type != OperationCandidate.DEFAULT_TYPE) {
28 cloe.setAttribute("type", type);
29 }
30
31
32 final String operationName = clo.getOperationName();
33 if (operationName != OperationCandidate.DEFAULT_OPERATIONNAME) {
34 cloe.setAttribute("operationName", operationName);
35 }
36
37
38 final String resourceName = clo.getResourceName();
39 if (resourceName != OperationCandidate.DEFAULT_RESOURCENAME) {
40 cloe.setAttribute("resourceName", resourceName);
41 }
42
43
44 cloe.setAttribute("quality", Float.toString(clo.getQuality()));
45
46
47 if (clo.isSelected()) {
48 cloe.setAttribute("selected", "true");
49 } else {
50
51 }
52
53
54 OwlsJdom.java2ocElement(clo,cloe);
55
56 return cloe;
57 }
58
59 public static OperationCandidate element2java(Element cloe) {
60 final OperationCandidate clo = Factory.newOperationCandidate();
61
62
63 final Attribute type = cloe.getAttribute("type");
64 if (type != null) {
65 clo.setType(type.getValue());
66 }
67
68
69 final Attribute operationName = cloe.getAttribute("operationName");
70 if (operationName != null) {
71 clo.setOperationName(operationName.getValue());
72 }
73
74
75 final Attribute resourceName = cloe.getAttribute("resourceName");
76 if (resourceName != null) {
77 clo.setResourceName(resourceName.getValue());
78 }
79
80
81 final Attribute qual = cloe.getAttribute("quality");
82 if (qual != null) {
83 clo.setQuality(Float.valueOf(qual.getValue()));
84 }
85
86
87 final Attribute att = cloe.getAttribute("selected");
88 if (att != null) {
89 final String s = att.getValue();
90 clo.setSelected("true".equals(s));
91 }
92
93
94 OwlsJdom.ocElement2java(cloe,clo);
95
96 return clo;
97 }
98 }
99