Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java @ 5164:8c65acf01adc 2.9.10
Fixed datacage to be oracle compatible.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 04 Mar 2013 11:44:11 +0100 |
parents | 53be73133104 |
children | ba489a16f4d8 |
comparison
equal
deleted
inserted
replaced
5163:9474e27e319a | 5164:8c65acf01adc |
---|---|
91 Object mode = args.get(0); | 91 Object mode = args.get(0); |
92 Object locations = args.get(1); | 92 Object locations = args.get(1); |
93 Object from = args.get(2); | 93 Object from = args.get(2); |
94 | 94 |
95 if (!(mode instanceof String)){ | 95 if (!(mode instanceof String)){ |
96 return -Double.MAX_VALUE; | 96 return -99999d; |
97 } | 97 } |
98 | 98 |
99 if (mode.equals("locations")) { | 99 if (mode.equals("locations")) { |
100 if (!(locations instanceof String)) { | 100 if (!(locations instanceof String)) { |
101 return -Double.MAX_VALUE; | 101 return -99999d; |
102 } | 102 } |
103 String loc = ((String)locations).replace(" ", ""); | 103 String loc = ((String)locations).replace(" ", ""); |
104 String[] split = loc.split(","); | 104 String[] split = loc.split(","); |
105 if (split.length < 1) { | 105 if (split.length < 1) { |
106 return -Double.MAX_VALUE; | 106 return -99999d; |
107 } | 107 } |
108 try { | 108 try { |
109 double min = Double.parseDouble(split[0]); | 109 double min = Double.parseDouble(split[0]); |
110 for (int i = 1; i < split.length; ++i) { | 110 for (int i = 1; i < split.length; ++i) { |
111 double v = Double.parseDouble(split[i]); | 111 double v = Double.parseDouble(split[i]); |
114 } | 114 } |
115 } | 115 } |
116 return min; | 116 return min; |
117 } | 117 } |
118 catch (NumberFormatException nfe) { | 118 catch (NumberFormatException nfe) { |
119 return -Double.MAX_VALUE; | 119 return -99999d; |
120 } | 120 } |
121 } | 121 } |
122 else if (mode.equals("distance")) { | 122 else if (mode.equals("distance")) { |
123 if (!(from instanceof String)) { | 123 if (!(from instanceof String)) { |
124 return -Double.MAX_VALUE; | 124 return -99999d; |
125 } | 125 } |
126 String f = (String)from; | 126 String f = (String)from; |
127 try { | 127 try { |
128 return Double.parseDouble(f); | 128 return Double.parseDouble(f); |
129 } | 129 } |
130 catch(NumberFormatException nfe) { | 130 catch(NumberFormatException nfe) { |
131 return -Double.MAX_VALUE; | 131 return -99999d; |
132 } | 132 } |
133 } | 133 } |
134 else { | 134 else { |
135 return -Double.MAX_VALUE; | 135 return -99999d; |
136 } | 136 } |
137 } | 137 } |
138 }); | 138 }); |
139 } | 139 } |
140 | 140 |
147 Object mode = args.get(0); | 147 Object mode = args.get(0); |
148 Object locations = args.get(1); | 148 Object locations = args.get(1); |
149 Object to = args.get(2); | 149 Object to = args.get(2); |
150 | 150 |
151 if (!(mode instanceof String)){ | 151 if (!(mode instanceof String)){ |
152 return Double.MAX_VALUE; | 152 return 99999d; |
153 } | 153 } |
154 | 154 |
155 if (mode.equals("locations")) { | 155 if (mode.equals("locations")) { |
156 if (!(locations instanceof String)) { | 156 if (!(locations instanceof String)) { |
157 return Double.MAX_VALUE; | 157 return 99999d; |
158 } | 158 } |
159 try { | 159 try { |
160 String loc = ((String)locations).replace(" ", ""); | 160 String loc = ((String)locations).replace(" ", ""); |
161 String[] split = loc.split(","); | 161 String[] split = loc.split(","); |
162 if (split.length < 1) { | 162 if (split.length < 1) { |
163 return Double.MAX_VALUE; | 163 return 99999d; |
164 } | 164 } |
165 double max = Double.parseDouble(split[0]); | 165 double max = Double.parseDouble(split[0]); |
166 for (int i = 1; i < split.length; ++i) { | 166 for (int i = 1; i < split.length; ++i) { |
167 double v = Double.parseDouble(split[i]); | 167 double v = Double.parseDouble(split[i]); |
168 if (v > max) { | 168 if (v > max) { |
170 } | 170 } |
171 } | 171 } |
172 return max; | 172 return max; |
173 } | 173 } |
174 catch (NumberFormatException nfe) { | 174 catch (NumberFormatException nfe) { |
175 return Double.MAX_VALUE; | 175 return 99999d; |
176 } | 176 } |
177 } | 177 } |
178 else if (mode.equals("distance")) { | 178 else if (mode.equals("distance")) { |
179 if (!(to instanceof String)) { | 179 if (!(to instanceof String)) { |
180 return Double.MAX_VALUE; | 180 return 99999d; |
181 } | 181 } |
182 else { | 182 else { |
183 String t = (String)to; | 183 String t = (String)to; |
184 try { | 184 try { |
185 return Double.parseDouble(t); | 185 return Double.parseDouble(t); |
186 } | 186 } |
187 catch(NumberFormatException nfe) { | 187 catch(NumberFormatException nfe) { |
188 return Double.MAX_VALUE; | 188 return 99999d; |
189 } | 189 } |
190 } | 190 } |
191 } | 191 } |
192 else { | 192 else { |
193 return Double.MAX_VALUE; | 193 return 99999d; |
194 } | 194 } |
195 } | 195 } |
196 }); | 196 }); |
197 } | 197 } |
198 | 198 |