Fix StAX parser

This commit is contained in:
Tanguy Herbron 2018-10-12 16:23:53 +02:00
parent b00913cb2f
commit c35879a65f
4 changed files with 34 additions and 24 deletions

View File

@ -1 +1,2 @@
/.DS_Store
/fr/ /fr/

View File

@ -13,27 +13,27 @@ public class Album {
private String id; private String id;
private String title; private String title;
private String cover; private String cover;
private List<Track> tracks = new ArrayList<Track>(); private List<Track> tracks = new ArrayList<Track>();
public Album() { public Album() {
} }
public void addTrack(Track title) { public void addTrack(Track title) {
tracks.add(title); tracks.add(title);
} }
public List<Track> getTracks() { public List<Track> getTracks() {
return tracks; return tracks;
} }
public void setTracks(List<Track> tracks) { public void setTracks(List<Track> tracks) {
this.tracks = tracks; this.tracks = tracks;
} }
public Artist getArtist() { public Artist getArtist() {
return artist; return artist;
} }
@ -42,14 +42,14 @@ public class Album {
} }
public String getCover() { public String getCover() {
return cover; return cover;
} }
public void setCover(String cover) { public void setCover(String cover) {
this.cover = cover; this.cover = cover;
} }
public String getId() { public String getId() {
return id; return id;
} }
@ -64,5 +64,5 @@ public class Album {
public void setTitle(String title) { public void setTitle(String title) {
this.title = title; this.title = title;
} }
} }

View File

@ -95,8 +95,14 @@ public class StAXSearchAlbums extends AbstractSearchAlbum {
switch(element) switch(element)
{ {
case "id": case "id":
if(isArtist) buildingArtist.setId(reader.getText()); if(isArtist)
else buildingAlbum.setId(reader.getText()); {
buildingArtist.setId(reader.getText());
}
else
{
buildingAlbum.setId(reader.getText());
}
break; break;
case "title": case "title":
buildingAlbum.setTitle(reader.getText()); buildingAlbum.setTitle(reader.getText());
@ -125,6 +131,8 @@ public class StAXSearchAlbums extends AbstractSearchAlbum {
buildingAlbum.setArtist(buildingArtist); buildingAlbum.setArtist(buildingArtist);
isArtist = false; isArtist = false;
break; break;
default:
element = "";
} }
} }
} }

View File

@ -1,7 +1,8 @@
12:30:47,649 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - >>testCount 16:23:10,446 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - >>testCount
12:30:47,657 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - >>count 16:23:10,449 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - >>count
12:30:47,677 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - <<count 10 16:23:10,460 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - <<count 10
12:30:47,677 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - <<testCount 16:23:10,461 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - <<testCount
12:30:47,677 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - >>testParse 16:23:10,462 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - >>testParse
12:30:47,681 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - >>readAlbums 16:23:10,462 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - >>readAlbums
12:30:47,689 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - <<readAlbums 16:23:10,467 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - <<readAlbums
16:23:10,468 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - <<testParse