I am writing a program that allows the user to provide the URL to RSS feeds, downloads and parses the information, and then displays it to JTextArea
s.
- The user can add as many feed categories as he/she wants. (each category is represented in a separate pane)
- The user can add as many feeds in a category as he/she wants.
- The user can either add a new feed or a new category.
I have an ArrayList(ArrayList) = categoryList. Each of it's items are category = ArrayList. And the Feed objects contain a getContents() method which returns ArrayList.
I want to associate every Feed with a JTextArea. Then I want to iterate through the FeedItems, while displaying them in the corresponding JTextArea.
I am really stuck on finding a way to associate a one to one map between Feed <=> JTextArea.
Here is my attempt:
if (category_list.size() > 0)
{
final java.util.Iterator<ArrayList<Feed>> categoryListIterator = category_list.iterator();
final ArrayList<Feed> currCategory;
final java.util.Iterator<Feed> currFeedIterator;
while (categoryListIterator.hasNext())
{
currCategory = categoryListIterator.next();
while (((java.util.Iterator<ArrayList<Feed>>) currCategory).hasNext())
{
ArrayList<Feed> currFeed = ((java.util.Iterator<ArrayList<Feed>>) currCategory).next();
currFeedIterator = currFeed.iterator();
while (currFeedIterator.hasNext())
{
Feed feed = currFeedIterator.next();
final java.util.Iterator<FeedItem> feedIterator = feed.getContents().iterator();
while (feedIterator.hasNext())
{
// find the appropriate JTextArea
// iterate through the articles.
correspondingJtextArea.setText(feedIterator.next().toString());
}
}
}
}
}
Please let me know, what would be the best way of keeping track in which JTextArea
I should change the text.
Am I iterating through all the Feeds here correctly? A short example that illustrates my situation would be very very helpful.
UPDATE:
Okay, so now I'm okay iterating through all the feeds. I only need to find a way to write a HashMap which associates a Feed with a JTextArea.