|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--kom.tools.ipc.IPCClient | +--kom.news.NewsClient
This is a subclass of IPCClient, used to communicate with NEWS servers using the NNTP protocol.
Inner Class Summary | |
class |
NewsClient.Status
Status structure used to record command/server status |
Field Summary | |
protected static ServerConfig |
config
Configuration instance |
protected IPCConnection |
connection
IP connection |
(package private) NewsGroup |
currentNewsGroup
|
protected java.lang.String |
host
|
protected java.lang.String[] |
overviewFormat
|
protected java.lang.String |
pass
User password for AUTHINFO |
protected int |
port
|
(package private) boolean |
posting
True when a posting has commenced and not finished |
protected NewsClient.Status |
status
|
protected java.io.File |
tmpFile
|
protected java.lang.String |
user
User name for AUTHINFO |
Fields inherited from class kom.tools.ipc.IPCClient |
connection |
Constructor Summary | |
NewsClient(java.lang.String host,
int port,
ServerConfig config,
java.lang.String user,
java.lang.String pass)
Class constructor |
|
NewsClient(java.lang.String host,
ServerConfig config,
java.lang.String user,
java.lang.String pass)
Class constructor using default NEWS port |
Method Summary | |
java.lang.StringBuffer |
article(int nnn)
Gets text of an article |
java.lang.StringBuffer |
article(java.lang.String msgid)
Gets text of an article |
boolean |
authenticate(java.lang.String user,
java.lang.String pass)
Sends authentication info to the server |
int[] |
available(java.lang.String interval)
Gets an array of available article numbers in the current newsgroup. |
java.lang.StringBuffer |
body(int nnn)
Gets body of an article |
java.lang.StringBuffer |
body(java.lang.String msgid)
Gets body of an article |
static java.lang.String |
canonicalize(java.lang.String s)
Normalizes the argument to the form "host:port". |
boolean |
checkActive()
Checks if the server is active or can be made active |
void |
close()
Closes connection to remote host. |
java.lang.StringBuffer |
getArticle(java.lang.String groupname,
java.lang.String art,
java.lang.String mid)
Gets the full text of a news article as a StringBuffer |
java.lang.String |
getError()
Gets the current error message String |
int |
getFirst()
Gets first available article number in current newsgroup |
java.lang.String |
getGroupName()
Gets the current group name, or null |
java.lang.StringBuffer |
getHelp()
Gets the standard help text from the server |
int |
getLast()
Gets last available article number in current newsgroup |
private java.util.Vector |
getList()
Gets a list of lines (up to a "." line) from the server |
static NewsClient |
getNewsClient(NewsClient nc,
java.lang.String nn,
ServerConfig conf,
java.lang.String user,
java.lang.String pass)
Retrieves or creates the current NewsClient instance |
java.lang.String |
getNntp()
Gets nntphost:port |
private java.lang.String[] |
getOverviewFormat()
Gets the format of overview data |
protected NewsClient.Status |
getStatus()
Gets current status info |
void |
group(java.lang.String g)
Defines current group |
java.lang.StringBuffer |
head(int nnn)
Gets headers of an article |
java.lang.StringBuffer |
head(java.lang.String msgid)
Gets headers of an article |
void |
init()
(Re)initializes this NewsClient with current info |
void |
init(java.lang.String host,
int port,
ServerConfig config,
java.lang.String user,
java.lang.String pass)
Initializes this NewsClient |
void |
init(java.lang.String nntp,
ServerConfig config,
java.lang.String user,
java.lang.String pass)
Initializes this NewsClient |
boolean |
isReady()
Returns true if status indicates that the server is ready to accept commandd |
int |
last()
Goes back one article in newsgroup, if valid |
java.util.Vector |
list()
Gets a list of newsgroups, one per line. |
Overview[] |
loadOverviews(java.lang.String ng,
java.lang.String load,
KomData rc)
Makes an Overview array from a newsgroup. |
java.util.Vector |
newgroups(java.lang.String datetime)
Gets a list of new newsgroups, one per line. |
int |
next()
Goes forward one article in newsgroup, if valid |
private int |
nextorlast(java.lang.String cmd)
Goes back or forward one article in newsgroup, if valid |
java.lang.StringBuffer |
particle(java.lang.String choice,
java.lang.String nnn)
Gets text of full ARTICLE, HEAD, OR BODY, or STAT results for an article |
boolean |
postfinish()
Finishes the current posting by sending a final dot + eol. |
java.io.OutputStream |
postprepare()
Gets an OutputStream for sending the text of a POST |
void |
quit()
Sends a QUIT command to the server, breaking the connection |
java.lang.StringBuffer |
readText(java.lang.StringBuffer sb)
Receives data from server |
int |
request(java.lang.String line)
Sends a request to the NEWS server |
boolean |
requestOk()
Returns true if request status is ok |
void |
resetError()
Resets status.requestOK to true |
int |
send(java.lang.String line)
Sends a line to the NEWS server |
void |
setAuth(java.lang.String user,
java.lang.String pass)
Sets parameters for possible authorization |
void |
setgroup(java.lang.String name)
Defines current group |
java.lang.StringBuffer |
status(int nnn)
Gets status of an article |
java.lang.StringBuffer |
status(java.lang.String msgid)
Gets status of an article |
Overview[] |
xover(int n)
Gets overview data for an article |
Overview[] |
xover(int m,
int n)
Gets overview data for a range of articles |
Overview[] |
xover(java.lang.String interval)
Gets an array of article overview data for the current newsgroup. |
Methods inherited from class kom.tools.ipc.IPCClient |
connect |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected static ServerConfig config
protected IPCConnection connection
protected java.lang.String host
protected int port
protected java.io.File tmpFile
protected java.lang.String[] overviewFormat
protected NewsClient.Status status
NewsGroup currentNewsGroup
protected java.lang.String user
protected java.lang.String pass
boolean posting
Constructor Detail |
public NewsClient(java.lang.String host, int port, ServerConfig config, java.lang.String user, java.lang.String pass)
host
- Remote server addressport
- Port on remote serverconfig
- Configuration for this clientpublic NewsClient(java.lang.String host, ServerConfig config, java.lang.String user, java.lang.String pass)
host
- Remote server addressconfig
- Configuration for this clientMethod Detail |
public java.lang.StringBuffer getArticle(java.lang.String groupname, java.lang.String art, java.lang.String mid)
groupname
- Newsgroup nameart
- Article number in newsgroupmid
- Message id of article. Used if article number failspublic void setAuth(java.lang.String user, java.lang.String pass)
user
- User name for authorizationpass
- Password for authorizationpublic java.lang.String getNntp()
public int getFirst()
public int getLast()
public java.lang.String getError()
public void resetError()
public static java.lang.String canonicalize(java.lang.String s)
s
- News url or just a host domain, possibly also ":port"public static NewsClient getNewsClient(NewsClient nc, java.lang.String nn, ServerConfig conf, java.lang.String user, java.lang.String pass) throws NewsClientException
nc
- Existing NewsClient reference, or nullnn
- NNTP reference (host:port) corresponding to ncconf
- KOM server configuration instanceuser
- Authinfo user data, or nullpass
- Authinfo password data, or nullpublic void init(java.lang.String nntp, ServerConfig config, java.lang.String user, java.lang.String pass)
nntp
- Host:port, or just host, maybe with "news://" as prefixconfig
- KOM server configuration datauser
- Authenticating user namepass
- Authenticating passwordpublic void init(java.lang.String host, int port, ServerConfig config, java.lang.String user, java.lang.String pass)
host
- Host domainport
- NNTP portconfig
- KOM server configuration datauser
- Authenticating user namepass
- Authenticating passwordpublic void init()
private java.lang.String[] getOverviewFormat()
public java.util.Vector list()
public java.util.Vector newgroups(java.lang.String datetime)
datetime
- YYMMDD HHMMSS [GMT] [private java.util.Vector getList()
public java.lang.String getGroupName()
public void group(java.lang.String g)
g
- Group namepublic void setgroup(java.lang.String name)
name
- Group namepublic java.lang.StringBuffer article(int nnn)
nnn
- Article numberpublic java.lang.StringBuffer article(java.lang.String msgid)
msgid
- Article MessageIDpublic java.lang.StringBuffer head(int nnn)
nnn
- Article numberpublic java.lang.StringBuffer head(java.lang.String msgid)
msgid
- Article MessageIDpublic java.lang.StringBuffer body(int nnn)
nnn
- Article numberpublic java.lang.StringBuffer body(java.lang.String msgid)
msgid
- Article MessageIDpublic java.lang.StringBuffer status(int nnn)
nnn
- Article numberpublic java.lang.StringBuffer status(java.lang.String msgid)
msgid
- Article MessageIDpublic java.lang.StringBuffer particle(java.lang.String choice, java.lang.String nnn)
choice
- One of "article", "head", "body" or "stat"nnn
- Optional article number or public boolean authenticate(java.lang.String user, java.lang.String pass)
user
- User namepass
- Passwordpublic java.io.OutputStream postprepare()
public boolean postfinish()
public final int send(java.lang.String line)
line
- Line w/o eolpublic final int request(java.lang.String line)
line
- Line w/o eolprotected NewsClient.Status getStatus()
public java.lang.StringBuffer getHelp()
public int last()
public int next()
private int nextorlast(java.lang.String cmd)
cmd
- "next" or "last"public Overview[] xover(int n)
n
- Article number in current newsgrouppublic Overview[] xover(int m, int n)
m
- First article numbern
- Last article numberpublic Overview[] loadOverviews(java.lang.String ng, java.lang.String load, KomData rc)
ng
- Newsgroup nameload
- Max new entries, or "all"rc
- If non-null, shows entries already loadedpublic void quit()
public java.lang.StringBuffer readText(java.lang.StringBuffer sb)
sb
- Existing StringBuffer, or nullpublic void close()
public boolean checkActive()
public boolean isReady()
public boolean requestOk()
public Overview[] xover(java.lang.String interval)
interval
- 1) empty: current article 2) an article number
3) a range: "mm-nn" 4) an open range: "mm-" (mm to last)public int[] available(java.lang.String interval)
interval
- 1) empty: current article 2) an article number
3) a range: "mm-nn" 4) an open range: "mm-" (mm to last)
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |