Package ghidra.program.database.mem

# Class ByteMappingScheme

java.lang.Object
ghidra.program.database.mem.ByteMappingScheme

public class ByteMappingScheme extends Object
`ByteMappingScheme` facilitate byte mapping/decimation scheme for a mapped sub-block to an underlying source memory region.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ByteMappingScheme(int mappedByteCount, int mappedSourceByteCount)`
  Construct byte mapping scheme specified as a ratio of mapped bytes to source bytes.
  `ByteMappingScheme(String mappingScheme)`
  Construct byte mapping scheme specified as a ratio of mapped bytes to source bytes.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getMappedByteCount()`
  Get the mapped-byte-count (left-hand value in mapping ratio)
  `Address`
  `getMappedSourceAddress(Address mappedSourceBaseAddress, long offsetInSubBlock)`
  Calculate the mapped source address for a specified offset with the mapped sub-block.
  `int`
  `getMappedSourceByteCount()`
  Get the mapped-source-byte-count (right-hand value in mapping ratio)
  `boolean`
  `isOneToOneMapping()`
  Determine this scheme corresponds to a 1:1 byte mapping
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

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

- ## Constructor Details

  - ### ByteMappingScheme

    public ByteMappingScheme(int mappedByteCount, int mappedSourceByteCount)
    Construct byte mapping scheme specified as a ratio of mapped bytes to source bytes.
    Parameters:
      `mappedByteCount` - number of mapped bytes per mappedSourcebyteCount (1..127). This value must be less-than or equal to schemeSrcByteCount.
      `mappedSourceByteCount` - number of source bytes for mapping ratio (1..127)
    Throws:
      `IllegalArgumentException` - if invalid mapping scheme specified

  - ### ByteMappingScheme

    public ByteMappingScheme(String mappingScheme)
    Construct byte mapping scheme specified as a ratio of mapped bytes to source bytes. The two integer values in the range 1..127 are seperated by a ':' character. The number of mapped bytes must be less-than or equal to the number of source bytes.
    Parameters:
      `mappingScheme` - mapping scheme in string form (e.g., "2:4").
    Throws:
      `IllegalArgumentException` - if invalid mapping scheme specified

- ## Method Details

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### isOneToOneMapping

    public boolean isOneToOneMapping()
    Determine this scheme corresponds to a 1:1 byte mapping
    Returns:
      true if 1:1 mapping else false

  - ### getMappedByteCount

    public int getMappedByteCount()
    Get the mapped-byte-count (left-hand value in mapping ratio)
    Returns:
      mapped-byte-count

  - ### getMappedSourceByteCount

    public int getMappedSourceByteCount()
    Get the mapped-source-byte-count (right-hand value in mapping ratio)
    Returns:
      mapped-source-byte-count

  - ### getMappedSourceAddress

    public Address getMappedSourceAddress(Address mappedSourceBaseAddress, long offsetInSubBlock) throws AddressOverflowException
    Calculate the mapped source address for a specified offset with the mapped sub-block.
    Parameters:
      `mappedSourceBaseAddress` - mapped source base address for sub-block
      `offsetInSubBlock` - byte offset within sub-block to be mapped into source
    Returns:
      mapped source address
    Throws:
      `AddressOverflowException` - if offset in sub-block produces a wrap condition in the mapped source address space.