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