Class ImageOrder
- java.lang.Object
-
- com.webcodepro.applecommander.storage.physical.ImageOrder
-
- Direct Known Subclasses:
DosOrder
,ProdosOrder
public abstract class ImageOrder extends java.lang.Object
Manages the interface between the physical disk image order and the logical operating system specific order. These management objects are intended to be hidden by Disk itself, although the ImageOrder may be changed (overridden).To implement this class, over-ride the block-oriented methods (readBlock, writeBlock) or the track and sector-oriented methods (readSector, writeSector). Ensure that isBlockDevice or isTrackAndSectorDevice is set appropriately.
Note that a block is generally assumed to be an Apple ProDOS (or Apple Pascal) formatted volume where a block is 512 bytes. The track and sector device is generally a 140K 5.25" disk, although it may be an 800K 3.5" disk with two 400K DOS volumes. In either case, the sector size will be 256 bytes.
At this time, the RDOS block of 256 bytes is managed by the RdosFormatDisk, and the 1024 byte CP/M block is managed by the CpmFormatDisk (the CP/M sector of 128 bytes is largely ignored).
Design note: The physical order could alternatively be implemented with a BlockPhysicalOrder structure which includes ProdosOrder and a Track and Sector adapter, as well as a TrackAndSectorPhysicalOrder which includes a NibblePhysicalOrder and DosOrder as well as a Block adapter class. This way, Disk contains two separate classes (block as well as a track/sector) to manage the disk.
-
-
Constructor Summary
Constructors Constructor Description ImageOrder(ByteArrayImageLayout diskImageManager)
Construct a ImageOrder.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
format()
Format the media.int
getBlocksOnDevice()
Answer with the number of blocks on this device.ByteArrayImageLayout
getDiskImageManager()
Get the physical disk image.abstract java.lang.String
getName()
Return the name of this image order.int
getPhysicalSize()
Answer with the physical size of this disk volume.int
getSectorsPerDisk()
Answer with the total number of sectors in a disk.int
getSectorsPerTrack()
Answer with the number of sectors per track on this device.int
getTracksPerDisk()
Answer with the number of tracks on this device.abstract boolean
isBlockDevice()
Indicates that this device is block ordered.boolean
isSizeApprox(int value)
Indicates if the physical disk is approximately this size.abstract boolean
isTrackAndSectorDevice()
Indicates that this device is track and sector ordered.abstract byte[]
readBlock(int block)
Read the block from the disk image.byte[]
readBytes(int start, int length)
Extract a portion of the disk image.abstract byte[]
readSector(int track, int sector)
Retrieve the specified sector.void
setDiskImageManager(ByteArrayImageLayout diskImageManager)
Set the physical disk image.abstract void
writeBlock(int block, byte[] data)
Write the block to the disk image.void
writeBytes(int start, byte[] bytes)
Write data to the disk image.abstract void
writeSector(int track, int sector, byte[] bytes)
Write the specified sector.
-
-
-
Constructor Detail
-
ImageOrder
public ImageOrder(ByteArrayImageLayout diskImageManager)
Construct a ImageOrder.
-
-
Method Detail
-
getDiskImageManager
public ByteArrayImageLayout getDiskImageManager()
Get the physical disk image.
-
getPhysicalSize
public int getPhysicalSize()
Answer with the physical size of this disk volume.
-
setDiskImageManager
public void setDiskImageManager(ByteArrayImageLayout diskImageManager)
Set the physical disk image.
-
readBytes
public byte[] readBytes(int start, int length)
Extract a portion of the disk image.
-
writeBytes
public void writeBytes(int start, byte[] bytes)
Write data to the disk image.
-
getBlocksOnDevice
public int getBlocksOnDevice()
Answer with the number of blocks on this device.
-
getName
public abstract java.lang.String getName()
Return the name of this image order.
-
readBlock
public abstract byte[] readBlock(int block)
Read the block from the disk image.
-
writeBlock
public abstract void writeBlock(int block, byte[] data)
Write the block to the disk image.
-
isBlockDevice
public abstract boolean isBlockDevice()
Indicates that this device is block ordered.
-
isTrackAndSectorDevice
public abstract boolean isTrackAndSectorDevice()
Indicates that this device is track and sector ordered.
-
getTracksPerDisk
public int getTracksPerDisk()
Answer with the number of tracks on this device.
-
getSectorsPerTrack
public int getSectorsPerTrack()
Answer with the number of sectors per track on this device.
-
readSector
public abstract byte[] readSector(int track, int sector) throws java.lang.IllegalArgumentException
Retrieve the specified sector.- Throws:
java.lang.IllegalArgumentException
-
writeSector
public abstract void writeSector(int track, int sector, byte[] bytes) throws java.lang.IllegalArgumentException
Write the specified sector.- Throws:
java.lang.IllegalArgumentException
-
isSizeApprox
public boolean isSizeApprox(int value)
Indicates if the physical disk is approximately this size. Currently hardcoded to allow up to 10 extra bytes at the end of a disk image. Must be at least the requested size!
-
format
public void format()
Format the media. Formatting at the ImageOrder level deals with low-level issues. A typical ordering just needs to have the image "wiped," and that is the assumed implementation. However, specialized orders - such as a nibbilized disk - need to lay down track and sector markers.
-
getSectorsPerDisk
public int getSectorsPerDisk()
Answer with the total number of sectors in a disk. This is used to size the disk and compare sizes instead of using byte counts which can differ.
-
-