Hello I am working on the google NewsReader
Application Using SAX
, Here I am using getters
and setter
s methods for get the data.
But I have issue that I could add the value into the setters
methods but could not get into the getters
methods, I don't know what's Mistake, Please let me know where I do Mistake .
public class Item implements Serializable {
private String title;
private String description;
private String link;
private String date;
public Item() {
setTitle(null);
setDescription(null);
setLink(null);
setDate(null);
}
public String getTitle() {
System.out.println(" value of the Gettitle ===============> "+ title);
return title;
}
public void setTitle(String title) {
this.title = title;
System.out.println("value of the settitle =============>"+this.title);
}
Output into Logcat:
value of the settitle =============>Oracle CEO Ellison to Buy Most of Hawaiian Island Lanai - Bloomberg
value of the Gettitle ===============> null
Here I got the value of item.getTitle().length()
is null.
Edit:
public void endElement(String uri, String localName, String qName)
throws SAXException {
// TODO Auto-generated method stub
//super.endElement(uri, localName, qName);
if(localName.equalsIgnoreCase("title")) {
if(inItem) {
//System.out.println("value of the content=========>"+content.toString());
item.setTitle(content.toString());
} else {
channel.setTitle(content.toString());
}
}
Item item = new Item();
for (int i = 0; i < item.getTitle().length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("title", item.getTitle().valueOf(i));
map.put("pubdate", item.getDate().valueOf(i));
map.put("desc", item.getDescription().valueOf(i));
items.add(map);
}