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

Delta Between Two Patch Sets: src/org/adblockplus/android/SubscriptionParser.java

Issue 8491080: ABP/Android subscription list (Closed)
Left Patch Set: Created Oct. 5, 2012, 9:44 a.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/org/adblockplus/android/Subscription.java ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package org.adblockplus.android; 1 package org.adblockplus.android;
2 2
3 import java.util.List; 3 import java.util.List;
4 4
5 import org.xml.sax.Attributes; 5 import org.xml.sax.Attributes;
6 import org.xml.sax.SAXException; 6 import org.xml.sax.SAXException;
7 import org.xml.sax.helpers.DefaultHandler; 7 import org.xml.sax.helpers.DefaultHandler;
8 8
9 class SubscriptionParser extends DefaultHandler 9 class SubscriptionParser extends DefaultHandler
10 { 10 {
11 private static final String SUBSCRIPTION = "subscription"; 11 private static final String SUBSCRIPTION = "subscription";
12 private static final String TITLE = "title"; 12 private static final String TITLE = "title";
13 private static final String SPECIALIZATION = "specialization"; 13 private static final String SPECIALIZATION = "specialization";
14 private static final String URL = "url"; 14 private static final String URL = "url";
15 private static final String HOMEPAGE = "homepage"; 15 private static final String HOMEPAGE = "homepage";
16 private static final String PREFIXES = "prefixes"; 16 private static final String PREFIXES = "prefixes";
17 private static final String AUTHOR = "author"; 17 private static final String AUTHOR = "author";
18 18
19 private List<Subscription> subscriptions; 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; 20 private Subscription currentSubscription;
21 21
22 public SubscriptionParser(List<Subscription> subscriptions) 22 public SubscriptionParser(List<Subscription> subscriptions)
23 { 23 {
24 super(); 24 super();
25 this.subscriptions = subscriptions; 25 this.subscriptions = subscriptions;
26 } 26 }
27 27
28 @Override 28 @Override
29 public void startElement(String uri, String localName, String qName, Attribute s attributes) throws SAXException 29 public void startElement(String uri, String localName, String qName, Attribute s attributes) throws SAXException
30 { 30 {
31 if (localName.equalsIgnoreCase(SUBSCRIPTION)) 31 if (localName.equalsIgnoreCase(SUBSCRIPTION))
32 { 32 {
33 subscription = new Subscription(); 33 currentSubscription = new Subscription();
34 subscription.title = attributes.getValue(TITLE); 34 currentSubscription.title = attributes.getValue(TITLE);
35 subscription.specialization = attributes.getValue(SPECIALIZATION); 35 currentSubscription.specialization = attributes.getValue(SPECIALIZATION);
36 subscription.url = attributes.getValue(URL); 36 currentSubscription.url = attributes.getValue(URL);
37 subscription.homepage = attributes.getValue(HOMEPAGE); 37 currentSubscription.homepage = attributes.getValue(HOMEPAGE);
38 String prefix = attributes.getValue(PREFIXES); 38 String prefix = attributes.getValue(PREFIXES);
39 if (prefix != null) 39 if (prefix != null)
40 { 40 {
41 String[] prefixes = prefix.split(","); 41 String[] prefixes = prefix.split(",");
42 subscription.prefixes = prefixes; 42 currentSubscription.prefixes = prefixes;
43 } 43 }
44 subscription.author = attributes.getValue(AUTHOR); 44 currentSubscription.author = attributes.getValue(AUTHOR);
45 } 45 }
46 super.startElement(uri, localName, qName, attributes); 46 super.startElement(uri, localName, qName, attributes);
47 } 47 }
48 48
49 @Override 49 @Override
50 public void endElement(String uri, String localName, String qName) throws SAXE xception 50 public void endElement(String uri, String localName, String qName) throws SAXE xception
51 { 51 {
52 if (localName.equalsIgnoreCase(SUBSCRIPTION)) 52 if (localName.equalsIgnoreCase(SUBSCRIPTION))
53 { 53 {
54 if (subscriptions != null && subscription != null) 54 if (subscriptions != null && currentSubscription != null)
55 { 55 {
56 subscriptions.add(subscription); 56 subscriptions.add(currentSubscription);
57 } 57 }
58 subscription = null; 58 currentSubscription = null;
59 } 59 }
60 super.endElement(uri, localName, qName); 60 super.endElement(uri, localName, qName);
61 } 61 }
62 } 62 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld