1 package eu.svjatoslav.meviz.htmlindexer.indexer;
3 import eu.svjatoslav.meviz.htmlindexer.IndexingContext;
4 import eu.svjatoslav.meviz.htmlindexer.layouts.Layout;
5 import eu.svjatoslav.meviz.htmlindexer.metadata.Dimension;
6 import eu.svjatoslav.meviz.htmlindexer.metadata.DirectoryMetadata;
7 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.*;
10 import java.io.UnsupportedEncodingException;
12 import static eu.svjatoslav.meviz.htmlindexer.Constants.SUPPORTED_IMAGE_EXTENSIONS;
13 import static eu.svjatoslav.meviz.htmlindexer.Constants.SUPPORTED_VIDEO_EXTENSIONS;
15 public abstract class AbstractIndexer {
17 public static boolean isImage(final String fileExtension) {
18 for (final String ext : SUPPORTED_IMAGE_EXTENSIONS)
19 if (ext.equals(fileExtension))
24 public static boolean isVideo(final String fileExtension) {
25 for (final String ext : SUPPORTED_VIDEO_EXTENSIONS)
26 if (ext.equals(fileExtension))
31 static boolean shallFileBeIndexed(final File file) {
33 if (file.getName().startsWith("."))
35 if (file.getName().startsWith("index"))
36 if (file.getName().endsWith(".html"))
42 void compileHtml(final Layout layout,
43 final DirectoryMetadata directory)
44 throws UnsupportedEncodingException {
46 for (final AbstractFile file : directory.getFiles())
47 if (file instanceof GeneralFile) {
48 layout.enlistFile(file, directory);
49 } else if (file instanceof Picture){
50 layout.enlistImage((Picture) file, directory);
51 } else if (file instanceof Video){
52 layout.enlistVideo((Video) file);
53 } else if (file instanceof DirectoryFile)
54 layout.enlistDirectory(file, directory);
57 public abstract String getDirectoryUrl(final AbstractFile directory,
58 IndexingContext context);
60 public abstract String getParentDirectoryUrl(IndexingContext context);
62 public abstract String getThumbnailUrl(Picture picture,
63 final Dimension desiredDimension, IndexingContext context);