1
2
3
4
5
6
7
8 package com.buckosoft.PicMan.dom;
9
10 import java.util.Iterator;
11 import java.util.List;
12
13 import org.dom4j.Document;
14 import org.dom4j.DocumentHelper;
15 import org.dom4j.Element;
16
17 import com.buckosoft.PicMan.business.PicManFacade;
18 import com.buckosoft.PicMan.domain.Root;
19
20
21
22
23 public class RootsDom {
24 static public Document createDocument(PicManFacade pmf) {
25 Document document = DocumentHelper.createDocument();
26 Element root = document.addElement("PicManRoots");
27 List<Root> roots = pmf.getDB().getRoots();
28 Iterator<Root> iter = roots.iterator();
29 while (iter.hasNext()) {
30 Root r = iter.next();
31 root.add(getRootElement(r));
32 }
33 return document;
34 }
35
36 static public Element getRootElement(Root r) {
37 Element ele = DocumentHelper.createElement("Root");
38 ele.addElement("name").addText(r.getName());
39 ele.addElement("rid").addText("" + r.getRid());
40 ele.addElement("path").addText(r.getPath());
41 ele.addElement("prefix").addText(r.getFilePrefix());
42 ele.addElement("active").addText(((Boolean)r.isActive()).toString());
43 return(ele);
44 }
45
46 }