Coverage Report - com.buckosoft.PicMan.dom.PicFilterDom
 
Classes in this File Line Coverage Branch Coverage Complexity
PicFilterDom
0%
0/22
0%
0/2
2
 
 1  
 /******************************************************************************
 2  
  * PicFilterDom.java - XML Chains for PicMan's Editors
 3  
  * 
 4  
  * PicMan - The BuckoSoft Picture Manager in Java
 5  
  * Copyright(c) 2008 - Dick Balaska
 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  
 /** Fetch a Pic's Filters as a DOM
 22  
  * @author Dick Balaska
 23  
  */
 24  0
 public class PicFilterDom {
 25  
         /** Fetch a Pic's Filters as a DOM
 26  
          * @param pmf The PicMan Facade
 27  
          * @param picName The Pic who's filters we want
 28  
          * @return the DOM
 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  
 }