| OLD | NEW | 
|   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 | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  26 class SubscriptionParser extends DefaultHandler |  26 class SubscriptionParser extends DefaultHandler | 
|  27 { |  27 { | 
|  28   private static final String SUBSCRIPTION = "subscription"; |  28   private static final String SUBSCRIPTION = "subscription"; | 
|  29   private static final String TITLE = "title"; |  29   private static final String TITLE = "title"; | 
|  30   private static final String SPECIALIZATION = "specialization"; |  30   private static final String SPECIALIZATION = "specialization"; | 
|  31   private static final String URL = "url"; |  31   private static final String URL = "url"; | 
|  32   private static final String HOMEPAGE = "homepage"; |  32   private static final String HOMEPAGE = "homepage"; | 
|  33   private static final String PREFIXES = "prefixes"; |  33   private static final String PREFIXES = "prefixes"; | 
|  34   private static final String AUTHOR = "author"; |  34   private static final String AUTHOR = "author"; | 
|  35  |  35  | 
|  36   private List<Subscription> subscriptions; |  36   private final List<Subscription> subscriptions; | 
|  37   private Subscription currentSubscription; |  37   private Subscription currentSubscription; | 
|  38  |  38  | 
|  39   public SubscriptionParser(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(String uri, String localName, String qName, Attribute
    s 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       currentSubscription = new Subscription(); |  50       currentSubscription = new Subscription(); | 
|  51       currentSubscription.title = attributes.getValue(TITLE); |  51       currentSubscription.title = attributes.getValue(TITLE); | 
|  52       currentSubscription.specialization = attributes.getValue(SPECIALIZATION); |  52       currentSubscription.specialization = attributes.getValue(SPECIALIZATION); | 
|  53       currentSubscription.url = attributes.getValue(URL); |  53       currentSubscription.url = attributes.getValue(URL); | 
|  54       currentSubscription.homepage = attributes.getValue(HOMEPAGE); |  54       currentSubscription.homepage = attributes.getValue(HOMEPAGE); | 
|  55       String prefix = attributes.getValue(PREFIXES); |  55       final String prefix = attributes.getValue(PREFIXES); | 
|  56       if (prefix != null) |  56       if (prefix != null) | 
|  57       { |  57       { | 
|  58         String[] prefixes = prefix.split(","); |  58         final String[] prefixes = prefix.split(","); | 
|  59         currentSubscription.prefixes = prefixes; |  59         currentSubscription.prefixes = prefixes; | 
|  60       } |  60       } | 
|  61       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(String uri, String localName, String qName) throws SAXE
    xception |  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 (subscriptions != null && currentSubscription != null) |  71       if (subscriptions != null && currentSubscription != null) | 
|  72       { |  72       { | 
|  73         subscriptions.add(currentSubscription); |  73         subscriptions.add(currentSubscription); | 
|  74       } |  74       } | 
|  75       currentSubscription = null; |  75       currentSubscription = null; | 
|  76     } |  76     } | 
|  77     super.endElement(uri, localName, qName); |  77     super.endElement(uri, localName, qName); | 
|  78   } |  78   } | 
|  79 } |  79 } | 
| OLD | NEW |