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

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

Issue 8491080: ABP/Android subscription list (Closed)
Patch Set: Created Oct. 5, 2012, 9:44 a.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;
Felix Dahlke 2012/11/13 09:58:12 How about naming this "currentSubscription" to hig
Andrey Novikov 2012/11/14 07:13:59 Do not see any reason but done.
20 private Subscription subscription;
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, Attribute s 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(SPECIALIZATION);
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) throws SAXE xception
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
« assets/subscriptions.xml ('K') | « src/org/adblockplus/android/Subscription.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld