better error handling
[meviz.git] / src / main / java / eu / svjatoslav / meviz / htmlindexer / AbstractIndexer.java
index 762fcad..84a5868 100644 (file)
@@ -12,9 +12,31 @@ import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.Picture;
 
 public abstract class AbstractIndexer {
 
+       public static boolean isImage(final String fileExtension) {
+               for (final String ext : Constants.SUPPORTED_IMAGE_EXTENSIONS)
+                       if (ext.equals(fileExtension))
+                               return true;
+               return false;
+       }
+
+       public static boolean isOgv(final String fileExtension) {
+               return fileExtension.equalsIgnoreCase("ogv");
+       }
+
+       public static boolean shallFileBeIndexed(final File file) {
+
+               if (file.getName().startsWith("."))
+                       return false;
+               if (file.getName().startsWith("index"))
+                       if (file.getName().endsWith(".html"))
+                               return false;
+
+               return true;
+       }
+
        public void compileHtml(final Layout layout,
                        final DirectoryMetadata directory)
-                       throws UnsupportedEncodingException {
+                                       throws UnsupportedEncodingException {
 
                for (final AbstractFile file : directory.getFiles())
                        if (file instanceof GeneralFile) {
@@ -26,7 +48,7 @@ public abstract class AbstractIndexer {
                                        layout.enlistFile(file);
 
                        } else if (file instanceof Picture)
-                               layout.enlistImage(file);
+                               layout.enlistImage((Picture) file);
                        else if (file instanceof DirectoryFile)
                                layout.enlistDirectory(file);
 
@@ -40,26 +62,4 @@ public abstract class AbstractIndexer {
        public abstract String getThumbnailUrl(Picture picture,
                        final Dimension desiredDimension, IndexingContext context);
 
-       public static boolean isImage(final String fileExtension) {
-               for (final String ext : Constants.SUPPORTED_IMAGE_EXTENSIONS)
-                       if (ext.equals(fileExtension))
-                               return true;
-               return false;
-       }
-
-       public static boolean isOgv(final String fileExtension) {
-               return fileExtension.equalsIgnoreCase("ogv");
-       }
-
-       public static boolean shallFileBeIndexed(final File file) {
-
-               if (file.getName().startsWith("."))
-                       return false;
-               if (file.getName().startsWith("index"))
-                       if (file.getName().endsWith(".html"))
-                               return false;
-
-               return true;
-       }
-
 }