Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

The name of the book is clipped if the book name is too long #84

Open
aawc opened this issue Sep 19, 2014 · 1 comment
Open

The name of the book is clipped if the book name is too long #84

aawc opened this issue Sep 19, 2014 · 1 comment

Comments

@aawc
Copy link

aawc commented Sep 19, 2014

I observed this in the Popular books list.
One of the books was showing the name ")" in the list. When I opened the details section for that book, it showed a much longer name: "Junie B. Jones Loves Handsome Warren (Junie B. Jones #7)".

It turns out that the response from the server is correct, but when parsing the XML, we set the title (and all other fields) incorrectly.
According to the SAXParser documentation, the characters function can be called multiple times for a single element, but the current implementation just sets the title or author name as is.

So in this case, there were two callbacks to characters function for the title:
"Junie B. Jones Loves Handsome Warren (Junie B. Jones #7", and
")"
So this code is incorrect:

if(title){
    result_bean.setTitle(new String(c,start,length));
}

Instead of setting the title on getting the characters, it should collect those characters in a StringBuilder and then on endElement, set the string in that StringBuilder to title, etc.

Stackoverflow discussion: http://stackoverflow.com/questions/4567636/java-sax-parser-split-calls-to-characters

@emmairwin
Copy link

Thanks Varun!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants