Package ghidra.program.util

# Class DefaultAddressTranslator

java.lang.Object
ghidra.program.util.DefaultAddressTranslator

All Implemented Interfaces:
  `AddressTranslator`

public class DefaultAddressTranslator extends Object implements AddressTranslator

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Program`
  `destinationProgram`
  `protected Program`
  `sourceProgram`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DefaultAddressTranslator(Program destinationProgram, Program sourceProgram)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Address`
  `getAddress(Address sourceAddress)`
  Converts the given source address to the returned destination address.
  `AddressRange`
  `getAddressRange(AddressRange sourceAddressRange)`
  Converts the given source address range to the returned destination address range.
  `AddressSet`
  `getAddressSet(AddressSetView sourceAddressSet)`
  Converts the given source address set to the returned destination address set.
  `Program`
  `getDestinationProgram()`
  Gets the destination program for addresses that have been translated.
  `Program`
  `getSourceProgram()`
  Gets the source program for obtaining the addresses that need to be translated.
  `boolean`
  `isOneForOneTranslator()`
  This method should return true if it can translate an address set from the source program to an address set for the destination program and there is a one to one correspondence between the two programs addresses.

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

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

- ## Field Details

  - ### destinationProgram

    protected Program destinationProgram

  - ### sourceProgram

    protected Program sourceProgram

- ## Constructor Details

  - ### DefaultAddressTranslator

    public DefaultAddressTranslator(Program destinationProgram, Program sourceProgram)

- ## Method Details

  - ### getDestinationProgram

    public Program getDestinationProgram()
    Description copied from interface: `AddressTranslator`
    Gets the destination program for addresses that have been translated.
    Specified by:
      `getDestinationProgram` in interface `AddressTranslator`
    Returns:
      program1.

  - ### getSourceProgram

    public Program getSourceProgram()
    Description copied from interface: `AddressTranslator`
    Gets the source program for obtaining the addresses that need to be translated.
    Specified by:
      `getSourceProgram` in interface `AddressTranslator`
    Returns:
      program2.

  - ### getAddress

    public Address getAddress(Address sourceAddress)
    Description copied from interface: `AddressTranslator`
    Converts the given source address to the returned destination address. This interface is intended to translate an address from the source program to an address in the destination program.
    Specified by:
      `getAddress` in interface `AddressTranslator`
    Parameters:
      `sourceAddress` - the source address to be converted.
    Returns:
      the destination address that is equivalent in some way to the source address. How the address is equivalent depends upon the particular translator. throws AddressTranslationException if the address can't be translated to an equivalent address in the other program.

  - ### isOneForOneTranslator

    public boolean isOneForOneTranslator()
    Description copied from interface: `AddressTranslator`
    This method should return true if it can translate an address set from the source program to an address set for the destination program and there is a one to one correspondence between the two programs addresses. In other words two addresses that make up the start and end of an address range would be at the same distance and relative location from each other as the equivalent two individual translated addresses are from each other. Otherwise this should return false.
    Specified by:
      `isOneForOneTranslator` in interface `AddressTranslator`

  - ### getAddressSet

    public AddressSet getAddressSet(AddressSetView sourceAddressSet)
    Description copied from interface: `AddressTranslator`
    Converts the given source address set to the returned destination address set. This interface is intended to translate an address set from the source program to an address set in the destination program.
    This method should be implemented if isOneForOneTranslator() returns true.
    Specified by:
      `getAddressSet` in interface `AddressTranslator`
    Parameters:
      `sourceAddressSet` - the source address set to be converted.
    Returns:
      the destination address set that is equivalent in some way to the source address set. How the address set is equivalent depends upon the particular translator. throws AddressTranslationException if the address set can't be translated to an equivalent address set in the other program.

  - ### getAddressRange

    public AddressRange getAddressRange(AddressRange sourceAddressRange) throws AddressTranslationException
    Description copied from interface: `AddressTranslator`
    Converts the given source address range to the returned destination address range. This interface is intended to translate an address range from the source program to an address range in the destination program.
    This method should be implemented if isOneForOneTranslator() returns true.
    Specified by:
      `getAddressRange` in interface `AddressTranslator`
    Parameters:
      `sourceAddressRange` - the source address range to be converted.
    Returns:
      the destination address range that is equivalent in some way to the source address range. How the address range is equivalent depends upon the particular translator. throws AddressTranslationException if the address set can't be translated to an equivalent address range in the other program.
    Throws:
      `AddressTranslationException`