001/* 002 * Version 0.70 01/04/2002 003 * 004 * Visit my url for update: http://www.geocities.com/beapetrovicova/ 005 * 006 * jFtp was developed by Bea Petrovicova <beapetrovicova@yahoo.com>. 007 * The design and implementation of jFtp are available for royalty-free 008 * adoption and use. This software is provided 'as is' without any 009 * guarantees. Copyright is retained by Bea Petrovicova. Redistribution 010 * of any part of jFtp or any derivative works must include this notice. 011 * 012 */ 013package cz.dhl.io; 014 015//import java.io.IOException; 016//import java.net.URL; 017//import java.net.MalformedURLException; 018 019/** 020 * Allows uniform manipulation with files from 021 * various sources. Equivalent for File object. 022 * 023 * <P><B>Only absolute pathnames are supported!</B></P> 024 * 025 * @Version 0.70 01/04/2002 026 * @author Bea Petrovicova <beapetrovicova@yahoo.com> 027 * 028 * @see java.io.File 029 */ 030public interface CoFile extends CoOrder, CoOpen 031{ 032 /** Returns the host name. 033 * <BR><I>This function is not part of java.io.File specification.</I><BR> */ 034 public String getHost(); 035 036 /* Returns the name of filesystem root. 037 * <BR><I>This function is not part of java.io.File specification.</I><BR> 038 public String getRoot(); */ 039 040 /** Returns the absolute pathname of the file represented 041 * by this object. 042 * @return full pathname (directory components + filename). */ 043 abstract public String getAbsolutePath(); 044 045 /** Returns depth (number of levels) of this abstract pathname. 046 * <BR><I>This function is not part of java.io.File specification.</I><BR> */ 047 abstract public int getPathDepth(); 048 049 /** Returns abstract pathname containing first depth 050 * levels of this pathname of the file represented by this object. 051 * <BR><I>This function is not part of java.io.File specification.</I><BR> */ 052 abstract public CoFile getPathFragment(int depth); 053 054 /** Tokens the pathname by separator. 055 * <BR><I>This function is not part of java.io.File specification.</I><BR> 056 * @return Array of strings describing directory part of the pathname: 057 * <CODE>[Server-name]/[Disk-root]<BR> 058 * [1st-level-parent-dir-name]<BR> 059 * [2nd-level-parent-dir-name]<BR> 060 * ...<BR> 061 * [Top-level-parent-dir-name]</CODE> */ 062 abstract public String []getPathArray(); 063 064 /** Returns the name of the file represented by this object. 065 * The name is everything in the pathame after 066 * the last occurrence of the separator character. 067 * @return name of the file (NO directory components). */ 068 abstract public String getName(); 069 070 /** Returns the parent part of the pathname of this File 071 * object, or null if the name has no parent part. 072 * The parent part is generally everything leading up to 073 * the last occurrence of the separator character, 074 * although the precise definition is system dependent. 075 * @return directory part of the pathname (NO filename). */ 076 abstract public String getParent(); 077 078 /** Deletes the file or directory denoted by this abstract pathname. */ 079 abstract public boolean delete() throws SecurityException; 080 081 /** Creates the directory named by this abstract pathname. */ 082 abstract public boolean mkdir() throws SecurityException; 083 084 /** Creates the directory named by this abstract pathname, 085 * including any necessary but nonexistent parent directories. */ 086 abstract public boolean mkdirs() throws SecurityException; 087 088 /** Renames the file denoted by this abstract pathname. */ 089 abstract public boolean renameTo(CoFile dest) throws SecurityException; 090 091 /** Returns the length of the file represented by this 092 * File object. 093 * @return the length, in bytes, of the file specified by 094 * this object, or 0L if the specified file does not exist. */ 095 abstract public long length(); 096 097 /** Returns the time that the file represented by this 098 * File object was last modified. 099 * @return the time the file specified by this object was 100 * last modified, or 0L if the specified file does not exist. */ 101 abstract public long lastModified(); 102 103 /** Returns the time string that the file represented by this 104 * CoFile object was last modified in short mode. 105 * @return the time string the file specified by this object was 106 * last modified. */ 107 public String lastModifiedString(); 108 109 /* Sets the last-modified time of the file or directory 110 * named by this abstract pathname. 111 * @version 1.2 112 public boolean setLastModified(long time); */ 113 114 /** Tests if the file represented by this File object 115 * is an absolute pathname. 116 * @return true if the pathname indicated by the File 117 * object is an absolute pathname; false otherwise */ 118 public boolean isAbsolute(); 119 120 /** Tests if the file represented by this File object 121 * is a directory. 122 * @return true if this File exists and is a 123 * directory; false otherwise */ 124 public boolean isDirectory(); 125 126 /** Tests if the file represented by this File object 127 * is a "normal" file. 128 * @return true if the file specified by this object 129 * exists and is a "normal" file; false otherwise */ 130 public boolean isFile(); 131 132 /** Tests whether the file named by this abstract pathname is a special file. 133 * <BR><I>This function is not part of java.io.File specification.</I><BR> */ 134 public boolean isSpecial(); 135 136 /** Tests whether the file named by this abstract pathname is a link. 137 * <BR><I>This function is not part of java.io.File specification.</I><BR> */ 138 public boolean isLink(); 139 140 /** Tests whether the file named by this abstract pathname is a hidden file. 141 * @version 1.2 */ 142 public boolean isHidden(); 143 144 /** Tests whether the application can read the file denoted 145 * by this abstract pathname. */ 146 public boolean canRead(); 147 148 /* Marks the file or directory named by this abstract pathname 149 * so that only read operations are allowed. 150 * @version 1.2 151 abstract public boolean setReadOnly(); */ 152 153 /** Tests whether the application can modify to the file 154 * denoted by this abstract pathname. */ 155 public boolean canWrite(); 156 157 /** Tests whether the file denoted by this abstract pathname exists. */ 158 public boolean exists(); 159 160 /** Returns access string. 161 * <BR><I>This function is not part of java.io.File specification.</I><BR> */ 162 public String getAccess(); 163 164 /** Returns a property string. 165 * <BR><I>This function is not part of java.io.File specification.</I><BR> 166 * @return a property string. */ 167 public String propertyString(); 168 169 /** List the available filesystem roots. 170 * <BR><I>This function is static in java.io.File specification.</I><BR> 171 * @version 1.2 */ 172 public CoFile[] listCoRoots(); 173 174 /** Returns an array of abstract pathnames denoting the files in 175 * the directory denoted by this abstract pathname. If this 176 * abstract pathname does not denote a directory, then this method 177 * returns null. Otherwise an array of File objects is returned, 178 * one for each file or directory in the directory. Pathnames 179 * denoting the directory itself and the directory's parent 180 * directory are not included in the result. Each resulting 181 * abstract pathname is constructed from this abstract pathname. 182 * There is no guarantee that the name strings in the resulting 183 * array will appear in any specific order; they are not, in 184 * particular, guaranteed to appear in alphabetical order. */ 185 abstract public CoFile[] listCoFiles() 186 throws SecurityException; 187 188 /** Returns an array of strings naming the files and directories 189 * in the directory denoted by this abstract pathname that satisfy 190 * the specified filter. The behavior of this method is the same as 191 * that of the {@link #listCoFiles()}} method, except that the strings 192 * in the returned array must satisfy the filter. If the given filter 193 * is null then all names are accepted. */ 194 abstract public CoFile[] listCoFiles(CoFilenameFilter filter) 195 throws SecurityException; 196 197 /** Returns a string representation of this object. 198 * @return a string giving the pathname of this object. */ 199 public String toString(); 200 201 /* Converts this abstract pathname into a file: URL. The exact 202 * form of the URL is system-dependent. If it can be determined 203 * that the file denoted by this abstract pathname is a directory, 204 * then the resulting URL will end with a slash. 205 * @since 1.2 206 abstract public URL toURL() throws MalformedURLException; */ 207}