View Javadoc
1 /*** 2 * PerspectiveGenerator.java 3 * Project: Dependency Tool 4 * 5 * Copyright 2003 ELCA Informatique SA 6 * Av. de la Harpe 22-24, 1000 Lausanne 13, Switzerland 7 * www.elca.ch 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public License 11 * as published by the Free Software Foundation; either version 2.1 of 12 * the License, or (at your option) any later version. 13 * 14 * This library is distributed in the hope that it will be useful, but 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 22 * USA 23 */ 24 25 package dptool.config; 26 27 import java.io.File; 28 import java.io.FileOutputStream; 29 import java.io.PrintStream; 30 import java.util.HashMap; 31 import java.util.Iterator; 32 import java.util.List; 33 34 import org.jdom.Document; 35 import org.jdom.Element; 36 import org.jdom.output.XMLOutputter; 37 38 import com.sun.rsasign.ag; 39 40 /*** 41 * Describe class <code>PerspectiveGenerator</code> here. 42 * 43 * @author Peter Moosmann 44 * @version 0.1-alpha 45 * @version $Id$ 46 */ 47 public class PerspectiveGenerator 48 { 49 50 public void generate(String[][] packageLayerData, String[] layerData, File file, List filters, List aggregators) 51 { 52 try 53 { 54 FileOutputStream fos = new FileOutputStream(file); 55 PrintStream ps = new PrintStream(fos); 56 57 generate(packageLayerData, layerData, ps, filters, aggregators); 58 59 ps.close(); 60 fos.close(); 61 62 } 63 catch (Exception e) 64 { 65 generate(packageLayerData, layerData, System.out, filters, aggregators); 66 } 67 } 68 69 public void generate(String[][] packageLayerData, String[] layerData, PrintStream ps, List filters, List aggregators) 70 { 71 HashMap processedPkg = new HashMap(); 72 73 Document doc = new Document(); 74 75 Element root = new Element("perspectives"); 76 Element perspective = new Element("perspective"); 77 Element layerOrder = new Element("LayerOrder"); 78 79 doc.setRootElement(root); 80 root.addContent(perspective); 81 perspective.setAttribute("name", "APLAT"); 82 Iterator it1 = filters.iterator(); 83 84 while (it1.hasNext()) 85 { 86 Element filter = (Element) it1.next(); 87 88 perspective.addContent((Element)filter.clone()); 89 } 90 91 Iterator it2 = aggregators.iterator(); 92 93 while (it2.hasNext()) 94 { 95 Element aggregator = (Element) it2.next(); 96 perspective.addContent((Element)aggregator.clone()); 97 } 98 99 perspective.addContent(layerOrder); 100 Element layerName = new Element("name"); 101 layerName.setText("APLAT Layers"); 102 layerOrder.addContent(layerName); 103 104 for (int i = 0; i < layerData.length; i++) 105 { 106 Element layer = new Element("layer"); 107 layerOrder.addContent(layer); 108 Element name = new Element("name"); 109 layer.addContent(name); 110 name.setText(layerData[i]); 111 112 for (int t = 0; t < packageLayerData.length; t++) 113 { 114 if (layerData[i].equals(packageLayerData[t][1])) 115 { 116 Element pkg = new Element("package"); 117 layer.addContent(pkg); 118 pkg.setText(packageLayerData[t][0]); 119 120 } 121 } 122 } 123 124 XMLOutputter writer = new XMLOutputter(" ", true); 125 try 126 { 127 writer.output(doc,ps); 128 } 129 catch (Exception ex) 130 { 131 ex.printStackTrace(); 132 } 133 } 134 }

This page was automatically generated by Maven