| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
package com.buckosoft.PicMan.dom; |
| 9 | |
|
| 10 | |
import java.util.Iterator; |
| 11 | |
import java.util.LinkedHashMap; |
| 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.Filter; |
| 19 | |
import com.buckosoft.PicMan.domain.Pic; |
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | 0 | public class PicFilterDom { |
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
static public Document createDocument(PicManFacade pmf, String picName) { |
| 31 | 0 | Document document = DocumentHelper.createDocument(); |
| 32 | 0 | Element root = document.addElement("PicFilter"); |
| 33 | 0 | root.addElement("picName").addText(picName); |
| 34 | 0 | Filter f = pmf.getDB().getFilter(picName); |
| 35 | 0 | Pic pic = pmf.getDB().getPic(picName); |
| 36 | 0 | root.addElement("dir").addText(pic.getLocation()); |
| 37 | 0 | root.addElement("rid").addText("" + pic.getRid()); |
| 38 | 0 | root.addElement("date").addText("" + (pic.getDate().getTime())); |
| 39 | |
|
| 40 | 0 | LinkedHashMap<String, Integer> ff = f.getFilters(); |
| 41 | 0 | Iterator<String> iter = ff.keySet().iterator(); |
| 42 | 0 | Element filters = DocumentHelper.createElement("Filters"); |
| 43 | 0 | while (iter.hasNext()) { |
| 44 | 0 | String key = iter.next(); |
| 45 | 0 | Integer value = ff.get(key); |
| 46 | 0 | Element ele = DocumentHelper.createElement("Filter"); |
| 47 | 0 | ele.addElement("setName").addText(key); |
| 48 | 0 | ele.addElement("value").addText("" + value); |
| 49 | 0 | filters.add(ele); |
| 50 | 0 | } |
| 51 | 0 | root.add(filters); |
| 52 | 0 | return document; |
| 53 | |
} |
| 54 | |
|
| 55 | |
} |