|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.inet.nntp.NNTPConnection
public class NNTPConnection
An NNTP client. This object is used to establish and manage a connection to an NNTP server.
Field Summary | |
---|---|
protected boolean |
canPost
Whether the host permits posting of articles. |
static int |
DEFAULT_PORT
The default NNTP port. |
protected java.lang.String |
hostname
The hostname of the host we are connected to. |
protected LineInputStream |
in
The socket input stream. |
static java.util.logging.Logger |
logger
The logger used for NNTP protocol traces. |
static java.util.logging.Level |
NNTP_TRACE
The network trace level. |
protected CRLFOutputStream |
out
The socket output stream. |
protected PendingData |
pendingData
Pending data, if any. |
protected int |
port
The port on the host we are connected to. |
protected java.net.Socket |
socket
The socket used for network communication. |
protected java.lang.String |
welcome
The greeting issued by the host when we connected. |
Constructor Summary | |
---|---|
NNTPConnection(java.lang.String hostname)
Creates a new connection object. |
|
NNTPConnection(java.lang.String hostname,
int port)
Creates a new connection object. |
|
NNTPConnection(java.lang.String hostname,
int port,
int connectionTimeout,
int timeout)
Creates a new connection object. |
Method Summary | |
---|---|
ArticleResponse |
article(int articleNumber)
Send an article retrieval request to the server. |
ArticleResponse |
article(java.lang.String messageId)
Send an article retrieval request to the server. |
protected ArticleResponse |
articleImpl(java.lang.String command,
java.lang.String messageId)
Performs an ARTICLE, BODY, HEAD, or STAT command. |
boolean |
authinfo(java.lang.String username,
java.lang.String password)
Basic authentication strategy. |
boolean |
authinfoGeneric(java.lang.String mechanism,
java.lang.String username,
java.lang.String password)
Authenticates the connection using the specified SASL mechanism, username and password. |
boolean |
authinfoSimple(java.lang.String username,
java.lang.String password)
Implementation of NNTP simple authentication. |
ArticleResponse |
body(int articleNumber)
Send an article body retrieval request to the server. |
ArticleResponse |
body(java.lang.String messageId)
Send an article body retrieval request to the server. |
boolean |
check(java.lang.String messageId)
|
java.util.Date |
date()
Returns the date on the server. |
java.lang.String |
getWelcome()
Return the welcome message sent by the server in reply to the initial connection. |
GroupResponse |
group(java.lang.String name)
Send a group selection command to the server. |
ArticleResponse |
head(int articleNumber)
Send an article head retrieval request to the server. |
ArticleResponse |
head(java.lang.String messageId)
Send an article head retrieval request to the server. |
LineIterator |
help()
Requests a help listing. |
PostStream |
ihave(java.lang.String messageId)
Sends an ihave command indicating that the client has an article with the specified message-id. |
ArticleResponse |
last()
Sends a previous article positioning command to the server. |
GroupIterator |
list()
Send a group listing command to the server. |
GroupIterator |
listActive(java.lang.String wildmat)
Returns an iterator over the groups specified according to the wildmat pattern. |
ActiveTimesIterator |
listActiveTimes()
Returns an iterator over the active.times file. |
ArticleNumberIterator |
listGroup(java.lang.String group)
Returns a listing of all the article numbers in the specified newsgroup. |
PairIterator |
listNewsgroups(java.lang.String wildmat)
Returns an iterator over the group descriptions for the given groups. |
LineIterator |
listOverviewFmt()
Returns an iterator over the order in which headers are stored in the overview database. |
GroupIterator |
listSubscriptions()
Returns a list of newsgroups suitable for new users of the server. |
boolean |
modeReader()
Indicates to the server that this is a user-agent. |
boolean |
modeStream()
Attempt to initialise the connection in streaming mode. |
LineIterator |
newGroups(java.util.Date since,
java.lang.String[] distributions)
Returns an iterator over the list of new groups on the server since the specified date. |
LineIterator |
newNews(java.lang.String newsgroup,
java.util.Date since,
java.lang.String[] distributions)
Returns an iterator over the list of message-ids posted or received to the specified newsgroup(s) since the specified date. |
ArticleResponse |
next()
Sends a next article positioning command to the server. |
protected StatusResponse |
parseResponse(java.lang.String line)
Parse a response object from a response line sent by the server. |
protected StatusResponse |
parseResponse(java.lang.String line,
boolean isListGroup)
Parse a response object from a response line sent by the server. |
java.io.OutputStream |
post()
Post an article. |
void |
quit()
Close the connection. |
protected java.lang.String |
read()
Read a single line from the server. |
protected void |
send(java.lang.String line)
Send a single line to the server. |
void |
slave()
Indicates to the server that this is a slave connection. |
ArticleResponse |
stat(int articleNumber)
Send an article status request to the server. |
ArticleResponse |
stat(java.lang.String messageId)
Send an article status request to the server. |
java.io.OutputStream |
takethis(java.lang.String messageId)
Implements the out-of-order takethis command. |
PairIterator |
xgtitle(java.lang.String wildmat)
Returns an iterator over the list of newsgroup descriptions. |
HeaderIterator |
xhdr(java.lang.String header,
java.lang.String range)
|
OverviewIterator |
xover(Range range)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.logging.Logger logger
public static final java.util.logging.Level NNTP_TRACE
public static final int DEFAULT_PORT
protected java.lang.String hostname
protected int port
protected java.net.Socket socket
protected LineInputStream in
protected CRLFOutputStream out
protected boolean canPost
protected java.lang.String welcome
protected PendingData pendingData
Constructor Detail |
---|
public NNTPConnection(java.lang.String hostname) throws java.io.IOException
hostname
- the hostname or IP address of the news server
java.io.IOException
public NNTPConnection(java.lang.String hostname, int port) throws java.io.IOException
hostname
- the hostname or IP address of the news serverport
- the port to connect to
java.io.IOException
public NNTPConnection(java.lang.String hostname, int port, int connectionTimeout, int timeout) throws java.io.IOException
hostname
- the hostname or IP address of the news serverport
- the port to connect toconnectionTimeout
- the socket connection timeouttimeout
- the read timeout on the socket
java.io.IOException
Method Detail |
---|
public java.lang.String getWelcome()
public ArticleResponse article(int articleNumber) throws java.io.IOException
articleNumber
- the article number of the article to retrieve
java.io.IOException
public ArticleResponse article(java.lang.String messageId) throws java.io.IOException
messageId
- the message-id of the article to retrieve
java.io.IOException
public ArticleResponse head(int articleNumber) throws java.io.IOException
articleNumber
- the article number of the article to head
java.io.IOException
public ArticleResponse head(java.lang.String messageId) throws java.io.IOException
messageId
- the message-id of the article to head
java.io.IOException
public ArticleResponse body(int articleNumber) throws java.io.IOException
articleNumber
- the article number of the article to body
java.io.IOException
public ArticleResponse body(java.lang.String messageId) throws java.io.IOException
messageId
- the message-id of the article to body
java.io.IOException
public ArticleResponse stat(int articleNumber) throws java.io.IOException
articleNumber
- the article number of the article to stat
java.io.IOException
public ArticleResponse stat(java.lang.String messageId) throws java.io.IOException
messageId
- the message-id of the article to stat
java.io.IOException
protected ArticleResponse articleImpl(java.lang.String command, java.lang.String messageId) throws java.io.IOException
command
- one of the above commandsmessageId
- the article-number or message-id in string form
java.io.IOException
public GroupResponse group(java.lang.String name) throws java.io.IOException
name
- the name of the group to select
java.io.IOException
public LineIterator help() throws java.io.IOException
java.io.IOException
public PostStream ihave(java.lang.String messageId) throws java.io.IOException
messageId
- the article message-id
java.io.IOException
public ArticleResponse last() throws java.io.IOException
java.io.IOException
public GroupIterator list() throws java.io.IOException
java.io.IOException
public LineIterator newGroups(java.util.Date since, java.lang.String[] distributions) throws java.io.IOException
since
- the date from which to list new groupsdistributions
- if non-null, an array of distributions to match
java.io.IOException
public LineIterator newNews(java.lang.String newsgroup, java.util.Date since, java.lang.String[] distributions) throws java.io.IOException
newsgroup
- the newsgroup wildmatsince
- the date from which to list new articlesdistributions
- if non-null, a list of distributions to match
java.io.IOException
public ArticleResponse next() throws java.io.IOException
java.io.IOException
public java.io.OutputStream post() throws java.io.IOException
write()
on the stream for all the
bytes of the article, and finally call close()
on the stream.
No other method should be called in between.
java.io.IOException
postComplete()
public void quit() throws java.io.IOException
java.io.IOException
public void slave() throws java.io.IOException
java.io.IOException
public boolean check(java.lang.String messageId) throws java.io.IOException
java.io.IOException
public boolean modeStream() throws java.io.IOException
java.io.IOException
public java.io.OutputStream takethis(java.lang.String messageId) throws java.io.IOException
close()
on the
stream.
java.io.IOException
takethisComplete()
public GroupIterator listActive(java.lang.String wildmat) throws java.io.IOException
wildmat
- the wildmat pattern. If null, returns all groups. If no
groups are matched, returns an empty iterator.
java.io.IOException
public ActiveTimesIterator listActiveTimes() throws java.io.IOException
java.io.IOException
public PairIterator listNewsgroups(java.lang.String wildmat) throws java.io.IOException
wildmat
- if non-null, limits the groups in the iterator to the
specified pattern
java.io.IOException
xgtitle(java.lang.String)
public LineIterator listOverviewFmt() throws java.io.IOException
java.io.IOException
xover(gnu.inet.nntp.Range)
public GroupIterator listSubscriptions() throws java.io.IOException
java.io.IOException
public ArticleNumberIterator listGroup(java.lang.String group) throws java.io.IOException
group
parameter is null, the currently
selected group is assumed.
group
- the name of the group to list articles for
java.io.IOException
public boolean modeReader() throws java.io.IOException
java.io.IOException
public PairIterator xgtitle(java.lang.String wildmat) throws java.io.IOException
wildmat
- if non-null, the newsgroups to match
java.io.IOException
public HeaderIterator xhdr(java.lang.String header, java.lang.String range) throws java.io.IOException
java.io.IOException
public OverviewIterator xover(Range range) throws java.io.IOException
java.io.IOException
public boolean authinfo(java.lang.String username, java.lang.String password) throws java.io.IOException
username
- the user to authenticatepassword
- the(cleartext) password
java.io.IOException
public boolean authinfoSimple(java.lang.String username, java.lang.String password) throws java.io.IOException
java.io.IOException
public boolean authinfoGeneric(java.lang.String mechanism, java.lang.String username, java.lang.String password) throws java.io.IOException
mechanism
- a SASL authentication mechanism, e.g. LOGIN, PLAIN,
CRAM-MD5, GSSAPIusername
- the authentication principalpassword
- the authentication credentials
java.io.IOException
public java.util.Date date() throws java.io.IOException
java.io.IOException
protected StatusResponse parseResponse(java.lang.String line) throws java.net.ProtocolException
java.net.ProtocolException
protected StatusResponse parseResponse(java.lang.String line, boolean isListGroup) throws java.net.ProtocolException
isListGroup
- whether we are invoking the LISTGROUP command
java.net.ProtocolException
protected void send(java.lang.String line) throws java.io.IOException
line
- the line to send
java.io.IOException
protected java.lang.String read() throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |