Java Doc for NNTPClient.java in  » Net » Apache-commons-net-1.4.1 » org » apache » commons » net » nntp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Apache commons net 1.4.1 » org.apache.commons.net.nntp 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.commons.net.nntp.NNTP
   org.apache.commons.net.nntp.NNTPClient

NNTPClient
public class NNTPClient extends NNTP (Code)
NNTPClient encapsulates all the functionality necessary to post and retrieve articles from an NNTP server. As with all classes derived from org.apache.commons.net.SocketClient , you must first connect to the server with org.apache.commons.net.SocketClient.connect connect before doing anything, and finally org.apache.commons.net.nntp.NNTP.disconnect disconnect() after you're completely finished interacting with the server. Remember that the org.apache.commons.net.nntp.NNTP.isAllowedToPost isAllowedToPost() method is defined in org.apache.commons.net.nntp.NNTP .

You should keep in mind that the NNTP server may choose to prematurely close a connection if the client has been idle for longer than a given time period or if the server is being shutdown by the operator or some other reason. The NNTP class will detect a premature NNTP server connection closing when it receives a org.apache.commons.net.nntp.NNTPReply.SERVICE_DISCONTINUED NNTPReply.SERVICE_DISCONTINUED response to a command. When that occurs, the NNTP class method encountering that reply will throw an org.apache.commons.net.nntp.NNTPConnectionClosedException . NNTPConectionClosedException is a subclass of IOException and therefore need not be caught separately, but if you are going to catch it separately, its catch block must appear before the more general IOException catch block. When you encounter an org.apache.commons.net.nntp.NNTPConnectionClosedException , you must disconnect the connection with org.apache.commons.net.nntp.NNTP.disconnect disconnect() to properly clean up the system resources used by NNTP. Before disconnecting, you may check the last reply code and text with org.apache.commons.net.nntp.NNTP.getReplyCode getReplyCode and org.apache.commons.net.nntp.NNTP.getReplyString getReplyString .

Rather than list it separately for each method, we mention here that every method communicating with the server and throwing an IOException can also throw a org.apache.commons.net.MalformedServerReplyException , which is a subclass of IOException. A MalformedServerReplyException will be thrown when the reply received from the server deviates enough from the protocol specification that it cannot be interpreted in a useful manner despite attempts to be as lenient as possible.


author:
   Daniel F. Savarese
author:
   Rory Winston
author:
   Ted Wise
See Also:   NNTP
See Also:   NNTPConnectionClosedException
See Also:   org.apache.commons.net.MalformedServerReplyException





Method Summary
public  booleanauthenticate(String username, String password)
     Log into a news server by sending the AUTHINFO USER/AUTHINFO PASS command sequence.
public  booleancompletePendingCommand()
     There are a few NNTPClient methods that do not complete the entire sequence of NNTP commands to complete a transaction.
public  WriterforwardArticle(String articleId)
    
public  StringlistHelp()
     List the command help from the server.

The sever help information.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400.

public  String[]listNewNews(NewGroupsOrNewsQuery query)
     List all new articles added to the NNTP server since a particular date subject to the conditions of the specified query.
public  NewsgroupInfo[]listNewNewsgroups(NewGroupsOrNewsQuery query)
     List all new newsgroups added to the NNTP server since a particular date subject to the conditions of the specified query.
public  NewsgroupInfo[]listNewsgroups()
     List all newsgroups served by the NNTP server.
public  NewsgroupInfo[]listNewsgroups(String wildmat)
     An overloaded listNewsgroups() command that allows us to specify with a pattern what groups we want to list.
public  booleanlogout()
     Logs out of the news server gracefully by sending the QUIT command.
public  WriterpostArticle()
     Post an article to the NNTP server.
public  ReaderretrieveArticle(String articleId, ArticlePointer pointer)
     Retrieves an article from the NNTP server.
public  ReaderretrieveArticle(String articleId)
    
public  ReaderretrieveArticle()
    
public  ReaderretrieveArticle(int articleNumber, ArticlePointer pointer)
     Retrieves an article from the currently selected newsgroup.
public  ReaderretrieveArticle(int articleNumber)
    
public  ReaderretrieveArticleBody(String articleId, ArticlePointer pointer)
     Retrieves an article body from the NNTP server.
public  ReaderretrieveArticleBody(String articleId)
    
public  ReaderretrieveArticleBody()
    
public  ReaderretrieveArticleBody(int articleNumber, ArticlePointer pointer)
     Retrieves an article body from the currently selected newsgroup.
public  ReaderretrieveArticleBody(int articleNumber)
    
public  ReaderretrieveArticleHeader(String articleId, ArticlePointer pointer)
     Retrieves an article header from the NNTP server.
public  ReaderretrieveArticleHeader(String articleId)
    
public  ReaderretrieveArticleHeader()
    
public  ReaderretrieveArticleHeader(int articleNumber, ArticlePointer pointer)
     Retrieves an article header from the currently selected newsgroup.
public  ReaderretrieveArticleHeader(int articleNumber)
    
public  ReaderretrieveArticleInfo(int articleNumber)
     Return article headers for a specified post.
public  ReaderretrieveArticleInfo(int lowArticleNumber, int highArticleNumber)
     Return article headers for all articles between lowArticleNumber and highArticleNumber, inclusively.
public  ReaderretrieveHeader(String header, int articleNumber)
     Return an article header for a specified post.
public  ReaderretrieveHeader(String header, int lowArticleNumber, int highArticleNumber)
     Return an article header for all articles between lowArticleNumber and highArticleNumber, inclusively.
public  booleanselectArticle(String articleId, ArticlePointer pointer)
     Select an article by its unique identifier (including enclosing < and >) and return its article number and id through the pointer parameter.
public  booleanselectArticle(String articleId)
    
public  booleanselectArticle(ArticlePointer pointer)
     Same as selectArticle(null, articleId) .
public  booleanselectArticle(int articleNumber, ArticlePointer pointer)
     Select an article in the currently selected newsgroup by its number. and return its article number and id through the pointer parameter.
public  booleanselectArticle(int articleNumber)
    
public  booleanselectNewsgroup(String newsgroup, NewsgroupInfo info)
     Select the specified newsgroup to be the target of for future article retrieval and posting operations.
public  booleanselectNewsgroup(String newsgroup)
    
public  booleanselectNextArticle(ArticlePointer pointer)
     Select the article following the currently selected article in the currently selected newsgroup and return its number and unique id through the pointer parameter.
public  booleanselectNextArticle()
    
public  booleanselectPreviousArticle(ArticlePointer pointer)
     Select the article preceeding the currently selected article in the currently selected newsgroup and return its number and unique id through the pointer parameter.
public  booleanselectPreviousArticle()
    



Method Detail
authenticate
public boolean authenticate(String username, String password) throws IOException(Code)
Log into a news server by sending the AUTHINFO USER/AUTHINFO PASS command sequence. This is usually sent in response to a 480 reply code from the NNTP server.


Parameters:
  username - a valid username
Parameters:
  password - the corresponding password True for successful login, false for a failure
throws:
  IOException -




completePendingCommand
public boolean completePendingCommand() throws IOException(Code)
There are a few NNTPClient methods that do not complete the entire sequence of NNTP commands to complete a transaction. These commands require some action by the programmer after the reception of a positive preliminary command. After the programmer's code completes its actions, it must call this method to receive the completion reply from the server and verify the success of the entire transaction.

For example

 writer = client.postArticle();
 if(writer == null) // failure
 return false;
 header = new SimpleNNTPHeader("foobar@foo.com", "Just testing");
 header.addNewsgroup("alt.test");
 writer.write(header.toString());
 writer.write("This is just a test");
 writer.close();
 if(!client.completePendingCommand()) // failure
 return false;
 

True if successfully completed, false if not.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




forwardArticle
public Writer forwardArticle(String articleId) throws IOException(Code)



listHelp
public String listHelp() throws IOException(Code)
List the command help from the server.

The sever help information.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




listNewNews
public String[] listNewNews(NewGroupsOrNewsQuery query) throws IOException(Code)
List all new articles added to the NNTP server since a particular date subject to the conditions of the specified query. If no new new news is found, a zero length array will be returned. If the command fails, null will be returned. You must add at least one newsgroup to the query, else the command will fail. Each String in the returned array is a unique message identifier including the enclosing < and >.


Parameters:
  query - The query restricting how to search for new news. Youmust add at least one newsgroup to the query. An array of String instances containing the unique messageidentifiers for each new article added to the NNTP server. If nonew news is found, a zero length array will be returned. If thecommand fails, null will be returned.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




listNewNewsgroups
public NewsgroupInfo[] listNewNewsgroups(NewGroupsOrNewsQuery query) throws IOException(Code)
List all new newsgroups added to the NNTP server since a particular date subject to the conditions of the specified query. If no new newsgroups were added, a zero length array will be returned. If the command fails, null will be returned.


Parameters:
  query - The query restricting how to search for new newsgroups. An array of NewsgroupInfo instances containing the informationfor each new newsgroup added to the NNTP server. If no newsgroupswere added, a zero length array will be returned. If the commandfails, null will be returned.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




listNewsgroups
public NewsgroupInfo[] listNewsgroups() throws IOException(Code)
List all newsgroups served by the NNTP server. If no newsgroups are served, a zero length array will be returned. If the command fails, null will be returned.

An array of NewsgroupInfo instances containing the informationfor each newsgroup served by the NNTP server. If no newsgroupsare served, a zero length array will be returned. If the commandfails, null will be returned.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




listNewsgroups
public NewsgroupInfo[] listNewsgroups(String wildmat) throws IOException(Code)
An overloaded listNewsgroups() command that allows us to specify with a pattern what groups we want to list. Wraps the LIST ACTIVE command.


Parameters:
  wildmat - a pseudo-regex pattern (cf. RFC 2980) An array of NewsgroupInfo instances containing the informationfor each newsgroup served by the NNTP server corresponding to thesupplied pattern. If no such newsgroups are served, a zero lengtharray will be returned. If the command fails, null will be returned.
throws:
  IOException -




logout
public boolean logout() throws IOException(Code)
Logs out of the news server gracefully by sending the QUIT command. However, you must still disconnect from the server before you can open a new connection.

True if successfully completed, false if not.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




postArticle
public Writer postArticle() throws IOException(Code)
Post an article to the NNTP server. This method returns a DotTerminatedMessageWriter instance to which the article can be written. Null is returned if the posting attempt fails. You should check NNTP.isAllowedToPost isAllowedToPost() before trying to post. However, a posting attempt can fail due to malformed headers.

You must not issue any commands to the NNTP server (i.e., call any (other methods) until you finish writing to the returned Writer instance and close it. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore the returned Writer actually writes directly to the NNTP connection. After you close the writer, you can execute new commands. If you do not follow these requirements your program will not work properly.

Different NNTP servers will require different header formats, but you can use the provided org.apache.commons.net.nntp.SimpleNNTPHeader class to construct the bare minimum acceptable header for most news readers. To construct more complicated headers you should refer to RFC 822. When the Java Mail API is finalized, you will be able to use it to compose fully compliant Internet text messages. The DotTerminatedMessageWriter takes care of doubling line-leading dots and ending the message with a single dot upon closing, so all you have to worry about is writing the header and the message.

Upon closing the returned Writer, you need to call NNTPClient.completePendingCommand completePendingCommand() to finalize the posting and verify its success or failure from the server reply.

A DotTerminatedMessageWriter to which the article (includingheader) can be written. Returns null if the command fails.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




retrieveArticle
public Reader retrieveArticle(String articleId, ArticlePointer pointer) throws IOException(Code)
Retrieves an article from the NNTP server. The article is referenced by its unique article identifier (including the enclosing < and >). The article number and identifier contained in the server reply are returned through an ArticlePointer. The articleId field of the ArticlePointer cannot always be trusted because some NNTP servers do not correctly follow the RFC 977 reply format.

A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned.

You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned Reader instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore the returned Reader actually reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not follow these requirements, your program will not work properly.


Parameters:
  articleId - The unique article identifier of the article toretrieve. If this parameter is null, the currently selectedarticle is retrieved.
Parameters:
  pointer - A parameter through which to return the article'snumber and unique id. The articleId field cannot always be trustedbecause of server deviations from RFC 977 reply formats. You mayset this parameter to null if you do not desire to retrieve thereturned article information. A DotTerminatedMessageReader instance from which the articlebe read. null if the article does not exist.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




retrieveArticle
public Reader retrieveArticle(String articleId) throws IOException(Code)
Same as retrieveArticle(articleId, null) **



retrieveArticle
public Reader retrieveArticle() throws IOException(Code)
Same as retrieveArticle(null) **



retrieveArticle
public Reader retrieveArticle(int articleNumber, ArticlePointer pointer) throws IOException(Code)
Retrieves an article from the currently selected newsgroup. The article is referenced by its article number. The article number and identifier contained in the server reply are returned through an ArticlePointer. The articleId field of the ArticlePointer cannot always be trusted because some NNTP servers do not correctly follow the RFC 977 reply format.

A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned.

You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned Reader instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore the returned Reader actually reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not follow these requirements, your program will not work properly.


Parameters:
  articleNumber - The number of the the article toretrieve.
Parameters:
  pointer - A parameter through which to return the article'snumber and unique id. The articleId field cannot always be trustedbecause of server deviations from RFC 977 reply formats. You mayset this parameter to null if you do not desire to retrieve thereturned article information. A DotTerminatedMessageReader instance from which the articlebe read. null if the article does not exist.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




retrieveArticle
public Reader retrieveArticle(int articleNumber) throws IOException(Code)
Same as retrieveArticle(articleNumber, null) **



retrieveArticleBody
public Reader retrieveArticleBody(String articleId, ArticlePointer pointer) throws IOException(Code)
Retrieves an article body from the NNTP server. The article is referenced by its unique article identifier (including the enclosing < and >). The article number and identifier contained in the server reply are returned through an ArticlePointer. The articleId field of the ArticlePointer cannot always be trusted because some NNTP servers do not correctly follow the RFC 977 reply format.

A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned.

You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned Reader instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore the returned Reader actually reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not follow these requirements, your program will not work properly.


Parameters:
  articleId - The unique article identifier of the article whosebody is being retrieved. If this parameter is null, thebody of the currently selected article is retrieved.
Parameters:
  pointer - A parameter through which to return the article'snumber and unique id. The articleId field cannot always be trustedbecause of server deviations from RFC 977 reply formats. You mayset this parameter to null if you do not desire to retrieve thereturned article information. A DotTerminatedMessageReader instance from which the articlebody can be read. null if the article does not exist.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




retrieveArticleBody
public Reader retrieveArticleBody(String articleId) throws IOException(Code)
Same as retrieveArticleBody(articleId, null) **



retrieveArticleBody
public Reader retrieveArticleBody() throws IOException(Code)
Same as retrieveArticleBody(null) **



retrieveArticleBody
public Reader retrieveArticleBody(int articleNumber, ArticlePointer pointer) throws IOException(Code)
Retrieves an article body from the currently selected newsgroup. The article is referenced by its article number. The article number and identifier contained in the server reply are returned through an ArticlePointer. The articleId field of the ArticlePointer cannot always be trusted because some NNTP servers do not correctly follow the RFC 977 reply format.

A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned.

You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned Reader instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore the returned Reader actually reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not follow these requirements, your program will not work properly.


Parameters:
  articleNumber - The number of the the article whose body isbeing retrieved.
Parameters:
  pointer - A parameter through which to return the article'snumber and unique id. The articleId field cannot always be trustedbecause of server deviations from RFC 977 reply formats. You mayset this parameter to null if you do not desire to retrieve thereturned article information. A DotTerminatedMessageReader instance from which the articlebody can be read. null if the article does not exist.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




retrieveArticleBody
public Reader retrieveArticleBody(int articleNumber) throws IOException(Code)
Same as retrieveArticleBody(articleNumber, null) **



retrieveArticleHeader
public Reader retrieveArticleHeader(String articleId, ArticlePointer pointer) throws IOException(Code)
Retrieves an article header from the NNTP server. The article is referenced by its unique article identifier (including the enclosing < and >). The article number and identifier contained in the server reply are returned through an ArticlePointer. The articleId field of the ArticlePointer cannot always be trusted because some NNTP servers do not correctly follow the RFC 977 reply format.

A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned.

You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned Reader instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore the returned Reader actually reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not follow these requirements, your program will not work properly.


Parameters:
  articleId - The unique article identifier of the article whoseheader is being retrieved. If this parameter is null, theheader of the currently selected article is retrieved.
Parameters:
  pointer - A parameter through which to return the article'snumber and unique id. The articleId field cannot always be trustedbecause of server deviations from RFC 977 reply formats. You mayset this parameter to null if you do not desire to retrieve thereturned article information. A DotTerminatedMessageReader instance from which the articleheader can be read. null if the article does not exist.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




retrieveArticleHeader
public Reader retrieveArticleHeader(String articleId) throws IOException(Code)
Same as retrieveArticleHeader(articleId, null) **



retrieveArticleHeader
public Reader retrieveArticleHeader() throws IOException(Code)
Same as retrieveArticleHeader(null) **



retrieveArticleHeader
public Reader retrieveArticleHeader(int articleNumber, ArticlePointer pointer) throws IOException(Code)
Retrieves an article header from the currently selected newsgroup. The article is referenced by its article number. The article number and identifier contained in the server reply are returned through an ArticlePointer. The articleId field of the ArticlePointer cannot always be trusted because some NNTP servers do not correctly follow the RFC 977 reply format.

A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned.

You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned Reader instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore the returned Reader actually reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not follow these requirements, your program will not work properly.


Parameters:
  articleNumber - The number of the the article whose header isbeing retrieved.
Parameters:
  pointer - A parameter through which to return the article'snumber and unique id. The articleId field cannot always be trustedbecause of server deviations from RFC 977 reply formats. You mayset this parameter to null if you do not desire to retrieve thereturned article information. A DotTerminatedMessageReader instance from which the articleheader can be read. null if the article does not exist.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




retrieveArticleHeader
public Reader retrieveArticleHeader(int articleNumber) throws IOException(Code)
Same as retrieveArticleHeader(articleNumber, null) **



retrieveArticleInfo
public Reader retrieveArticleInfo(int articleNumber) throws IOException(Code)
Return article headers for a specified post.


Parameters:
  articleNumber - the article to retrieve headers for a DotTerminatedReader if successful, null otherwise
throws:
  IOException -




retrieveArticleInfo
public Reader retrieveArticleInfo(int lowArticleNumber, int highArticleNumber) throws IOException(Code)
Return article headers for all articles between lowArticleNumber and highArticleNumber, inclusively.


Parameters:
  lowArticleNumber -
Parameters:
  highArticleNumber - a DotTerminatedReader if successful, null otherwise
throws:
  IOException -




retrieveHeader
public Reader retrieveHeader(String header, int articleNumber) throws IOException(Code)
Return an article header for a specified post.


Parameters:
  header - the header to retrieve
Parameters:
  articleNumber - the article to retrieve the header for a DotTerminatedReader if successful, null otherwise
throws:
  IOException -




retrieveHeader
public Reader retrieveHeader(String header, int lowArticleNumber, int highArticleNumber) throws IOException(Code)
Return an article header for all articles between lowArticleNumber and highArticleNumber, inclusively.


Parameters:
  header -
Parameters:
  lowArticleNumber -
Parameters:
  highArticleNumber - a DotTerminatedReader if successful, null otherwise
throws:
  IOException -




selectArticle
public boolean selectArticle(String articleId, ArticlePointer pointer) throws IOException(Code)
Select an article by its unique identifier (including enclosing < and >) and return its article number and id through the pointer parameter. This is achieved through the STAT command. According to RFC 977, this will NOT set the current article pointer on the server. To do that, you must reference the article by its number.


Parameters:
  articleId - The unique article identifier of the article thatis being selectedd. If this parameter is null, thebody of the current article is selected
Parameters:
  pointer - A parameter through which to return the article'snumber and unique id. The articleId field cannot always be trustedbecause of server deviations from RFC 977 reply formats. You mayset this parameter to null if you do not desire to retrieve thereturned article information. True if successful, false if not.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




selectArticle
public boolean selectArticle(String articleId) throws IOException(Code)
Same as selectArticle(articleId, null) **



selectArticle
public boolean selectArticle(ArticlePointer pointer) throws IOException(Code)
Same as selectArticle(null, articleId) . Useful for retrieving the current article number.



selectArticle
public boolean selectArticle(int articleNumber, ArticlePointer pointer) throws IOException(Code)
Select an article in the currently selected newsgroup by its number. and return its article number and id through the pointer parameter. This is achieved through the STAT command. According to RFC 977, this WILL set the current article pointer on the server. Use this command to select an article before retrieving it, or to obtain an article's unique identifier given its number.


Parameters:
  articleNumber - The number of the article to select from thecurrently selected newsgroup.
Parameters:
  pointer - A parameter through which to return the article'snumber and unique id. Although the articleId field cannot alwaysbe trusted because of server deviations from RFC 977 reply formats,we haven't found a server that misformats this information in responseto this particular command. You may set this parameter to null ifyou do not desire to retrieve the returned article information. True if successful, false if not.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




selectArticle
public boolean selectArticle(int articleNumber) throws IOException(Code)
Same as selectArticle(articleNumber, null) **



selectNewsgroup
public boolean selectNewsgroup(String newsgroup, NewsgroupInfo info) throws IOException(Code)
Select the specified newsgroup to be the target of for future article retrieval and posting operations. Also return the newsgroup information contained in the server reply through the info parameter.


Parameters:
  newsgroup - The newsgroup to select.
Parameters:
  info - A parameter through which the newsgroup information ofthe selected newsgroup contained in the server reply is returned.Set this to null if you do not desire this information. True if the newsgroup exists and was selected, false otherwise.
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




selectNewsgroup
public boolean selectNewsgroup(String newsgroup) throws IOException(Code)
Same as selectNewsgroup(newsgroup, null) **



selectNextArticle
public boolean selectNextArticle(ArticlePointer pointer) throws IOException(Code)
Select the article following the currently selected article in the currently selected newsgroup and return its number and unique id through the pointer parameter. Because of deviating server implementations, the articleId information cannot be trusted. To obtain the article identifier, issue a selectArticle(pointer.articleNumber, pointer) immediately afterward.


Parameters:
  pointer - A parameter through which to return the article'snumber and unique id. The articleId field cannot always be trustedbecause of server deviations from RFC 977 reply formats. You mayset this parameter to null if you do not desire to retrieve thereturned article information. True if successful, false if not (e.g., there is no followingarticle).
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




selectNextArticle
public boolean selectNextArticle() throws IOException(Code)
Same as selectNextArticle(null) **



selectPreviousArticle
public boolean selectPreviousArticle(ArticlePointer pointer) throws IOException(Code)
Select the article preceeding the currently selected article in the currently selected newsgroup and return its number and unique id through the pointer parameter. Because of deviating server implementations, the articleId information cannot be trusted. To obtain the article identifier, issue a selectArticle(pointer.articleNumber, pointer) immediately afterward.


Parameters:
  pointer - A parameter through which to return the article'snumber and unique id. The articleId field cannot always be trustedbecause of server deviations from RFC 977 reply formats. You mayset this parameter to null if you do not desire to retrieve thereturned article information. True if successful, false if not (e.g., there is no previousarticle).
exception:
  NNTPConnectionClosedException - If the NNTP server prematurely closes the connection as a resultof the client being idle or some other reason causing the serverto send NNTP reply code 400. This exception may be caught eitheras an IOException or independently as itself.
exception:
  IOException - If an I/O error occurs while either sending acommand to the server or receiving a reply from the server.




selectPreviousArticle
public boolean selectPreviousArticle() throws IOException(Code)
Same as selectPreviousArticle(null) **



Fields inherited from org.apache.commons.net.nntp.NNTP
final public static int DEFAULT_PORT(Code)(Java Doc)
protected ProtocolCommandSupport _commandSupport_(Code)(Java Doc)
boolean _isAllowedToPost(Code)(Java Doc)
protected BufferedReader _reader_(Code)(Java Doc)
int _replyCode(Code)(Java Doc)
String _replyString(Code)(Java Doc)
protected BufferedWriter _writer_(Code)(Java Doc)

Methods inherited from org.apache.commons.net.nntp.NNTP
protected void _connectAction_() throws IOException(Code)(Java Doc)
public void addProtocolCommandListener(ProtocolCommandListener listener)(Code)(Java Doc)
public int article(String messageId) throws IOException(Code)(Java Doc)
public int article(int articleNumber) throws IOException(Code)(Java Doc)
public int article() throws IOException(Code)(Java Doc)
public int authinfoPass(String password) throws IOException(Code)(Java Doc)
public int authinfoUser(String username) throws IOException(Code)(Java Doc)
public int body(String messageId) throws IOException(Code)(Java Doc)
public int body(int articleNumber) throws IOException(Code)(Java Doc)
public int body() throws IOException(Code)(Java Doc)
public void disconnect() throws IOException(Code)(Java Doc)
public int getReply() throws IOException(Code)(Java Doc)
public int getReplyCode()(Code)(Java Doc)
public String getReplyString()(Code)(Java Doc)
public int group(String newsgroup) throws IOException(Code)(Java Doc)
public int head(String messageId) throws IOException(Code)(Java Doc)
public int head(int articleNumber) throws IOException(Code)(Java Doc)
public int head() throws IOException(Code)(Java Doc)
public int help() throws IOException(Code)(Java Doc)
public int ihave(String messageId) throws IOException(Code)(Java Doc)
public boolean isAllowedToPost()(Code)(Java Doc)
public int last() throws IOException(Code)(Java Doc)
public int list() throws IOException(Code)(Java Doc)
public int listActive(String wildmat) throws IOException(Code)(Java Doc)
public int newgroups(String date, String time, boolean GMT, String distributions) throws IOException(Code)(Java Doc)
public int newnews(String newsgroups, String date, String time, boolean GMT, String distributions) throws IOException(Code)(Java Doc)
public int next() throws IOException(Code)(Java Doc)
public int post() throws IOException(Code)(Java Doc)
public int quit() throws IOException(Code)(Java Doc)
public void removeProtocolCommandListener(ProtocolCommandListener listener)(Code)(Java Doc)
public int sendCommand(String command, String args) throws IOException(Code)(Java Doc)
public int sendCommand(int command, String args) throws IOException(Code)(Java Doc)
public int sendCommand(String command) throws IOException(Code)(Java Doc)
public int sendCommand(int command) throws IOException(Code)(Java Doc)
public int stat(String messageId) throws IOException(Code)(Java Doc)
public int stat(int articleNumber) throws IOException(Code)(Java Doc)
public int stat() throws IOException(Code)(Java Doc)
public int xhdr(String header, String selectedArticles) throws IOException(Code)(Java Doc)
public int xover(String selectedArticles) throws IOException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.