added special meviz file type
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 30 Oct 2014 19:22:03 +0000 (21:22 +0200)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 30 Oct 2014 19:22:03 +0000 (21:22 +0200)
src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java
src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/MevizSpecialFile.java [new file with mode: 0644]

index 574da98..110f2bd 100755 (executable)
@@ -1,7 +1,7 @@
 /*
  * Meviz - Various tools collection to work with multimedia.
  * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- * 
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public License
  * as published by the Free Software Foundation.
@@ -26,6 +26,7 @@ import eu.svjatoslav.meviz.htmlindexer.ImageFormatError;
 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.AbstractFile;
 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.DirectoryFile;
 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.GeneralFile;
+import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.MevizSpecialFile;
 import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.Picture;
 
 /**
@@ -71,6 +72,25 @@ public class DirectoryMetadata implements Serializable {
 
        }
 
+       private AbstractFile getAbstractFile(final File parentDirectory,
+                       final File file, final String fileName) throws IOException,
+                       ImageFormatError {
+
+               if (file.isDirectory())
+                       return new DirectoryFile(parentDirectory, fileName);
+
+               final String fileExtension = FilePathParser.getFileExtension(fileName)
+                               .toLowerCase();
+
+               if (AbstractIndexer.isImage(fileExtension))
+                       return new Picture(parentDirectory, fileName);
+
+               if (fileExtension.equals("meviz"))
+                       return new MevizSpecialFile(parentDirectory, fileName);
+
+               return new GeneralFile(parentDirectory, fileName);
+       }
+
        public AbstractFile getFile(final String fileName) throws IOException {
                return fileNameToFileMap.get(fileName);
        }
@@ -96,19 +116,8 @@ public class DirectoryMetadata implements Serializable {
 
                final String fileName = file.getName();
 
-               final AbstractFile abstractFile;
-
-               if (file.isDirectory())
-                       abstractFile = new DirectoryFile(parentDirectory, fileName);
-               else {
-                       final String fileExtension = FilePathParser.getFileExtension(
-                                       fileName).toLowerCase();
-
-                       if (AbstractIndexer.isImage(fileExtension))
-                               abstractFile = new Picture(parentDirectory, fileName);
-                       else
-                               abstractFile = new GeneralFile(parentDirectory, fileName);
-               }
+               final AbstractFile abstractFile = getAbstractFile(parentDirectory,
+                               file, fileName);
 
                fileNameToFileMap.put(fileName, abstractFile);
 
diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/MevizSpecialFile.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/MevizSpecialFile.java
new file mode 100644 (file)
index 0000000..7748cb7
--- /dev/null
@@ -0,0 +1,20 @@
+package eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes;
+
+import java.io.File;
+import java.io.IOException;
+
+public class MevizSpecialFile extends AbstractFile {
+
+       private static final long serialVersionUID = -8749190459653455640L;
+
+       public MevizSpecialFile(final File parentDirectory, final String fileName)
+                       throws IOException {
+               super(parentDirectory, fileName);
+       }
+
+       @Override
+       protected void updateFileMetainfo(final File parentDirectory)
+                       throws IOException {
+       }
+
+}