X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Ffcp%2FFcpMessage.java;h=d9fff9b85d75771e49fb73bf6cbd2830bfb96d65;hb=24c7c279c67bd5fe34bfef81e1ab936d7b555b3a;hp=b238db3f7b297ab93a29ab18cab962fe5a469782;hpb=508624458578f01a393f8b44f32b98b40054fdc8;p=jFCPlib.git diff --git a/src/main/java/net/pterodactylus/fcp/FcpMessage.java b/src/main/java/net/pterodactylus/fcp/FcpMessage.java index b238db3..d9fff9b 100644 --- a/src/main/java/net/pterodactylus/fcp/FcpMessage.java +++ b/src/main/java/net/pterodactylus/fcp/FcpMessage.java @@ -59,9 +59,9 @@ public class FcpMessage implements Iterable { } /** - * Creates a new FCP message with the given name and the given payload input - * stream. The payload input stream is not read until the message is sent to - * the node using {@link FcpConnection#sendMessage(FcpMessage)}. + * Creates a new FCP message with the given name and the given payload + * input stream. The payload input stream is not read until the message is + * sent to the node using {@link FcpConnection#sendMessage(FcpMessage)}. * * @param name * The name of the message @@ -87,8 +87,8 @@ public class FcpMessage implements Iterable { * * @param field * The name of the field to check for - * @return true if the message has a field with the given name, - * false otherwise + * @return true if the message has a field with the given + * name, false otherwise */ public boolean hasField(String field) { return fields.containsKey(field); @@ -110,6 +110,11 @@ public class FcpMessage implements Iterable { fields.put(field, value); } + public FcpMessage put(String field, String value) { + setField(field, value); + return this; + } + /** * Returns the value of the given field. * @@ -134,6 +139,7 @@ public class FcpMessage implements Iterable { /** * {@inheritDoc} */ + @Override public Iterator iterator() { return fields.keySet().iterator(); } @@ -152,8 +158,8 @@ public class FcpMessage implements Iterable { * Writes this message to the given output stream. If the message has a * payload (i.e. {@link #payloadInputStream} is not null) the * payload is written to the given output stream after the message as well. - * That means that this method can only be called once because on the second - * invocation the payload input stream could not be read (again). + * That means that this method can only be called once because on the + * second invocation the payload input stream could not be read (again). * * @param outputStream * The output stream to write the message to