| 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 | 0 | public class RootsDom { |
| 24 | |
static public Document createDocument(PicManFacade pmf) { |
| 25 | 0 | Document document = DocumentHelper.createDocument(); |
| 26 | 0 | Element root = document.addElement("PicManRoots"); |
| 27 | 0 | List<Root> roots = pmf.getDB().getRoots(); |
| 28 | 0 | Iterator<Root> iter = roots.iterator(); |
| 29 | 0 | while (iter.hasNext()) { |
| 30 | 0 | Root r = iter.next(); |
| 31 | 0 | root.add(getRootElement(r)); |
| 32 | 0 | } |
| 33 | 0 | return document; |
| 34 | |
} |
| 35 | |
|
| 36 | |
static public Element getRootElement(Root r) { |
| 37 | 0 | Element ele = DocumentHelper.createElement("Root"); |
| 38 | 0 | ele.addElement("name").addText(r.getName()); |
| 39 | 0 | ele.addElement("rid").addText("" + r.getRid()); |
| 40 | 0 | ele.addElement("path").addText(r.getPath()); |
| 41 | 0 | ele.addElement("prefix").addText(r.getFilePrefix()); |
| 42 | 0 | ele.addElement("active").addText(((Boolean)r.isActive()).toString()); |
| 43 | 0 | return(ele); |
| 44 | |
} |
| 45 | |
|
| 46 | |
} |