From 89616731c3b8756def227874531df1b0cb2e83b4 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Thu, 30 Oct 2014 21:22:03 +0200 Subject: [PATCH] added special meviz file type --- .../metadata/DirectoryMetadata.java | 37 ++++++++++++------- .../metadata/fileTypes/MevizSpecialFile.java | 20 ++++++++++ 2 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/MevizSpecialFile.java diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java index 574da98..110f2bd 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java @@ -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 index 0000000..7748cb7 --- /dev/null +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/MevizSpecialFile.java @@ -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 { + } + +} -- 2.20.1