Improve export methods.
This commit is contained in:
parent
9e914df643
commit
d409b8a8f3
1 changed files with 34 additions and 7 deletions
|
@ -15,6 +15,7 @@ import fr.devinsy.util.xml.XMLReader;
|
||||||
import fr.devinsy.util.xml.XMLTag;
|
import fr.devinsy.util.xml.XMLTag;
|
||||||
import fr.devinsy.util.xml.XMLTag.TagType;
|
import fr.devinsy.util.xml.XMLTag.TagType;
|
||||||
import fr.devinsy.util.xml.XMLWriter;
|
import fr.devinsy.util.xml.XMLWriter;
|
||||||
|
import fr.devinsy.util.xml.XMLZipWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a AccountManager File reader and writer.
|
* This class represents a AccountManager File reader and writer.
|
||||||
|
@ -24,6 +25,23 @@ import fr.devinsy.util.xml.XMLWriter;
|
||||||
public class XMLSikevaDB {
|
public class XMLSikevaDB {
|
||||||
static private final Logger logger = LoggerFactory.getLogger(XMLSikevaDB.class);
|
static private final Logger logger = LoggerFactory.getLogger(XMLSikevaDB.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves a net in a file.
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* Target.
|
||||||
|
* @param source
|
||||||
|
* Source.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static void export(final OutputStream out, final SikevaDB source) throws Exception {
|
||||||
|
//
|
||||||
|
String fileName = "sikevadb-" + DateTime.now().toString("yyyy-MM-dd-HH'h'mm'mn'ss's'") + ".xml.zip";
|
||||||
|
|
||||||
|
//
|
||||||
|
export(out, source, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a net in a file.
|
* Saves a net in a file.
|
||||||
*
|
*
|
||||||
|
@ -39,17 +57,26 @@ public class XMLSikevaDB {
|
||||||
throw new NullPointerException("out is null.");
|
throw new NullPointerException("out is null.");
|
||||||
} else if (source == null) {
|
} else if (source == null) {
|
||||||
throw new NullPointerException("source is null.");
|
throw new NullPointerException("source is null.");
|
||||||
|
} else if (fileName == null) {
|
||||||
|
export(out, source, fileName);
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
XMLWriter target = new XMLWriter(out);// new XMLZipWriter(out,
|
XMLZipWriter target = null;
|
||||||
// fileName,
|
try {
|
||||||
// "Generated by SikevaDB.");
|
//
|
||||||
|
target = new XMLZipWriter(out, fileName, "Generated by SikevaDB.");
|
||||||
|
|
||||||
//
|
//
|
||||||
target.writeXMLHeader();
|
target.writeXMLHeader();
|
||||||
|
|
||||||
//
|
//
|
||||||
write(target, source);
|
write(target, source);
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
if (target != null) {
|
||||||
|
target.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue