Package ghidra.program.util

# Interface AddressTranslator

All Known Implementing Classes:
  `DefaultAddressTranslator`, `ExternalsAddressTranslator`

public interface AddressTranslator

- ## 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.

- ## Method Details

  - ### getDestinationProgram

    Program getDestinationProgram()
    Gets the destination program for addresses that have been translated.
    Returns:
      program1.

  - ### getSourceProgram

    Program getSourceProgram()
    Gets the source program for obtaining the addresses that need to be translated.
    Returns:
      program2.

  - ### getAddress

    Address getAddress(Address sourceAddress) throws AddressTranslationException
    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.
    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.
    Throws:
      `AddressTranslationException`

  - ### isOneForOneTranslator

    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. 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.

  - ### getAddressRange

    AddressRange getAddressRange(AddressRange sourceAddressRange) throws AddressTranslationException
    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.
    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`

  - ### getAddressSet

    AddressSet getAddressSet(AddressSetView sourceAddressSet) throws AddressTranslationException
    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.
    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.
    Throws:
      `AddressTranslationException`