7befff4f842111e41c844eb9c8b1e65d8c0a9984
[jSite2.git] / src / net / pterodactylus / util / fcp / ProtocolError.java
1 /**
2  * © 2008 INA Service GmbH
3  */
4 package net.pterodactylus.util.fcp;
5
6 /**
7  * The “ProtocolError” message signals that something has gone really wrong.
8  * 
9  * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
10  * @version $Id$
11  */
12 public class ProtocolError extends BaseMessage {
13
14         /**
15          * Creates a new “ProtocolError” message that wraps the received message.
16          * 
17          * @param receivedMessage
18          *            The received message
19          */
20         ProtocolError(FcpMessage receivedMessage) {
21                 super(receivedMessage);
22         }
23
24         /**
25          * Returns whether the causing message had the “Global” flag set.
26          * 
27          * @return <code>true</code> if the causing message had the “Global” flag
28          *         set
29          */
30         public boolean isGlobal() {
31                 return Boolean.valueOf(getField("Global"));
32         }
33
34         /**
35          * Returns the error code.
36          * 
37          * @return The error code, or <code>-1</code> if the error code could not
38          *         be parsed
39          */
40         public int getCode() {
41                 return FcpUtils.safeParseInt(getField("Code"));
42         }
43
44         /**
45          * Returns the description of the error.
46          * 
47          * @return The description of the error
48          */
49         public String getCodeDescription() {
50                 return getField("CodeDescription");
51         }
52
53         /**
54          * Returns some extra description of the error.
55          * 
56          * @return Extra description of the error, or <code>null</code> if there
57          *         is none
58          */
59         public String getExtraDescription() {
60                 return getField("ExtraDescription");
61         }
62
63         /**
64          * Returns whether the connection to the node can stay open.
65          * 
66          * @return <code>true</code> when the connection has to be closed,
67          *         <code>false</code> otherwise
68          */
69         public boolean isFatal() {
70                 return Boolean.valueOf(getField("Fatal"));
71         }
72
73         /**
74          * The identifier of the causing request, if any.
75          * 
76          * @return The identifier of the causing request
77          */
78         public String getIdentifier() {
79                 return getField("Identifier");
80         }
81
82 }