/*
 * Created on Nov 1, 2004
 * Copyright (C) Andrea Schweer, 2004
 *
 * This file is part of the Greenstone Alerting Service.
 * Refer to the COPYING file in the base directory of this package
 * for licensing information.
 */
package org.greenstone.gsdlas.profiles;

import java.util.Map;


/**
 * @author schweer
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class SubstringMatchPredicate extends Predicate {

    public SubstringMatchPredicate(String field, String substring) {
        super.field = field;
        super.value = substring;
    }

    /* (non-Javadoc)
     * @see org.greenstone.gsdlas.profiles.Predicate#isSatisfied(java.util.Map)
     */
    public boolean isSatisfied(Map event) {
        String fieldValue = (String) event.get(field);
        return fieldValue != null && fieldValue.indexOf(value) >= 0;
    }

    public String toString() {
        return field + " contains " + value;
    }
    
}