e5f043a5cc54085e0c036bfa3aa8883f3b5c9045
[jSite2.git] / src / net / pterodactylus / util / fcp / BaseMessage.java
1 /**
2  * © 2008 INA Service GmbH
3  */
4 package net.pterodactylus.util.fcp;
5
6 import java.util.Map;
7
8 /**
9  * A basic message abstraction that wraps a received FCP message.
10  * 
11  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
12  * @version $Id$
13  */
14 public class BaseMessage {
15
16         /** The received message, wrapped here. */
17         private final FcpMessage receivedMessage;
18
19         /**
20          * Creates a new base message that wraps the given message.
21          * 
22          * @param receivedMessage
23          *            The FCP message that was received
24          */
25         BaseMessage(FcpMessage receivedMessage) {
26                 this.receivedMessage = receivedMessage;
27         }
28
29         /**
30          * Returns the name of the message.
31          * 
32          * @return The name of the message
33          */
34         public String getName() {
35                 return receivedMessage.getName();
36         }
37
38         /**
39          * Returns the content of the field.
40          * 
41          * @param field
42          *            The name of the field
43          * @return The content of the field, or <code>null</code> if there is no
44          *         such field
45          */
46         protected String getField(String field) {
47                 return receivedMessage.getField(field);
48         }
49
50         /**
51          * Returns all fields from the received message.
52          * 
53          * @see FcpMessage#getFields()
54          * @return All fields from the message
55          */
56         protected Map<String, String> getFields() {
57                 return receivedMessage.getFields();
58         }
59
60 }