KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > routing > filters > EqualsFilter


1 /*
2  * $Id: EqualsFilter.java 4219 2006-12-09 10:15:14Z lajos $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.routing.filters;
12
13 import org.mule.umo.UMOFilter;
14 import org.mule.umo.UMOMessage;
15
16 /**
17  * <code>EqualsFilter</code> is a filter for comparing two objects using the
18  * equals() method.
19  */

20 public class EqualsFilter implements UMOFilter, ObjectFilter
21 {
22     private Object JavaDoc pattern;
23
24     public EqualsFilter()
25     {
26         super();
27     }
28
29     public EqualsFilter(Object JavaDoc compareTo)
30     {
31         this.pattern = compareTo;
32     }
33
34     public boolean accept(UMOMessage message)
35     {
36         return accept(message.getPayload());
37     }
38
39     public boolean accept(Object JavaDoc object)
40     {
41         if (object == null && pattern == null)
42         {
43             return true;
44         }
45
46         if (object == null || pattern == null)
47         {
48             return false;
49         }
50
51         return pattern.equals(object);
52     }
53
54     public Object JavaDoc getPattern()
55     {
56         return pattern;
57     }
58
59     public void setPattern(Object JavaDoc pattern)
60     {
61         this.pattern = pattern;
62     }
63
64 }
65
Popular Tags