com.webcodepro.applecommander.storage.os.pascal
Class PascalFileEntry

java.lang.Object
  extended by com.webcodepro.applecommander.storage.os.pascal.PascalFileEntry
All Implemented Interfaces:
FileEntry

public class PascalFileEntry
extends java.lang.Object
implements FileEntry

Represents a Pascal file entry on disk.

Date created: Oct 5, 2002 12:22:34 AM

Author:
Rob Greene, John B. Matthews

Constructor Summary
PascalFileEntry(byte[] fileEntry, PascalFormatDisk disk)
          Constructor for PascalFileEntry.
 
Method Summary
 boolean canCompile()
          Indicates that this filetype can be compiled.
 void delete()
          Delete the file.
 int getBlocksUsed()
          Compute the blocks used.
 int getBytesUsedInLastBlock()
          Get the number of bytes used in files last block.
 java.util.List getFileColumnData(int displayMode)
          Get the standard file column header information.
 byte[] getFileData()
          Get file data.
 java.lang.String getFilename()
          Return the name of this file.
 java.util.List getFiles()
          Retrieve the list of files in this directory.
 java.lang.String getFiletype()
          Return the filetype of this file.
 int getFirstBlock()
          Get the block number of the file's 1st block.
 FormattedDisk getFormattedDisk()
          Get the FormattedDisk associated with this FileEntry.
 int getLastBlock()
          Get the block number of the file's last block + 1.
 int getMaximumFilenameLength()
          Return the maximum filename length.
 java.util.Date getModificationDate()
          Get the file modification date.
 int getSize()
          Compute the size of this file (in bytes).
 FileFilter getSuggestedFilter()
          Get the suggested FileFilter.
 boolean isDeleted()
          Pascal file entries are removed upon deletion, so a file entry need not be marked as deleted.
 boolean isDirectory()
          Pascal does not support directories.
 boolean isLocked()
          Identify if this file is locked
 boolean needsAddress()
          Indicates if this filetype requires an address component.
 void setAddress(int address)
          Set the address that this file loads at.
 void setBytesUsedInLastBlock(int value)
          Set the number of bytes used in files last block.
 void setEntryIndex(int index)
          Remember the index of a newly created file entry.
 void setFileCount(int count)
          Set the file count in a volume entry.
 void setFileData(byte[] data)
          Set file data for this file entry.
 void setFilename(java.lang.String filename)
          Set the name of this file.
 void setFiletype(java.lang.String filetype)
          Set the filetype.
 void setFirstBlock(int first)
          Set the block number of the file's 1st block.
 void setLastBlock(int last)
          Set the block number of the file's last block + 1.
 void setLocked(boolean lock)
          Set the lock indicator.
 void setModificationDate(java.util.Date date)
          Set the file modification date.
 byte[] toBytes()
          Get the byte[] associated with this FileEntry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PascalFileEntry

public PascalFileEntry(byte[] fileEntry,
                       PascalFormatDisk disk)
Constructor for PascalFileEntry.

Method Detail

getFirstBlock

public int getFirstBlock()
Get the block number of the file's 1st block.


setFirstBlock

public void setFirstBlock(int first)
Set the block number of the file's 1st block.


getLastBlock

public int getLastBlock()
Get the block number of the file's last block + 1.


setLastBlock

public void setLastBlock(int last)
Set the block number of the file's last block + 1.


getFilename

public java.lang.String getFilename()
Return the name of this file.

Specified by:
getFilename in interface FileEntry

setFilename

public void setFilename(java.lang.String filename)
Set the name of this file.

Specified by:
setFilename in interface FileEntry

getMaximumFilenameLength

public int getMaximumFilenameLength()
Return the maximum filename length.

Specified by:
getMaximumFilenameLength in interface FileEntry

getFiletype

public java.lang.String getFiletype()
Return the filetype of this file.

Specified by:
getFiletype in interface FileEntry

setFiletype

public void setFiletype(java.lang.String filetype)
Set the filetype.

Specified by:
setFiletype in interface FileEntry

isLocked

public boolean isLocked()
Identify if this file is locked

Specified by:
isLocked in interface FileEntry

setLocked

public void setLocked(boolean lock)
Set the lock indicator.

Specified by:
setLocked in interface FileEntry

getBytesUsedInLastBlock

public int getBytesUsedInLastBlock()
Get the number of bytes used in files last block.


setBytesUsedInLastBlock

public void setBytesUsedInLastBlock(int value)
Set the number of bytes used in files last block.


getSize

public int getSize()
Compute the size of this file (in bytes).

Specified by:
getSize in interface FileEntry

getBlocksUsed

public int getBlocksUsed()
Compute the blocks used.


isDirectory

public boolean isDirectory()
Pascal does not support directories.

Specified by:
isDirectory in interface FileEntry

getFiles

public java.util.List getFiles()
Retrieve the list of files in this directory. Always returns null, as Pascal does not support directories.


isDeleted

public boolean isDeleted()
Pascal file entries are removed upon deletion, so a file entry need not be marked as deleted. But the GUI still has a copy of the file list in memory, so we mark it deleted in delete().

Specified by:
isDeleted in interface FileEntry

delete

public void delete()
Delete the file.

Specified by:
delete in interface FileEntry

getModificationDate

public java.util.Date getModificationDate()
Get the file modification date.


setModificationDate

public void setModificationDate(java.util.Date date)
Set the file modification date.


getFileColumnData

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

Specified by:
getFileColumnData in interface FileEntry

getFileData

public byte[] getFileData()
Get file data. This handles any operating-system specific issues. Currently, the disk itself handles this.

Specified by:
getFileData in interface FileEntry

setFileData

public void setFileData(byte[] data)
                 throws DiskFullException
Set file data for this file entry. Because the directory entry may have been changed, use this.index to determine which entry to update. author John B. Matthews.

Specified by:
setFileData in interface FileEntry
Throws:
DiskFullException
See Also:
setEntryIndex(int), PascalFormatDisk.createFile()

getSuggestedFilter

public FileFilter getSuggestedFilter()
Get the suggested FileFilter. This appears to be operating system specific, so each operating system needs to implement some manner of guessing the appropriate filter.

Specified by:
getSuggestedFilter in interface FileEntry

getFormattedDisk

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

Specified by:
getFormattedDisk in interface FileEntry

toBytes

public byte[] toBytes()
Get the byte[] associated with this FileEntry. This is need to manipuate the directory as a whole.


needsAddress

public boolean needsAddress()
Indicates if this filetype requires an address component. Note that the FormattedDisk also has this method - normally, this will defer to the method on FormattedDisk, as it will be more generic.

Specified by:
needsAddress in interface FileEntry

setAddress

public void setAddress(int address)
Set the address that this file loads at.

Specified by:
setAddress in interface FileEntry

canCompile

public boolean canCompile()
Indicates that this filetype can be compiled.

Specified by:
canCompile in interface FileEntry

setEntryIndex

public void setEntryIndex(int index)
Remember the index of a newly created file entry. Required to update the entry after setFileData, which may change any or all of the new entry's fields. author John B. Matthews


setFileCount

public void setFileCount(int count)
Set the file count in a volume entry. Use only on the volume entry: dir.get(0). author John B. Matthews