com.webcodepro.applecommander.storage
Class FormattedDisk

java.lang.Object
  extended by com.webcodepro.applecommander.storage.Disk
      extended by com.webcodepro.applecommander.storage.FormattedDisk
All Implemented Interfaces:
DirectoryEntry
Direct Known Subclasses:
CpmFormatDisk, DosFormatDisk, PascalFormatDisk, ProdosFormatDisk, RdosFormatDisk

public abstract class FormattedDisk
extends Disk
implements DirectoryEntry

Abstract representation of a formatted Apple2 disk (floppy, 800k, hard disk).

Date created: Oct 5, 2002 3:51:44 PM

Author:
Rob Greene

Nested Class Summary
 class FormattedDisk.DiskInformation
          Use this inner class for label/value mappings in the disk info page.
static interface FormattedDisk.DiskUsage
          Use this inner interface for managing the disk usage data.
 class FormattedDisk.FileColumnHeader
           
 
Nested classes/interfaces inherited from class com.webcodepro.applecommander.storage.Disk
Disk.FilenameFilter
 
Field Summary
static int FILE_DISPLAY_DETAIL
           
static int FILE_DISPLAY_NATIVE
           
static int FILE_DISPLAY_STANDARD
          This inner class represents the column header information used in the directory display.
 
Fields inherited from class com.webcodepro.applecommander.storage.Disk
APPLE_10MB_HARDDISK, APPLE_140KB_DISK, APPLE_140KB_NIBBLE_DISK, APPLE_20MB_HARDDISK, APPLE_32MB_HARDDISK, APPLE_5MB_HARDDISK, APPLE_800KB_2IMG_DISK, APPLE_800KB_DISK, BLOCK_SIZE, DOS33_SECTORS_ON_140KB_DISK, PRODOS_BLOCKS_ON_140KB_DISK, SECTOR_SIZE
 
Constructor Summary
FormattedDisk(java.lang.String filename, ImageOrder imageOrder)
          Constructor for FormattedDisk.
 
Method Summary
abstract  boolean canDeleteFile()
          Indicates if this disk image can delete a file.
abstract  boolean canHaveDirectories()
          Identify if this disk format is capable of having directories.
abstract  boolean canReadFileData()
          Indicates if this disk image can read data from a file.
abstract  boolean canWriteFileData()
          Indicates if this disk image can write data to a file.
abstract  void changeImageOrder(ImageOrder imageOrder)
          Change the physical ordering of the disk.
abstract  void format()
          Format the disk.
abstract  int[] getBitmapDimensions()
          Get suggested dimensions for display of bitmap.
abstract  java.lang.String[] getBitmapLabels()
          Get the labels to use in the bitmap.
abstract  int getBitmapLength()
          Get the length of the bitmap.
 java.util.List getDiskInformation()
          Get disk information.
abstract  java.lang.String getDiskName()
          Return the name of the disk.
abstract  FormattedDisk.DiskUsage getDiskUsage()
          Get the disk usage iterator.
protected  FileEntry getFile(java.util.List files, java.lang.String filename)
          Recursive routine to locate a specific file by filename.
 FileEntry getFile(java.lang.String filename)
          Locate a specific file by filename.
 java.util.List getFileColumnHeaders(int displayMode)
          Get the standard file column header information.
abstract  byte[] getFileData(FileEntry fileEntry)
          Get the data associated with the specified FileEntry.
abstract  java.lang.String[] getFiletypes()
          Returns a list of possible file types.
abstract  java.lang.String getFormat()
          Identify the operating system format of this disk.
 FormattedDisk getFormattedDisk()
          Get the FormattedDisk associated with this DirectoryEntry.
abstract  int getFreeSpace()
          Return the amount of free space in bytes.
abstract  int getLogicalDiskNumber()
          Returns the logical disk number.
abstract  java.lang.String getSuggestedFilename(java.lang.String filename)
          Returns a valid filename for the given filename.
abstract  java.lang.String getSuggestedFiletype(java.lang.String filename)
          Returns a valid filetype for the given filename.
abstract  int getUsedSpace()
          Return the amount of used space in bytes.
abstract  boolean needsAddress(java.lang.String filetype)
          Indicates if this filetype requires an address component.
 void resizeDiskImage()
          Resize the disk image to be its full size.
abstract  void setFileData(FileEntry fileEntry, byte[] fileData)
          Writes the raw bytes into the file.
abstract  boolean supportsDeletedFiles()
          Indicates if this disk format supports "deleted" files.
 boolean supportsDiskMap()
          Indicates if this FormattedDisk supports a disk map.
protected  void writeBootCode()
          Write the AppleCommander boot code to track 0 sector 0 of the disk.
 
Methods inherited from class com.webcodepro.applecommander.storage.Disk
getDiskImageManager, getFilename, getFilenameFilters, getFormattedDisks, getImageOrder, getPhysicalSize, hasChanged, is140KbDisk, is2ImgOrder, is800KbDisk, isCompressed, isCpmFormat, isDosFormat, isDosOrder, isNewImage, isNibbleOrder, isOzDosFormat, isPascalFormat, isProdosFormat, isProdosOrder, isRdosFormat, isUniDosFormat, readBlock, readSector, resizeDiskImage, save, saveAs, setFilename, setImageOrder, writeBlock, writeSector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.webcodepro.applecommander.storage.DirectoryEntry
canCreateDirectories, canCreateFile, createDirectory, createFile, getFiles
 

Field Detail

FILE_DISPLAY_STANDARD

public static final int FILE_DISPLAY_STANDARD
This inner class represents the column header information used in the directory display. Note that this needs to be synchronized with the appropriate FileEntry objects.

See Also:
Constant Field Values

FILE_DISPLAY_NATIVE

public static final int FILE_DISPLAY_NATIVE
See Also:
Constant Field Values

FILE_DISPLAY_DETAIL

public static final int FILE_DISPLAY_DETAIL
See Also:
Constant Field Values
Constructor Detail

FormattedDisk

public FormattedDisk(java.lang.String filename,
                     ImageOrder imageOrder)
Constructor for FormattedDisk.

Method Detail

getDiskName

public abstract java.lang.String getDiskName()
Return the name of the disk. Not the physical file name, but "DISK VOLUME #xxx" (DOS 3.3) or "/MY.DISK" (ProDOS).


getFormat

public abstract java.lang.String getFormat()
Identify the operating system format of this disk.


getFreeSpace

public abstract int getFreeSpace()
Return the amount of free space in bytes.


getUsedSpace

public abstract int getUsedSpace()
Return the amount of used space in bytes.


getBitmapDimensions

public abstract int[] getBitmapDimensions()
Get suggested dimensions for display of bitmap. Typically, this will be only used for 5.25" floppies. This can return null if there is no suggestion.


getBitmapLength

public abstract int getBitmapLength()
Get the length of the bitmap.


getDiskUsage

public abstract FormattedDisk.DiskUsage getDiskUsage()
Get the disk usage iterator.


getBitmapLabels

public abstract java.lang.String[] getBitmapLabels()
Get the labels to use in the bitmap. Note that this should, at a minimum, return an array of String[1] unless the bitmap has not been implemented.


getDiskInformation

public java.util.List getDiskInformation()
Get disk information. This is intended to be pretty generic - each disk format can build this as appropriate. Each subclass should override this method and add its own detail.


getFileColumnHeaders

public java.util.List getFileColumnHeaders(int displayMode)
Get the standard file column header information. This default implementation is intended only for standard mode.


supportsDeletedFiles

public abstract boolean supportsDeletedFiles()
Indicates if this disk format supports "deleted" files. Not to be confused with being able to delete a file, this indicates that deleted entries remain in the filesystem after the file has been deleted. There are some filesystems that "compress" the file out of the structure by completely removing the entry instead of marking it deleted (like Apple Pascal).


canReadFileData

public abstract boolean canReadFileData()
Indicates if this disk image can read data from a file. If not, the reason may be as simple as it has not beem implemented to something specific about the disk.


canWriteFileData

public abstract boolean canWriteFileData()
Indicates if this disk image can write data to a file. If not, the reason may be as simple as it has not beem implemented to something specific about the disk (such as read-only image).


canHaveDirectories

public abstract boolean canHaveDirectories()
Identify if this disk format is capable of having directories.


canDeleteFile

public abstract boolean canDeleteFile()
Indicates if this disk image can delete a file. If not, the reason may be as simple as it has not beem implemented to something specific about the disk.


getFileData

public abstract byte[] getFileData(FileEntry fileEntry)
Get the data associated with the specified FileEntry. This is just the raw data. Use the FileEntry itself to read data appropriately! For instance, DOS "B" (binary) files store length and address as part of the file itself, but it is not treated as file data.

See Also:
FileEntry.getFileData()

getFile

public FileEntry getFile(java.lang.String filename)
Locate a specific file by filename. Returns a null if specific filename is not located.


getFile

protected FileEntry getFile(java.util.List files,
                            java.lang.String filename)
Recursive routine to locate a specific file by filename. Note that in the instance of a system with directories (ie, ProDOS), this really returns the first file with the given filename.


format

public abstract void format()
Format the disk. Make sure that this is what is intended - there is no backing out!


writeBootCode

protected void writeBootCode()
Write the AppleCommander boot code to track 0 sector 0 of the disk. This will work for a floppy, but may cause problems for other devices.


getLogicalDiskNumber

public abstract int getLogicalDiskNumber()
Returns the logical disk number. This can be used to identify between disks when a format supports multiple logical volumes. If a value of 0 is returned, there is not multiple logical volumes to distinguish.


getSuggestedFilename

public abstract java.lang.String getSuggestedFilename(java.lang.String filename)
Returns a valid filename for the given filename. This does not necessarily guarantee a unique filename - just validity of the filename.


getSuggestedFiletype

public abstract java.lang.String getSuggestedFiletype(java.lang.String filename)
Returns a valid filetype for the given filename. The most simple format will just assume a filetype of binary. This method is available for the interface to make an intelligent first guess as to the filetype.


getFiletypes

public abstract java.lang.String[] getFiletypes()
Returns a list of possible file types. Since the filetype is specific to each operating system, a simple String is used.


needsAddress

public abstract boolean needsAddress(java.lang.String filetype)
Indicates if this filetype requires an address component.


getFormattedDisk

public FormattedDisk getFormattedDisk()
Get the FormattedDisk associated with this DirectoryEntry. This is useful to interfaces that need to retrieve the associated disk.

Specified by:
getFormattedDisk in interface DirectoryEntry

resizeDiskImage

public void resizeDiskImage()
Resize the disk image to be its full size. Only invole this method if a size does not match exception is thrown.


supportsDiskMap

public boolean supportsDiskMap()
Indicates if this FormattedDisk supports a disk map.


changeImageOrder

public abstract void changeImageOrder(ImageOrder imageOrder)
Change the physical ordering of the disk. This must be implemented by all subclasses. See AppleUtil for common utility methods. (It is assumed that a disk needs to be copied in the appropriate order - ie, by track and sector for a DOS type disk or by blocks in a ProDOS type disk.)


setFileData

public abstract void setFileData(FileEntry fileEntry,
                                 byte[] fileData)
                          throws DiskFullException
Writes the raw bytes into the file. This bypasses any special formatting of the data (such as prepending the data with a length and/or an address). Typically, the FileEntry.setFileData method should be used.

Throws:
DiskFullException