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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
public class DescMatTest {
static Element racine = new Element("MatricesTests");
static org.jdom.Document descMat = new Document(racine);
private MatriceTest matrices;
private Masques masks;
private List<Matrice> listMat;
public DescMatTest(List<Matrice> matrices, Masques masks){
this.listMat = matrices;
this.masks = masks;
}
public void createDescMat(){
Attribute path = new Attribute("CheminMatriceTest","test");
racine.setAttribute(path);
for(int i=0; i<listMat.size(); i++){
Element matrice = new Element("Matrice");
Attribute id = new Attribute("id",String.valueOf(i));
matrice.setAttribute(id);
Attribute masque = new Attribute("masque",listMat.get(i).getMask().getName());
matrice.setAttribute(masque);
Element nomMat = new Element("NomMatrice");
nomMat.addContent(listMat.get(i).getName());
matrice.addContent(nomMat);
Element onglets = new Element("ListeOnglets");
for(int j=0; j<listMat.get(i).getListOnglets().size(); j++){
onglets.addContent(listMat.get(i).getListOnglets().get(j));
if(j<listMat.get(i).getListOnglets().size()-1){
onglets.addContent(",");
}
}
matrice.addContent(onglets);
racine.addContent(matrice);
}
Element masques = new Element("Masques");
racine.addContent(masques);
List<Masque> listMask = masks.getListMasks();
for(int i=0; i<listMask.size(); i++){
Element masque = new Element("Masque");
Attribute nomMasque = new Attribute("nom",listMask.get(i).getName());
masque.setAttribute(nomMasque);
Attribute nbTab = new Attribute("nbTableau",String.valueOf(listMask.get(i).getNbTab()));
masque.setAttribute(nbTab);
Element ssi = new Element("SSI");
List<EquipementTab> eqpSSI = listMask.get(i).getEqps();
for(int j=0; j<eqpSSI.size(); j++){
ssi.addContent(eqpSSI.get(j).getName());
if(j<eqpSSI.size()-1){
ssi.addContent(",");
}
}
masque.addContent(ssi);
Element testType = new Element("TestType");
testType.addContent("{"+String.valueOf(listMask.get(i).getLTest())+
","+String.valueOf(listMask.get(i).getCTest())+"}");
masque.addContent(testType);
List<Tableau> listTab = listMask.get(i).getTab();
for(int j=0; j<listTab.size(); j++){
Element tab = new Element("Tableau");
Attribute tabNum = new Attribute("number",String.valueOf(listTab.get(j).getIdTab()));
tab.setAttribute(tabNum);
masque.addContent(tab);
Element l1 = new Element("L1");
l1.addContent(String.valueOf(listTab.get(j).getL1()));
tab.addContent(l1);
Element c1 = new Element("C1");
c1.addContent(String.valueOf(listTab.get(j).getC1()));
tab.addContent(c1);
Element l2 = new Element("L2");
l2.addContent(String.valueOf(listTab.get(j).getL2()));
tab.addContent(l2);
Element c2 = new Element("C2");
c2.addContent(String.valueOf(listTab.get(j).getC2()));
tab.addContent(c2);
Element elementsSSI = new Element("ElementsSSI");
tab.addContent(elementsSSI);
List<EquipementTab> listEqpTab = listTab.get(j).getListEqpTab();
for(int e=0; e<listEqpTab.size(); e++){
Element eqp = new Element(listEqpTab.get(e).getName());
eqp.addContent(listEqpTab.get(e).getPosTab());
elementsSSI.addContent(eqp);
}
}
masques.addContent(masque);
}
Element chaines = new Element("Chaines");
chaines.addContent("x");
racine.addContent(chaines);
affiche();
enregistre("descMat.xml");
}
static void affiche()
{
try
{
XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
sortie.output(descMat, System.out);
}
catch (java.io.IOException e){}
}
static void enregistre(String fichier)
{
try
{
XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
sortie.output(descMat, new FileOutputStream(fichier));
}
catch (java.io.IOException e){}
}
} |
Partager