View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.plugin.gift.net.event;
21  
22  import java.util.Enumeration;
23  import java.util.Hashtable;
24  
25  
26  /***
27   * ShareItemEvent
28   *
29   * @author <a href="mailto:tvanlessen@taval.de">Tammo van Lessen</a>
30   * @version CVS $Id: ShareItemEvent.java,v 1.1 2003/10/05 00:20:32 squig Exp $
31   */
32  public class ShareItemEvent extends Event {
33      //~ Instance fields --------------------------------------------------------
34  
35      private Hashtable meta;
36      private String hash;
37      private String mime;
38      private String path;
39      private long size;
40  
41      //~ Constructors -----------------------------------------------------------
42  
43      /***
44       * Constructor for ShareItemEvent.
45       */
46      public ShareItemEvent() {
47          super();
48          meta = new Hashtable();
49      }
50  
51      //~ Methods ----------------------------------------------------------------
52  
53      /***
54       * Sets the hash.
55       *
56       * @param hash The hash to set
57       */
58      public void setHash(String hash) {
59          this.hash = hash;
60      }
61  
62      /***
63       * Returns the hash.
64       *
65       * @return String
66       */
67      public String getHash() {
68          return hash;
69      }
70  
71      /***
72       * Returns the meta object specified by name
73       *
74       * @param name
75       *
76       * @return meta object
77       */
78      public Object getMetaItem(String name) {
79          return meta.get(name);
80      }
81  
82      /***
83       * Returns all meta tags
84       *
85       * @return all meta tag names
86       */
87      public Enumeration getMetaTags() {
88          return meta.elements();
89      }
90  
91      /***
92       * Sets the mime type.
93       *
94       * @param mime The mime to set
95       */
96      public void setMime(String mime) {
97          this.mime = mime;
98      }
99  
100     /***
101      * Returns the mime type.
102      *
103      * @return String
104      */
105     public String getMime() {
106         return mime;
107     }
108 
109     /***
110      * Sets the path.
111      *
112      * @param path The path to set
113      */
114     public void setPath(String path) {
115         this.path = path;
116     }
117 
118     /***
119      * Returns the path.
120      *
121      * @return String
122      */
123     public String getPath() {
124         return path;
125     }
126 
127     /***
128      * Sets the size.
129      *
130      * @param size The size to set
131      */
132     public void setSize(long size) {
133         this.size = size;
134     }
135 
136     /***
137      * Returns the size.
138      *
139      * @return long
140      */
141     public long getSize() {
142         return size;
143     }
144 
145     /***
146      * Adds a meta object
147      *
148      * @param name
149      * @param item
150      */
151     public void addMetaItem(String name, Object item) {
152         meta.put(name, item);
153     }
154 
155     /***
156      * @see java.lang.Object#toString()
157      */
158     public String toString() {
159         return path + "@SharesItemEvent";
160     }
161 }