add ListPeerNote command and replies
[jSite2.git] / src / net / pterodactylus / util / fcp / message / PeerNote.java
1 /**
2  * © 2008 INA Service GmbH
3  */
4 package net.pterodactylus.util.fcp.message;
5
6 import net.pterodactylus.util.fcp.FcpMessage;
7
8 /**
9  * The “PeerNote” message contains a private note that has been entered for a
10  * darknet peer.
11  * 
12  * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
13  * @version $Id$
14  */
15 public class PeerNote extends BaseMessage {
16
17         /** The type for base64 encoded peer notes. */
18         public static final int NOTE_TYPE_BASE64 = 1;
19
20         /**
21          * Creates a “PeerNote” message that wraps the recevied message.
22          * 
23          * @param receivedMessage
24          *            The received message
25          */
26         public PeerNote(FcpMessage receivedMessage) {
27                 super(receivedMessage);
28         }
29
30         /**
31          * Returns the note text in whatever format is specified by
32          * {@link #getPeerNoteType()}.
33          * 
34          * @return The note text
35          */
36         public String getNoteText() {
37                 return getField("NoteText");
38         }
39
40         /**
41          * Returns the type of the peer note. The type <code>1</code> means that
42          * the text of the note is base64-encoded.
43          * 
44          * @return The type of the peer note
45          * @throws NumberFormatException
46          *             if the field can not be parsed
47          */
48         public int getPeerNoteType() throws NumberFormatException {
49                 return Integer.valueOf(getField("PeerNoteType"));
50         }
51
52 }