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.util;
21  
22  import org.xnap.util.AbstractPluginPreferences;
23  import org.xnap.util.prefs.IntValidator;
24  
25  public class GiFTPreferences extends AbstractPluginPreferences {
26  
27      //--- Constant(s) ---
28  
29      private static final int VERSION = 1;
30  
31      //--- Data field(s) ---
32  
33      private static GiFTPreferences singleton = null;
34  
35      //--- Constructor(s) ---
36  
37      private GiFTPreferences()
38      {
39  		super("plugin.gift", VERSION);
40  
41  		setDefault("daemon", "");
42  		setDefault("host", "127.0.0.1");
43  		setDefault("port", "1213", new IntValidator(0));
44  		setDefault("httpport", "1216", new IntValidator(0));
45  		setDefault("autoconnect", "true");
46  		setDefault("startDaemon", "false");
47      }
48  
49      //--- Method(s) ---
50  
51      public static synchronized GiFTPreferences getInstance() {
52  		if (singleton == null) {
53  			singleton = new GiFTPreferences();
54  		}
55  
56  		return singleton;
57      }
58  
59      public void destroy() {
60  		singleton = null;
61      }
62  
63      public String getGiftDaemon() {
64          return get("daemon");
65      }
66  
67      public void setGiftDaemon(String newValue) {
68  		set("daemon", newValue);
69      }    
70  
71      public String getGiftHost() {
72  		return get("host");
73      }
74  
75      public void setGiftHost(String newValue) {
76  		set("host", newValue);
77      }    
78  
79      public int getDaemonPort() {
80          return getInt("port");
81      }
82  
83      public void setDaemonPort(int newValue) {
84  		set("port", newValue);
85      }
86  
87  	public int getHttpPort() {
88  		return getInt("httpport");
89  	}
90  
91  	public void setHttpPort(int newValue) {
92  		set("httpport", newValue);
93  	}
94  
95  	public boolean getAutoconnect()
96  	{
97  		return getBoolean("autoconnect");
98  	}
99  
100 	public void setAutoconnect(boolean newValue)
101 	{
102 		set("autoconnect", newValue);
103 	}
104 
105 	public boolean getStartDaemon()
106 	{
107 		return getBoolean("startDaemon");
108 	}
109 
110 	public void setStartDaemon(boolean newValue)
111 	{
112 		set("startDaemon", newValue);
113 	}
114 
115 	/***
116 	 * @see xnap.util.AbstractPreferences#convert(int)
117 	 */
118 	public void convert(int oldVersion) {
119 		// TODO
120 	}
121 
122 }