1 package eu.svjatoslav.meviz.htmlindexer;
4 import java.io.UnsupportedEncodingException;
6 import eu.svjatoslav.meviz.htmlindexer.metadata.Dimension;
7 import eu.svjatoslav.meviz.htmlindexer.metadata.DirectoryMetadata;
8 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.AbstractFile;
9 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.DirectoryFile;
10 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.GeneralFile;
11 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.Picture;
13 public abstract class AbstractIndexer {
15 public void compileHtml(final Layout layout,
16 final DirectoryMetadata directory)
17 throws UnsupportedEncodingException {
19 for (final AbstractFile file : directory.getFiles())
20 if (file instanceof GeneralFile) {
21 final String fileExtension = file.getFileExtension();
23 if ("ogv".equals(fileExtension))
24 layout.enlistOgv(file);
26 layout.enlistFile(file);
28 } else if (file instanceof Picture)
29 layout.enlistImage(file);
30 else if (file instanceof DirectoryFile)
31 layout.enlistDirectory(file);
35 public abstract String getDirectoryUrl(final AbstractFile directory);
37 public abstract String getThumbnailPath(Picture picture,
38 final Dimension desiredDimension);
40 public static boolean isImage(final String fileExtension) {
41 for (final String ext : Constants.SUPPORTED_IMAGE_EXTENSIONS)
42 if (ext.equals(fileExtension))
47 public static boolean isOgv(final String fileExtension) {
48 return fileExtension.equalsIgnoreCase("ogv");
51 public static boolean shallFileBeIndexed(final File file) {
53 if (file.getName().startsWith("."))
55 if (file.getName().startsWith("index"))
56 if (file.getName().endsWith(".html"))