1 package eu.svjatoslav.meviz.htmlindexer;
3 import eu.svjatoslav.meviz.htmlindexer.metadata.Dimension;
4 import eu.svjatoslav.meviz.htmlindexer.metadata.DirectoryMetadata;
5 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.*;
8 import java.io.UnsupportedEncodingException;
10 import static eu.svjatoslav.meviz.htmlindexer.Constants.SUPPORTED_IMAGE_EXTENSIONS;
11 import static eu.svjatoslav.meviz.htmlindexer.Constants.SUPPORTED_VIDEO_EXTENSIONS;
13 public abstract class AbstractIndexer {
15 public static boolean isImage(final String fileExtension) {
16 for (final String ext : SUPPORTED_IMAGE_EXTENSIONS)
17 if (ext.equals(fileExtension))
22 public static boolean isVideo(final String fileExtension) {
23 for (final String ext : SUPPORTED_VIDEO_EXTENSIONS)
24 if (ext.equals(fileExtension))
29 static boolean shallFileBeIndexed(final File file) {
31 if (file.getName().startsWith("."))
33 if (file.getName().startsWith("index"))
34 if (file.getName().endsWith(".html"))
40 void compileHtml(final Layout layout,
41 final DirectoryMetadata directory)
42 throws UnsupportedEncodingException {
44 for (final AbstractFile file : directory.getFiles())
45 if (file instanceof GeneralFile) {
46 layout.enlistFile(file, directory);
47 } else if (file instanceof Picture){
48 layout.enlistImage((Picture) file, directory);
49 } else if (file instanceof Video){
50 layout.enlistVideo((Video) file);
51 } else if (file instanceof DirectoryFile)
52 layout.enlistDirectory(file, directory);
55 public abstract String getDirectoryUrl(final AbstractFile directory,
56 IndexingContext context);
58 public abstract String getParentDirectoryUrl(IndexingContext context);
60 public abstract String getThumbnailUrl(Picture picture,
61 final Dimension desiredDimension, IndexingContext context);