diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/Shaka Ponk.html b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/Shaka Ponk.html
index 9f7b478..d39b431 100644
--- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/Shaka Ponk.html
+++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/Shaka Ponk.html
@@ -1,68 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/Runner.java b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/Runner.java
index 64c443c..4f4fba1 100644
--- a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/Runner.java
+++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/Runner.java
@@ -20,6 +20,7 @@ import fr.ensim.xml.deezer.dom.DOMSearchAlbums;
import fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks;
import fr.ensim.xml.deezer.sax.SAXSearchAlbums;
import fr.ensim.xml.deezer.stax.HtmlAlbum;
+import fr.ensim.xml.deezer.stax.StAXHtmlAlbum;
/**
@@ -34,7 +35,7 @@ public class Runner {
ProxyConfiguration.configure();
}
- public File start(String searchString)
+ public File start(String searchString, boolean useCustom)
{
Logger log = Logger.getLogger(Runner.class);
@@ -50,7 +51,17 @@ public class Runner {
File fileHtml = new File(listAlbum.get(0).getArtist().getName() + ".html");
out = new FileOutputStream(fileHtml);
- HtmlAlbum.write(listAlbum, out);
+
+ if(useCustom)
+ {
+ HtmlAlbum.write(listAlbum, out);
+ }
+ else
+ {
+ StAXHtmlAlbum.write(listAlbum, out);
+ }
+
+
out.close();
if(fileHtml.isFile())
@@ -78,7 +89,7 @@ public class Runner {
return null;
}
- public File start(String searchString, boolean useDom)
+ public File start(String searchString, boolean useDom, boolean useCustom)
{
Logger log = Logger.getLogger(Runner.class);
@@ -100,7 +111,16 @@ public class Runner {
// Ecriture de la page html
File fileHtml = new File(listAlbum.get(0).getArtist().getName() + ".html");
out = new FileOutputStream(fileHtml);
- HtmlAlbum.write(listAlbum, out);
+
+ if(useCustom)
+ {
+ HtmlAlbum.write(listAlbum, out);
+ }
+ else
+ {
+ StAXHtmlAlbum.write(listAlbum, out);
+ }
+
out.close();
// Ouverture de la page
diff --git a/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/stax/StAXHtmlAlbum.java b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/stax/StAXHtmlAlbum.java
new file mode 100644
index 0000000..8c1d582
--- /dev/null
+++ b/ENSIM/Java/tp-deezer3-HERBRON_Tanguy/src/fr/ensim/xml/deezer/stax/StAXHtmlAlbum.java
@@ -0,0 +1,157 @@
+package fr.ensim.xml.deezer.stax;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.log4j.Logger;
+
+import fr.ensim.xml.deezer.data.Album;
+import fr.ensim.xml.deezer.data.Track;
+
+public class StAXHtmlAlbum {
+ private static Logger log = Logger.getLogger(StAXHtmlAlbum.class);
+
+ public static void write(List albums, OutputStream outputStream) throws IOException
+ {
+ log.debug(">>write");
+
+ XMLOutputFactory factoty = XMLOutputFactory.newInstance();
+ FileWriter fileWriter = new FileWriter(albums.get(0).getArtist().getName() + ".html");
+
+ try {
+ XMLStreamWriter writer = factoty.createXMLStreamWriter(fileWriter);
+ writer.writeStartDocument();
+ writer.writeStartElement("html");
+ writer.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
+ writer.writeStartElement("head");
+ writer.writeStartElement("link");
+ writer.writeAttribute("rel", "stylesheet");
+ writer.writeAttribute("href", "https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css");
+ writer.writeEndElement(); //Close link
+
+ writer.writeStartElement("script");
+ writer.writeAttribute("src", "https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js");
+ writer.writeEndElement(); //Close script
+ writer.writeEndElement(); //Close head
+
+ writer.writeStartElement("body");
+ writer.writeStartElement("div");
+ writer.writeStartElement("nav");
+ writer.writeAttribute("style", "background-color: #3A3A3A");
+ writer.writeStartElement("div");
+ writer.writeAttribute("class", "nav-wrapper");
+ writer.writeStartElement("a");
+ writer.writeAttribute("href", "#");
+ writer.writeAttribute("class", "brand-logo");
+ writer.writeCharacters(albums.get(0).getArtist().getName());
+ writer.writeEndElement(); // Close a
+ writer.writeEndElement(); // Close div
+ writer.writeEndElement(); // Close nav
+ writer.writeEndElement(); // Close div
+ writer.writeStartElement("div");
+ writer.writeAttribute("class", "container");
+
+ generateAlbumElements(writer, albums);
+
+ writer.writeEndElement(); // Close div
+ writer.writeEndElement(); // Close body
+ writer.writeEndElement(); // Close html
+ writer.writeEndDocument();
+ } catch (XMLStreamException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ fileWriter.close();
+ }
+ }
+
+ private static void generateAlbumElements(XMLStreamWriter writer, List albums) throws XMLStreamException
+ {
+ int i = 0;
+
+ while(i < albums.size())
+ {
+ writer.writeStartElement("div");
+ writer.writeAttribute("class", "row");
+
+ generateAlbumCards(writer
+ , albums.get(i).getTitle()
+ , albums.get(i).getCover()
+ , albums.get(i).getTracks());
+
+ if(albums.size() > i+1)
+ {
+ i++;
+
+ generateAlbumCards(writer
+ , albums.get(i).getTitle()
+ , albums.get(i).getCover()
+ , albums.get(i).getTracks());
+ }
+
+ i++;
+
+ writer.writeEndElement();
+ }
+ }
+
+ private static void generateAlbumCards(XMLStreamWriter writer, String title, String cover, List