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
|
public static SDDData makeData(char[] p_string, int deb, int fin) {
SDDData data = null;
if (p_string != null && p_string.length > 0) {
data = new SDDData();
//On découpe en morceau cle=valeur
List<char[]> listParam = splitString(p_string, '#', deb, fin);
for(char[] iteParam : listParam) {
int ln = iteParam.length;
//On identifie le type de la valeur en fonction de la clé.
int indexOfEqual = -1;
for (int i = 0; i < ln; i++) {
if (iteParam[i] == '=') {
indexOfEqual = i;
break;
}
}
String keyStr = new String(iteParam, 0, indexOfEqual);
Integer keyInt = Integer.valueOf(keyStr);
char[] valueStr = new char[(ln - indexOfEqual)-1];
System.arraycopy(iteParam, indexOfEqual+1, valueStr, 0, (ln - indexOfEqual - 1));
switch(keyInt) {
case 1:
Integer valueInt = getInteger(valueStr);
data.m_ListData.put(keyInt, valueInt);
break;
case 2:
Double valueDou = Double.parseDouble(new String(valueStr));
data.m_ListData.put(keyInt, valueDou);
break;
case 3 :
Map<char[], Integer> listVariousParam = new HashMap<char[], Integer>();
List<char[]> testValue2 = splitString(valueStr, '¤');
int maxLn = testValue2.size();
for(int i = 0; i < maxLn; i+=2) {
listVariousParam.put(testValue2.get(i), getInteger(testValue2.get(i+1)) );
}
data.m_ListData.put(keyInt, listVariousParam);
break;
}
}
}
return data;
} |
Partager