01: /*
02: * Created on 23.06.2005 for PIROL
03: *
04: * SVN header information:
05: * $Author: javamap $
06: * $Rev: 856 $
07: * $Date: 2007-06-18 21:15:27 -0700 (Mon, 18 Jun 2007) $
08: * $Id: AttributeValue.java 856 2007-06-19 04:15:27Z javamap $
09: */
10: package de.fho.jump.pirol.utilities.FormulaParsing.Values;
11:
12: import com.vividsolutions.jump.feature.Feature;
13:
14: import de.fho.jump.pirol.utilities.FormulaParsing.FormulaValue;
15: import de.fho.jump.pirol.utilities.comparisonAndSorting.ObjectComparator;
16:
17: /**
18: * Class to extract integer or double values (as double) out of the given Feature...
19: *
20: * @author Ole Rahn
21: * <br>
22: * <br>FH Osnabrück - University of Applied Sciences Osnabrück,
23: * <br>Project: PIROL (2005),
24: * <br>Subproject: Daten- und Wissensmanagement
25: *
26: * @version $Rev: 856 $
27: *
28: */
29: public class AttributeValue extends FormulaValue {
30:
31: protected String attributeName = "";
32: protected int attributeIndex = -1;
33:
34: public AttributeValue(String attributeName) {
35: super ();
36: this .attributeName = attributeName;
37: }
38:
39: /**
40: * Gets the value (as a double) of the specified attribute out of the given feature.
41: *@param feature the Feature we want to get the attribute value from
42: *@return value of the specified attribute
43: */
44: public double getValue(Feature feature) {
45: if (this .attributeIndex < 0) {
46: this .attributeIndex = feature.getSchema()
47: .getAttributeIndex(this .attributeName);
48: }
49: return ObjectComparator.getDoubleValue(feature
50: .getAttribute(this .attributeIndex));
51: }
52:
53: /**
54: * @inheritDoc
55: */
56: public boolean isFeatureDependent() {
57: return true;
58: }
59:
60: /**
61: * @inheritDoc
62: */
63: public String toString() {
64: return this.attributeName;
65: }
66:
67: }
|