dégager un string selon l'indice
j'en ai ce code permettant de dégager l'indice d'une transition donner au sein d'une structure de donner matrice ou Vector je veux inversement dégager le nom de transition tout en connaissant l'indice un peu d'aide S'il vous plait :zoubi:
Code:
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
| public static int getIndexTlocal (String Nom_T)
{ int index=-1;
if(Nom_T.contains("Creation")){return index = 0;}
if(Nom_T.contains("IncremtPeriod")){return index = 1;}
if(Nom_T.contains("Reset")){return index = 2;}
if(Nom_T.contains("Activation")){return index = 3;}
if(Nom_T.contains("Execution")){return index = 4;}
if(Nom_T.contains("Incrementing ")){return index = 5;}
if(Nom_T.contains("Receiving" )){return index = 6;}
if(Nom_T.contains("Releasing" )){return index = 7;}
if(Nom_T.contains("Sending" )){return index = 8;}
return index;
}
public static int getIndexTFromString (String Nom_T)
{
int i=-1;
if (Nom_T.contains("Creation"))
{
String sub ="" ;
int posT = Nom_T.indexOf("T") ;
int posC = Nom_T.indexOf("C") ;
sub = Nom_T.substring(posT+1,posC) ;
return i = Integer.parseInt(sub) ;
}
if (Nom_T.contains("IncremtPeriod"))
{
String sub ="" ;
int posT = Nom_T.indexOf("T") ;
int posI = Nom_T.indexOf("I") ;
sub = Nom_T.substring(posT+1,posI) ;
return i = Integer.parseInt(sub) ;
}
if (Nom_T.contains("Reset"))
{
String sub ="" ;
int posT = Nom_T.indexOf("T") ;
int posR = Nom_T.indexOf("R") ;
sub = Nom_T.substring(posT+1,posR) ;
return i = Integer.parseInt(sub) ;
}
if (Nom_T.contains("Activation"))
{
String sub ="" ;
int posT = Nom_T.indexOf("T") ;
int posA = Nom_T.indexOf("A") ;
sub = Nom_T.substring(posT+1,posA) ;
return i = Integer.parseInt(sub) ;
}
if (Nom_T.contains("Execution"))
{
String sub ="" ;
int posT = Nom_T.indexOf("T") ;
int posE = Nom_T.indexOf("E") ;
sub = Nom_T.substring(posT+1,posE) ;
return i = Integer.parseInt(sub) ;
}
if (Nom_T.contains("Incrementing"))
{
String sub ="" ;
int posT = Nom_T.indexOf("T") ;
int posI = Nom_T.indexOf("I") ;
sub = Nom_T.substring(posT+1,posI) ;
return i = Integer.parseInt(sub) ;
}
if (Nom_T.contains("Receiving"))
{
String sub ="" ;
int posT = Nom_T.indexOf("T") ;
int posR = Nom_T.indexOf("R") ;
sub = Nom_T.substring(posT+1,posR) ;
return i = Integer.parseInt(sub) ;
}
if (Nom_T.contains("Releasing"))
{
String sub ="" ;
int posT = Nom_T.indexOf("T") ;
int posR = Nom_T.indexOf("R") ;
sub = Nom_T.substring(posT+1,posR) ;
return i = Integer.parseInt(sub) ;
}
if (Nom_T.contains("Sending"))
{
String sub ="" ;
int posT = Nom_T.indexOf("T") ;
int posS = Nom_T.indexOf("S") ;
sub = Nom_T.substring(posT+1,posS) ;
return i = Integer.parseInt(sub) ;
}
return i ;
}
public static int getIndexglobal (String Nom_T)
{int i ;
i =getIndexTlocal(Nom_T)+(getIndexTFromString (Nom_T)-1)* 9 ;
return i;
} |