Version 1.1.0
[fanfix.git] / src / be / nikiroo / fanfix / output / BasicOutput.java
index 2e77eaebdc6d13de7d24bd42e19061b28131bc41..33a42c574bed176d90556bce1c447fba61ed26fe 100644 (file)
@@ -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.
-        * <p>
-        * Cannot be NULL!
         * 
         * @return the extension
         */
-       protected String getDefaultExtension() {
+       public String getDefaultExtension() {
                return "";
        }
 
@@ -240,6 +257,10 @@ public abstract class BasicOutput {
                String paragraphNumber = String.format("%04d", 0);
                imageName = paragraphNumber + "_" + chapterNameNum + ".png";
 
+               if (story.getMeta() != null) {
+                       story.getMeta().setType("" + getType());
+               }
+
                if (writeCover) {
                        InfoCover.writeCover(targetDir, targetName, story.getMeta());
                }
@@ -419,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);
                        }
                }