Package ghidra.program.model.address
Class AddressRangeImpl
- java.lang.Object
-
- ghidra.program.model.address.AddressRangeImpl
-
- All Implemented Interfaces:
AddressRange
,java.io.Serializable
,java.lang.Comparable<AddressRange>
,java.lang.Iterable<Address>
public class AddressRangeImpl extends java.lang.Object implements AddressRange, java.io.Serializable
Implementation of an AddressRange. An AddressRange is a contiguous inclusive set of addresses from some minimum to a maximum address. Once created it is immutable.- Since:
- 2000-2-16
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AddressRangeImpl(Address start, long length)
Construct an AddressRange with the given start address and length.AddressRangeImpl(AddressRange range)
Construct a new AddressRangeImpl from the given range.AddressRangeImpl(Address start, Address end)
Construct an AddressRange with the given start and end address.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Address addr)
Compares the given address to this address range.int
compareTo(AddressRange o)
boolean
contains(Address addr)
Returns true if the given address is contained in the range.boolean
equals(java.lang.Object obj)
AddressSpace
getAddressSpace()
java.math.BigInteger
getBigLength()
Returns the number of addresses as a BigInteger.long
getLength()
Returns the number of addresses in the range.Address
getMaxAddress()
Address
getMinAddress()
int
hashCode()
AddressRange
intersect(AddressRange range)
Computes the intersection of this range with another.AddressRange
intersectRange(Address start, Address end)
Computes the intersection of this range with another.boolean
intersects(AddressRange range)
Returns true if the given range intersects this range.boolean
intersects(Address start, Address end)
Returns true if the given range intersects this range.java.util.Iterator<Address>
iterator()
java.lang.String
toString()
-
-
-
Constructor Detail
-
AddressRangeImpl
public AddressRangeImpl(AddressRange range)
Construct a new AddressRangeImpl from the given range.- Parameters:
range
- the address range to copy.
-
AddressRangeImpl
public AddressRangeImpl(Address start, Address end)
Construct an AddressRange with the given start and end address. If the start address is before the end address, they are swapped to be in order.- Parameters:
start
- start address in the rangeend
- end address in the range- Throws:
java.lang.IllegalArgumentException
- thrown if the minimum and maximum addresses are not comparable.
-
AddressRangeImpl
public AddressRangeImpl(Address start, long length) throws AddressOverflowException
Construct an AddressRange with the given start address and length.- Parameters:
start
- start address in the rangelength
- the length of the range.- Throws:
AddressOverflowException
- if the length would wrap.
-
-
Method Detail
-
contains
public boolean contains(Address addr)
Description copied from interface:AddressRange
Returns true if the given address is contained in the range.- Specified by:
contains
in interfaceAddressRange
- See Also:
AddressRange.contains(ghidra.program.model.address.Address)
-
getAddressSpace
public AddressSpace getAddressSpace()
- Specified by:
getAddressSpace
in interfaceAddressRange
- Returns:
- address space this range resides within
-
getMinAddress
public Address getMinAddress()
- Specified by:
getMinAddress
in interfaceAddressRange
- Returns:
- the minimum address in the range.
- See Also:
AddressRange.getMinAddress()
-
getMaxAddress
public Address getMaxAddress()
- Specified by:
getMaxAddress
in interfaceAddressRange
- Returns:
- the maximum address in the range.
- See Also:
AddressRange.getMaxAddress()
-
getLength
public long getLength()
Description copied from interface:AddressRange
Returns the number of addresses in the range.- Specified by:
getLength
in interfaceAddressRange
- See Also:
AddressRange.getLength()
-
getBigLength
public java.math.BigInteger getBigLength()
Description copied from interface:AddressRange
Returns the number of addresses as a BigInteger.- Specified by:
getBigLength
in interfaceAddressRange
- Returns:
- the number of addresses as a BigInteger.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(Address addr)
Description copied from interface:AddressRange
Compares the given address to this address range.- Specified by:
compareTo
in interfaceAddressRange
- Parameters:
addr
- the address to compare.- Returns:
- a negative integer if the address is greater than the maximum range address, zero if the address is in the range, and a positive integer if the address is less than minimum range address.
- See Also:
AddressRange.compareTo(ghidra.program.model.address.Address)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
intersects
public boolean intersects(AddressRange range)
Description copied from interface:AddressRange
Returns true if the given range intersects this range.- Specified by:
intersects
in interfaceAddressRange
- Parameters:
range
- the range to test for intersection with.- See Also:
AddressRange.intersects(ghidra.program.model.address.AddressRange)
-
intersects
public boolean intersects(Address start, Address end)
Description copied from interface:AddressRange
Returns true if the given range intersects this range.- Specified by:
intersects
in interfaceAddressRange
- Parameters:
start
- the first address in the range to test for intersection.end
- the last address in the range to test for intersection.- See Also:
AddressRange.intersects(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
-
intersect
public AddressRange intersect(AddressRange range)
Description copied from interface:AddressRange
Computes the intersection of this range with another.- Specified by:
intersect
in interfaceAddressRange
- Parameters:
range
- the range to intersect this range with- Returns:
- AddressRange the intersection or null if the ranges do not intersect.
- See Also:
AddressRange.intersect(ghidra.program.model.address.AddressRange)
-
intersectRange
public AddressRange intersectRange(Address start, Address end)
Description copied from interface:AddressRange
Computes the intersection of this range with another.- Specified by:
intersectRange
in interfaceAddressRange
- Parameters:
start
- of rangeend
- end of range- Returns:
- AddressRange the intersection or null if the ranges do not intersect.
- See Also:
AddressRange.intersectRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
-
compareTo
public int compareTo(AddressRange o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<AddressRange>
-
-