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: ABP/Android subscription list Created Nov. 14, 2012, 7:13 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
« no previous file with comments | « src/org/adblockplus/android/Subscription.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 currentSubscription;
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 currentSubscription = new Subscription();
34 currentSubscription.title = attributes.getValue(TITLE);
35 currentSubscription.specialization = attributes.getValue(SPECIALIZATION);
36 currentSubscription.url = attributes.getValue(URL);
37 currentSubscription.homepage = attributes.getValue(HOMEPAGE);
38 String prefix = attributes.getValue(PREFIXES);
39 if (prefix != null)
40 {
41 String[] prefixes = prefix.split(",");
42 currentSubscription.prefixes = prefixes;
43 }
44 currentSubscription.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 && currentSubscription != null)
55 {
56 subscriptions.add(currentSubscription);
57 }
58 currentSubscription = null;
59 }
60 super.endElement(uri, localName, qName);
61 }
62 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/android/Subscription.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld