git-svn-id: http://trooper/svn/projects/jFCPlib/branch/high-level-client@840
c3eda9e8-030b-0410-8277-
bc7414b0a119
* An FCP message. FCP messages consist of a name, an arbitrary amount of
* “fields” (i.e. key-value pairs), a message end marker, and optional payload
* data that follows the marker.
* An FCP message. FCP messages consist of a name, an arbitrary amount of
* “fields” (i.e. key-value pairs), a message end marker, and optional payload
* data that follows the marker.
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
/**
* Creates a new FCP message with the given name.
/**
* Creates a new FCP message with the given name.
* @param name
* The name of the FCP message
*/
* @param name
* The name of the FCP message
*/
* 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
* @param payloadInputStream
* @param name
* The name of the message
* @param payloadInputStream
/**
* Returns the name of the message.
/**
* Returns the name of the message.
* @return The name of the message
*/
public String getName() {
* @return The name of the message
*/
public String getName() {
/**
* Checks whether this message has a field with the given name.
/**
* Checks whether this message has a field with the given name.
* @param field
* The name of the field to check for
* @return <code>true</code> if the message has a field with the given
* @param field
* The name of the field to check for
* @return <code>true</code> if the message has a field with the given
/**
* Sets the field with the given name to the given value. If the field
* already exists in this message it is overwritten.
/**
* Sets the field with the given name to the given value. If the field
* already exists in this message it is overwritten.
* @param field
* The name of the field
* @param value
* @param field
* The name of the field
* @param value
/**
* Returns the value of the given field.
/**
* Returns the value of the given field.
* @param field
* The name of the field
* @return The value of the field, or <code>null</code> if there is no
* @param field
* The name of the field
* @return The value of the field, or <code>null</code> if there is no
/**
* Returns all fields of this message.
/**
* Returns all fields of this message.
* @return All fields of this message
*/
public Map<String, String> getFields() {
* @return All fields of this message
*/
public Map<String, String> getFields() {
/**
* Sets the payload input stream of the message.
/**
* Sets the payload input stream of the message.
* @param payloadInputStream
* The payload input stream
*/
* @param payloadInputStream
* The payload input stream
*/
* 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).
* 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).
* @param outputStream
* The output stream to write the message to
* @throws IOException
* @param outputStream
* The output stream to write the message to
* @throws IOException
outputStream.flush();
if (payloadInputStream != null) {
FcpUtils.copy(payloadInputStream, outputStream);
outputStream.flush();
if (payloadInputStream != null) {
FcpUtils.copy(payloadInputStream, outputStream);
/**
* Writes the given line (followed by {@link #LINEFEED} to the given output
* stream, using UTF-8 as encoding.
/**
* Writes the given line (followed by {@link #LINEFEED} to the given output
* stream, using UTF-8 as encoding.
* @param outputStream
* The output stream to write to
* @param line
* @param outputStream
* The output stream to write to
* @param line