KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
22 import java.util.Map JavaDoc;
23
24 import net.sf.drftpd.master.usermanager.User;
25
26 import org.drftpd.plugins.SiteBot;
27 import org.jdom.Element;
28
29 /**
30  * @author mog
31  *
32  * @version $Id: NukeEvent.java,v 1.20 2004/03/26 00:16:32 mog Exp $
33  */

34 public class NukeEvent extends UserEvent {
35     private int multiplier;
36     private long nukedAmount;
37     private Map JavaDoc nukees;
38     private String JavaDoc path;
39
40     private String JavaDoc reason;
41     private long size;
42
43     public NukeEvent(
44         User user,
45         String JavaDoc command,
46         String JavaDoc path,
47         long size,
48         long nukedAmount,
49         int multiplier,
50         String JavaDoc reason,
51         Map JavaDoc nukees) {
52         this(
53             user,
54             command,
55             path,
56             System.currentTimeMillis(),
57             size,
58             nukedAmount,
59             multiplier,
60             reason,
61             nukees);
62     }
63     /**
64      * @param user
65      * @param preNukeName
66      * @param multiplier
67      * @param nukees
68      */

69     public NukeEvent(
70         User user,
71         String JavaDoc command,
72         String JavaDoc path,
73         long time,
74         long size,
75         long nukedAmount,
76         int multiplier,
77         String JavaDoc reason,
78         Map JavaDoc nukees) {
79         super(user, command, time);
80         this.multiplier = multiplier;
81         this.reason = reason;
82         this.path = path;
83         this.nukees = nukees;
84         this.size = size;
85         this.nukedAmount = nukedAmount;
86     }
87
88     public int getMultiplier() {
89         return multiplier;
90     }
91
92     public long getNukedAmount() {
93         return nukedAmount;
94     }
95
96     /**
97      * String username as key
98      * Integer debt as value
99      * @deprecated
100      */

101     public Map JavaDoc getNukees() {
102         return nukees;
103     }
104
105     /**
106      * Returns a list of <code>net.sf.drftpd.Nukee</code> objects.
107      * @return a list of <code>net.sf.drftpd.Nukee</code> objects.
108      * @see net.sf.drftpd.Nukee
109      */

110     public List JavaDoc getNukees2() {
111         return SiteBot.map2nukees(nukees);
112     }
113
114     public String JavaDoc getPath() {
115         return path;
116     }
117
118     public String JavaDoc getReason() {
119         return reason;
120     }
121
122     public long getSize() {
123         return size;
124     }
125
126     public void setReason(String JavaDoc string) {
127         reason = string;
128     }
129
130     public Element toJDOM() {
131         Element element = new Element("nuke");
132         element.addContent(
133             new Element("user").setText(this.getUser().getUsername()));
134         element.addContent(new Element("path").setText(this.getPath()));
135         element.addContent(
136             new Element("multiplier").setText(
137                 Integer.toString(this.getMultiplier())));
138         element.addContent(new Element("reason").setText(this.getReason()));
139         element.addContent(
140             new Element("time").setText(Long.toString(this.getTime())));
141
142         element.addContent(
143             new Element("size").setText(Long.toString(getSize())));
144         element.addContent(
145             new Element("nukedAmount").setText(
146                 Long.toString(getNukedAmount())));
147
148         Element nukees = new Element("nukees");
149         for (Iterator JavaDoc iter = this.getNukees().entrySet().iterator();
150             iter.hasNext();
151             ) {
152             Map.Entry JavaDoc entry = (Map.Entry JavaDoc) iter.next();
153             String JavaDoc username = (String JavaDoc) entry.getKey();
154             Long JavaDoc amount = (Long JavaDoc) entry.getValue();
155             Element nukee = new Element("nukee");
156             nukee.addContent(new Element("username").setText(username));
157             nukee.addContent(new Element("amount").setText(amount.toString()));
158             nukees.addContent(nukee);
159         }
160         element.addContent(nukees);
161         return element;
162     }
163
164     public String JavaDoc toString() {
165         return "[NUKE:" + getPath() + ",multiplier=" + getMultiplier() + "]";
166     }
167
168 }
169
Popular Tags