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.opennap.net;
21  
22  import java.io.File;
23  import java.io.Serializable;
24  
25  import org.xnap.plugin.opennap.OpenNapPlugin;
26  
27  /***
28   * 
29   */
30  public class OpenNapDownloadContainerData implements Serializable {
31  
32  	//--- Constant(s) ---
33  
34  	//--- Data Field(s) ---
35  
36  	String filename;
37  	long filesize;
38  	OpenNapSegmentData[] segments;
39  
40  	String searchText = "";
41  	String realm;
42  	boolean autoSearchingEnabled;
43  
44  	transient File resumeFile;
45  
46      //--- Constructor(s) ---
47  
48      public OpenNapDownloadContainerData()
49      {
50  	}
51  
52      //--- Methods ---
53  
54  	public void setAutoSearchingEnabled(String autoSearchingEnabled)
55  	{
56  		if (autoSearchingEnabled == null) {
57  			throw new IllegalArgumentException();
58  		}
59  		this.autoSearchingEnabled = autoSearchingEnabled.equals("true");
60  	}
61  
62  	public void setFilename(String filename)
63  	{
64  		if (filename == null || filename.length() == 0) {
65  			throw new IllegalArgumentException();
66  		}
67  
68  		this.filename = filename;
69  	}
70  
71  	public void setFilesize(String filesize)
72  	{
73  		if (filesize == null) {
74  			throw new IllegalArgumentException();
75  		}
76  
77  		try {
78  			this.filesize = Long.parseLong(filesize);
79  		}
80  		catch (NumberFormatException e) {
81  			throw new IllegalArgumentException();
82  		}
83  	}
84  
85  	public void setRealm(String realm)
86  	{
87  		if (realm != null && !OpenNapPlugin.getSearchManager().isRealm(realm)) {
88  			throw new IllegalArgumentException();
89  		}
90  
91  		this.realm = realm;
92  	}
93  
94  	public void setSearchText(String searchText)
95  	{
96  		if (searchText == null) {
97  			throw new IllegalArgumentException();
98  		}
99  
100 		this.searchText = searchText;
101 	}
102 
103 	public void setSegments(OpenNapSegmentData[] segments)
104 	{
105 		this.segments = segments;
106 	}
107 
108 }