X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Foutput%2FBasicOutput.java;h=33a42c574bed176d90556bce1c447fba61ed26fe;hp=8728284c5e074bfc2dc5f86428a2d4bccf946afb;hb=92fb0719f84f5b6734b51e528332546d78e9ccec;hpb=fe999aa400c2627291325558f1ae8c734da7900c diff --git a/src/be/nikiroo/fanfix/output/BasicOutput.java b/src/be/nikiroo/fanfix/output/BasicOutput.java index 8728284..33a42c5 100644 --- a/src/be/nikiroo/fanfix/output/BasicOutput.java +++ b/src/be/nikiroo/fanfix/output/BasicOutput.java @@ -36,7 +36,12 @@ public abstract class BasicOutput { /** ZIP with (PNG) images */ CBZ, /** LaTeX file with "book" template */ - LATEX; + LATEX, + /** HTML files in a dedicated directory */ + HTML, + + ; + public String toString() { return super.toString().toLowerCase(); } @@ -58,6 +63,20 @@ public abstract class BasicOutput { return desc; } + /** + * The default extension to add to the output files. + * + * @return the extension + */ + public String getDefaultExtension() { + BasicOutput output = BasicOutput.getOutput(this, false); + if (output != null) { + return output.getDefaultExtension(); + } + + return null; + } + /** * Call {@link OutputType#valueOf(String.toUpperCase())}. * @@ -73,7 +92,7 @@ public abstract class BasicOutput { /** * Call {@link OutputType#valueOf(String.toUpperCase())} but return NULL - * for NULL instead of raising exception. + * for NULL and empty instead of raising an exception. * * @param typeName * the possible type name @@ -81,7 +100,7 @@ public abstract class BasicOutput { * @return NULL or the type */ public static OutputType valueOfNullOkUC(String typeName) { - if (typeName == null) { + if (typeName == null || typeName.isEmpty()) { return null; } @@ -208,12 +227,10 @@ public abstract class BasicOutput { /** * The default extension to add to the output files. - *

- * Cannot be NULL! * * @return the extension */ - protected String getDefaultExtension() { + public String getDefaultExtension() { return ""; } @@ -241,9 +258,9 @@ public abstract class BasicOutput { imageName = paragraphNumber + "_" + chapterNameNum + ".png"; if (story.getMeta() != null) { - story.getMeta().setType(getType().toString()); + story.getMeta().setType("" + getType()); } - + if (writeCover) { InfoCover.writeCover(targetDir, targetName, story.getMeta()); } @@ -423,6 +440,8 @@ public abstract class BasicOutput { return new Cbz().setType(type, infoCover, infoCover); case LATEX: return new LaTeX().setType(type, infoCover, infoCover); + case HTML: + return new Html().setType(type, infoCover, infoCover); } }