nan.nntp
Interface NNTPClient

All Known Implementing Classes:
NNTPClientImpl

public interface NNTPClient

An interface for NNTP client connections.

Version:
1.7, 12/28/03
Author:
John David Ratliff

Method Summary
 void connect(java.lang.String hostname, int port)
          Connects to the NNTP server.
 void disconnect()
          Disconnects from the server.
 MessageHeader getHeader(int article)
          Gets the MessageHeader of a newsgroup article.
 MessageHeader getHeader(java.lang.String messageId)
          Gets the MessageHeader of a newsgroup article.
 Message getMessage(int article)
          Gets a message from the news server.
 Message getMessage(int article, MessageHeader header)
          Gets a message from the news server.
 Message getMessage(java.lang.String messageId)
          Gets a message from the news server.
 Message getMessage(java.lang.String messageId, MessageHeader header)
          Gets a message from the news server.
 java.util.Iterator getMessagesSince(Newsgroup newsgroup, java.util.Date when)
          Gets the message IDs in an iterator of all messages added to a Newsgroup since a Date.
 NewsgroupList getNewsgroupList()
          Gets the list of available Newsgroups from the NNTP server.
 NewsgroupList getNewsgroupsSince(java.util.Date when)
          Gets the list of Newsgroups added to the server since a Date.
 boolean isConnected()
          Checks if this client is connected.
 boolean isPostingAllowed()
          Checks if posting is allowed on this server.
 boolean post(Message message)
          Posts a message to the NNTP server.
 boolean selectNewsgroup(Newsgroup newsgroup)
          Selects the current Newsgroup.
 

Method Detail

connect

public void connect(java.lang.String hostname,
                    int port)
             throws NNTPConnectException
Connects to the NNTP server.

Parameters:
hostname - The NNTP server's hostname.
port - The NNTP server's port.
Throws:
NNTPConnectException - if the connection failed.

disconnect

public void disconnect()
Disconnects from the server.


isConnected

public boolean isConnected()
Checks if this client is connected.

Returns:
true if this client is connected; false otherwise.

isPostingAllowed

public boolean isPostingAllowed()
Checks if posting is allowed on this server.

Returns:
true if posting is allowed; false otherwise.

getNewsgroupList

public NewsgroupList getNewsgroupList()
                               throws UnconnectedException
Gets the list of available Newsgroups from the NNTP server.

Returns:
The NewsgroupList of available Newsgroups.
Throws:
UnconnectedException - if this client is not connected.

selectNewsgroup

public boolean selectNewsgroup(Newsgroup newsgroup)
                        throws UnconnectedException
Selects the current Newsgroup.

Parameters:
newsgroup - The Newsgroup to select.
Returns:
true if the Newsgroup was selected; false otherwise.
Throws:
UnconnectedException - if this client is not connected.

getHeader

public MessageHeader getHeader(int article)
                        throws UnconnectedException,
                               InvalidArticleException
Gets the MessageHeader of a newsgroup article.

Parameters:
article - The article ID in the current group.
Returns:
The MessageHeader.
Throws:
UnconnectedException - if this client is not connected.
InvalidArticleException - if the article does not exist on this server.

getHeader

public MessageHeader getHeader(java.lang.String messageId)
                        throws UnconnectedException,
                               InvalidArticleException
Gets the MessageHeader of a newsgroup article.

Parameters:
messageId - The message ID of the article.
Returns:
The MessageHeader.
Throws:
UnconnectedException - if this client is not connected.
InvalidArticleException - if the article does not exist on this server.

getMessage

public Message getMessage(int article)
                   throws UnconnectedException,
                          InvalidArticleException
Gets a message from the news server.

Parameters:
article - The article ID in the current group.
Returns:
The Message.
Throws:
UnconnectedException - if this client is not connected.
InvalidArticleException - if the article does not exist on this server.

getMessage

public Message getMessage(int article,
                          MessageHeader header)
                   throws UnconnectedException,
                          InvalidArticleException
Gets a message from the news server. If the MessageHeader argument is null, the MessageHeader will be retrieved as well. If the MessageHeader is not null, it will be added as the MessageHeader of the Message.

Parameters:
article - The article ID in the current group.
header - The MessageHeader of this article.
Returns:
The Message.
Throws:
UnconnectedException - if this client is not connected.
InvalidArticleException - if the article does not exist on this server.

getMessage

public Message getMessage(java.lang.String messageId)
                   throws UnconnectedException,
                          InvalidArticleException
Gets a message from the news server.

Parameters:
messageId - The message ID of the article.
Returns:
The Message.
Throws:
UnconnectedException - if this client is not connected.
InvalidArticleException - if the article does not exist on this server.

getMessage

public Message getMessage(java.lang.String messageId,
                          MessageHeader header)
                   throws UnconnectedException,
                          InvalidArticleException
Gets a message from the news server. If the MessageHeader argument is null, the MessageHeader will be retrieved as well. If the MessageHeader is not null, it will be added as the MessageHeader of the Message.

Parameters:
messageId - The message ID of the article.
header - The MessageHeader of this article.
Returns:
The Message.
Throws:
UnconnectedException - if this client is not connected.
InvalidArticleException - if the article does not exist on this server.

getNewsgroupsSince

public NewsgroupList getNewsgroupsSince(java.util.Date when)
                                 throws UnconnectedException
Gets the list of Newsgroups added to the server since a Date.

Parameters:
when - The Date after which the newsgroups were added.
Returns:
The NewsgroupList of recent newsgroups, which may be empty.
Throws:
UnconnectedException - if this client is not connected.

getMessagesSince

public java.util.Iterator getMessagesSince(Newsgroup newsgroup,
                                           java.util.Date when)
                                    throws UnconnectedException
Gets the message IDs in an iterator of all messages added to a Newsgroup since a Date.

Parameters:
newsgroup - The Newsgroup to check for new messages in.
when - The Date after which the messages were added.
Returns:
An Iterator of the message IDs of the new messages.
Throws:
UnconnectedException - if this client is not connected.

post

public boolean post(Message message)
             throws UnconnectedException
Posts a message to the NNTP server.

Parameters:
message - The Message to post.
Returns:
true if the message was posted; false otherwise.
Throws:
UnconnectedException - if this client is not connected.