package org.geotools.filter.function;

import java.util.List;

import org.geotools.feature.Feature;
import org.geotools.filter.Expression;
import org.geotools.filter.FunctionImpl;
import org.geotools.filter.LiteralExpression;
import org.opengis.filter.expression.ExpressionVisitor;

/**
 * The data structure returned by classification functions. We can take this
 * object, tweak it, and then pass it to a ClassifyFunction.
 * 
 * @author Cory Horner, Refractions Research
 */
public abstract class Classifier {

    //TODO: handle null, NaN, else
    //TODO: simply this by just adding labelled bins
    //TODO: add size
    
    String[] titles;
    
    public String[] getTitles() {
        return titles;
    }
    
    public void setTitles(String[] titles) {
        this.titles = titles;
    }
    
    public void setTitle(int slot, String title) {
        titles[slot] = title;
    }
    
    public String getTitle(int slot) {
        return titles[slot];
    }
    
    /**
     * Returns the slot containing the passed expression's value. 
     */
    public int classify(org.opengis.filter.expression.Expression expr, Object feature) {
        Object value = expr.evaluate(feature); // retrive value from context
        return classify(value);
    }
    
    /**
     * Returns the slot this value belongs in.
     * 
     * @param value
     * @return index, starting from zero
     */
    public abstract int classify(Object value);
    
    /**
     * @return the number of bins
     */
    public abstract int getSize();
}
