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 static boolean isImage(final String fileExtension) {
16 for (final String ext : Constants.SUPPORTED_IMAGE_EXTENSIONS)
17 if (ext.equals(fileExtension))
22 public static boolean isOgv(final String fileExtension) {
23 return fileExtension.equalsIgnoreCase("ogv");
26 public static boolean shallFileBeIndexed(final File file) {
28 if (file.getName().startsWith("."))
30 if (file.getName().startsWith("index"))
31 if (file.getName().endsWith(".html"))
37 public void compileHtml(final Layout layout,
38 final DirectoryMetadata directory)
39 throws UnsupportedEncodingException {
41 for (final AbstractFile file : directory.getFiles())
42 if (file instanceof GeneralFile) {
43 final String fileExtension = file.getFileExtension();
45 if ("ogv".equals(fileExtension))
46 layout.enlistOgv(file, directory);
47 else if ("webm".equals(fileExtension))
48 layout.enlistWebm(file, directory);
50 layout.enlistFile(file, directory);
52 } else if (file instanceof Picture)
53 layout.enlistImage((Picture) file, directory);
54 else if (file instanceof DirectoryFile)
55 layout.enlistDirectory(file, directory);
59 public abstract String getDirectoryUrl(final AbstractFile directory,
60 IndexingContext context);
62 public abstract String getParentDirectoryUrl(IndexingContext context);
64 public abstract String getThumbnailUrl(Picture picture,
65 final Dimension desiredDimension, IndexingContext context);