List of usage examples for org.apache.commons.net.nntp Article isDummy
public boolean isDummy()
From source file:examples.nntp.ExtendedNNTPOps.java
private void demo(String host, String user, String password) { try {// w w w .j a va2 s. co m client.connect(host); // AUTHINFO USER/AUTHINFO PASS if (user != null && password != null) { boolean success = client.authenticate(user, password); if (success) { System.out.println("Authentication succeeded"); } else { System.out.println("Authentication failed, error =" + client.getReplyString()); } } // XOVER NewsgroupInfo testGroup = new NewsgroupInfo(); client.selectNewsgroup("alt.test", testGroup); long lowArticleNumber = testGroup.getFirstArticleLong(); long highArticleNumber = lowArticleNumber + 100; Iterable<Article> articles = client.iterateArticleInfo(lowArticleNumber, highArticleNumber); for (Article article : articles) { if (article.isDummy()) { // Subject will contain raw response System.out.println("Could not parse: " + article.getSubject()); } else { System.out.println(article.getSubject()); } } // LIST ACTIVE NewsgroupInfo[] fanGroups = client.listNewsgroups("alt.fan.*"); for (NewsgroupInfo fanGroup : fanGroups) { System.out.println(fanGroup.getNewsgroup()); } } catch (IOException e) { e.printStackTrace(); } }
From source file:com.almarsoft.GroundhogReader.lib.HeaderItemClass.java
public HeaderItemClass(Article article, int level) { mArticle = article;//from w w w. j a v a 2 s .c o m mLevel = level; if (!article.isDummy()) { String from = article.getFrom(); int idx = from.indexOf('<'); if (idx != -1) { mFromNoEmail = from.substring(0, from.indexOf('<')); } else mFromNoEmail = from; mFromNoEmail = mFromNoEmail.replaceAll("\"", "").trim(); // Fix for some articles that have level 0 even being inside a thread // (probably bug in the Threader) if (article.getReferences().length > 0 && mLevel == 0) mLevel = 1; } }
From source file:com.almarsoft.GroundhogReader.MessageListActivity.java
private void fillListNonRecursive(Article root, int depth, String replyto) { Stack<MiniHeader> stack = new Stack<MiniHeader>(); boolean markReplies = mPrefs.getBoolean("markReplies", true); boolean finished = false; String clean_subject;//from w w w. ja v a2 s . c om MiniHeader tmpMiniItem; HeaderItemClass ih = null; String[] refsArray; String msgId; ArrayList<HeaderItemClass> nonStarredItems = new ArrayList<HeaderItemClass>(); HashSet<String> bannedTrollsSet = DBUtils.getBannedTrolls(getApplicationContext()); HashSet<String> starredSet = DBUtils.getStarredSubjectsSet(getApplicationContext()); // Proxy for speed HashSet<String> myPostsSetProxy = mMyPostsSet; ArrayList<HeaderItemClass> headerItemsListProxy = new ArrayList<HeaderItemClass>(); int refsArrayLen; while (!finished) { if (root == null) finished = true; root.setReplyTo(replyto); if (!root.isDummy()) { ih = new HeaderItemClass(root, depth); // Don't feed the troll if (!bannedTrollsSet.contains(root.getFrom())) { // Put the replies in red (if configured) if (markReplies) { refsArray = root.getReferences(); refsArrayLen = refsArray.length; msgId = null; if (refsArray != null && refsArrayLen > 0) { msgId = refsArray[refsArrayLen - 1]; } if (msgId != null && myPostsSetProxy != null && myPostsSetProxy.contains(msgId)) ih.myreply = true; else ih.myreply = false; } clean_subject = root.simplifiedSubject(); if (starredSet.contains(clean_subject)) { ih.starred = true; headerItemsListProxy.add(ih); // Starred items first } else { // Nonstarred items will be added to mHeaderItemsList at the end nonStarredItems.add(ih); } } } if (root.next != null) { tmpMiniItem = new MiniHeader(root.next, depth, replyto); stack.push(tmpMiniItem); } if (root.kid != null) { replyto = root.getFrom(); if (!root.isDummy()) ++depth; root = root.kid; } else if (!stack.empty()) { tmpMiniItem = stack.pop(); root = tmpMiniItem.article; depth = tmpMiniItem.depth; replyto = tmpMiniItem.replyto; } else finished = true; } // Now add the non starred items after the starred ones int nonStarredItemsLen = nonStarredItems.size(); for (int i = 0; i < nonStarredItemsLen; i++) { headerItemsListProxy.add(nonStarredItems.get(i)); } mHeaderItemsList = headerItemsListProxy; nonStarredItems = null; }
From source file:org.apache.common.net.examples.nntp.ExtendedNNTPOps.java
private void demo(String host, String user, String password) { try {//from w w w. jav a 2s .c om client.connect(host); // AUTHINFO USER/AUTHINFO PASS if (user != null && password != null) { boolean success = client.authenticate(user, password); if (success) { System.out.println("Authentication succeeded"); } else { System.out.println("Authentication failed, error =" + client.getReplyString()); } } // XOVER NewsgroupInfo testGroup = new NewsgroupInfo(); client.selectNewsgroup("alt.test", testGroup); long lowArticleNumber = testGroup.getFirstArticleLong(); long highArticleNumber = lowArticleNumber + 100; Iterable<Article> articles = client.iterateArticleInfo(lowArticleNumber, highArticleNumber); for (Article article : articles) { if (article.isDummy()) { // Subject will contain raw response System.out.println("Could not parse: " + article.getSubject()); } else { System.out.println(article.getSubject()); } } // LIST ACTIVE NewsgroupInfo[] fanGroups = client.listNewsgroups("alt.fan.*"); for (int i = 0; i < fanGroups.length; ++i) { System.out.println(fanGroups[i].getNewsgroup()); } } catch (IOException e) { e.printStackTrace(); } }