Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/integralsource/monsoon/io/ListWriter.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: ListWriter.java,v 1.4 2001/06/25 22:36:34 jbjk Exp $
20   */
21  package org.integralsource.monsoon.io;
22  
23  public class ListWriter {
24  
25      private java.util.ArrayList _items;   
26  
27      private java.lang.String _listName;
28  
29      public ListWriter(java.lang.String listName, java.util.ArrayList items) {
30    _items    = items;
31    _listName = listName;
32      }
33      
34      public void writeItems() throws java.io.IOException {
35    java.io.FileWriter $writer = new java.io.FileWriter("data/"+_listName+".xml");
36  
37    java.lang.StringBuffer $listBuff = new java.lang.StringBuffer();
38  
39    int $size = _items.size();
40  
41    $listBuff.append("<list>\n");
42    for(int i=0; i < $size; i++) {
43        org.integralsource.monsoon.data.Item $item = 
44      (org.integralsource.monsoon.data.Item)_items.get(i);
45  
46        $listBuff.append("<item id=\"" + $item.getId() + "\">\n");
47        $listBuff.append("  <title>\n");
48        $listBuff.append($item.getTitle()).append("\n");
49        $listBuff.append("   </title>\n");
50        $listBuff.append("  <description>\n");
51        $listBuff.append($item.getDescription()).append("\n");
52        $listBuff.append("   </description>\n");
53        $listBuff.append("  <priority>\n");
54        $listBuff.append($item.getPriority()).append("\n");
55        $listBuff.append("   </priority>\n");
56        $listBuff.append("  <complete>\n");
57        $listBuff.append($item.isComplete()).append("\n");
58        $listBuff.append("   </complete>\n");
59        $listBuff.append("</item>\n");
60    }
61    $listBuff.append("</list>\n");
62    $writer.write($listBuff.toString());
63    $writer.close();
64      }
65  
66      public void initList(java.lang.String name) throws java.io.IOException {
67    java.io.FileWriter $writer = new java.io.FileWriter("data/"+name+".xml");
68    $writer.write("<list></list>");
69    $writer.close();
70      }
71  }