java.lang.Object
com.webcodepro.applecommander.storage.physical.ImageOrder
All Implemented Interfaces:
HintProvider
Direct Known Subclasses:
DosOrder, ProdosOrder, WozOrder

public abstract class ImageOrder extends Object implements HintProvider
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
    Construct a ImageOrder.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Format the media.
    int
    Answer with the number of blocks on this device.
    abstract String
    Return the name of this image order.
    int
    Answer with the physical size of this disk volume.
    int
    Answer with the total number of sectors in a disk.
    int
    Answer with the number of sectors per track on this device.
    Get the physical disk image.
    int
    Answer with the number of tracks on this device.
    abstract boolean
    Indicates that this device is block ordered.
    boolean
    isSizeApprox(int value)
    Indicates if the physical disk is approximately this size.
    abstract boolean
    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
    setSource(Source source)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.applecommander.hint.HintProvider

    is, isAny
  • Constructor Details

    • ImageOrder

      public ImageOrder(Source source)
      Construct a ImageOrder.
  • Method Details

    • getSource

      public Source getSource()
      Get the physical disk image.
    • getPhysicalSize

      public int getPhysicalSize()
      Answer with the physical size of this disk volume.
    • setSource

      public void setSource(Source source)
      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 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 IllegalArgumentException
      Retrieve the specified sector.
      Throws:
      IllegalArgumentException
    • writeSector

      public abstract void writeSector(int track, int sector, byte[] bytes) throws IllegalArgumentException
      Write the specified sector.
      Throws:
      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.