rename fcplib to jFCPlib
[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  * @version $Id$
28  */
29 public class ConfigData extends BaseMessage {
30
31         /**
32          * Creates a new “ConfigData” message that wraps the received message.
33          * 
34          * @param receivedMessage
35          *            The received message
36          */
37         ConfigData(FcpMessage receivedMessage) {
38                 super(receivedMessage);
39         }
40
41         /**
42          * Returns the current value of the given option.
43          * 
44          * @param option
45          *            The name of the option
46          * @return The current value of the option
47          */
48         public String getCurrent(String option) {
49                 return getField("current." + option);
50         }
51
52         /**
53          * Returns the short description of the given option.
54          * 
55          * @param option
56          *            The name of the option
57          * @return The short description of the option
58          */
59         public String getShortDescription(String option) {
60                 return getField("shortDescription." + option);
61         }
62
63         /**
64          * Returns the long description of the given option.
65          * 
66          * @param option
67          *            The name of the option
68          * @return The long description of the option
69          */
70         public String getLongDescription(String option) {
71                 return getField("longDescription." + option);
72         }
73
74         /**
75          * Returns the data type of the given option.
76          * 
77          * @param option
78          *            The name of the option
79          * @return The data type of the option
80          */
81         public String getDataType(String option) {
82                 return getField("dataType." + option);
83         }
84
85         /**
86          * Returns the default value of the given option.
87          * 
88          * @param option
89          *            The name of the option
90          * @return The default value of the option
91          */
92         public String getDefault(String option) {
93                 return getField("default." + option);
94         }
95
96         /**
97          * Returns the sort order of the given option.
98          * 
99          * @param option
100          *            The name of the option
101          * @return The sort order of the option, or <code>-1</code> if the sort
102          *         order could not be parsed
103          */
104         public int getSortOrder(String option) {
105                 return FcpUtils.safeParseInt(getField("sortOrder." + option));
106         }
107
108         /**
109          * Returns the expert flag of the given option.
110          * 
111          * @param option
112          *            The name of the option
113          * @return The expert flag of the option
114          */
115         public boolean getExpertFlag(String option) {
116                 return Boolean.valueOf(getField("expertFlag." + option));
117         }
118
119         /**
120          * Returns the force-write flag of the given option
121          * 
122          * @param option
123          *            The name of the option
124          * @return The force-write flag of the given option
125          */
126         public boolean getForceWriteFlag(String option) {
127                 return Boolean.valueOf(getField("forceWriteFlag." + option));
128         }
129
130 }