1
2
3
4
5
6
7
8 package net.kwfgrid.gworkflowdl.structure;
9
10 import org.apache.log4j.Logger;
11 import org.jdom.Attribute;
12 import org.jdom.Element;
13
14 import java.util.List;
15
16 /***
17 * User: hans
18 * Date: 05.04.2006
19 * Time: 13:39:54
20 */
21 public class OperationClassJdom {
22
23 private static final Logger logger = Logger.getLogger(OperationClassJdom.class);
24
25 public OperationClassJdom() {
26 }
27
28 public static Element java2element(OperationClass oc) {
29
30 final Element oce = new Element("operationClass", JdomString.ocSpace);
31
32
33 if (oc.getName() != OperationClass.DEFAULT_OPERATIONCLASSNAME) {
34 oce.setAttribute("name", oc.getName());
35 }
36
37
38 OwlsJdom.java2ocElement(oc,oce);
39
40
41 final OperationCandidate[] ocs = oc.getOperationCandidates();
42 if (ocs != OperationClass.DEFAULT_OPERATIONCANDIDATES) {
43 for (OperationCandidate oc1 : ocs) {
44 oce.addContent(OperationCandidateJdom.java2element(oc1));
45 }
46 }
47 return oce;
48 }
49
50 public static OperationClass element2java(Element oce) {
51
52 final OperationClass oc = Factory.newOperationClass();
53
54
55 final Attribute na = oce.getAttribute("name");
56 if (na != null) {
57 oc.setName(na.getValue());
58 }
59
60
61 OwlsJdom.ocElement2java(oce,oc);
62
63
64 List list = oce.getChildren();
65 if (0 < list.size()) {
66 for (Object aList : list) {
67 Element e = (Element) aList;
68 oc.addOperationCandidate(OperationCandidateJdom.element2java(e));
69 }
70 }
71
72 return oc;
73 }
74 }