remove $Id$ keyword
[jFCPlib.git] / src / net / pterodactylus / fcp / ConfigData.java
1 /*
2  * jSite2 - ConfigData.java -
3  * Copyright © 2008 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
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 net.pterodactylus.fcp;
21
22 /**
23  * A “ConfigData” message contains various aspects of the node’s configuration.
24  * 
25  * @see GetConfig
26  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
27  */
28 public class ConfigData extends BaseMessage {
29
30         /**
31          * Creates a new “ConfigData” message that wraps the received message.
32          * 
33          * @param receivedMessage
34          *            The received message
35          */
36         ConfigData(FcpMessage receivedMessage) {
37                 super(receivedMessage);
38         }
39
40         /**
41          * Returns the current value of the given option.
42          * 
43          * @param option
44          *            The name of the option
45          * @return The current value of the option
46          */
47         public String getCurrent(String option) {
48                 return getField("current." + option);
49         }
50
51         /**
52          * Returns the short description of the given option.
53          * 
54          * @param option
55          *            The name of the option
56          * @return The short description of the option
57          */
58         public String getShortDescription(String option) {
59                 return getField("shortDescription." + option);
60         }
61
62         /**
63          * Returns the long description of the given option.
64          * 
65          * @param option
66          *            The name of the option
67          * @return The long description of the option
68          */
69         public String getLongDescription(String option) {
70                 return getField("longDescription." + option);
71         }
72
73         /**
74          * Returns the data type of the given option.
75          * 
76          * @param option
77          *            The name of the option
78          * @return The data type of the option
79          */
80         public String getDataType(String option) {
81                 return getField("dataType." + option);
82         }
83
84         /**
85          * Returns the default value of the given option.
86          * 
87          * @param option
88          *            The name of the option
89          * @return The default value of the option
90          */
91         public String getDefault(String option) {
92                 return getField("default." + option);
93         }
94
95         /**
96          * Returns the sort order of the given option.
97          * 
98          * @param option
99          *            The name of the option
100          * @return The sort order of the option, or <code>-1</code> if the sort
101          *         order could not be parsed
102          */
103         public int getSortOrder(String option) {
104                 return FcpUtils.safeParseInt(getField("sortOrder." + option));
105         }
106
107         /**
108          * Returns the expert flag of the given option.
109          * 
110          * @param option
111          *            The name of the option
112          * @return The expert flag of the option
113          */
114         public boolean getExpertFlag(String option) {
115                 return Boolean.valueOf(getField("expertFlag." + option));
116         }
117
118         /**
119          * Returns the force-write flag of the given option
120          * 
121          * @param option
122          *            The name of the option
123          * @return The force-write flag of the given option
124          */
125         public boolean getForceWriteFlag(String option) {
126                 return Boolean.valueOf(getField("forceWriteFlag." + option));
127         }
128
129 }