Add more warnings source to 1.6) and fix warnings
[nikiroo-utils.git] / src / be / nikiroo / fanfix / supported / BasicSupport.java
index 0de0c4aa1eae107550b3266ed23820d558d830b9..d56e52d3aea48afa64b28792fba5a8e2fa42090e 100644 (file)
@@ -25,7 +25,7 @@ import be.nikiroo.fanfix.data.MetaData;
 import be.nikiroo.fanfix.data.Paragraph;
 import be.nikiroo.fanfix.data.Paragraph.ParagraphType;
 import be.nikiroo.fanfix.data.Story;
-import be.nikiroo.utils.IOUtils;
+import be.nikiroo.utils.ImageUtils;
 import be.nikiroo.utils.Progress;
 import be.nikiroo.utils.StringUtils;
 
@@ -106,7 +106,8 @@ public abstract class BasicSupport {
                }
 
                /**
-                * Call {@link SupportType#valueOf(String.toUpperCase())}.
+                * Call {@link SupportType#valueOf(String)} after conversion to upper
+                * case.
                 * 
                 * @param typeName
                 *            the possible type name
@@ -119,8 +120,8 @@ public abstract class BasicSupport {
                }
 
                /**
-                * Call {@link SupportType#valueOf(String.toUpperCase())} but return
-                * NULL for NULL instead of raising exception.
+                * Call {@link SupportType#valueOf(String)} after conversion to upper
+                * case but return NULL for NULL instead of raising exception.
                 * 
                 * @param typeName
                 *            the possible type name
@@ -136,8 +137,9 @@ public abstract class BasicSupport {
                }
 
                /**
-                * Call {@link SupportType#valueOf(String.toUpperCase())} but return
-                * NULL in case of error instead of raising an exception.
+                * Call {@link SupportType#valueOf(String)} after conversion to upper
+                * case but return NULL in case of error instead of raising an
+                * exception.
                 * 
                 * @param typeName
                 *            the possible type name
@@ -192,6 +194,19 @@ public abstract class BasicSupport {
         */
        protected abstract boolean isHtml();
 
+       /**
+        * Return the {@link MetaData} of this story.
+        * 
+        * @param source
+        *            the source of the story
+        * @param in
+        *            the input (the main resource)
+        * 
+        * @return the associated {@link MetaData}
+        * 
+        * @throws IOException
+        *             in case of I/O error
+        */
        protected abstract MetaData getMeta(URL source, InputStream in)
                        throws IOException;
 
@@ -313,9 +328,10 @@ public abstract class BasicSupport {
         * 
         * @param url
         *            the story resource
-        * 
         * @param close
         *            close "this" and "in" when done
+        * @param getDesc
+        *            retrieve the description of the story, or not
         * @param pg
         *            the optional progress reporter
         * 
@@ -358,7 +374,7 @@ public abstract class BasicSupport {
 
                        pg.setProgress(50);
 
-                       if (meta != null && meta.getCover() == null) {
+                       if (meta.getCover() == null) {
                                meta.setCover(getDefaultCover(meta.getSubject()));
                        }
 
@@ -560,6 +576,7 @@ public abstract class BasicSupport {
         * @throws IOException
         *             on I/O error
         */
+       @SuppressWarnings("unused")
        protected void preprocess(URL source, InputStream in) throws IOException {
        }
 
@@ -576,6 +593,8 @@ public abstract class BasicSupport {
         * Create a {@link Chapter} object from the given information, formatting
         * the content as it should be.
         * 
+        * @param source
+        *            the source of the story
         * @param number
         *            the chapter number
         * @param name
@@ -737,9 +756,9 @@ public abstract class BasicSupport {
 
                if (image != null) {
                        return new Paragraph(image);
-               } else {
-                       return processPara(line);
                }
+
+               return processPara(line);
        }
 
        /**
@@ -822,9 +841,9 @@ public abstract class BasicSupport {
        static String[] getImageExt(boolean emptyAllowed) {
                if (emptyAllowed) {
                        return new String[] { "", ".png", ".jpg", ".jpeg", ".gif", ".bmp" };
-               } else {
-                       return new String[] { ".png", ".jpg", ".jpeg", ".gif", ".bmp" };
                }
+
+               return new String[] { ".png", ".jpg", ".jpeg", ".gif", ".bmp" };
        }
 
        /**
@@ -845,7 +864,7 @@ public abstract class BasicSupport {
                        InputStream in = null;
                        try {
                                in = Instance.getCache().open(url, getSupport(url), true);
-                               return IOUtils.toImage(in);
+                               return ImageUtils.fromStream(in);
                        } catch (IOException e) {
                        } finally {
                                if (in != null) {
@@ -1143,9 +1162,9 @@ public abstract class BasicSupport {
                                        if (prev == car) {
                                                builder.append(closeDoubleQuote);
                                                continue;
-                                       } else {
-                                               builder.append(closeQuote);
                                        }
+
+                                       builder.append(closeQuote);
                                }
                        }