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

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

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Left Patch Set: Created April 11, 2014, 1:31 p.m.
Right Patch Set: Even more review issues fixed. Created April 28, 2014, 10:18 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/Starter.java ('k') | src/org/adblockplus/android/SummarizedPreferences.java » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 package org.adblockplus.android; 18 package org.adblockplus.android;
19 19
20 import java.util.List; 20 import java.util.List;
21 21
22 import org.xml.sax.Attributes; 22 import org.xml.sax.Attributes;
23 import org.xml.sax.SAXException; 23 import org.xml.sax.SAXException;
24 import org.xml.sax.helpers.DefaultHandler; 24 import org.xml.sax.helpers.DefaultHandler;
25 25
26 class SubscriptionParser extends DefaultHandler 26 class SubscriptionParser extends DefaultHandler
27 { 27 {
28 private final static String SUBSCRIPTION = "subscription"; 28 private static final String SUBSCRIPTION = "subscription";
29 private final static String TITLE = "title"; 29 private static final String TITLE = "title";
30 private final static String SPECIALIZATION = "specialization"; 30 private static final String SPECIALIZATION = "specialization";
31 private final static String URL = "url"; 31 private static final String URL = "url";
32 private final static String HOMEPAGE = "homepage"; 32 private static final String HOMEPAGE = "homepage";
33 private final static String PREFIXES = "prefixes"; 33 private static final String PREFIXES = "prefixes";
34 private final static String AUTHOR = "author"; 34 private static final String AUTHOR = "author";
35 35
36 private final List<Subscription> subscriptions; 36 private final List<Subscription> subscriptions;
37 private Subscription currentSubscription; 37 private Subscription currentSubscription;
38 38
39 public SubscriptionParser(final List<Subscription> subscriptions) 39 public SubscriptionParser(final List<Subscription> subscriptions)
40 { 40 {
41 super(); 41 super();
42 this.subscriptions = subscriptions; 42 this.subscriptions = subscriptions;
43 } 43 }
44 44
45 @Override 45 @Override
46 public void startElement(final String uri, final String localName, final Strin g qName, final Attributes attributes) throws SAXException 46 public void startElement(final String uri, final String localName, final Strin g qName, final Attributes attributes) throws SAXException
47 { 47 {
48 if (localName.equalsIgnoreCase(SUBSCRIPTION)) 48 if (localName.equalsIgnoreCase(SUBSCRIPTION))
49 { 49 {
50 this.currentSubscription = new Subscription(); 50 currentSubscription = new Subscription();
51 this.currentSubscription.title = attributes.getValue(TITLE); 51 currentSubscription.title = attributes.getValue(TITLE);
52 this.currentSubscription.specialization = attributes.getValue(SPECIALIZATI ON); 52 currentSubscription.specialization = attributes.getValue(SPECIALIZATION);
53 this.currentSubscription.url = attributes.getValue(URL); 53 currentSubscription.url = attributes.getValue(URL);
54 this.currentSubscription.homepage = attributes.getValue(HOMEPAGE); 54 currentSubscription.homepage = attributes.getValue(HOMEPAGE);
55 final String prefix = attributes.getValue(PREFIXES); 55 final String prefix = attributes.getValue(PREFIXES);
56 if (prefix != null) 56 if (prefix != null)
57 { 57 {
58 final String[] prefixes = prefix.split(","); 58 final String[] prefixes = prefix.split(",");
59 this.currentSubscription.prefixes = prefixes; 59 currentSubscription.prefixes = prefixes;
60 } 60 }
61 this.currentSubscription.author = attributes.getValue(AUTHOR); 61 currentSubscription.author = attributes.getValue(AUTHOR);
62 } 62 }
63 super.startElement(uri, localName, qName, attributes); 63 super.startElement(uri, localName, qName, attributes);
64 } 64 }
65 65
66 @Override 66 @Override
67 public void endElement(final String uri, final String localName, final String qName) throws SAXException 67 public void endElement(final String uri, final String localName, final String qName) throws SAXException
68 { 68 {
69 if (localName.equalsIgnoreCase(SUBSCRIPTION)) 69 if (localName.equalsIgnoreCase(SUBSCRIPTION))
70 { 70 {
71 if (this.subscriptions != null && this.currentSubscription != null) 71 if (subscriptions != null && currentSubscription != null)
72 { 72 {
73 this.subscriptions.add(this.currentSubscription); 73 subscriptions.add(currentSubscription);
74 } 74 }
75 this.currentSubscription = null; 75 currentSubscription = null;
76 } 76 }
77 super.endElement(uri, localName, qName); 77 super.endElement(uri, localName, qName);
78 } 78 }
79 } 79 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld