KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > drftpd > event > UserEvent


1 /*
2  * This file is part of DrFTPD, Distributed FTP Daemon.
3  *
4  * DrFTPD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * DrFTPD is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with DrFTPD; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package net.sf.drftpd.event;
19
20 import net.sf.drftpd.event.listeners.Trial;
21 import net.sf.drftpd.master.usermanager.User;
22
23 /**
24  * @author mog
25  *
26  * Dispatched for LOGIN, LOGOUT and RELOAD.
27  *
28  * Subclassed for events that are paired with a user object.
29  * @version $Id: UserEvent.java,v 1.10 2004/06/01 15:40:26 mog Exp $
30  */

31 public class UserEvent extends Event {
32     public static String JavaDoc getCommandFromPeriod(int period) {
33         switch (period) {
34             case Trial.PERIOD_DAILY :
35                 return "RESETDAY";
36             case Trial.PERIOD_MONTHLY :
37                 return "RESETMONTH";
38             case Trial.PERIOD_WEEKLY :
39                 return "RESETWEEK";
40             default :
41                 throw new RuntimeException JavaDoc();
42         }
43     }
44     User user;
45     public UserEvent(User user, int period, long time) {
46         this(user, getCommandFromPeriod(period), time);
47     }
48     public UserEvent(User user, String JavaDoc command) {
49         this(user, command, System.currentTimeMillis());
50     }
51     public UserEvent(User user, String JavaDoc command, long time) {
52         super(command, time);
53         this.user = user;
54     }
55
56     public User getUser() {
57         return user;
58     }
59
60     public void setUser(User user) {
61         this.user = user;
62     }
63
64     public String JavaDoc toString() {
65         return getClass().getName()
66             + "[user="
67             + getUser()
68             + ",cmd="
69             + getCommand()
70             + "]";
71     }
72 }
73
Popular Tags