| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 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 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 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; |
| 71 |
} |
| 72 |
|
| 73 |
public void addListDataListener(ListDataListener listDataListener) { |
| 74 |
|
| 75 |
} |
| 76 |
|
| 77 |
public void removeListDataListener(ListDataListener listDataListener) { |
| 78 |
|
| 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 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
} |