KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > rero > client > server > IgnoreHandler


1 package rero.client.server;
2
3 import java.util.*;
4 import rero.config.*;
5 import rero.util.*;
6
7 /** I don't currently have an "on raw" event that fires before normal processing occurs. So this is called directly from the
8     ServerHandler class and that determines wether or not to halt processing of the event. Kind of a hacked way to do this but
9     it works I guess... *shrug* */

10 public class IgnoreHandler implements ClientStateListener
11 {
12    protected boolean checkIgnore;
13    protected StringList ignoreMasks;
14
15    public void propertyChanged(String JavaDoc prop, String JavaDoc parms) { hash(); }
16
17    public void hash()
18    {
19       ignoreMasks = ClientState.getClientState().getStringList("ignore.masks");
20       checkIgnore = ignoreMasks.getList().size() > 0;
21    }
22
23    public IgnoreHandler()
24    {
25       hash();
26       ClientState.getClientState().addClientStateListener("ignore.masks", this);
27    }
28
29    public boolean isCheckingIgnore()
30    {
31       return checkIgnore;
32    }
33
34    public boolean isIgnore(String JavaDoc nick, String JavaDoc host)
35    {
36       String JavaDoc temp = nick + "!" + host;
37
38       Iterator i = ignoreMasks.getList().iterator();
39       while (i.hasNext())
40       {
41          String JavaDoc mask = (String JavaDoc)i.next();
42          if (StringUtils.iswm(mask, temp))
43             return true;
44       }
45
46       return false;
47    }
48 }
49
50
Popular Tags