summaryrefslogtreecommitdiff
path: root/src/de/podfetcher/syndication/namespace/simplechapters/NSSimpleChapters.java
blob: 4b3a69cbe064eb1ac74bd253600335ab3b0526f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package de.podfetcher.syndication.namespace.simplechapters;

import java.util.ArrayList;

import org.xml.sax.Attributes;

import de.podfetcher.feed.SimpleChapter;
import de.podfetcher.syndication.handler.HandlerState;
import de.podfetcher.syndication.namespace.Namespace;
import de.podfetcher.syndication.namespace.SyndElement;
import de.podfetcher.syndication.util.SyndDateUtils;

public class NSSimpleChapters extends Namespace {
	public static final String NSTAG = "sc";
	public static final String NSURI = "http://podlove.org/simple-chapters";

	public static final String CHAPTERS = "chapters";
	public static final String CHAPTER = "chapter";
	public static final String START = "start";
	public static final String TITLE = "title";

	@Override
	public SyndElement handleElementStart(String localName, HandlerState state,
			Attributes attributes) {
		if (localName.equals(CHAPTERS)) {
			state.getCurrentItem().setSimpleChapters(
					new ArrayList<SimpleChapter>());
		} else if (localName.equals(CHAPTER)) {
			state.getCurrentItem()
					.getSimpleChapters()
					.add(new SimpleChapter(SyndDateUtils
							.parseTimeString(attributes.getValue(START)),
							attributes.getValue(TITLE)));
		}

		return new SyndElement(localName, this);
	}

	@Override
	public void handleElementEnd(String localName, HandlerState state) {
	}

}