/* * Created on Nov 2, 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.*; import java.util.Set; import java.util.TreeSet; /** * @author schweer * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public abstract class Predicate implements Comparable { protected Set subscriptions = new TreeSet(); protected String field; protected String value; protected int id; public void addSubscription(Subscription sub) { subscriptions.add(sub); } /* (non-Javadoc) * @see org.greenstone.gsdlas.profiles.Predicate#getSubscriptions() */ public Set getSubscriptions() { return Collections.unmodifiableSet(subscriptions); } public int getID() { return id; } public void setID(int i) { this.id = i; } /* (non-Javadoc) * @see org.greenstone.gsdlas.profiles.Predicate#getKey() */ public String getField() { return field; } /* (non-Javadoc) * @see org.greenstone.gsdlas.profiles.Predicate#getValue() */ public String getValue() { return value; } public String toString() { return field + "=" + value; } public boolean equals(Object other) { if (other == null || !(other instanceof Predicate)) return false; return id == ((Predicate)other).getID(); } public int compareTo(Object other) { Predicate otherPredicate = (Predicate) other; return new Integer(id).compareTo(new Integer(otherPredicate.getID())); } public abstract boolean isSatisfied(Map event); }