Package ghidra.util.map
Class ValueMap<T>
java.lang.Object
ghidra.util.map.ValueMap<T>
- Type Parameters:
T
- data value type
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
IntValueMap
,ObjectValueMap
Base class for managing data values that are accessed by an ordered long index key. Specific
data value types are determined by the derived class.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final NoValueException
protected int
protected short
protected ghidra.util.map.ValueStoragePageIndex
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract int
Returns the size (in bytes) of the data that is stored in this property set.long
Get the first index where a property value exists.protected final long
getIndex
(long pageID, short offset) Create an index from the pageID and the offset in the page.long
Get the last index where a property value exists.getName()
Get the name for this property manager.long
getNextPropertyIndex
(long index) Get the next index where the property value exists.Returns property object class associated with this set.protected ghidra.util.map.ValueStoragePage
<T> getOrCreatePage
(long pageID) protected ghidra.util.map.ValueStoragePage
<T> getPage
(long pageId) protected final long
getPageID
(long index) Extract the page ID from the given index.protected final short
getPageOffset
(long index) Extract the page offset from the given index.long
getPreviousPropertyIndex
(long index) Get the previous index where a property value exists.Returns an iterator over the indices having the given property value.getPropertyIterator
(long start) Returns an iterator over the indices having the given property value.getPropertyIterator
(long start, boolean before) Returns an iterator over the indices having the given property value.getPropertyIterator
(long start, long end) Creates an iterator over all the indexes that have this property within the given range.getPropertyIterator
(long start, long end, boolean atStart) Creates an iterator over all the indexes that have this property within the given range.int
getSize()
Get the number of properties in the set.boolean
hasProperty
(long index) returns whether there is a property value at index.boolean
intersects
(long start, long end) Given two indices it indicates whether there is an index in that range (inclusive) having the property.protected abstract void
moveIndex
(long from, long to) void
moveRange
(long start, long end, long newStart) Move the range of properties to the newStart index.boolean
remove
(long index) Remove the property value at the given index.boolean
removeRange
(long start, long end) Removes all property values within a given range.void
Restores all the properties from the input stream.protected abstract void
restoreProperty
(ObjectInputStream ois, long addr) void
saveProperties
(ObjectOutputStream oos, long start, long end) Saves all property values between start and end to the output streamprotected abstract void
saveProperty
(ObjectOutputStream oos, long addr)
-
Field Details
-
noValueException
-
propertyPageIndex
protected ghidra.util.map.ValueStoragePageIndex propertyPageIndex -
pageSize
protected short pageSize -
numProperties
protected int numProperties
-
-
Constructor Details
-
ValueMap
-
ValueMap
Construct a PropertyMap- Parameters:
name
- property namenumPageBits
- number of bits to use for the page size. Will be set to be at least 8 and no more than 15.objectClass
- saveable property value class
-
-
Method Details
-
getDataSize
public abstract int getDataSize()Returns the size (in bytes) of the data that is stored in this property set.- Returns:
- the size (in bytes) of the data that is stored in this property set.
-
getName
Get the name for this property manager. -
getObjectClass
Returns property object class associated with this set. -
getPage
-
getOrCreatePage
-
intersects
public boolean intersects(long start, long end) Given two indices it indicates whether there is an index in that range (inclusive) having the property.- Parameters:
start
- the start of the index range.end
- the end of the index range.- Returns:
- boolean true if at least one index in the range has the property, false otherwise.
-
removeRange
public boolean removeRange(long start, long end) Removes all property values within a given range.- Parameters:
start
- begin rangeend
- end range, inclusive- Returns:
- true if any property value was removed; return false otherwise.
-
remove
public boolean remove(long index) Remove the property value at the given index.- Parameters:
index
- the long representation of an address.- Returns:
- true if the property value was removed, false otherwise.
-
hasProperty
public boolean hasProperty(long index) returns whether there is a property value at index.- Parameters:
index
- the long representation of an address.
-
getNextPropertyIndex
Get the next index where the property value exists.- Parameters:
index
- the address from which to begin the search (exclusive).- Throws:
NoSuchIndexException
- thrown if there is no address with a property value after the given address.
-
getPreviousPropertyIndex
Get the previous index where a property value exists.- Parameters:
index
- the long representation of an address from which to begin the search (exclusive).- Throws:
NoSuchIndexException
- when there is no index with a property value before the given address.
-
getFirstPropertyIndex
Get the first index where a property value exists.- Throws:
NoSuchIndexException
- when there is no property value for any index.
-
getLastPropertyIndex
Get the last index where a property value exists.- Throws:
NoSuchIndexException
- thrown if there is no address having the property value.
-
getSize
public int getSize()Get the number of properties in the set.- Returns:
- the number of properties
-
getPageID
protected final long getPageID(long index) Extract the page ID from the given index.- Parameters:
index
- the long representation of an address.
-
getPageOffset
protected final short getPageOffset(long index) Extract the page offset from the given index.- Parameters:
index
- the long representation of an address.
-
getIndex
protected final long getIndex(long pageID, short offset) Create an index from the pageID and the offset in the page.- Returns:
- the long representation of an address.
-
moveRange
public void moveRange(long start, long end, long newStart) Move the range of properties to the newStart index.- Parameters:
start
- the beginning of the property range to moveend
- the end of the property range to movenewStart
- the new beginning of the property range after the move
-
moveIndex
protected abstract void moveIndex(long from, long to) -
saveProperty
- Throws:
IOException
-
restoreProperty
protected abstract void restoreProperty(ObjectInputStream ois, long addr) throws IOException, ClassNotFoundException - Throws:
IOException
ClassNotFoundException
-
getPropertyIterator
Creates an iterator over all the indexes that have this property within the given range.- Parameters:
start
- The start address to searchend
- The end address to search- Returns:
- LongIterator Iterator over indexes that have properties.
-
getPropertyIterator
Creates an iterator over all the indexes that have this property within the given range.- Parameters:
start
- The start address to searchend
- The end address to searchatStart
- indicates if the iterator should begin at the start address, otherwise it will start at the last address. Set this flag to false if you want to iterate backwards through the properties.- Returns:
- LongIterator Iterator over indexes that have properties.
-
getPropertyIterator
Returns an iterator over the indices having the given property value. -
getPropertyIterator
Returns an iterator over the indices having the given property value.- Parameters:
start
- the starting index for the iterator.
-
getPropertyIterator
Returns an iterator over the indices having the given property value.- Parameters:
start
- the starting index for the iterator.before
- if true the iterator will be positioned before the start value.
-
saveProperties
Saves all property values between start and end to the output stream- Parameters:
oos
- the output streamstart
- the first index in the range to save.end
- the last index in the range to save.- Throws:
IOException
- if an I/O error occurs on the write.
-
restoreProperties
Restores all the properties from the input stream. Any existing properties will first be removed.- Parameters:
ois
- the input stream.- Throws:
IOException
- if I/O error occurs.ClassNotFoundException
- if the a class cannot be determined for the property value.
-