Source code: org/integralsource/monsoon/io/ListsWriter.java
1 /*
2 * Copyright (c) 2001 John Keyes
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to:
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * $Id: ListsWriter.java,v 1.2 2001/06/16 14:06:51 jbjk Exp $
20 */
21 package org.integralsource.monsoon.io;
22
23 public class ListsWriter {
24
25 private java.util.ArrayList _lists;
26
27 public ListsWriter(java.util.ArrayList lists) {
28 _lists = lists;
29 }
30
31 public void writeLists()
32 throws java.io.IOException
33 {
34
35 java.io.FileWriter $writer = new java.io.FileWriter("data/"+"lists.xml");
36
37 java.lang.StringBuffer $listsBuff = new java.lang.StringBuffer();
38
39 int $size = _lists.size();
40
41 $listsBuff.append("<lists>\n");
42 for(int i=0; i<$size; i++) {
43 org.integralsource.monsoon.data.List $list
44 = (org.integralsource.monsoon.data.List)_lists.get(i);
45
46 $listsBuff.append("<list name=\"")
47 .append($list.getName())
48 .append("\" description = \"")
49 .append($list.getDescription())
50 .append("\" />\n");
51 }
52 $listsBuff.append("</lists>\n");
53 $writer.write($listsBuff.toString());
54 $writer.close();
55 }
56
57 public boolean deleteList(java.lang.String name)
58 throws java.io.IOException
59 {
60 java.io.File $list = new java.io.File("data/"+ name + ".xml");
61 return $list.delete();
62 }
63 }