View Javadoc
1   /******************************************************************************
2    * ImportPicsDom.java - XML for PicMan's Import Pics Editor
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.io.File;
11  import java.util.Iterator;
12  import java.util.List;
13  
14  import org.dom4j.Document;
15  import org.dom4j.DocumentHelper;
16  import org.dom4j.Element;
17  
18  /** XML for PicMan's Import Pics Editor
19   * @author Dick Balaska
20   */
21  public class ImportPicsDom {
22  
23  	/** Create a DOM of the <code>File</code>s that need importing
24  	 * @param pics The list to convert
25  	 * @return A DOM of <code>File</code>s
26  	 */
27  	static public Document createDocument(List<File> pics) {
28  		Document document = DocumentHelper.createDocument();
29  		Element root = document.addElement("ImportPicsNames");
30  		Iterator<File> iter = pics.iterator();
31  		while (iter.hasNext()) {
32  			File f = iter.next();
33  			Element ele = DocumentHelper.createElement("File");
34  			ele.addElement("name").addText(f.getName());
35  			ele.addElement("date").addText("" + (f.lastModified()));
36  			root.add(ele);
37  		}
38  		return(document);
39  	}
40  	
41  	/** Create a status dom
42  	 * @param name The Pic name that has this status
43  	 * @param istatus The integer value of the status. 0 = success
44  	 * @param status A String describing the status
45  	 * @return A DOM
46  	 */
47  	static public Document createDocument(String name, int istatus, String status) {
48  		Document document = DocumentHelper.createDocument();
49  		Element root = document.addElement("ImportPicReturn");
50  		root.addElement("name").addText(name);
51  		root.addElement("istatus").addText("" + istatus);
52  		root.addElement("status").addText(status);
53  		return(document);		
54  	}
55  }