Revision 38080 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/FInterval.java
FInterval.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.fmap.rendering; |
42 | 42 |
|
43 |
import java.util.regex.Matcher; |
|
44 |
import java.util.regex.Pattern; |
|
45 |
|
|
43 | 46 |
import com.hardcode.gdbms.engine.values.DateValue; |
44 | 47 |
import com.hardcode.gdbms.engine.values.DoubleValue; |
45 | 48 |
import com.hardcode.gdbms.engine.values.FloatValue; |
... | ... | |
124 | 127 |
* @return FInterval nuevo. |
125 | 128 |
*/ |
126 | 129 |
public static IInterval create(String s) { |
127 |
String[] str = s.split("-"); |
|
128 |
if (s.startsWith("-")) { |
|
129 |
str[0]="-"+str[1]; |
|
130 |
s.replaceFirst("-",""); |
|
131 |
str[1]=str[2]; |
|
130 |
Pattern pattern = Pattern.compile("(-?[^-]*)-(-?.*)"); |
|
131 |
Matcher matcher = pattern.matcher(s); |
|
132 |
IInterval inter=new NullIntervalValue(); // temporal pessimism |
|
133 |
if (matcher.find()) { |
|
134 |
try{ |
|
135 |
inter = new FInterval(Double.parseDouble(matcher.group(1)), |
|
136 |
Double.parseDouble(matcher.group(2))); |
|
137 |
}catch (NumberFormatException e) { |
|
138 |
} |
|
132 | 139 |
} |
133 |
if (s.contentEquals(new StringBuffer("--"))) { |
|
134 |
str[1]=s.substring(s.indexOf('-')+1,s.length()-1); |
|
135 |
} |
|
136 | 140 |
|
137 |
IInterval inter=null; |
|
138 |
try{ |
|
139 |
inter = new FInterval(Double.parseDouble(str[0]), |
|
140 |
Double.parseDouble(str[1])); |
|
141 |
}catch (NumberFormatException e) { |
|
142 |
return new NullIntervalValue(); |
|
143 |
} |
|
144 | 141 |
return inter; |
145 | 142 |
} |
146 | 143 |
} |
Also available in: Unified diff