View Javadoc
1   /******************************************************************************
2    * DirsInDirDom.java - DOM to fetch a list of directories in this directory
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.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  
19  /** DOM to fetch a list of directories in this directory. <br>
20   * @author Dick Balaska
21   * @since 2008/08/15
22   * @see <a href="http://cvs.buckosoft.com/Projects/java/PicMan/PicMan/src/com/buckosoft/PicMan/dom/DirsInDirDom.java">DirsInDirDom.java</a>
23   */
24  public class DirsInDirDom {
25  	/** Create a DOM of the dirs in this directory
26  	 * @param rid The root id to look under
27  	 * @param dir The subdirectory to look under.  "" means look under the top directory.
28  	 * @return A DOM of dirNames
29  	 */
30  	static public Document createDocument(PicManFacade pmf, int rid, String dir) {
31  		Document document = DocumentHelper.createDocument();
32  		Element root = document.addElement("DirsInDir");
33  		List<String> list = pmf.getDirsInDir(rid, dir);
34  		Iterator<String> iter = list.iterator();
35  		while (iter.hasNext()) {
36  			String s = iter.next();
37  			Element ele = DocumentHelper.createElement("Dir");
38  			ele.addElement("name").addText(s);
39  			root.add(ele);
40  		}
41  		return(document);
42  	}
43  
44  }