001    package org.maltparser.core.feature.value;
002    
003    import org.maltparser.core.feature.function.Function;
004    /**
005     *  
006     *
007     * @author Johan Hall
008     * @since 1.0
009    **/
010    public class SingleFeatureValue extends FeatureValue {
011            protected int indexCode;
012            protected String symbol;
013            protected double value;
014            
015            public SingleFeatureValue(Function function) {
016                    super(function);
017                    setIndexCode(0);
018                    setSymbol(null);
019                    setValue(0);
020            }
021            
022            public void reset() {
023                    super.reset();
024                    setIndexCode(0);
025                    setSymbol(null);
026                    setValue(0);
027            }
028            
029            public void update(int indexCode, String symbol, boolean nullValue, double value) {
030                    this.indexCode = indexCode;
031                    this.symbol = symbol;
032                    this.nullValue = nullValue;
033                    this.value = value;
034            }
035            
036            public int getIndexCode() {
037                    return indexCode;
038            }
039    
040            public void setIndexCode(int code) {
041                    this.indexCode = code;
042            }
043    
044            public String getSymbol() {
045                    return symbol;
046            }
047    
048            public void setSymbol(String symbol) {
049                    this.symbol = symbol;
050            }
051    
052            public double getValue() {
053                    return value;
054            }
055    
056            public void setValue(double value) {
057                    this.value = value;
058            }
059            
060            public boolean equals(Object obj) {
061                    if (this == obj)
062                            return true;
063                    if (obj == null)
064                            return false;
065                    if (getClass() != obj.getClass())
066                            return false;
067                    SingleFeatureValue v = (SingleFeatureValue)obj;
068                    if (indexCode != v.indexCode)
069                            return false;
070                    if (!symbol.equals(v.symbol))
071                            return false;
072                    return super.equals(obj);
073            }
074            
075            public String toString() {
076                    StringBuilder sb = new StringBuilder();
077                    sb.append(super.toString());
078                    sb.append('{');
079                    sb.append(symbol);
080                    sb.append("->");
081                    sb.append(indexCode);
082                    sb.append('}');
083                    return sb.toString();
084            }
085    }