1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.jour.rt.view;
22
23 import net.sf.jour.filter.TimeListFilter;
24 import net.sf.jour.rt.agent.EventTimed;
25 import net.sf.jour.rt.agent.ProfilerEvent;
26 import net.sf.jour.rt.view.config.FilterType;
27
28 import org.apache.log4j.Logger;
29
30 /***
31 * TODO Add docs
32 * Created on 04.12.2004
33 *
34 * Contributing Author(s):
35 *
36 * Misha Lifschitz <mishalifschitz at users.sourceforge.net> (Inital implementation)
37 * Vlad Skarzhevskyy <vlads at users.sourceforge.net> (Inital implementation)
38 *
39 * @author vlads
40 * @version $Revision: 1.1 $ ($Author: vlads $) $Date: 2004/12/15 20:50:32 $
41 */
42
43 public class ViewFilterItem extends ClassMatchFilter {
44
45 private boolean enabled;
46
47 private String description;
48
49 private TimeListFilter time;
50
51 private long timeFrame;
52
53 public ViewFilterItem() {
54 time = new TimeListFilter();
55 }
56
57 public void readConfig(FilterType definition) {
58 enabled = definition.isEnabled();
59 this.description = definition.getDescr();
60 if (definition.getAccumulation() != null) {
61 this.timeFrame = definition.getAccumulation().getTimeFrame();
62 }
63 super.readConfig(definition.getClasses());
64
65 time.readConfig(definition.getTime());
66 }
67
68 public int matchState(Object obj) {
69 if (!isEnabled()) {
70 return MATCH_NO;
71 }
72 if (obj instanceof ProfilerEvent) {
73 ProfilerEvent event = (ProfilerEvent)obj;
74 if (this.time.match(event.getTimestamp())) {
75 if (super.isEmpty()) {
76 return MATCH_YES;
77 } else {
78 return super.matchState(event);
79 }
80 } else {
81 return MATCH_NO;
82 }
83 } else if (obj instanceof EventTimed) {
84 EventTimed event = (EventTimed)obj;
85 return b2Match(this.time.match(event.getTimestamp()));
86 } else {
87 return super.matchState(obj);
88 }
89 }
90
91 public void debug() {
92 super.debug();
93 this.time.debug();
94 }
95 /***
96 * @return
97 */
98 public boolean isEnabled() {
99 return this.enabled;
100 }
101
102 /***
103 * @param enabled
104 */
105 public void setEnabled(boolean enabled) {
106 this.enabled = enabled;
107 }
108
109 /***
110 * @return Description
111 */
112 public String getDescription() {
113 return this. description;
114 }
115
116 /***
117 * @return Returns the timeFrame.
118 */
119 public long getTimeFrame() {
120 return timeFrame;
121 }
122 }