| 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.Pic; |
| 19 | |
import com.buckosoft.PicMan.domain.Set; |
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | 0 | public class PicsInSetDom { |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
static public Document createDocument(PicManFacade pmf, int sid, int size) { |
| 34 | 0 | Document document = DocumentHelper.createDocument(); |
| 35 | 0 | Element root = document.addElement("PicsInSet"); |
| 36 | 0 | Set set = pmf.getDB().getSet(sid); |
| 37 | 0 | List<Pic> list = pmf.getDB().getPics(set, size); |
| 38 | 0 | Iterator<Pic> iter = list.iterator(); |
| 39 | 0 | while (iter.hasNext()) { |
| 40 | 0 | Pic pic = iter.next(); |
| 41 | 0 | Element ele = DocumentHelper.createElement("Pic"); |
| 42 | 0 | ele.addElement("pid").addText(((Integer)pic.getPid()).toString()); |
| 43 | 0 | ele.addElement("name").addText(pic.getName()); |
| 44 | 0 | root.add(ele); |
| 45 | 0 | } |
| 46 | 0 | return document; |
| 47 | |
} |
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
static public Document createDocument(PicManFacade pmf, String setName, int size) { |
| 56 | 0 | Document document = DocumentHelper.createDocument(); |
| 57 | 0 | Element root = document.addElement("PicsInSetCount"); |
| 58 | 0 | Set set = pmf.getDB().getSet(setName); |
| 59 | 0 | List<Pic> list = pmf.getDB().getPics(set, size); |
| 60 | 0 | root.addElement("name").addText(set.getName()); |
| 61 | 0 | root.addElement("sid").addText("" + set.getSid()); |
| 62 | 0 | root.addElement("size").addText("" + size); |
| 63 | 0 | root.addElement("count").addText("" + list.size()); |
| 64 | 0 | return document; |
| 65 | |
} |
| 66 | |
} |