/** * Gets be called on opening Tags like: <Tag> Can provide attribute(s), when xml was like: <Tag * attribute="attributeValue"> */ @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { super.startElement(namespaceURI, localName, qName, atts); if (localName.equals("channel")) { this.inChannelTag = true; String id = atts.getValue("id"); String sid = atts.getValue("spotId"); if (id != null) { mChannel = new Channel(Integer.parseInt(id)); if (sid != null) { mChannel.setSpotId(Integer.parseInt(sid)); } } } else if (localName.equals("name")) { this.inNameTag = true; } else if (localName.equals("user")) { this.inUserTag = true; } else if (localName.equals("genre")) { this.inGenreTag = true; } else if (localName.equals("musics")) { this.inMusicsTag = true; } else if (localName.equals("creation")) { this.inCreationTag = true; } else if (localName.equals("update")) { this.inLastUpdateTag = true; } }
/** Gets be called on the following structure: <Tag>characters</Tag> */ @Override public void characters(char ch[], int start, int length) { super.characters(ch, start, length); if (this.inRootTag && this.inChannelTag) { if (this.inNameTag) { mChannel.setName(new String(ch, start, length)); } else if (this.inUserTag) { mChannel.setUser(new String(ch, start, length)); } else if (this.inGenreTag) { mChannel.setGenre(new String(ch, start, length)); } else if (this.inCreationTag) { mChannel.setCreationTime(new Integer(new String(ch, start, length))); } else if (this.inLastUpdateTag) { mChannel.setLastUpdate(new Integer(new String(ch, start, length))); } else if (this.inMusicsTag) { mChannel.setCountOfMusics(new Integer(new String(ch, start, length))); } } }