Reformat source code, new line length for comments (79), some trailing whitespace...
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / ProtocolError.java
1 /*
2  * jFCPlib - ProtocolError.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  * The “ProtocolError” message signals that something has gone really wrong.
23  *
24  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
25  */
26 public class ProtocolError extends BaseMessage {
27
28         /**
29          * Creates a new “ProtocolError” message that wraps the received message.
30          *
31          * @param receivedMessage
32          *            The received message
33          */
34         ProtocolError(FcpMessage receivedMessage) {
35                 super(receivedMessage);
36         }
37
38         /**
39          * Returns whether the causing message had the “Global” flag set.
40          *
41          * @return <code>true</code> if the causing message had the “Global” flag
42          *         set
43          */
44         public boolean isGlobal() {
45                 return Boolean.valueOf(getField("Global"));
46         }
47
48         /**
49          * Returns the error code.
50          *
51          * @return The error code, or <code>-1</code> if the error code could not
52          *         be parsed
53          */
54         public int getCode() {
55                 return FcpUtils.safeParseInt(getField("Code"));
56         }
57
58         /**
59          * Returns the description of the error.
60          *
61          * @return The description of the error
62          */
63         public String getCodeDescription() {
64                 return getField("CodeDescription");
65         }
66
67         /**
68          * Returns some extra description of the error.
69          *
70          * @return Extra description of the error, or <code>null</code> if there is
71          *         none
72          */
73         public String getExtraDescription() {
74                 return getField("ExtraDescription");
75         }
76
77         /**
78          * Returns whether the connection to the node can stay open.
79          *
80          * @return <code>true</code> when the connection has to be closed,
81          *         <code>false</code> otherwise
82          */
83         public boolean isFatal() {
84                 return Boolean.valueOf(getField("Fatal"));
85         }
86
87         /**
88          * The identifier of the causing request, if any.
89          *
90          * @return The identifier of the causing request
91          */
92         public String getIdentifier() {
93                 return getField("Identifier");
94         }
95
96 }