29 |
******************************************************************************/ |
******************************************************************************/ |
30 |
package skrueger; |
package skrueger; |
31 |
|
|
|
import java.util.ArrayList; |
|
32 |
import java.util.HashSet; |
import java.util.HashSet; |
33 |
import java.util.List; |
import java.util.List; |
34 |
|
|
35 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
36 |
import org.geotools.feature.NameImpl; |
import org.geotools.feature.NameImpl; |
|
import org.geotools.feature.Feature.NULL; |
|
37 |
import org.opengis.feature.type.AttributeDescriptor; |
import org.opengis.feature.type.AttributeDescriptor; |
38 |
import org.opengis.feature.type.Name; |
import org.opengis.feature.type.Name; |
39 |
|
|
77 |
* be set and will always be interpreted as NULL internally and will usually |
* be set and will always be interpreted as NULL internally and will usually |
78 |
* be ignored. This overcomes the problem, that |
* be ignored. This overcomes the problem, that |
79 |
**/ |
**/ |
80 |
protected HashSet<Object> nodataValues = new HashSet<Object>(); |
protected final HashSet<Object> nodataValues = new HashSet<Object>(); |
81 |
|
|
82 |
/** Translation of the attribute's title **/ |
/** Translation of the attribute's title **/ |
83 |
protected Translation title = new Translation(); |
protected Translation title = new Translation(); |
338 |
this.name = name; |
this.name = name; |
339 |
} |
} |
340 |
|
|
341 |
public void setNodataValues(final HashSet<Object> nodataValues) { |
public void addNodataValue(Object nodataValue) { |
342 |
this.nodataValues = nodataValues; |
this.nodataValues.add(nodataValue); |
343 |
|
} |
344 |
|
|
345 |
|
public void removeNodataValue(Object nodataValue) { |
346 |
|
this.nodataValues.remove(nodataValue); |
347 |
} |
} |
348 |
|
|
349 |
public void setTitle(final Translation title) { |
public void setTitle(final Translation title) { |
389 |
} |
} |
390 |
|
|
391 |
/** |
/** |
392 |
* Takes any value object and checks it againsts the NODATA values. If the |
* Takes any value object and checks it against the NODATA values. If the |
393 |
* value equals a NODATA value, <code>null</code> is returned. Otherwise the |
* value equals a NODATA value, <code>null</code> is returned. Otherwise the |
394 |
* same object is returned. |
* same object is returned. |
395 |
* |
* |
396 |
* Note: This method is called often. |
* Note: This method is called often. |
397 |
*/ |
*/ |
398 |
public Object fiterNodata(final Object value) { |
public Object fiterNodata(final Object value) { |
399 |
|
if (nodataValues.contains(value)) return null; |
|
// contains.. hash |
|
|
for (final Object nodataValue : getNodataValues()) { |
|
|
if (nodataValue.equals(value)) |
|
|
return null; |
|
|
} |
|
400 |
return value; |
return value; |
401 |
} |
} |
402 |
} |
} |