Debian Codegraph @

src/dr/xml/XMLModelCombiner.java

raw symbols SCIP
1 /*
2 * XMLModelCombiner.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.xml;
27
28 import org.jdom.output.XMLOutputter;
29
30 import javax.swing.*;
31 import javax.swing.event.ListDataListener;
32 import java.io.OutputStream;
33 import java.util.HashMap;
34
35 /**
36 * Package: XMLModelCombiner
37 * Description:
38 * <p/>
39 * <p/>
40 * Created by
41 * Alexander V. Alekseyenko ([email protected])
42 * Date: Apr 13, 2009
43 * Time: 1:23:34 PM
44 */
45 public class XMLModelCombiner implements ListModel {
46 private XMLModelFile from;
47 private XMLModelFile to;
48 private XMLIDMapping mapping;
49
50 public XMLModelCombiner(XMLModelFile model1, XMLModelFile model2) {
51 from = model1;
52 to = model2;
53 mapping = new XMLIDMapping();
54 }
55
56 public void writeXML(OutputStream ostream) {
57 from.prefixIdentifiedNames("from", mapping.getFromNames(), true);
58 to.prefixIdentifiedNames("to", mapping.getToNames(), false);
59 XMLOutputter outputter = new XMLOutputter();
60 from.print(outputter, ostream);
61 to.print(outputter, ostream);
62
63 }
64
65 public int getSize() {
66 return mapping.getFromNames().size();
67 }
68
69 public Object getElementAt(int i) {
70 return null; //AUTOGENERATED METHOD IMPLEMENTATION
71 }
72
73 public void addListDataListener(ListDataListener listDataListener) {
74 //AUTOGENERATED METHOD IMPLEMENTATION
75 }
76
77 public void removeListDataListener(ListDataListener listDataListener) {
78 //AUTOGENERATED METHOD IMPLEMENTATION
79 }
80
81 public class XMLIDMapping {
82 HashMap<String, String> fromMap;
83 HashMap<String, String> toMap;
84
85 public XMLIDMapping() {
86 fromMap = new HashMap<String, String>();
87 toMap = new HashMap<String, String>();
88 }
89
90 public void addRule(String cName, String m1Name, String m2Name) {
91 fromMap.put(cName, m1Name);
92 toMap.put(cName, m2Name);
93 }
94
95 public void removeRule(String cName) {
96 fromMap.remove(cName);
97 toMap.remove(cName);
98 }
99
100 public HashMap<String, String> getFromNames() {
101 return fromMap;
102 }
103
104 public HashMap<String, String> getToNames() {
105 return toMap;
106 }
107 }
108
109 // public static void main(String[] args){
110 // XMLModelCombiner mc = new XMLModelCombiner(new XMLModelFile("small1.xml"), new XMLModelFile("small2.xml"));
111 //
112 //
113 // }
114 }