Code example for RootElement

Methods: getChild, getContentHandler

0
	 * Parse plenum speakers (Plenum) object. 
	 */ 
	public PlenumSpeakerObject parseSpeakers() { 
		final PlenumSpeakerObject currentPlenumObject = new PlenumSpeakerObject();
 
		RootElement root = new RootElement(TAG_PLENUM_SPEAKER_ROOT_ELEMENT);
		root.getChild(TAG_PLENUM_SPEAKER_TOPICNUMBER)
				.setEndTextElementListener(new EndTextElementListener() {
					public void end(String body) {
						currentPlenumObject.setTopicNumber(body);
					} 
				}); 
		root.getChild(TAG_PLENUM_SPEAKER_LIVE).setEndTextElementListener(
				new EndTextElementListener() {
					public void end(String body) {
						currentPlenumObject.setLive(body);
					} 
				}); 
 
		Element speakersElement = root.getChild(TAG_PLENUM_SPEAKER_SPEAKERS);
		// speakers 
		final PlenumSpeakerItemObject plenumSpeakerItemObject = new PlenumSpeakerItemObject();
		final List<PlenumSpeakerItemObject> speakers = new ArrayList<PlenumSpeakerItemObject>();
 
		Element groupsElement = speakersElement
				.getChild(TAG_PLENUM_SPEAKER_SPEAKER_ITEM);
		groupsElement.setEndElementListener(new EndElementListener() {
			public void end() { 
				speakers.add(plenumSpeakerItemObject.copy());
			} 
		}); 
 
		groupsElement.getChild(TAG_PLENUM_SPEAKER_SPEAKER_ITEM_TOPIC)
				.setEndTextElementListener(new EndTextElementListener() {
					public void end(String body) {
						plenumSpeakerItemObject.setTopic(body);
					} 
				}); 
		groupsElement.getChild(TAG_PLENUM_SPEAKER_SPEAKER_ITEM_STARTTIME)
				.setEndTextElementListener(new EndTextElementListener() {
					public void end(String body) {
						plenumSpeakerItemObject.setStartTime(body);
					} 
				}); 
		groupsElement.getChild(TAG_PLENUM_SPEAKER_SPEAKER_ITEM_STATE)
				.setEndTextElementListener(new EndTextElementListener() {
					public void end(String body) {
						plenumSpeakerItemObject.setState(body);
					} 
				}); 
		groupsElement.getChild(TAG_PLENUM_SPEAKER_SPEAKER_ITEM_FUNCTION)
				.setEndTextElementListener(new EndTextElementListener() {
					public void end(String body) {
						plenumSpeakerItemObject.setFunction(body);
					} 
				}); 
		groupsElement.getChild(TAG_PLENUM_SPEAKER_SPEAKER_ITEM_NAME)
				.setEndTextElementListener(new EndTextElementListener() {
					public void end(String body) {
						plenumSpeakerItemObject.setName(body);
					} 
				}); 
		currentPlenumObject.setSpeakers(speakers);
 
		this.setSpecificParserURL(PLENUM_SPEAKER_URL);
		try { 
			Xml.Encoding encoding = ParseEncodingDetector
					.detectEncoding(getDetailsXMLURL()); 
			Xml.parse(this.getSpecificInputStream(), encoding,
					root.getContentHandler());
		} catch (Exception e) {
			throw new RuntimeException(e);
		} 
 
		return currentPlenumObject;