Commit 9322b686 authored by Vincent Calame's avatar Vincent Calame
Browse files

Possibilité d'ajouter une date à la racine

parent 9d3d557f
/* ScrutariDataExport - Java implementation of ScrutariDataExport API
* http://www.scrutari.net/dokuwiki/scrutaridata:exportapi
*
* Copyright (c) 2010-2016 Vincent Calame - Exemole
* Copyright (c) 2010-2018 Vincent Calame - Exemole
* Licensed under MIT
* (http://en.wikipedia.org/wiki/MIT_License)
*/
......@@ -9,6 +9,7 @@
package net.scrutari.dataexport;
import java.util.Date;
import net.scrutari.dataexport.api.ScrutariDataExport;
import net.scrutari.dataexport.xml.XmlScrutariDataExport;
import net.scrutari.dataexport.xml.XmlWriter;
......@@ -28,4 +29,9 @@ public final class ScrutariDataExportFactory {
return new XmlScrutariDataExport(xmlWriter);
}
public static ScrutariDataExport newInstance(Appendable appendable, int indentLength, boolean includeXMLDeclaration, Date date) {
XmlWriter xmlWriter = new XmlWriter(appendable, indentLength, includeXMLDeclaration);
return new XmlScrutariDataExport(xmlWriter, date);
}
}
/* ScrutariDataExport - Java implementation of ScrutariDataExport API
* http://www.scrutari.net/dokuwiki/scrutaridata:exportapi
*
* Copyright (c) 2010-2016 Vincent Calame - Exemole
* Copyright (c) 2010-2018 Vincent Calame - Exemole
* Licensed under MIT
* (http://en.wikipedia.org/wiki/MIT_License)
*/
......@@ -9,6 +9,8 @@
package net.scrutari.dataexport.xml;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import net.scrutari.dataexport.api.BaseMetadataExport;
......@@ -26,15 +28,23 @@ import net.scrutari.dataexport.api.ThesaurusMetadataExport;
*/
public class XmlScrutariDataExport implements ScrutariDataExport {
private static final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
private final XmlWriter xmlWriter;
private final XmlFicheExport ficheExport = new XmlFicheExport();
private final XmlMotcleExport motcleExport = new XmlMotcleExport();
private final Map<String, Map<String, Integer>> indexationMap = new LinkedHashMap<String, Map<String, Integer>>();
private final Date date;
private XmlBuilder xmlBuilder;
private int currentState = START;
public XmlScrutariDataExport(XmlWriter xmlWriter) {
this.xmlWriter = xmlWriter;
this.date = null;
}
public XmlScrutariDataExport(XmlWriter xmlWriter, Date date) {
this.xmlWriter = xmlWriter;
this.date = date;
}
@Override
......@@ -42,7 +52,11 @@ public class XmlScrutariDataExport implements ScrutariDataExport {
if (currentState != START) {
throw new ExportStateException(currentState, "startExport");
}
xmlWriter.openTag("base");
if (date != null) {
xmlWriter.openTagWithAttribute("base", "date", ISO_FORMAT.format(date));
} else {
xmlWriter.openTag("base");
}
currentState = BASEMETADATA;
XmlBaseMetadataExport baseMetadataExport = new XmlBaseMetadataExport();
this.xmlBuilder = baseMetadataExport;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment