KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jivesoftware > util > log > filter > PriorityFilter


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE file.
7  */

8 package org.jivesoftware.util.log.filter;
9
10 import org.jivesoftware.util.log.LogEvent;
11 import org.jivesoftware.util.log.Priority;
12
13 /**
14  * Filters log events based on priority.
15  *
16  * @author <a HREF="mailto:peter@apache.org">Peter Donald</a>
17  */

18 public class PriorityFilter extends AbstractFilterTarget {
19
20     ///Priority to filter against
21
private Priority m_priority;
22
23     /**
24      * Constructor that sets the priority that is filtered against.
25      *
26      * @param priority the Priority
27      */

28     public PriorityFilter(final Priority priority) {
29         m_priority = priority;
30     }
31
32     /**
33      * Set priority used to filter.
34      *
35      * @param priority the priority to filter on
36      */

37     public void setPriority(final Priority priority) {
38         m_priority = priority;
39     }
40
41     /**
42      * Filter the log event based on priority.
43      * <p/>
44      * If LogEvent has a Lower priroity then discard it.
45      *
46      * @param event the event
47      * @return return true to discard event, false otherwise
48      */

49     protected boolean filter(final LogEvent event) {
50         return (!m_priority.isLower(event.getPriority()));
51     }
52 }
53
Popular Tags