ewe.io
Class FileAdapter

java.lang.Object
  extended byewe.io.FileSys
      extended byewe.io.FileBase
          extended byewe.io.File
              extended byewe.io.FileAdapter
All Implemented Interfaces:
FilePermissions, Streamable, Textable
Direct Known Subclasses:
EweFile.EweEntryFile, ZipEntryFile

public abstract class FileAdapter
extends File

This is the class that you should use when implementing a new File object. A fully implemented File object/system can be used by a FileChooser for browsing and manipulation.


Field Summary
 
Fields inherited from class ewe.io.FileBase
ClosedFolderIcon, CREATE, DriveIcon, FileIcon, FLAG_CASE_SENSITIVE, FLAG_FILE_SYSTEM_IS_READ_ONLY, FLAG_READ_ONLY, FLAG_SLOW_ACCESS, FLAG_SLOW_CHILD_COUNT, FLAG_SLOW_LIST, INFO_DETAIL_NAMES, INFO_DETAIL_WIDTHS, INFO_DETAILS, INFO_DEVICE_ICON, INFO_DEVICE_NAME, INFO_FILE_TIMES, INFO_FLAGS, INFO_FREE_DRIVE_SPACE, INFO_GROUP, INFO_ICON, INFO_ICON_LARGE, INFO_ICON_MEDIUM, INFO_ICON_SMALL, INFO_LINK_DESTINATION, INFO_OWNER, INFO_PROGRAM_DIRECTORY, INFO_ROOT_LIST, INFO_SYSTEM_TYPE, INFO_TEMPORARY_DIRECTORY, INFO_TOOL_TIP, INFO_TOTAL_DRIVE_SPACE, LIST_ALWAYS_INCLUDE_DIRECTORIES, LIST_BY_DATE, LIST_BY_SIZE, LIST_BY_TYPE, LIST_CHECK_FOR_ANY_MATCHING_CHILDREN, LIST_DESCENDING, LIST_DIRECTORIES_LAST, LIST_DIRECTORIES_ONLY, LIST_DONT_SORT, LIST_FILES_ONLY, LIST_IGNORE_DIRECTORY_STATUS, name, OpenFolderIcon, PageIcon, pathSeparator, pathSeparatorChar, READ_ONLY, READ_WRITE, separator, separatorChar, WRITE_ONLY
 
Fields inherited from class ewe.io.FileSys
DOS_SYSTEM, MEMORY_SYSTEM, PALM_SYSTEM, UNIX_SYSTEM
 
Fields inherited from interface ewe.io.FilePermissions
ALL_DOS_FLAGS, ALL_UNIX_PERMISSIONS, FLAG_ARCHIVE, FLAG_HIDDEN, FLAG_READONLY, FLAG_ROM, FLAG_ROMMODULE, FLAG_SYSTEM, GROUP_EXECUTE, GROUP_READ, GROUP_WRITE, OTHER_EXECUTE, OTHER_READ, OTHER_WRITE, OWNER_EXECUTE, OWNER_READ, OWNER_WRITE
 
Constructor Summary
protected FileAdapter()
           
 
Method Summary
 boolean createDir()
          Creates a directory.
 boolean delete()
          Deletes the file or directory.
protected  String[] doList(String mask, int listAndSortOptions)
           
protected abstract  void endFind(int search)
          This tells the File to free all resources associated with the find given the search ID returned by startFind().
abstract  boolean exists()
          Returns true if the file exists and false otherwise.
protected abstract  Object findNext(int search)
          This will find the next file in sequence given the search ID returned by startFind().
 String getFullPath()
          Return the fully qualified pathname of the file.
 Object getInfo(int value, Object source, Object resultDestination, int options)
          This method is used to get extended information about the File or the File system in general.
abstract  int getLength()
          Returns the length of the file in bytes.
protected  File getNewInstance()
           
protected  void getSetModified(Time time, boolean doGet)
          This gets/sets the modified time of the file.
protected  int getSetPermissionsAndFlags(boolean isGet, int valuesToSetOrGet, int valuesToClear)
          This is used to implement getPermissionsAndFlags() and changePermissionsAndFlags().
abstract  boolean isDirectory()
          Returns true if the file is a directory and false otherwise.
 Handle listFiles(String mask, int listAndSortOptions)
          List files asynchronously.
 boolean move(File dest)
          This moves/renames the file to the destination newFile.
 void set(File parent, String file)
          This is used to tell the File to represent a different File entity.
protected  void setFullPathName(File parent, String file)
           
 Handle setInfo(int infoCode, Object sourceParameters, int options)
          This is used to set extended information about the File or the File system in general.
protected abstract  int startFind(String mask)
          This is used as the start point for listing.
 RandomAccessStream toRandomAccessStream(String mode)
          Create and return a RandomAccessStream for reading/writing to the data associated with this File object.
 
Methods inherited from class ewe.io.File
deleteOnExit, executeFileChooser, getFileChooserClass, length, nativeGetInfo, nativeSetInfo, setFileChooserClass
 
Methods inherited from class ewe.io.FileBase
canRead, canWrite, changePermissionsAndFlags, convertMode, createTempFile, createTempFile, equals, filePathsAreEqual, fixupPath, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getChild, getCreationName, getDrivePath, getDrivePath, getFileExt, getFileExt, getFlags, getIcon, getInfo, getInputStream, getModified, getName, getNew, getNew, getNewFile, getNewFile, getNewFile, getOutputStream, getParent, getParentFile, getPath, getPermissionsAndFlags, getProgramDirectory, getPropertiesString, getRandomAccessStream, getText, getTrueChild, getTrueParent, hashCode, isFile, isHidden, isSameFileSystem, isSameVolume, lastModified, list, list, list, listMultiple, listRoots, makePath, makePath, mkdir, mkdirs, refresh, removeTrailingSlash, rename, renameTo, setInfo, setLastModified, setModified, setText, toReadableStream, toStream, toString, toSystemDependantPath, toWritableStream
 
Methods inherited from class java.lang.Object
clone, finalize, getClass
 

Constructor Detail

FileAdapter

protected FileAdapter()
Method Detail

setFullPathName

protected void setFullPathName(File parent,
                               String file)

set

public void set(File parent,
                String file)
This is used to tell the File to represent a different File entity. By default all it does is call setFullPathName() so that the protected name variable represents the full path name. If your File representation has more state than just the full path name, then override this method to setup the new state.

Overrides:
set in class File

exists

public abstract boolean exists()
Description copied from class: File
Returns true if the file exists and false otherwise.

Overrides:
exists in class File

isDirectory

public abstract boolean isDirectory()
Description copied from class: File
Returns true if the file is a directory and false otherwise.

Overrides:
isDirectory in class File

getLength

public abstract int getLength()
Description copied from class: File
Returns the length of the file in bytes.

Overrides:
getLength in class File

createDir

public boolean createDir()
Description copied from class: File
Creates a directory. Returns true if the operation is successful and false otherwise.

Overrides:
createDir in class File

delete

public boolean delete()
Description copied from class: File
Deletes the file or directory. Returns true if the operation is successful and false otherwise.

Overrides:
delete in class File

move

public boolean move(File dest)
Description copied from class: File
This moves/renames the file to the destination newFile. The newFile should not exist.

Overrides:
move in class File

getNewInstance

protected File getNewInstance()
Overrides:
getNewInstance in class File

toRandomAccessStream

public RandomAccessStream toRandomAccessStream(String mode)
                                        throws IOException
Description copied from class: FileBase
Create and return a RandomAccessStream for reading/writing to the data associated with this File object.

Overrides:
toRandomAccessStream in class FileBase
Parameters:
mode - must be "r" or "rw".
Returns:
An open RandomAccessStream
Throws:
IOException - if an open stream could not be created.

getInfo

public Object getInfo(int value,
                      Object source,
                      Object resultDestination,
                      int options)
Description copied from class: File
This method is used to get extended information about the File or the File system in general. It is used with the INFO_ specifiers and options.

Overrides:
getInfo in class File

setInfo

public Handle setInfo(int infoCode,
                      Object sourceParameters,
                      int options)
Description copied from class: FileBase
This is used to set extended information about the File or the File system in general. It is used with some of the INFO_ values.

Overrides:
setInfo in class File

getSetModified

protected void getSetModified(Time time,
                              boolean doGet)
Description copied from class: FileBase
This gets/sets the modified time of the file. should not exist.

Overrides:
getSetModified in class File

getSetPermissionsAndFlags

protected int getSetPermissionsAndFlags(boolean isGet,
                                        int valuesToSetOrGet,
                                        int valuesToClear)
                                 throws IOException,
                                        IllegalArgumentException
Description copied from class: FileBase
This is used to implement getPermissionsAndFlags() and changePermissionsAndFlags(). It should work like this:

If isGet is true, then the valuesToSetOrGet parameter will hold the flags that the user is interested in. If any of these flags are invalid on this system an IllegalArgumentException should be thrown. Otherwise the current state of the flags should be returned - it is OK to return extra flags even if they are not specified as flags the user is interested in.

If isGet is false, then the valuesToSetOrGet parameter will hold the flags to set and the valuesToClear parameter will hold the flags to clear. If any of these are not valid then an IllegalArgumentException should be thrown. Otherwise the flags should be changed and then the state of the flags AFTER the change has been made should be returned.

Overrides:
getSetPermissionsAndFlags in class File
Throws:
IOException
IllegalArgumentException

getFullPath

public String getFullPath()
Description copied from class: File
Return the fully qualified pathname of the file. Note that this will never end with a "/" EXCEPT for the root directory on a disk.

Overrides:
getFullPath in class File

listFiles

public Handle listFiles(String mask,
                        int listAndSortOptions)
List files asynchronously. NOTE: version 1.16 of Ewe does not list the files asynchronously - it is synchronous. Therefore it always returns a Handle that is completed.

By default this method calls the doList() method and then returns a completed Handle that either indicates success or failure. Methods that inherit from FileBase are encouraged to provide a better version of this (preferrable one that spawns a thread).

Overrides:
listFiles in class File
Parameters:
mask - The a file maks using '*' characters.
listAndSortOptions - LIST_ and SORT_ options ORed together.
Returns:
A Handle which can be used to monitor the progress of the operation.

doList

protected String[] doList(String mask,
                          int listAndSortOptions)

startFind

protected abstract int startFind(String mask)
This is used as the start point for listing. The method should begin the find operation and return a unique ID for the find operation.


findNext

protected abstract Object findNext(int search)
This will find the next file in sequence given the search ID returned by startFind(). It can either return a File Object or the name of the file.


endFind

protected abstract void endFind(int search)
This tells the File to free all resources associated with the find given the search ID returned by startFind().