1 | package org.medias.eccad.modele; |
---|
2 | |
---|
3 | import java.lang.Double; |
---|
4 | |
---|
5 | import org.medias.eccad.helpers.LoggerPerso; |
---|
6 | import org.medias.eccad.metier.statistique.ServiceStatistique; |
---|
7 | |
---|
8 | public class ResultatStat { |
---|
9 | public String min; |
---|
10 | public String max; |
---|
11 | public String moyenne; |
---|
12 | public String ecart; |
---|
13 | public String somme; |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | public ResultatStat() { |
---|
18 | super(); |
---|
19 | } |
---|
20 | |
---|
21 | public ResultatStat(String min, String max, String moyenne, String ecart, String somme) { |
---|
22 | super(); |
---|
23 | |
---|
24 | /*min = fixeDecimal(min); |
---|
25 | max = fixeDecimal(max); |
---|
26 | moyenne = fixeDecimal(moyenne); |
---|
27 | ecart = fixeDecimal(ecart); |
---|
28 | somme = fixeDecimal(somme);*/ |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | double minFloat = Double.parseDouble(min); |
---|
33 | double maxFloat = Double.parseDouble(max); |
---|
34 | double moyenneFloat = Double.parseDouble(moyenne); |
---|
35 | double ecartFloat = Double.parseDouble(ecart); |
---|
36 | double sommeFloat = Double.parseDouble(somme); |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | min = (String)Double.toString(minFloat); |
---|
41 | max = (String)Double.toString(maxFloat); |
---|
42 | moyenne = (String)Double.toString(moyenneFloat); |
---|
43 | ecart = (String)Double.toString(ecartFloat); |
---|
44 | somme = (String)Double.toString(sommeFloat); |
---|
45 | |
---|
46 | LoggerPerso.log(ResultatStat.class, LoggerPerso.DEBUG, "min : "+ min + fixeDecimal(moyenne)); |
---|
47 | //min = fixeDecimal(min.toString()); |
---|
48 | |
---|
49 | this.min = fixeDecimal(min); |
---|
50 | this.max = fixeDecimal(max); |
---|
51 | this.moyenne = fixeDecimal(moyenne); |
---|
52 | this.ecart = fixeDecimal(ecart); |
---|
53 | this.somme =fixeDecimal(somme); |
---|
54 | } |
---|
55 | |
---|
56 | /*private String fixeDecimal(String entree) { |
---|
57 | if (entree == null) |
---|
58 | return "nc"; |
---|
59 | int index = entree.lastIndexOf("."); |
---|
60 | if (index != -1 && entree.length() >= index + 3); |
---|
61 | entree = entree.substring(0, entree.lastIndexOf(".")+3); |
---|
62 | return entree; |
---|
63 | }*/ |
---|
64 | |
---|
65 | private String fixeDecimal(String entree) { |
---|
66 | LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "entree 1 "+entree); |
---|
67 | if (entree == null) |
---|
68 | return "nc"; |
---|
69 | int index = entree.lastIndexOf("."); |
---|
70 | int indexE = entree.lastIndexOf("E"); |
---|
71 | LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "entree --lll-->2 "+indexE+" "+index+" "+entree.length()); |
---|
72 | if ( indexE == -1 && index != -1 && entree.length() >= index + 5) { |
---|
73 | LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "cas 1 entree"); |
---|
74 | entree = entree.substring(0, entree.lastIndexOf(".")+5); |
---|
75 | } |
---|
76 | else if ( indexE != -1 && index != -1 && entree.length() >= index + 5) |
---|
77 | { |
---|
78 | LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "cas 2 entree"); |
---|
79 | String aEntree = entree; |
---|
80 | LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "aEntree "+aEntree.lastIndexOf("E")+" "+aEntree.length()+" "+aEntree.lastIndexOf("E")+" "+aEntree.length()); |
---|
81 | aEntree=aEntree.substring(aEntree.lastIndexOf("E"), aEntree.lastIndexOf("E")+aEntree.length()-aEntree.lastIndexOf("E")); |
---|
82 | entree = entree.substring(0, entree.lastIndexOf(".")+5)+aEntree; |
---|
83 | } |
---|
84 | else { |
---|
85 | LoggerPerso.log(ServiceStatistique.class, LoggerPerso.DEBUG, "entree= "+entree); |
---|
86 | } |
---|
87 | |
---|
88 | return entree; |
---|
89 | } |
---|
90 | |
---|
91 | public String getEcart() { |
---|
92 | return ecart; |
---|
93 | } |
---|
94 | public void setEcart(String ecart) { |
---|
95 | this.ecart = ecart; |
---|
96 | } |
---|
97 | public String getMax() { |
---|
98 | return max; |
---|
99 | } |
---|
100 | public void setMax(String max) { |
---|
101 | this.max = max; |
---|
102 | } |
---|
103 | public String getMin() { |
---|
104 | return min; |
---|
105 | } |
---|
106 | public void setMin(String min) { |
---|
107 | this.min = min; |
---|
108 | } |
---|
109 | public String getMoyenne() { |
---|
110 | return moyenne; |
---|
111 | } |
---|
112 | public void setMoyenne(String moyenne) { |
---|
113 | this.moyenne = moyenne; |
---|
114 | } |
---|
115 | public String getSomme() { |
---|
116 | return somme; |
---|
117 | } |
---|
118 | public void setSomme(String somme) { |
---|
119 | this.somme = somme; |
---|
120 | } |
---|
121 | |
---|
122 | } |
---|