|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ipworks.Nntp
The NNTP class is used to read and post articles on Usenet news servers.
The NNTP class implements a standard Usenet news reader as specified in RFC 977. It can be used to browse Usenet news groups and read and post articles.
The class operates mainly by setting action codes to the Action property. The CurrentGroup property sets the current newsgroup. From then on, news articles from that group can be read by setting the article number in CurrentArticle and then setting the appropriate Action code. Properties like ArticleCount , FirstArticle , LastArticle provide information about the current state.
The headers and text of the articles are received respectively through the Header and Transfer events. The GroupOverview event returns information about a range of articles ( OverviewRange ) in CurrentGroup , and the GroupList event is used when listing newsgroup names. The PITrail event provides a trace of the interaction with the server.
The class supports posting of articles through the ArticleText and AttachedFile properties. The article text is specified in one or both of the above, and then the appropriate Action code is sent. Article headers are given in a series of properties like From , Subject , Organization , etc. that map directly to the article header with the same name.
Field Summary | |
static int |
a_Connect
|
static int |
a_Disconnect
|
static int |
a_GetArticle
|
static int |
a_GetArticleBody
|
static int |
a_GetArticleHeaders
|
static int |
a_GroupOverview
|
static int |
a_Idle
|
static int |
a_ListGroups
|
static int |
a_ListNewGroups
|
static int |
a_PostArticle
|
static int |
a_ResetHeaders
|
Constructor Summary | |
Nntp()
|
Method Summary | |
void |
addNntpEventListener(NntpEventListener l)
|
void |
fireEndTransfer()
Fired when the article text completes transferring. |
void |
fireError(int errorCode,
java.lang.String description)
Information about errors during data delivery. |
void |
fireGroupList(java.lang.String group,
int firstArticle,
int lastArticle,
boolean canPost)
Fired while group data transfers (during group listings). |
void |
fireGroupOverview(int articleNumber,
java.lang.String subject,
java.lang.String from,
java.lang.String articleDate,
java.lang.String messageId,
java.lang.String references,
int articleSize,
int articleLines,
java.lang.String otherHeaders)
Fired for each line of article overview data (during group overviews). |
void |
fireHeader(java.lang.String field,
java.lang.String value)
Fired for every article header being retrieved during article retrieval. |
void |
firePITrail(int direction,
java.lang.String message)
Traces the commands sent to the mail server, and the respective replies. |
void |
fireStartTransfer()
Fired when the article text starts transferring. |
void |
fireTransfer(int bytesTransferred,
byte[] text)
Fired while the article text gets transferred (to or from the NewsServer ). |
int |
getAction()
An action code for the component. |
int |
getArticleCount()
The estimated number of articles in CurrentGroup . |
java.lang.String |
getArticleText()
The full text of the article to post (without headers). |
java.lang.String |
getAttachedFile()
A file name which contents to append to ArticleText when posting articles. |
java.lang.String |
getCheckDate()
The date (format YYMMDD HHMMSS) since when to check for creation of new groups. |
java.lang.String |
getCurrentArticle()
The number or message-id of the current article. |
java.lang.String |
getCurrentGroup()
The name of the current group (action property). |
int |
getFirstArticle()
The number of the first article in CurrentGroup. |
java.lang.String |
getFrom()
The email address of the author (for posting articles). |
int |
getLastArticle()
The number of the last article in CurrentGroup . |
java.lang.String |
getLastReply()
The last reply from the server. |
java.lang.String |
getLocalHost()
The name of the local host. |
int |
getMaxHeaderLength()
Maximum length for headers to avoid line folding (default 80). |
java.lang.String |
getNewsgroups()
A comma separated list of newsgroups where to post the article. |
int |
getNewsPort()
The server port for NNTP (default 119). |
java.lang.String |
getNewsServer()
The name or address of a news server. |
java.lang.String |
getOrganization()
The organization of the author (for posting articles). |
java.lang.String |
getOtherHeaders()
An RFC850 compliant string consisting of extra headers (for posting articles). |
java.lang.String |
getOverviewRange()
A range for the Group Overview action (first-last). |
java.lang.String |
getPassword()
A login password to login with in the NewsServer . |
java.lang.String |
getReferences()
Articles the posted article follows up to. |
java.lang.String |
getReplyTo()
The address to reply to (for posting articles). |
java.lang.String |
getSubject()
The article subject (for posted articles). |
java.lang.String |
getUser()
A user id login as in the NewsServer . |
void |
removeNntpEventListener(NntpEventListener l)
|
void |
setAction(int action)
An action code for the component. |
void |
setArticleText(java.lang.String articleText)
The full text of the article to post (without headers). |
void |
setAttachedFile(java.lang.String attachedFile)
A file name which contents to append to ArticleText when posting articles. |
void |
setCheckDate(java.lang.String checkDate)
The date (format YYMMDD HHMMSS) since when to check for creation of new groups. |
void |
setCommand(java.lang.String command)
Can be used to send additional commands directly to the NNTP server. |
void |
setCurrentArticle(java.lang.String currentArticle)
The number or message-id of the current article. |
void |
setCurrentGroup(java.lang.String currentGroup)
The name of the current group (action property). |
void |
setFrom(java.lang.String from)
The email address of the author (for posting articles). |
void |
setMaxHeaderLength(int maxHeaderLength)
Maximum length for headers to avoid line folding (default 80). |
void |
setNewsgroups(java.lang.String newsgroups)
A comma separated list of newsgroups where to post the article. |
void |
setNewsPort(int newsPort)
The server port for NNTP (default 119). |
void |
setNewsServer(java.lang.String newsServer)
The name or address of a news server. |
void |
setOrganization(java.lang.String organization)
The organization of the author (for posting articles). |
void |
setOtherHeaders(java.lang.String otherHeaders)
An RFC850 compliant string consisting of extra headers (for posting articles). |
void |
setOverviewRange(java.lang.String overviewRange)
A range for the Group Overview action (first-last). |
void |
setPassword(java.lang.String password)
A login password to login with in the NewsServer . |
void |
setReferences(java.lang.String references)
Articles the posted article follows up to. |
void |
setReplyTo(java.lang.String replyTo)
The address to reply to (for posting articles). |
void |
setSubject(java.lang.String subject)
The article subject (for posted articles). |
void |
setUser(java.lang.String user)
A user id login as in the NewsServer . |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int a_Idle
public static final int a_Connect
public static final int a_Disconnect
public static final int a_ListGroups
public static final int a_ListNewGroups
public static final int a_GroupOverview
public static final int a_GetArticle
public static final int a_GetArticleHeaders
public static final int a_GetArticleBody
public static final int a_PostArticle
public static final int a_ResetHeaders
Constructor Detail |
public Nntp()
Method Detail |
public int getAction()
The following are the possible values for the Action property and the corresponding descriptions:
public void setAction(int action) throws IPWorksException
The following are the possible values for the Action property and the corresponding descriptions:
public int getArticleCount()
public java.lang.String getArticleText()
It is advisable that the text contained in this property be a collection of lines with lengths less than or equal to 80 bytes separated by CRLF ("\\r\\n"). The text in the article lines must contain 7-bit characters so that the article can be successfully transferred through the various Usenet news servers on the Internet.
The class automatically escapes lines that start with a "." by adding another "." as specified in RFC 822. The article text is unescaped by the news server, so the process is fully transparent.
public void setArticleText(java.lang.String articleText) throws IPWorksException
It is advisable that the text contained in this property be a collection of lines with lengths less than or equal to 80 bytes separated by CRLF ("\\r\\n"). The text in the article lines must contain 7-bit characters so that the article can be successfully transferred through the various Usenet news servers on the Internet.
The class automatically escapes lines that start with a "." by adding another "." as specified in RFC 822. The article text is unescaped by the news server, so the process is fully transparent.
public java.lang.String getAttachedFile()
It is advisable that the text contained in the file be a collection of lines with lengths less than or equal to 80 bytes separated by CRLF ("\\r\\n") . The text in the message lines must contain only 7-bit characters so that the message may be successfully sent through the various Usenet news servers on the Internet.
The class automatically escapes lines that start with a "." by adding another as specified in RFC 822. The article text is unescaped by the news server, so the process is fully transparent.
public void setAttachedFile(java.lang.String attachedFile) throws IPWorksException
It is advisable that the text contained in the file be a collection of lines with lengths less than or equal to 80 bytes separated by CRLF ("\\r\\n") . The text in the message lines must contain only 7-bit characters so that the message may be successfully sent through the various Usenet news servers on the Internet.
The class automatically escapes lines that start with a "." by adding another as specified in RFC 822. The article text is unescaped by the news server, so the process is fully transparent.
public java.lang.String getCheckDate()
public void setCheckDate(java.lang.String checkDate) throws IPWorksException
public void setCommand(java.lang.String command) throws IPWorksException
public java.lang.String getCurrentArticle()
public void setCurrentArticle(java.lang.String currentArticle) throws IPWorksException
public java.lang.String getCurrentGroup()
public void setCurrentGroup(java.lang.String currentGroup) throws IPWorksException
public int getFirstArticle()
public java.lang.String getFrom()
If the resulting From header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public void setFrom(java.lang.String from) throws IPWorksException
If the resulting From header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public int getLastArticle()
public java.lang.String getLastReply()
public java.lang.String getLocalHost()
If the class is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).
public int getMaxHeaderLength()
It is generally a good idea to use a MaxHeaderLength of less than 100 bytes, although different news servers have different requirements for header lengths.
public void setMaxHeaderLength(int maxHeaderLength) throws IPWorksException
It is generally a good idea to use a MaxHeaderLength of less than 100 bytes, although different news servers have different requirements for header lengths.
public java.lang.String getNewsgroups()
If the Newsgroups property contains "" (empty string), then the value of the CurrentGroup property is used to specify the target newsgroup for the posted article.
If the resulting Newsgroups header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public void setNewsgroups(java.lang.String newsgroups) throws IPWorksException
If the Newsgroups property contains "" (empty string), then the value of the CurrentGroup property is used to specify the target newsgroup for the posted article.
If the resulting Newsgroups header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public int getNewsPort()
public void setNewsPort(int newsPort) throws IPWorksException
public java.lang.String getNewsServer()
If the NewsServer property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the NewsServer property is set to the corresponding address. If the search is not successful, an error is returned.
public void setNewsServer(java.lang.String newsServer) throws IPWorksException
If the NewsServer property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the NewsServer property is set to the corresponding address. If the search is not successful, an error is returned.
public java.lang.String getOrganization()
If the resulting Organization header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public void setOrganization(java.lang.String organization) throws IPWorksException
If the resulting Organization header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public java.lang.String getOtherHeaders()
The headers must be of the format "header: value" as specified in RFC 850. Header lines should be separated by CRLF ("\\r\\n").
Use this property with caution. If OtherHeaders contains invalid headers, article posting might not be successful.
The OtherHeaders property is useful for extending the functionality of the class. A good example is posting of MIME attachments.
public void setOtherHeaders(java.lang.String otherHeaders) throws IPWorksException
The headers must be of the format "header: value" as specified in RFC 850. Header lines should be separated by CRLF ("\\r\\n").
Use this property with caution. If OtherHeaders contains invalid headers, article posting might not be successful.
The OtherHeaders property is useful for extending the functionality of the class. A good example is posting of MIME attachments.
public java.lang.String getOverviewRange()
The default value of the property is '-', meaning 'all articles in the group' .
public void setOverviewRange(java.lang.String overviewRange) throws IPWorksException
The default value of the property is '-', meaning 'all articles in the group' .
public java.lang.String getPassword()
public void setPassword(java.lang.String password) throws IPWorksException
public java.lang.String getReferences()
The references must be separated by commas with no spaces in between.
If the resulting References header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public void setReferences(java.lang.String references) throws IPWorksException
The references must be separated by commas with no spaces in between.
If the resulting References header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public java.lang.String getReplyTo()
If the resulting Reply-To header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public void setReplyTo(java.lang.String replyTo) throws IPWorksException
If the resulting Reply-To header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public java.lang.String getSubject()
If the resulting Subject header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public void setSubject(java.lang.String subject) throws IPWorksException
If the resulting Subject header is longer than MaxHeaderLength , then it is folded according to RFC 850 specifications.
public java.lang.String getUser()
public void setUser(java.lang.String user) throws IPWorksException
public void fireEndTransfer()
NntpEndTransferEvent
public void fireError(int errorCode, java.lang.String description)
NntpErrorEvent
public void fireGroupList(java.lang.String group, int firstArticle, int lastArticle, boolean canPost)
NntpGroupListEvent
public void fireGroupOverview(int articleNumber, java.lang.String subject, java.lang.String from, java.lang.String articleDate, java.lang.String messageId, java.lang.String references, int articleSize, int articleLines, java.lang.String otherHeaders)
NntpGroupOverviewEvent
public void fireHeader(java.lang.String field, java.lang.String value)
NntpHeaderEvent
public void firePITrail(int direction, java.lang.String message)
NntpPITrailEvent
public void fireStartTransfer()
NntpStartTransferEvent
public void fireTransfer(int bytesTransferred, byte[] text)
NntpTransferEvent
public void addNntpEventListener(NntpEventListener l) throws java.util.TooManyListenersException
public void removeNntpEventListener(NntpEventListener l)
|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |