Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.nntp
Class NNTPResponseBuffer

java.lang.Object
  extended by com.jivesoftware.forum.nntp.NNTPResponseBuffer
All Implemented Interfaces:
NNTPResponse
Direct Known Subclasses:
NewNewsResponse, NewsGroupListResponse, XHDRResponse, XOverResponse

public class NNTPResponseBuffer
extends java.lang.Object
implements NNTPResponse

A simple tool for building dynamic responses.

NNTP responses have an integer response code, a line of text describing the response, and possibly continuation text that is terminated by a '.'.


Field Summary
 
Fields inherited from interface com.jivesoftware.forum.nntp.NNTPResponse
DOT_TERMINATOR, ENDLINE
 
Constructor Summary
NNTPResponseBuffer(Connection connection, int val)
          Create a simple NNTP response with the given response value.
NNTPResponseBuffer(Connection connection, int val, java.lang.String text, boolean continued)
          Create a simple NNTP response with the given response value and the response text on the first line of the response.
 
Method Summary
 NNTPResponseBuffer append(java.lang.String text)
          Append the given text to the response.
 NNTPResponseBuffer appendBulkText(java.lang.String text)
          Append a large quantity of text to the response buffer.
 void appendLine(java.lang.String text)
          Append the given text followed by an NNTP line end CR-LF pair.
 NNTPResponseBuffer appendParameter(java.lang.String text)
          Append a space (' ') followed by the given text to the response.
 NNTPResponseBuffer appendXParameter(java.lang.String text)
          Append a tab ('\t') followed by the given text to the response.
 NNTPResponseBuffer close()
          Closes the response buffer and prevents any further appends to occur.
 void endLine()
          Append an NNTP line end CR-LF pair.
 void flush()
           
 int getValue()
          Returns the int value associated with the response.
 void send(Connection con)
          Sends the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NNTPResponseBuffer

public NNTPResponseBuffer(Connection connection,
                          int val)
                   throws java.io.IOException

Create a simple NNTP response with the given response value.

The response will be terminated with a trailing '.' if it contains more than one line of text.

Parameters:
val - the NNTP response code
connection - the connection.
Throws:
java.io.IOException - if initial writes to the buffer for opening response line fails.

NNTPResponseBuffer

public NNTPResponseBuffer(Connection connection,
                          int val,
                          java.lang.String text,
                          boolean continued)
                   throws java.io.IOException

Create a simple NNTP response with the given response value and the response text on the first line of the response.

Parameters:
connection - the connection to write data to.
val - The response code
text - The first line response text or null to append it later
continued - True if a trailing '.' should be forced onto the end of the message. If the value is false, a trailing '.' will still be added if the response has more than one line.
Throws:
java.io.IOException - if initial writes to the buffer for opening response line fails.
Method Detail

getValue

public int getValue()
Description copied from interface: NNTPResponse
Returns the int value associated with the response.

Specified by:
getValue in interface NNTPResponse
Returns:
the int value of the enum.

send

public void send(Connection con)
          throws java.io.IOException
Description copied from interface: NNTPResponse

Sends the response.

Specified by:
send in interface NNTPResponse
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

close

public NNTPResponseBuffer close()
                         throws java.io.IOException
Closes the response buffer and prevents any further appends to occur.

Returns:
NNTPResponseBuffer this response buffer for call chaning
Throws:
java.io.IOException - if writes to the buffer for closing response fails.

append

public NNTPResponseBuffer append(java.lang.String text)
                          throws java.io.IOException

Append the given text to the response.

The method allows method chaining by returning the response for further appends (e.g. response.appendParameter("bob").appendParameter("sally");).

Parameters:
text - The text to add (null adds nothing)
Returns:
The buffer to allow call chaining
Throws:
java.io.IOException - if writes to the buffer fails due to underlying connection errors.

appendParameter

public NNTPResponseBuffer appendParameter(java.lang.String text)
                                   throws java.io.IOException

Append a space (' ') followed by the given text to the response.

Many NNTP responses will contain several space separated parameters on a single line. This convenience method allows the addition of these parameters.

The method allows method chaining by returning the response for further appends (e.g. response.appendParameter("bob").appendParameter("sally");).

Parameters:
text - The text to add (null adds the space but nothing else)
Returns:
The buffer to allow call chaining
Throws:
java.io.IOException - if writes to the buffer fails due to underlying connection errors.

appendXParameter

public NNTPResponseBuffer appendXParameter(java.lang.String text)
                                    throws java.io.IOException

Append a tab ('\t') followed by the given text to the response.

Many X NNTP extension responses will contain several tab separated parameters on a single line. This convenience method allows the addition of these parameters.

The method allows method chaining by returning the response for further appends (e.g. response.appendParameter("bob").appendParameter("sally");).

Parameters:
text - The text to add (null adds the space but nothing else)
Returns:
The buffer to allow call chaining
Throws:
java.io.IOException - if writes to the buffer fails due to underlying connection errors.

endLine

public void endLine()
             throws java.io.IOException

Append an NNTP line end CR-LF pair.

Throws:
java.io.IOException - if writes to the buffer fails due to underlying connection errors.

appendLine

public void appendLine(java.lang.String text)
                throws java.io.IOException

Append the given text followed by an NNTP line end CR-LF pair.

Parameters:
text - The text to append (or null to just add an end line)
Throws:
java.io.IOException - if writes to the buffer fails due to underlying connection errors.

appendBulkText

public NNTPResponseBuffer appendBulkText(java.lang.String text)
                                  throws java.io.IOException
Append a large quantity of text to the response buffer. The response buffer will ensure that the platform specific line end characters are properly converted to the NNTP line ends, and that any beginning line dot characters are turned into double dots.

Parameters:
text - The text to add to the response buffer
Returns:
The buffer to allow call chaining
Throws:
java.io.IOException - if writes to the buffer fails due to underlying connection errors.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.