1 /*** 2 * Copyright (c) 2003 held jointly by the individual authors. 3 * 4 * This library is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU Lesser General Public License as published 6 * by the Free Software Foundation; either version 2.1 of the License, or 7 * (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; with out even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with this library; if not, write to the Free Software Foundation, 16 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 * 18 * > http://www.gnu.org/copyleft/lesser.html 19 * > http://www.opensource.org/licenses/lgpl-license.php 20 */ 21 package net.mlw.vlh.adapter.file; 22 23 import java.io.File; 24 import java.util.Date; 25 26 /*** 27 * @author Matthew L. Wilson 28 * @version $Revision: 1.3 $ $Date: 2004/08/10 20:41:38 $ 29 */ 30 public class FileInfo 31 { 32 /*** The decorated File Object **/ 33 private File file; 34 35 /*** Default constructor 36 * 37 * @param file to decorate. 38 */ 39 public FileInfo(File file) 40 { 41 this.file = file; 42 } 43 44 /*** @see java.io.File#lastModified() 45 */ 46 public Date getLastModified() 47 { 48 return new Date(file.lastModified()); 49 } 50 51 /*** @see java.io.File#getName() 52 */ 53 public String getName() 54 { 55 return file.getName(); 56 } 57 58 /*** Gets the extention of the file. 59 * 60 * @return The extension if one exists. 61 */ 62 public String getExtention() 63 { 64 return (getName().lastIndexOf('.') != -1) ? getName().substring(getName().lastIndexOf('.'), getName().length()) : ""; 65 } 66 67 /*** @see java.io.File#getLength() 68 */ 69 public long getLength() 70 { 71 return file.length(); 72 } 73 74 /*** @see java.io.File#isDirectory() 75 */ 76 public boolean getDirectory() 77 { 78 return file.isDirectory(); 79 } 80 81 /*** @see java.io.File#canRead() 82 */ 83 public boolean getReadable() 84 { 85 return file.canRead(); 86 } 87 88 /*** @see java.io.File#canWrite() */ 89 public boolean getWritable() 90 { 91 return file.canWrite(); 92 } 93 94 /*** @see java.io.File#getAbsolutePath() */ 95 public String getAbsolutePath() 96 { 97 return file.getAbsolutePath(); 98 } 99 100 /*** @see java.lang.Object#toString() 101 */ 102 public String toString() 103 { 104 return file.getName() + " " + super.toString(); 105 } 106 107 }