Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/org/adblockplus/android/SubscriptionParser.java

Issue 8363097: ABP/Android preferences UI (Closed) Base URL: https://hg.adblockplus.org/adblockplusandroid/
Patch Set: Created Sept. 14, 2012, 8:20 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 package org.adblockplus.android;
2
3 import java.util.List;
4
5 import org.xml.sax.Attributes;
6 import org.xml.sax.SAXException;
7 import org.xml.sax.helpers.DefaultHandler;
8
9 class SubscriptionParser extends DefaultHandler
10 {
11 private static final String SUBSCRIPTION = "subscription";
12 private static final String TITLE = "title";
13 private static final String SPECIALIZATION = "specialization";
14 private static final String URL = "url";
15 private static final String HOMEPAGE = "homepage";
16 private static final String PREFIXES = "prefixes";
17 private static final String AUTHOR = "author";
18
19 private List<Subscription> subscriptions;
20 private Subscription subscription;
Felix Dahlke 2012/09/18 15:32:49 Could you give this a more descriptive name, like
21
22 public SubscriptionParser(List<Subscription> subscriptions)
23 {
24 super();
25 this.subscriptions = subscriptions;
26 }
27
28 @Override
29 public void startElement(String uri, String localName, String qName, Att ributes attributes) throws SAXException
30 {
31 if (localName.equalsIgnoreCase(SUBSCRIPTION))
32 {
33 subscription = new Subscription();
34 subscription.title = attributes.getValue(TITLE);
35 subscription.specialization = attributes.getValue(SPECIA LIZATION);
36 subscription.url = attributes.getValue(URL);
37 subscription.homepage = attributes.getValue(HOMEPAGE);
38 String prefix = attributes.getValue(PREFIXES);
39 if (prefix != null)
40 {
41 String[] prefixes = prefix.split(",");
42 subscription.prefixes = prefixes;
43 }
44 subscription.author = attributes.getValue(AUTHOR);
45 }
46 super.startElement(uri, localName, qName, attributes);
47 }
48
49 @Override
50 public void endElement(String uri, String localName, String qName) throw s SAXException
51 {
52 if (localName.equalsIgnoreCase(SUBSCRIPTION))
53 {
54 if (subscriptions != null && subscription != null)
55 {
56 subscriptions.add(subscription);
57 }
58 subscription = null;
59 }
60 super.endElement(uri, localName, qName);
61 }
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld