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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
| public class Liste {
public String cn;
public String st;
public Liste suivant;
public Liste (){}
public Liste (String x,String y, Liste a) {
this.cn = x;
this.st=y;
this.suivant = a;
}
public Liste ajouter (String x, String y, Liste a) {
return new Liste (x, y, a);
}
public boolean recherche(String x, String y, Liste a) {
// \esc{Recherche, voir page \pageref{prog:recherche-liste}}
while (a != null) {
if ((a.cn.equals(x)) && ((a.st.equals(y))))
return true;
a = a.suivant;
}
return false;
}
public boolean rechercheR (String x, String y, Liste a) {
// \esc{recherche re'cursive, voir page \pageref{prog:recherche-liste-rec}}
if (a == null)
return false;
else if ((a.cn.equals(x)) && ((a.st.equals(y))))
return true;
else
return rechercheR (x, y, a.suivant);
}
public int longueur(Liste a) {
if (a == null)
return 0;
else
return 1 + longueur (a.suivant);
}
public int longueurI(Liste a) {
int longueur = 0;
while (a != null) {
++longueur;
a = a.suivant;
}
return longueur;
}
public Liste supprimer (String x, String y, Liste a) {
if (a != null)
if ((a.cn.equals(x)) && ((a.st.equals(y))))
a = a.suivant;
else
a.suivant = supprimer (x, y, a.suivant);
return a;
}
public Liste supprimerI (String x, String y, Liste a) {
Liste b, c;
if (a != null)
if ((a.cn.equals(x)) && ((a.st.equals(y)))){
c = a;
a = a.suivant;
} else {
b = a ;
while ((b.suivant != null )&& (!(b.suivant.cn.equals(x))) && (!(b.suivant.cn.equals(y))) )
b = b.suivant;
if (b.suivant != null) {
c = b.suivant;
b.suivant = b.suivant.suivant;
}
}
return a;
}
public void imprimer (Liste a) {
for (Liste b = a; b != null; b = b.suivant)
System.out.print (b.cn + " "+ b.st);
System.out.println ();
}
//j'utlise une liste dans une classe test.java qui se trouve dans un autre //package:
//je déclare ma liste:
Liste concept_util =new Liste("","",null);
//et je l'utilse dans cette boucle:
while(CurrentNode1!=null){
switch((CurrentNode1.getNodeType()))
{
case Node.ELEMENT_NODE : {
i++;
url = CurrentNode1.getTextContent().replaceAll("&","&");
UrlToRdf transformer = new UrlToRdf(url, t.treeRDFCcpt, Configuration, GateHome, TreeTagger, Result, concept_util//<--);
transformer.Transform(styleSource2);
};break;}
CurrentNode1 = CurrentNode1.getNextSibling();}
concept_util.imprimer(concept_util);//<--
// et la méthode transformer de la classe UrlToRdf est la suivante:
public Liste concept_util;
public UrlToRdf(String Url, ArrayList TreeRdf, Document Configur, String GateHome, String TreeTagger, String Result,Liste conceptutil){
this.url = Url;
this.TreeRdf=TreeRdf;
this.Configuration = Configur;
this.GateHome = GateHome;
this.TreeTagger = TreeTagger;
this.Result = Result;
this.concept_util=conceptutil;
}
public void Transform (StreamSource styleSource) throws TransformerFactoryConfigurationError, IOException{
SAXBuilder sxb = new SAXBuilder();
String fichier ="Z:\\concept\\conceptfrequent.txt";
String inputfile=this.Result+"/"+gn.PatId+"/ConceptPatent"+this.ID.replaceAll(",", "")+".xml";
System.out.println(inputfile);
String path=this.Result+"/"+gn.PatId+"/"+this.ID.replaceAll(",", "")+".xml";
System.out.println(path);
try
{
//On crée un nouveau document JDOM avec en argument le fichier XML
//Le parsing est terminé ;)
this.document2 = sxb.build(new File(inputfile));
System.out.println("aloooooooooooooooooooooo");
JdomParserXml ins = new JdomParserXml (this.document2);
ins.afficheALL(path,fichier,concept_util//<--);
}
//et la fonction afficheALL c'est une méthode d'une autre classe dont j'utlise la liste pour vider un vecteur et le mettre dans la liste
for(int p=0; p < conceptfrequent2.size(); p++){
if(conceptfrequent2.elementAt(p) != null)
concept_util.ajouter(conceptfrequent2.elementAt(p).toString(), conceptfrequent2.elementAt(p+1).toString(), concept_util //<--);
} |
Partager