source: trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/profiles/Predicate.java@ 8609

Last change on this file since 8609 was 8609, checked in by schweer, 19 years ago

putting the alerting service servlet under version control

  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1/*
2 * Created on Nov 2, 2004
3 * Copyright (C) Andrea Schweer, 2004
4 *
5 * This file is part of the Greenstone Alerting Service.
6 * Refer to the COPYING file in the base directory of this package
7 * for licensing information.
8 */
9package org.greenstone.gsdlas.profiles;
10
11import java.util.*;
12import java.util.Set;
13import java.util.TreeSet;
14
15/**
16 * @author schweer
17 *
18 * TODO To change the template for this generated type comment go to
19 * Window - Preferences - Java - Code Style - Code Templates
20 */
21public abstract class Predicate implements Comparable {
22
23 protected Set subscriptions = new TreeSet();
24 protected String field;
25 protected String value;
26 protected int id;
27
28 public void addSubscription(Subscription sub) {
29 subscriptions.add(sub);
30 }
31
32 /* (non-Javadoc)
33 * @see org.greenstone.gsdlas.profiles.Predicate#getSubscriptions()
34 */
35 public Set getSubscriptions() {
36 return Collections.unmodifiableSet(subscriptions);
37 }
38
39 public int getID() {
40 return id;
41 }
42
43 public void setID(int i) {
44 this.id = i;
45 }
46
47 /* (non-Javadoc)
48 * @see org.greenstone.gsdlas.profiles.Predicate#getKey()
49 */
50 public String getField() {
51 return field;
52 }
53
54 /* (non-Javadoc)
55 * @see org.greenstone.gsdlas.profiles.Predicate#getValue()
56 */
57 public String getValue() {
58 return value;
59 }
60
61 public String toString() {
62 return field + "=" + value;
63 }
64
65 public boolean equals(Object other) {
66 if (other == null || !(other instanceof Predicate)) return false;
67 return id == ((Predicate)other).getID();
68 }
69
70 public int compareTo(Object other) {
71 Predicate otherPredicate = (Predicate) other;
72 return new Integer(id).compareTo(new Integer(otherPredicate.getID()));
73 }
74
75 public abstract boolean isSatisfied(Map event);
76
77}
Note: See TracBrowser for help on using the repository browser.