Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5959055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:37:54+00:00 2026-05-22T18:37:54+00:00

I am following the well famous IBM tutorial on parsing an RSS feed. I

  • 0

I am following the well famous IBM tutorial on parsing an RSS feed. I tested it and I am getting a list of the first item only. In the AndroidSaxFeedParser, we can see that currentMessage is final which means that it can’t be changed, and when I wrote my own implementation I removed the copy() call from currentMessage because the compiler doesn’t find this method (hence the replicated set of data in my opinion).

public class AndroidSaxFeedParser extends BaseFeedParser {

    public AndroidSaxFeedParser(String feedUrl) {
        super(feedUrl);
    }

    public List<Message> parse() {
        final Message currentMessage = new Message();
        RootElement root = new RootElement("rss");
        final List<Message> messages = new ArrayList<Message>();
        Element channel = root.getChild("channel");
        Element item = channel.getChild(ITEM);
        item.setEndElementListener(new EndElementListener(){
            public void end() {
                // Here, what's copy()?!!
                messages.add(currentMessage.copy()); 
            }
        });
        item.getChild(TITLE).setEndTextElementListener(new EndTextElementListener(){
            public void end(String body) {
                currentMessage.setTitle(body);
            }
        });
        item.getChild(LINK).setEndTextElementListener(new EndTextElementListener(){
            public void end(String body) {
                currentMessage.setLink(body);
            }
        });
        item.getChild(DESCRIPTION).setEndTextElementListener(new 
EndTextElementListener(){
            public void end(String body) {
                currentMessage.setDescription(body);
            }
        });
        item.getChild(PUB_DATE).setEndTextElementListener(new EndTextElementListener(){
            public void end(String body) {
                currentMessage.setDate(body);
            }
        });
        try {
            Xml.parse(this.getInputStream(), Xml.Encoding.UTF_8, 
root.getContentHandler());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return messages;
    }
}

So my question is, what’s copy(), am I missing something important here?

Edit
Basically, what I want to know is:

  • What is copy()? and why does it seem to work with everyone but not me? (all the people mentioning the tutorial never said anything about it..)

Also, the reason why I am making it final is because the compiler is asking me to do it. If I remove the final keyword, I get the following error message:

Cannot refer to a non-final variable
currentMessage inside an inner class
defiend in a different method.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:37:55+00:00Added an answer on May 22, 2026 at 6:37 pm

    The currentMessage instance is used as an accumulator for parsed message attributes, and when a message is finished parsing, a copy of the current message is stored in the list. The current message itself is unchanged by copying, and its attributes are overwritten with the attributes of the following message. Without the copy, the messages list would end up containing the very same message instance over and over.

    So the copy method should behave like clone, and indeed that method is missing from the listing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following some well-known OpenGL Haskell tutorial , I've made my first HOpenGL program. Here's
Is the following well-defined in C++, or not? I am forced to 'convert' exceptions
Following A well earned retirement for the SOAP Search API from Google announcing they
According to the C++11 standard, is the following program well-formed and portable C++? int
The following is a well known implementation of singleton pattern in C++. However, I'm
The following CSS works well under firefox but doesn't work under IE browser, Why?
The following code plays well on the simulator but the audio doesnt play on
Is the following C++ code well-formed? void consumer(char const* p) { std::printf("%s", p); }
Well I am using the following code to take any old image into a
I have the following script that works well in Firefox and Chrome (not sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.