Package ghidra.program.model.address
Class AddressSetViewAdapter
- java.lang.Object
-
- ghidra.program.model.address.AddressSetViewAdapter
-
- All Implemented Interfaces:
AddressSetView
,java.lang.Iterable<AddressRange>
public class AddressSetViewAdapter extends java.lang.Object implements AddressSetView
This class wraps an address set and provides read-only access to that set. This class is used to ensure that users can not violate the read-only access by casting the object to an address set.
-
-
Constructor Summary
Constructors Constructor Description AddressSetViewAdapter(AddressSetView set)
Construct an AddressSetViewAdapter for an address set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(Address addr)
Test if the address is contained within this set.boolean
contains(Address start, Address end)
Test if the given address range is contained in this set.boolean
contains(AddressSetView rangeSet)
Test if the given address set is a subset of this set.Address
findFirstAddressInCommon(AddressSetView otherSet)
Finds the first address in this collection that is also in the given addressSet.AddressIterator
getAddresses(boolean forward)
Returns an iterator over all addresses in this set.AddressIterator
getAddresses(Address start, boolean forward)
Returns an iterator over the addresses in this address set starting at the start addressAddressRangeIterator
getAddressRanges()
Returns an iterator over the address ranges in this address set.AddressRangeIterator
getAddressRanges(boolean startAtFront)
Returns an iterator over the ranges in the specified orderAddressRangeIterator
getAddressRanges(Address start, boolean forward)
Returns an iterator of address ranges starting with the range that contains the given address.AddressRange
getFirstRange()
Returns the first range in this set or null if the set is empty;AddressRange
getLastRange()
Returns the last range in this set or null if the set is empty;Address
getMaxAddress()
Return the maximum address for this set.Address
getMinAddress()
Return the minimum address for this set.long
getNumAddresses()
Returns the number of addresses in this set.int
getNumAddressRanges()
Return the number of address ranges in this set.AddressRange
getRangeContaining(Address address)
Returns the range that contains the given addressboolean
hasSameAddresses(AddressSetView view)
Returns true if the given address set contains the same set of addresses as this set.AddressSet
intersect(AddressSetView view)
Computes the intersection of this address set with the given address set.AddressSet
intersectRange(Address start, Address end)
Computes the intersection of this address set with the given address range.boolean
intersects(Address start, Address end)
Determine if the start and end range intersects with the specified address set.boolean
intersects(AddressSetView addrSet)
Determine if this address set intersects with the specified address set.boolean
isEmpty()
Returns true if this set is empty.java.util.Iterator<AddressRange>
iterator()
Returns an iterator over the address ranges in this address set.java.util.Iterator<AddressRange>
iterator(boolean forward)
Returns an iterator over the ranges in the specified orderjava.util.Iterator<AddressRange>
iterator(Address start, boolean forward)
Returns an iterator of address ranges starting with the range that contains the given address.AddressSet
subtract(AddressSetView addrSet)
Computes the difference of this address set with the given address set (this - set).AddressSet
union(AddressSetView addrSet)
Computes the union of this address set with the given address set.AddressSet
xor(AddressSetView addrSet)
Computes the exclusive-or of this address set with the given set.
-
-
-
Constructor Detail
-
AddressSetViewAdapter
public AddressSetViewAdapter(AddressSetView set)
Construct an AddressSetViewAdapter for an address set.- Parameters:
set
- the address set to wrap as a read-only object.
-
-
Method Detail
-
contains
public boolean contains(Address addr)
Description copied from interface:AddressSetView
Test if the address is contained within this set.- Specified by:
contains
in interfaceAddressSetView
- Parameters:
addr
- address to test.- Returns:
- true if addr exists in the set, false otherwise.
-
contains
public boolean contains(Address start, Address end)
Description copied from interface:AddressSetView
Test if the given address range is contained in this set.- Specified by:
contains
in interfaceAddressSetView
- Parameters:
start
- the first address in the range.end
- the last address in the range.- Returns:
- true if entire range is contained within the set, false otherwise.
-
contains
public boolean contains(AddressSetView rangeSet)
Description copied from interface:AddressSetView
Test if the given address set is a subset of this set.- Specified by:
contains
in interfaceAddressSetView
- Parameters:
rangeSet
- the set to test.- Returns:
- true if the entire set is contained within this set, false otherwise.
-
isEmpty
public boolean isEmpty()
Description copied from interface:AddressSetView
Returns true if this set is empty.- Specified by:
isEmpty
in interfaceAddressSetView
-
getMinAddress
public Address getMinAddress()
Description copied from interface:AddressSetView
Return the minimum address for this set. Returns null if the set is empty.- Specified by:
getMinAddress
in interfaceAddressSetView
-
getMaxAddress
public Address getMaxAddress()
Description copied from interface:AddressSetView
Return the maximum address for this set. Returns null if the set is empty.- Specified by:
getMaxAddress
in interfaceAddressSetView
-
getNumAddressRanges
public int getNumAddressRanges()
Description copied from interface:AddressSetView
Return the number of address ranges in this set.- Specified by:
getNumAddressRanges
in interfaceAddressSetView
-
getAddressRanges
public AddressRangeIterator getAddressRanges()
Description copied from interface:AddressSetView
Returns an iterator over the address ranges in this address set.- Specified by:
getAddressRanges
in interfaceAddressSetView
-
iterator
public java.util.Iterator<AddressRange> iterator()
Description copied from interface:AddressSetView
Returns an iterator over the address ranges in this address set.- Specified by:
iterator
in interfaceAddressSetView
- Specified by:
iterator
in interfacejava.lang.Iterable<AddressRange>
-
getAddressRanges
public AddressRangeIterator getAddressRanges(boolean startAtFront)
Description copied from interface:AddressSetView
Returns an iterator over the ranges in the specified order- Specified by:
getAddressRanges
in interfaceAddressSetView
- Parameters:
startAtFront
- the ranges are returned from lowest to highest, otherwise from highest to lowest- Returns:
- an iterator over all the addresse ranges in the set.
-
getNumAddresses
public long getNumAddresses()
Description copied from interface:AddressSetView
Returns the number of addresses in this set.- Specified by:
getNumAddresses
in interfaceAddressSetView
-
getAddresses
public AddressIterator getAddresses(boolean forward)
Description copied from interface:AddressSetView
Returns an iterator over all addresses in this set.- Specified by:
getAddresses
in interfaceAddressSetView
- Parameters:
forward
- if true the address are return in increasing order, otherwise in decreasing order.
-
getAddresses
public AddressIterator getAddresses(Address start, boolean forward)
Description copied from interface:AddressSetView
Returns an iterator over the addresses in this address set starting at the start address- Specified by:
getAddresses
in interfaceAddressSetView
- Parameters:
start
- address to start iterating at in the address setforward
- if true address are return from lowest to highest, else from highest to lowest
-
intersects
public boolean intersects(AddressSetView addrSet)
Description copied from interface:AddressSetView
Determine if this address set intersects with the specified address set.- Specified by:
intersects
in interfaceAddressSetView
- Parameters:
addrSet
- address set to check intersection with.
-
intersects
public boolean intersects(Address start, Address end)
Description copied from interface:AddressSetView
Determine if the start and end range intersects with the specified address set.- Specified by:
intersects
in interfaceAddressSetView
- Parameters:
start
- start of rangeend
- end of range- Returns:
- true if the given range intersects this address set.
-
intersect
public AddressSet intersect(AddressSetView view)
Description copied from interface:AddressSetView
Computes the intersection of this address set with the given address set. This method does not modify this address set.- Specified by:
intersect
in interfaceAddressSetView
- Parameters:
view
- the address set to intersect with.- Returns:
- AddressSet a new address set that contains all addresses that are contained in both this set and the given set.
-
intersectRange
public AddressSet intersectRange(Address start, Address end)
Description copied from interface:AddressSetView
Computes the intersection of this address set with the given address range. This method does not modify this address set.- Specified by:
intersectRange
in interfaceAddressSetView
- Parameters:
start
- start of rangeend
- end of range- Returns:
- AddressSet a new address set that contains all addresses that are contained in both this set and the given range.
-
union
public AddressSet union(AddressSetView addrSet)
Description copied from interface:AddressSetView
Computes the union of this address set with the given address set. This method does not change this address set.- Specified by:
union
in interfaceAddressSetView
- Parameters:
addrSet
- The address set to be unioned with this address set.- Returns:
- AddressSet A new address set which contains all the addresses from both this set and the given set.
-
subtract
public AddressSet subtract(AddressSetView addrSet)
Description copied from interface:AddressSetView
Computes the difference of this address set with the given address set (this - set). Note that this is not the same as (set - this). This method does not change this address set.- Specified by:
subtract
in interfaceAddressSetView
- Parameters:
addrSet
- the set to subtract from this set.- Returns:
- AddressSet a new address set which contains all the addresses that are in this set, but not in the given set.
-
xor
public AddressSet xor(AddressSetView addrSet)
Description copied from interface:AddressSetView
Computes the exclusive-or of this address set with the given set. This method does not modify this address set.- Specified by:
xor
in interfaceAddressSetView
- Returns:
- AddressSet a new address set containing all addresses that are in either this set or the given set, but not in both sets
-
hasSameAddresses
public boolean hasSameAddresses(AddressSetView view)
Description copied from interface:AddressSetView
Returns true if the given address set contains the same set of addresses as this set.- Specified by:
hasSameAddresses
in interfaceAddressSetView
- Parameters:
view
- the address set to compare.- Returns:
- true if the given set contains the same addresses as this set.
-
getAddressRanges
public AddressRangeIterator getAddressRanges(Address start, boolean forward)
Description copied from interface:AddressSetView
Returns an iterator of address ranges starting with the range that contains the given address. If there is no range containing the start address, then the the first range will be the next range greater than the start address if going forward, otherwise the range less than the start address- Specified by:
getAddressRanges
in interfaceAddressSetView
- Parameters:
start
- the address the the first range should contain.forward
- true iterators forward, false backwards- Returns:
- the AddressRange iterator
-
getFirstRange
public AddressRange getFirstRange()
Description copied from interface:AddressSetView
Returns the first range in this set or null if the set is empty;- Specified by:
getFirstRange
in interfaceAddressSetView
- Returns:
- the first range in this set or null if the set is empty;
-
getLastRange
public AddressRange getLastRange()
Description copied from interface:AddressSetView
Returns the last range in this set or null if the set is empty;- Specified by:
getLastRange
in interfaceAddressSetView
- Returns:
- the last range in this set or null if the set is empty;
-
getRangeContaining
public AddressRange getRangeContaining(Address address)
Description copied from interface:AddressSetView
Returns the range that contains the given address- Specified by:
getRangeContaining
in interfaceAddressSetView
- Parameters:
address
- the address for which to find a range.- Returns:
- the range that contains the given address.
-
iterator
public java.util.Iterator<AddressRange> iterator(boolean forward)
Description copied from interface:AddressSetView
Returns an iterator over the ranges in the specified order- Specified by:
iterator
in interfaceAddressSetView
- Parameters:
forward
- the ranges are returned from lowest to highest, otherwise from highest to lowest- Returns:
- an iterator over all the addresse ranges in the set.
-
iterator
public java.util.Iterator<AddressRange> iterator(Address start, boolean forward)
Description copied from interface:AddressSetView
Returns an iterator of address ranges starting with the range that contains the given address. If there is no range containing the start address, then the the first range will be the next range greater than the start address if going forward, otherwise the range less than the start address- Specified by:
iterator
in interfaceAddressSetView
- Parameters:
start
- the address the the first range should contain.forward
- true iterators forward, false backwards- Returns:
- the AddressRange iterator
-
findFirstAddressInCommon
public Address findFirstAddressInCommon(AddressSetView otherSet)
Description copied from interface:AddressSetView
Finds the first address in this collection that is also in the given addressSet.- Specified by:
findFirstAddressInCommon
in interfaceAddressSetView
- Parameters:
otherSet
- the addressSet to search for the first (lowest) common address.- Returns:
- the first address that is contained in this set and the given set.
-
-