From c35879a65f7f29c771a91a4f03d14856b9bba167 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Fri, 12 Oct 2018 16:23:53 +0200 Subject: [PATCH] Fix StAX parser --- .../tp-deezer3-HERBRON_Tanguy/bin/.gitignore | 1 + .../src/fr/ensim/xml/deezer/data/Album.java | 30 +++++++++---------- .../xml/deezer/stax/StAXSearchAlbums.java | 12 ++++++-- .../Java/tp-deezer3-HERBRON_Tanguy/tp-xml.log | 15 +++++----- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/bin/.gitignore b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/bin/.gitignore index 44fde90..e9e8828 100644 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/bin/.gitignore +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/bin/.gitignore @@ -1 +1,2 @@ +/.DS_Store /fr/ diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/data/Album.java b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/data/Album.java index 896e99d..5168558 100644 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/data/Album.java +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/data/Album.java @@ -13,27 +13,27 @@ public class Album { private String id; private String title; - + private String cover; - + private List tracks = new ArrayList(); - public Album() { + public Album() { } - + public void addTrack(Track title) { tracks.add(title); } - + public List getTracks() { return tracks; } public void setTracks(List tracks) { - this.tracks = tracks; - } + this.tracks = tracks; + } - public Artist getArtist() { + public Artist getArtist() { return artist; } @@ -42,14 +42,14 @@ public class Album { } public String getCover() { - return cover; - } + return cover; + } - public void setCover(String cover) { - this.cover = cover; - } + public void setCover(String cover) { + this.cover = cover; + } - public String getId() { + public String getId() { return id; } @@ -64,5 +64,5 @@ public class Album { public void setTitle(String title) { this.title = title; } - + } diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/stax/StAXSearchAlbums.java b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/stax/StAXSearchAlbums.java index b3243b7..6facd87 100644 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/stax/StAXSearchAlbums.java +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/stax/StAXSearchAlbums.java @@ -95,8 +95,14 @@ public class StAXSearchAlbums extends AbstractSearchAlbum { switch(element) { case "id": - if(isArtist) buildingArtist.setId(reader.getText()); - else buildingAlbum.setId(reader.getText()); + if(isArtist) + { + buildingArtist.setId(reader.getText()); + } + else + { + buildingAlbum.setId(reader.getText()); + } break; case "title": buildingAlbum.setTitle(reader.getText()); @@ -125,6 +131,8 @@ public class StAXSearchAlbums extends AbstractSearchAlbum { buildingAlbum.setArtist(buildingArtist); isArtist = false; break; + default: + element = ""; } } } diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/tp-xml.log b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/tp-xml.log index d62c606..2bf0518 100644 --- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/tp-xml.log +++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/tp-xml.log @@ -1,7 +1,8 @@ -12:30:47,649 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - >>testCount -12:30:47,657 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - >>count -12:30:47,677 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - <>testParse -12:30:47,681 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - >>readAlbums -12:30:47,689 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - <>testCount +16:23:10,449 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - >>count +16:23:10,460 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - <>testParse +16:23:10,462 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - >>readAlbums +16:23:10,467 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - <