Class AbstractDumpFormat

java.lang.Object
mars.mips.dump.AbstractDumpFormat
All Implemented Interfaces:
DumpFormat
Direct Known Subclasses:
AsciiTextDumpFormat, BinaryDumpFormat, BinaryTextDumpFormat, HexTextDumpFormat, IntelHexDumpFormat, SegmentWindowDumpFormat

public abstract class AbstractDumpFormat extends Object implements DumpFormat
Abstract class for memory dump file formats. Provides constructors and defaults for everything except the dumpMemoryRange method itself.
Version:
December 2007
Author:
Pete Sanderson
  • Constructor Details

    • AbstractDumpFormat

      public AbstractDumpFormat(String name, String commandDescriptor, String description, String extension)
      Typical constructor. Note you cannot creates objects from this class but subclass constructor can call this one.
      Parameters:
      name - Brief descriptive name to be displayed in selection list.
      commandDescriptor - One-word descriptive name to be used by MARS command mode parser and user. Any spaces in this string will be removed.
      description - Description to go with standard file extension for display in file save dialog or to be used as tool tip.
      extension - Standard file extension for this format. Null if none.
  • Method Details

    • getFileExtension

      public String getFileExtension()
      Get the file extension associated with this format.
      Specified by:
      getFileExtension in interface DumpFormat
      Returns:
      String containing file extension -- without the leading "." -- or null if there is no standard extension.
    • getDescription

      public String getDescription()
      Get a short description of the format, suitable for displaying along with the extension, in the file save dialog, or as a tool tip.
      Specified by:
      getDescription in interface DumpFormat
      Returns:
      String containing short description to go with the extension or for use as tool tip. Possibly null.
    • toString

      public String toString()
      String representing this object.
      Specified by:
      toString in interface DumpFormat
      Overrides:
      toString in class Object
      Returns:
      Name given for this object.
    • getCommandDescriptor

      public String getCommandDescriptor()
      One-word description of format to be used by MARS command mode parser and user in conjunction with the "dump" option.
      Specified by:
      getCommandDescriptor in interface DumpFormat
      Returns:
      One-word String describing the format.
    • dumpMemoryRange

      public abstract void dumpMemoryRange(File file, int firstAddress, int lastAddress) throws AddressErrorException, IOException
      Write MIPS memory contents according to the specification for this format.
      Specified by:
      dumpMemoryRange in interface DumpFormat
      Parameters:
      file - File in which to store MIPS memory contents.
      firstAddress - first (lowest) memory address to dump. In bytes but must be on word boundary.
      lastAddress - last (highest) memory address to dump. In bytes but must be on word boundary. Will dump the word that starts at this address.
      Throws:
      AddressErrorException - if firstAddress is invalid or not on a word boundary.
      IOException - if error occurs during file output.