Bonjour
J'ai une application a faire au cours de mon stage mais j'ai quelque probleme dans mon code qui m'empeche d'avancer si quelqu'un peut m'aider SVP
le code me renvoi des erreurs que je n'arrive pas a localiser,il m'envoi meme la ligne 147 qui n'exite meme pas dans mon programme .


Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
at java.util.Vector.elementAt(Unknown Source)
at paris.SetTreeAutomata(paris.java:72)
at paris.<init>(paris.java:30)
at paris.main(paris.java:147)







Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
import java.io.*;
import java.util.*;
 
import dk.brics.automaton.Automaton;
import dk.brics.automaton.RegExp;
import dk.brics.automaton.RunAutomaton;
 
 
public class paris{
 
private int maxtransit;
private int maxcomponent = 4;
String AutomatonFileTxtName;
public Vector[][] transrule;
private int nbrTransRules;
 
//données pour remplir une table de transition
static String str="a,a,a p p l e,2"+"p,ap,a p p l e,4"+"p,app,a p p l e,5"+"l,appl,a p p l e,7"+"e,apple,a p p l e,8"+
     "a,a,a p p l e,2"+"p,ap,a p p l e,4"+"p,app,a p p l e,5"+"l,appl,a p p l e,7"+"e,apple,a p p l e,8"+"s,apples,a p p l e s 9"+
     "p,p,p l y,3"+"l,pl,p l y,6"+"y,ply,p l y,9"+"p,p,p a l y,3"+"a,pa,p a l y,5"+"l,pal,p a l y,7"+"y,paly,p a l y,9";
/**@Constructeur */
/* transrule[i][0]: est un vecteur contenat le label 
 * transrule[i][1]:contient l'enchainement du mot
 * transrule[i][2]: est un vecteur contenat l'expression reg
 
 * transrule[i][3]: est un vecteur contenat les etats 
 *                  appartenant a transrule[i][1]     
 */ 
  public paris(int maxtrans, String str1){
     this.maxtransit=maxtrans;
     this.transrule = new Vector[maxtransit][maxcomponent];
     this.AutomatonFileTxtName=str1;
	 this.SetTreeAutomata(str1);
	//this.RegExpToFSA();
  }
 
 
 
/**@intialize(): crée la table de transition @Transrule*/
   public void initialize(){
    System.out.println("initialize");
	   for (int i=0; i<=(maxtransit-1); i++)
      {
        for (int j = 0; j <= (maxcomponent-1); j++)
          transrule[i][j] = new Vector();
      }
   }
 
 
 
 
 
  /**@SetTreeAutomata:
   * A partir d'une chaine de caracteres  "str", cette procédure va remplir
   * la table de transition @transrule  
  */
  public  void SetTreeAutomata(String str2){
	  System.out.println("SetTreeAutomata");
	  initialize();
      int cnt = 0;
       if (str2.length() == 0) {
         System.err.println("   Missing sequence ");
         System.exit(1);
       }
 
         while (str2!= null){
           StringTokenizer st=new StringTokenizer(str2,",");
           int j=0;
            while (st.hasMoreTokens()){
              String x1= st.nextToken();
              String x=x1.toLowerCase();              
              if (x.equals("()")) transrule[cnt][j].add(new String("")); 
                else
                   if (!x.equals(" ")) transrule[cnt][j].add(new String(x)); 
              j++;
            }
           String Rexp=transrule[cnt][2].elementAt(0).toString();
           if(!Rexp.equals(""))
           {
              StringTokenizer state=new StringTokenizer(Rexp,"()?*+| ");
              while (state.hasMoreTokens()){
                String q = state.nextToken();
                transrule[cnt][2].add(new String(q));                
              }
           }
      		String Rexp1=this.NoWhite(Rexp);
      		Automaton A_E=new Automaton();
      		if (Rexp1.length()!=0){
     			RegExp E=new RegExp(Rexp1);  			
      			A_E = E.toAutomaton();	
      		} 
      		RunAutomaton RA=new RunAutomaton(A_E);
      		this.transrule[cnt][4].addElement((RunAutomaton) RA);           
           cnt++;
 
         }
 
 
 
       this.nbrTransRules=cnt;
     }
public int setNumberTransitionRules(){
	return(nbrTransRules);
}
/**@SetToLowerSet: en entrée un ensemble @S_in de chaînes de caracteres qlq 
         * A retourner un ensemble contenat les mêmes chaines 
         * de caractères mais en miniscule "Lowercase"
         */
	public HashSet SetToLowerSet(HashSet S_in){
		HashSet s_out=new HashSet();
		if(!S_in.isEmpty()){
			Iterator it=S_in.iterator();
			while(it.hasNext()){
				String s1=it.next().toString().trim();
				s_out.add(s1.toLowerCase());
			}
		}
		return(s_out);
	}
 
 
 
 
 
	     public String NoWhite(String RegExp){
	    	 System.out.println("NoWhite");
	    	 String s="";
	      	int size=RegExp.length();
	      	int j=0;
	      	while (j<size){
	             char c= RegExp.charAt(j);
	      		if (c!=' ') s=s+c;
	      		j++;		
	      	}
	      	return(s);
	      }
 
 
 
  public static void main(String[] args){
paris P=new paris(19,str);	  
 
 
  }}