scala-news-reader
rss/atom news reader in scala
git clone https://9o.is/git/scala-news-reader.git
GDataModuleParser.java
(1288B)
1 package com.joereader.lib.rss.gdata.io;
2
3 import com.joereader.lib.rss.gdata.GDataModule;
4 import com.joereader.lib.rss.gdata.GDataModuleImpl;
5 import org.jdom.Element;
6 import org.jdom.Namespace;
7
8 import com.sun.syndication.feed.module.Module;
9 import com.sun.syndication.io.ModuleParser;
10
11 /**
12 * @author Lukasz Radziwonowicz
13 *
14 */
15 public class GDataModuleParser implements ModuleParser {
16
17 // public GDataModuleParser(){
18 // super();
19 // }
20
21 /*
22 * (non-Javadoc)
23 *
24 * @see com.sun.syndication.io.ModuleParser#getNamespaceUri()
25 */
26 @Override
27 public String getNamespaceUri() {
28 return GDataModule.URI;
29 }
30
31 /*
32 * (non-Javadoc)
33 *
34 * @see com.sun.syndication.io.ModuleParser#parse(org.jdom.Element)
35 */
36 @Override
37 public Module parse(Element element) {
38 Namespace gdNS = Namespace.getNamespace("gd", GDataModule.URI);
39 GDataModule gDataModule = new GDataModuleImpl();
40 Element image = element.getChild("image", gdNS);
41 // if (element.getNamespace().equals(gdNS)) {
42 if (image != null) {
43 if (image.getAttributeValue("rel").equals(GDataModule.URI + "#thumbnail")) {
44 gDataModule.setThumbnail(image.getAttributeValue("src"));
45 }
46 }
47 // }
48 return gDataModule;
49 }
50 }