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