List of usage examples for org.apache.commons.net.nntp NewsgroupInfo _setLastArticle
void _setLastArticle(long last)
From source file:net.longfalcon.newsj.nntp.client.MockNewsClient.java
@Override public boolean selectNewsgroup(String newsgroup, NewsgroupInfo info) throws IOException { if (!newsServer.hasNewsgroup(newsgroup)) { return false; } else {/*from w w w .j av a 2 s .c o m*/ info._setNewsgroup(newsgroup); info._setArticleCount(newsServer.getArticleCount(newsgroup)); info._setFirstArticle(newsServer.getFirstArticle(newsgroup)); info._setLastArticle(newsServer.getLastArticle(newsgroup)); info._setPostingPermission(0); newsServer.selectGroup(newsgroup); return true; } }
From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java
static NewsgroupInfo __parseNewsgroupListEntry(String entry) { String tokens[] = entry.split(" "); if (tokens.length < 4) { return null; }/*w w w . j a v a 2 s .c o m*/ NewsgroupInfo result = new NewsgroupInfo(); int i = 0; result._setNewsgroup(tokens[i++]); try { long lastNum = Long.parseLong(tokens[i++]); long firstNum = Long.parseLong(tokens[i++]); result._setFirstArticle(firstNum); result._setLastArticle(lastNum); if ((firstNum == 0) && (lastNum == 0)) { result._setArticleCount(0); } else { result._setArticleCount(lastNum - firstNum + 1); } } catch (NumberFormatException e) { return null; } switch (tokens[i++].charAt(0)) { case 'y': case 'Y': result._setPostingPermission(NewsgroupInfo.PERMITTED_POSTING_PERMISSION); break; case 'n': case 'N': result._setPostingPermission(NewsgroupInfo.PROHIBITED_POSTING_PERMISSION); break; case 'm': case 'M': result._setPostingPermission(NewsgroupInfo.MODERATED_POSTING_PERMISSION); break; default: result._setPostingPermission(NewsgroupInfo.UNKNOWN_POSTING_PERMISSION); break; } return result; }
From source file:net.longfalcon.newsj.nntp.client.CustomNNTPClient.java
private static void __parseGroupReply(String reply, NewsgroupInfo info) throws MalformedServerReplyException { String tokens[] = reply.split(" "); if (tokens.length >= 5) { int i = 1; // Skip numeric response value try {/*from ww w. ja v a 2 s . co m*/ // Get estimated article count info._setArticleCount(Long.parseLong(tokens[i++])); // Get first article number info._setFirstArticle(Long.parseLong(tokens[i++])); // Get last article number info._setLastArticle(Long.parseLong(tokens[i++])); // Get newsgroup name info._setNewsgroup(tokens[i++]); info._setPostingPermission(NewsgroupInfo.UNKNOWN_POSTING_PERMISSION); return; } catch (NumberFormatException e) { // drop through to report error } } throw new MalformedServerReplyException("Could not parse newsgroup info.\nServer reply: " + reply); }