Clover Coverage Report - Subsonic-Android Coverage Report
Coverage timestamp: ven dic 19 2014 17:57:13 EST
../../../../../../img/srcFileCovDistChart8.png 45% of files have more coverage
25   75   8   12,5
12   44   0,32   2
2     4  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  SearchResult2Parser       Line # 36 25 8 76,9% 0.7692308
 
No Tests
 
1    /*
2    This file is part of Subsonic.
3   
4    Subsonic is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8   
9    Subsonic is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12    GNU General Public License for more details.
13   
14    You should have received a copy of the GNU General Public License
15    along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
16   
17    Copyright 2009 (C) Sindre Mehus
18    */
19    package net.sourceforge.subsonic.androidapp.service.parser;
20   
21    import android.content.Context;
22    import net.sourceforge.subsonic.androidapp.R;
23    import net.sourceforge.subsonic.androidapp.domain.MusicDirectory;
24    import net.sourceforge.subsonic.androidapp.domain.SearchResult;
25    import net.sourceforge.subsonic.androidapp.domain.Artist;
26    import net.sourceforge.subsonic.androidapp.util.ProgressListener;
27    import org.xmlpull.v1.XmlPullParser;
28   
29    import java.io.Reader;
30    import java.util.List;
31    import java.util.ArrayList;
32   
33    /**
34    * @author Sindre Mehus
35    */
 
36    public class SearchResult2Parser extends MusicDirectoryEntryParser {
37   
 
38  1 toggle public SearchResult2Parser(Context context) {
39  1 super(context);
40    }
41   
 
42  1 toggle public SearchResult parse(Reader reader, ProgressListener progressListener) throws Exception {
43  1 updateProgress(progressListener, R.string.parser_reading);
44  1 init(reader);
45   
46  1 List<Artist> artists = new ArrayList<Artist>();
47  1 List<MusicDirectory.Entry> albums = new ArrayList<MusicDirectory.Entry>();
48  1 List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>();
49  1 int eventType;
50  1 do {
51  11 eventType = nextParseEvent();
52  11 if (eventType == XmlPullParser.START_TAG) {
53  3 String name = getElementName();
54  3 if ("artist".equals(name)) {
55  0 Artist artist = new Artist();
56  0 artist.setId(get("id"));
57  0 artist.setName(get("name"));
58  0 artists.add(artist);
59  3 } else if ("album".equals(name)) {
60  1 albums.add(parseEntry());
61  2 } else if ("song".equals(name)) {
62  0 songs.add(parseEntry());
63  2 } else if ("error".equals(name)) {
64  0 handleError();
65    }
66    }
67  11 } while (eventType != XmlPullParser.END_DOCUMENT);
68   
69  1 validate();
70  1 updateProgress(progressListener, R.string.parser_reading_done);
71   
72  1 return new SearchResult(artists, albums, songs);
73    }
74   
75    }