code cleanup and formatting
[meviz.git] / src / main / java / eu / svjatoslav / meviz / htmlindexer / metadata / fileTypes / AbstractFile.java
index 5c8b105..9c35a32 100644 (file)
@@ -1,92 +1,92 @@
 package eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes;
 
+import eu.svjatoslav.commons.file.FilePathParser;
+
 import java.io.File;
 import java.io.IOException;
 import java.io.Serializable;
 
-import eu.svjatoslav.commons.file.FilePathParser;
-
 public abstract class AbstractFile implements Serializable {
 
-       private static final long serialVersionUID = -2547388204667088033L;
-
-       /**
-        * File name relative to the immediate parent directory.
-        */
-       public final String fileName;
-
-       /**
-        * File length in bytes.
-        */
-       private long fileLength = -1;
-
-       private transient boolean metaInfoVerified;
-
-       public AbstractFile(final File parentDirectory, final String fileName)
-                       throws Exception {
-               this.fileName = fileName;
-               ensureFileMetainfoIsUpToDate(parentDirectory);
-       }
-
-       /**
-        * @return <code>true</code> if file metadata was updated.
-        */
-       public boolean ensureFileMetainfoIsUpToDate(final File parentDirectory)
-                       throws Exception {
-               if (!isMetainfoUpToDate(parentDirectory)) {
-                       fileLength = getFile(parentDirectory).length();
-                       updateFileMetainfo(parentDirectory);
-                       metaInfoVerified = true;
-                       return true;
-               }
-               return false;
-       };
-
-       public boolean fileExists(final File parentDirectory) {
-               return getFile(parentDirectory).exists();
-       }
-
-       public File getFile(final File parentDirectory) {
-               return new File(parentDirectory.getAbsolutePath(), fileName);
-       }
-
-       public String getFileExtension() {
-               return FilePathParser.getFileExtension(fileName);
-       }
-
-       public long getFileLength() {
-               return fileLength;
-       }
-
-       private boolean isMetainfoUpToDate(final java.io.File parentDirectory)
-                       throws IOException {
-
-               if (metaInfoVerified)
-                       return true;
-
-               final File file = getFile(parentDirectory);
-
-               // first check that file exists at all
-               if (!file.exists()) {
-                       System.out.println(file);
-                       throw new RuntimeException("Picture file by name \"" + fileName
-                                       + "\" does not exist in the parent directory \""
-                                       + parentDirectory.getAbsolutePath() + "\"");
-               }
-
-               // check that file length is the same as before
-               if (file.length() != fileLength)
-                       return false;
-
-               metaInfoVerified = true;
-               return true;
-       }
-
-       public boolean isMetaInfoVerified() {
-               return metaInfoVerified;
-       }
-
-       protected abstract void updateFileMetainfo(final File parentDirectory)
-                       throws Exception;
+    private static final long serialVersionUID = -2547388204667088033L;
+
+    /**
+     * File name relative to the immediate parent directory.
+     */
+    public final String fileName;
+
+    /**
+     * File length in bytes.
+     */
+    private long fileLength = -1;
+
+    private transient boolean metaInfoVerified;
+
+    public AbstractFile(final File parentDirectory, final String fileName)
+            throws Exception {
+        this.fileName = fileName;
+        ensureFileMetainfoIsUpToDate(parentDirectory);
+    }
+
+    /**
+     * @return <code>true</code> if file metadata was updated.
+     */
+    public boolean ensureFileMetainfoIsUpToDate(final File parentDirectory)
+            throws Exception {
+        if (!isMetainfoUpToDate(parentDirectory)) {
+            fileLength = getFile(parentDirectory).length();
+            updateFileMetainfo(parentDirectory);
+            metaInfoVerified = true;
+            return true;
+        }
+        return false;
+    }
+
+    public boolean fileExists(final File parentDirectory) {
+        return getFile(parentDirectory).exists();
+    }
+
+    public File getFile(final File parentDirectory) {
+        return new File(parentDirectory.getAbsolutePath(), fileName);
+    }
+
+    public String getFileExtension() {
+        return FilePathParser.getFileExtension(fileName);
+    }
+
+    public long getFileLength() {
+        return fileLength;
+    }
+
+    private boolean isMetainfoUpToDate(final java.io.File parentDirectory)
+            throws IOException {
+
+        if (metaInfoVerified)
+            return true;
+
+        final File file = getFile(parentDirectory);
+
+        // first check that file exists at all
+        if (!file.exists()) {
+            System.out.println(file);
+            throw new RuntimeException("Picture file by name \"" + fileName
+                    + "\" does not exist in the parent directory \""
+                    + parentDirectory.getAbsolutePath() + "\"");
+        }
+
+        // check that file length is the same as before
+        if (file.length() != fileLength)
+            return false;
+
+        metaInfoVerified = true;
+        return true;
+    }
+
+    public boolean isMetaInfoVerified() {
+        return metaInfoVerified;
+    }
+
+    protected abstract void updateFileMetainfo(final File parentDirectory)
+            throws Exception;
 
 }