/** * * @param _reader the reader to wrap * @param addDotReader whether to additionally wrap the reader in a DotTerminatedMessageReader * @throws IOException */ ReplyIterator(BufferedReader _reader, boolean addDotReader) throws IOException { reader = addDotReader ? new DotTerminatedMessageReader(_reader) : _reader; line = reader.readLine(); // prime the iterator if (line == null) { Util.closeQuietly(reader); } }
/** * Send a "LIST OVERVIEW.FMT" command to the server. * * @return the contents of the Overview format, of {@code null} if the command failed * @throws IOException on error */ public String[] listOverviewFmt() throws IOException { if (!NNTPReply.isPositiveCompletion(sendCommand("LIST", "OVERVIEW.FMT"))){ return null; } BufferedReader reader = new DotTerminatedMessageReader(_reader_); String line; ArrayList<String> list = new ArrayList<String>(); while((line=reader.readLine()) != null) { list.add(line); } reader.close(); return list.toArray(new String[list.size()]); }
private NewsgroupInfo[] __readNewsgroupListing() throws IOException { BufferedReader reader = new DotTerminatedMessageReader(_reader_); // Start of with a big vector because we may be reading a very large // amount of groups. Vector<NewsgroupInfo> list = new Vector<NewsgroupInfo>(2048); String line; try { while ((line = reader.readLine()) != null) { NewsgroupInfo tmp = __parseNewsgroupListEntry(line); if (tmp != null) { list.addElement(tmp); } else { throw new MalformedServerReplyException(line); } } } finally { reader.close(); } int size; if ((size = list.size()) < 1) { return new NewsgroupInfo[0]; } NewsgroupInfo[] info = new NewsgroupInfo[size]; list.copyInto(info); return info; }
/*** * List the command help from the server. * <p> * @return The sever help information. * @throws NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @throws IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. ***/ public String listHelp() throws IOException { if (!NNTPReply.isInformational(help())) { return null; } StringWriter help = new StringWriter(); BufferedReader reader = new DotTerminatedMessageReader(_reader_); Util.copyReader(reader, help); reader.close(); help.close(); return help.toString(); }
/*** * Private implementation of XOVER functionality. * * See {@link NNTP#xover} * for legal agument formats. Alternatively, read RFC 2980 :-) * <p> * @param articleRange * @return Returns a DotTerminatedMessageReader if successful, null * otherwise * @throws IOException */ private BufferedReader __retrieveArticleInfo(String articleRange) throws IOException { if (!NNTPReply.isPositiveCompletion(xover(articleRange))) { return null; } return new DotTerminatedMessageReader(_reader_); }
/*** * Private implementation of XHDR functionality. * * See {@link NNTP#xhdr} * for legal agument formats. Alternatively, read RFC 1036. * <p> * @param header * @param articleRange * @return Returns a DotTerminatedMessageReader if successful, null * otherwise * @throws IOException */ private BufferedReader __retrieveHeader(String header, String articleRange) throws IOException { if (!NNTPReply.isPositiveCompletion(xhdr(header, articleRange))) { return null; } return new DotTerminatedMessageReader(_reader_); }
return new DotTerminatedMessageReader(_reader);
private BufferedReader __retrieve(int command, long articleNumber, ArticleInfo pointer) throws IOException { if (!NNTPReply.isPositiveCompletion(sendCommand(command, Long.toString(articleNumber)))) { return null; } if (pointer != null) { __parseArticlePointer(getReplyString(), pointer); } return new DotTerminatedMessageReader(_reader_); }
return new DotTerminatedMessageReader(_reader);
BufferedReader reader = new DotTerminatedMessageReader(_reader_);
private BufferedReader __retrieve(int command, String articleId, ArticleInfo pointer) throws IOException { if (articleId != null) { if (!NNTPReply.isPositiveCompletion(sendCommand(command, articleId))) { return null; } } else { if (!NNTPReply.isPositiveCompletion(sendCommand(command))) { return null; } } if (pointer != null) { __parseArticlePointer(getReplyString(), pointer); } return new DotTerminatedMessageReader(_reader_); }
/*** * List the command help from the server. * <p> * @return The sever help information. * @exception NNTPConnectionClosedException * If the NNTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send NNTP reply code 400. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. ***/ public String listHelp() throws IOException { StringWriter help; Reader reader; if (!NNTPReply.isInformational(help())) return null; help = new StringWriter(); reader = new DotTerminatedMessageReader(_reader_); Util.copyReader(reader, help); reader.close(); help.close(); return help.toString(); }
/*** * Private implementation of XOVER functionality. * * See {@link NNTP#xover} * for legal agument formats. Alternatively, read RFC 2980 :-) * <p> * @param articleRange * @return Returns a DotTerminatedMessageReader if successful, null * otherwise * @exception IOException */ private Reader __retrieveArticleInfo(String articleRange) throws IOException { if (!NNTPReply.isPositiveCompletion(xover(articleRange))) return null; return new DotTerminatedMessageReader(_reader_); }
/*** * Private implementation of XOVER functionality. * * See {@link NNTP#xover} * for legal agument formats. Alternatively, read RFC 2980 :-) * <p> * @param articleRange * @return Returns a DotTerminatedMessageReader if successful, null * otherwise * @exception IOException */ private Reader __retrieveArticleInfo(String articleRange) throws IOException { if (!NNTPReply.isPositiveCompletion(xover(articleRange))) return null; return new DotTerminatedMessageReader(_reader_); }
/*** * Private implementation of XHDR functionality. * * See {@link NNTP#xhdr} * for legal agument formats. Alternatively, read RFC 1036. * <p> * @param header * @param articleRange * @return Returns a DotTerminatedMessageReader if successful, null * otherwise * @exception IOException */ private Reader __retrieveHeader(String header, String articleRange) throws IOException { if (!NNTPReply.isPositiveCompletion(xhdr(header, articleRange))) return null; return new DotTerminatedMessageReader(_reader_); }
/*** * Private implementation of XHDR functionality. * * See {@link NNTP#xhdr} * for legal agument formats. Alternatively, read RFC 1036. * <p> * @param header * @param articleRange * @return Returns a DotTerminatedMessageReader if successful, null * otherwise * @exception IOException */ private Reader __retrieveHeader(String header, String articleRange) throws IOException { if (!NNTPReply.isPositiveCompletion(xhdr(header, articleRange))) return null; return new DotTerminatedMessageReader(_reader_); }
private Reader __retrieve(int command, int articleNumber, ArticlePointer pointer) throws IOException { Reader reader; if (!NNTPReply.isPositiveCompletion(sendCommand(command, Integer.toString(articleNumber)))) return null; if (pointer != null) __parseArticlePointer(getReplyString(), pointer); reader = new DotTerminatedMessageReader(_reader_); return reader; }
private Reader __retrieve(int command, int articleNumber, ArticlePointer pointer) throws IOException { Reader reader; if (!NNTPReply.isPositiveCompletion(sendCommand(command, Integer.toString(articleNumber)))) return null; if (pointer != null) __parseArticlePointer(getReplyString(), pointer); reader = new DotTerminatedMessageReader(_reader_); return reader; }
private Reader __retrieve(int command, String articleId, ArticlePointer pointer) throws IOException { Reader reader; if (articleId != null) { if (!NNTPReply.isPositiveCompletion(sendCommand(command, articleId))) return null; } else { if (!NNTPReply.isPositiveCompletion(sendCommand(command))) return null; } if (pointer != null) __parseArticlePointer(getReplyString(), pointer); reader = new DotTerminatedMessageReader(_reader_); return reader; }
private Reader __retrieve(int command, String articleId, ArticlePointer pointer) throws IOException { Reader reader; if (articleId != null) { if (!NNTPReply.isPositiveCompletion(sendCommand(command, articleId))) return null; } else { if (!NNTPReply.isPositiveCompletion(sendCommand(command))) return null; } if (pointer != null) __parseArticlePointer(getReplyString(), pointer); reader = new DotTerminatedMessageReader(_reader_); return reader; }