1 /* 2 * dpkg - Debian Package library and the Debian Package Maven plugin 3 * (c) Copyright 2016 Gerrit Hohl 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 package net.sourceforge.javadpkg.io; 20 21 import java.util.Date; 22 23 /** 24 * <p> 25 * The meta data of a file or directory. 26 * </p> 27 * 28 * @author Gerrit Hohl (gerrit-hohl@users.sourceforge.net) 29 * @version <b>1.0</b>, 12.05.2016 by Gerrit Hohl 30 */ 31 public interface FileMetaData { 32 33 34 /** 35 * <p> 36 * Returns the path of the file excluding the name. 37 * </p> 38 * 39 * @return The path. 40 * @see #getName() 41 * @see #getAbsolutePath() 42 */ 43 String getPath(); 44 45 46 /** 47 * <p> 48 * Returns the name of the file. 49 * </p> 50 * 51 * @return The name. 52 * @see #getPath() 53 * @see #getAbsolutePath() 54 */ 55 String getName(); 56 57 58 /** 59 * <p> 60 * Returns the absolute path consisting of the path and the name of the 61 * file. 62 * </p> 63 * <p> 64 * If the file is a directory a trailing slash will be added. 65 * </p> 66 * 67 * @return The absolute path. 68 * @see #getPath() 69 * @see #getName() 70 */ 71 String getAbsolutePath(); 72 73 74 /** 75 * <p> 76 * Returns the flag if the file is a regular file. 77 * </p> 78 * <p> 79 * A symbolic link is also a file. 80 * </p> 81 * 82 * @return The flag: <code>true</code>, if the file is a regular file, 83 * <code>false</code> otherwise. 84 * @see #isDirectory() 85 * @see #isSymbolicLink() 86 */ 87 boolean isFile(); 88 89 90 /** 91 * <p> 92 * Returns the flag if the file is a directory. 93 * </p> 94 * 95 * @return The flag: <code>true</code>, if the file is a directory, 96 * <code>false</code> otherwise. 97 * @see #isFile() 98 */ 99 boolean isDirectory(); 100 101 102 /** 103 * <p> 104 * Returns the flag if the file is a symbolic link. 105 * </p> 106 * 107 * @return The flag: <code>true</code>, if the file is a symbolic link, 108 * <code>false</code> otherwise. 109 * @see #isFile() 110 * @see #getTargetPath() 111 */ 112 boolean isSymbolicLink(); 113 114 115 /** 116 * <p> 117 * Returns the target path of the symbolic link. 118 * </p> 119 * 120 * @return The target path or <code>null</code>, if this meta data does not 121 * represent a symbolic link. 122 * @see #isSymbolicLink() 123 */ 124 String getTargetPath(); 125 126 127 /** 128 * <p> 129 * Returns the owner of the file. 130 * </p> 131 * 132 * @return The owner. 133 */ 134 FileOwner getOwner(); 135 136 137 /** 138 * <p> 139 * Returns the mode of the file. 140 * </p> 141 * 142 * @return The mode. 143 */ 144 FileMode getMode(); 145 146 147 /** 148 * <p> 149 * Returns the textual representation of the mode including the directory 150 * flag. 151 * </p> 152 * <p> 153 * The returned value may look like this: <blockquote> 154 * <code>drwxrwxrwx</code></blockquote> or like this: <blockquote> 155 * <code>----------</code></blockquote> 156 * </p> 157 * 158 * @return The mode. 159 * @see FileMode#getText() 160 */ 161 String getModeAsText(); 162 163 164 /** 165 * <p> 166 * Returns the of the file in bytes. 167 * </p> 168 * 169 * @return The length or <code>-1</code>, if the length is unknown or the 170 * file is not a regular file. 171 */ 172 long getLength(); 173 174 175 /** 176 * <p> 177 * Returns the timestamp of the last modification. 178 * </p> 179 * 180 * @return The timestamp. 181 */ 182 Date getLastModifiedDate(); 183 184 185 }