Package ghidra.program.model.util
Class DefaultPropertyMap
- java.lang.Object
-
- ghidra.program.model.util.DefaultPropertyMap
-
- All Implemented Interfaces:
PropertyMap
- Direct Known Subclasses:
DefaultIntPropertyMap,DefaultLongPropertyMap,DefaultObjectPropertyMap,DefaultSettingsPropertyMap,DefaultStringPropertyMap,DefaultVoidPropertyMap
public abstract class DefaultPropertyMap extends java.lang.Object implements PropertyMap
PropertyMap is used to store values for a fixed property at address locations given as longs. The values for the property must be homogeneous, i.e. all have the same type, and are determined by which subclass of PropertyMap is instantiated. For any long the property manager can be used to tell if the property exists there and what its value is. It also maintains information that allows it to efficiently search for the next and previous occurence of the property relative to a given address. The subclass provides the createPage() method that dictates the type of PropertyPage that will be managed.
-
-
Field Summary
Fields Modifier and Type Field Description protected AddressMapImpladdrMapprotected java.lang.Stringdescriptionprotected PropertySetpropertyMgr
-
Constructor Summary
Constructors Constructor Description DefaultPropertyMap(PropertySet propertyMgr)Construct a PropertyMap
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyValue(PropertyVisitor visitor, Address addr)Applies a property value at the indicated address without knowing its type (String, int, long, etc.) by using the property visitor.java.lang.StringgetDescription()Return the property description.AddressgetFirstPropertyAddress()Get the first Address where a property value exists.AddressgetLastPropertyAddress()Get the last Address where a property value exists.java.lang.StringgetName()Get the name for this property manager.AddressgetNextPropertyAddress(Address addr)Get the next address where the property value exists.AddressgetPreviousPropertyAddress(Address addr)Get the previous Address where a property value exists.AddressIteratorgetPropertyIterator()Returns an iterator over addresses that have a property value within the property map.AddressIteratorgetPropertyIterator(Address start, boolean forward)Returns an iterator over the address having a property value.AddressIteratorgetPropertyIterator(Address start, Address end)Returns an iterator over addresses that have a property value within the given address range.AddressIteratorgetPropertyIterator(Address start, Address end, boolean forward)Returns an iterator over addresses that have a property value.AddressIteratorgetPropertyIterator(AddressSetView asv)Returns an iterator over the addresses that have a property value and are in the given address set.AddressIteratorgetPropertyIterator(AddressSetView asv, boolean forward)Returns an iterator over the addresses that have a property value and are in the given address set.intgetSize()Get the number of properties in the map.booleanhasProperty(Address addr)returns whether there is a property value at addr.booleanintersects(Address start, Address end)Given two addresses, indicate whether there is an address in that range (inclusive) having the property.booleanintersects(AddressSetView set)Indicate whether there is an address within the set which exists within this map.voidmoveRange(Address start, Address end, Address newStart)Moves the properties defined in the range from the start address thru the end address to now be located beginning at the newStart address.booleanremove(Address addr)Remove the property value at the given address.booleanremoveRange(Address start, Address end)Removes all property values within a given range.voidrestoreAll(java.io.ObjectInputStream in)Restore properties read from the given input stream.voidrestoreProperties(java.io.ObjectInputStream ois)Restore properties from the given input stream.voidsaveAll(java.io.ObjectOutputStream out)Write all properties in the map to the given output stream.voidsaveProperties(java.io.ObjectOutputStream oos, Address start, Address end)Save the properties in the given range to output stream.voidsetDescription(java.lang.String description)Set the description for this property.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ghidra.program.model.util.PropertyMap
getObject
-
-
-
-
Field Detail
-
propertyMgr
protected PropertySet propertyMgr
-
addrMap
protected AddressMapImpl addrMap
-
description
protected java.lang.String description
-
-
Constructor Detail
-
DefaultPropertyMap
public DefaultPropertyMap(PropertySet propertyMgr)
Construct a PropertyMap- Parameters:
propertyMgr- property manager that manages storage of properties
-
-
Method Detail
-
getName
public java.lang.String getName()
Get the name for this property manager.- Specified by:
getNamein interfacePropertyMap
-
setDescription
public void setDescription(java.lang.String description)
Set the description for this property.- Parameters:
description- property description
-
getDescription
public java.lang.String getDescription()
Return the property description.- Returns:
- the property description
-
intersects
public boolean intersects(Address start, Address end)
Given two addresses, indicate whether there is an address in that range (inclusive) having the property.- Specified by:
intersectsin interfacePropertyMap- Parameters:
start- the start of the range.end- the end of the range.- Returns:
- boolean true if at least one address in the range has the property, false otherwise.
-
intersects
public boolean intersects(AddressSetView set)
Description copied from interface:PropertyMapIndicate whether there is an address within the set which exists within this map.- Specified by:
intersectsin interfacePropertyMap- Parameters:
set- set of addresses- Returns:
- boolean true if at least one address in the set has the property, false otherwise.
-
removeRange
public boolean removeRange(Address start, Address end)
Removes all property values within a given range.- Specified by:
removeRangein interfacePropertyMap- Parameters:
start- begin rangeend- end range, inclusive- Returns:
- true if any property value was removed; return false otherwise.
-
remove
public boolean remove(Address addr)
Remove the property value at the given address.- Specified by:
removein interfacePropertyMap- Parameters:
addr- the address where the property should be removed- Returns:
- true if the property value was removed, false otherwise.
-
hasProperty
public boolean hasProperty(Address addr)
returns whether there is a property value at addr.- Specified by:
hasPropertyin interfacePropertyMap- Parameters:
addr- the address in question
-
getNextPropertyAddress
public Address getNextPropertyAddress(Address addr)
Get the next address where the property value exists.- Specified by:
getNextPropertyAddressin interfacePropertyMap- Parameters:
addr- 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.
-
getPreviousPropertyAddress
public Address getPreviousPropertyAddress(Address addr)
Get the previous Address where a property value exists.- Specified by:
getPreviousPropertyAddressin interfacePropertyMap- Parameters:
addr- the address from which to begin the search (exclusive).- Throws:
NoSuchIndexException- when there is no address with a property value before the given address.
-
getFirstPropertyAddress
public Address getFirstPropertyAddress()
Get the first Address where a property value exists.- Specified by:
getFirstPropertyAddressin interfacePropertyMap
-
getLastPropertyAddress
public Address getLastPropertyAddress()
Get the last Address where a property value exists.- Specified by:
getLastPropertyAddressin interfacePropertyMap- Throws:
NoSuchIndexException- thrown if there is no address having the property value.
-
getSize
public int getSize()
Get the number of properties in the map.- Specified by:
getSizein interfacePropertyMap
-
getPropertyIterator
public AddressIterator getPropertyIterator(Address start, Address end)
Returns an iterator over addresses that have a property value within the given address range.- Specified by:
getPropertyIteratorin interfacePropertyMap- Parameters:
start- the first address in the range.end- the last address in the range.- Throws:
TypeMismatchException- thrown if the property does not have values of typeObject.
-
getPropertyIterator
public AddressIterator getPropertyIterator(Address start, Address end, boolean forward)
Description copied from interface:PropertyMapReturns an iterator over addresses that have a property value.- Specified by:
getPropertyIteratorin interfacePropertyMapforward- if true will iterate in increasing address order, otherwise it will start at the end and iterate in decreasing address order- See Also:
PropertyMap.getPropertyIterator(ghidra.program.model.address.Address, ghidra.program.model.address.Address, boolean)
-
getPropertyIterator
public AddressIterator getPropertyIterator()
Returns an iterator over addresses that have a property value within the property map.- Specified by:
getPropertyIteratorin interfacePropertyMap- Throws:
TypeMismatchException- thrown if the property does not have values of typeObject.
-
getPropertyIterator
public AddressIterator getPropertyIterator(AddressSetView asv)
Returns an iterator over the addresses that have a property value and are in the given address set.- Specified by:
getPropertyIteratorin interfacePropertyMap- Parameters:
asv- the set of addresses to iterate over.
-
getPropertyIterator
public AddressIterator getPropertyIterator(AddressSetView asv, boolean forward)
Description copied from interface:PropertyMapReturns an iterator over the addresses that have a property value and are in the given address set.- Specified by:
getPropertyIteratorin interfacePropertyMapforward- if true will iterate in increasing address order, otherwise it will start at the end and iterate in decreasing address order- See Also:
PropertyMap.getPropertyIterator(ghidra.program.model.address.AddressSetView, boolean)
-
getPropertyIterator
public AddressIterator getPropertyIterator(Address start, boolean forward)
Description copied from interface:PropertyMapReturns an iterator over the address having a property value.- Specified by:
getPropertyIteratorin interfacePropertyMap- Parameters:
start- the starting addressforward- if true will iterate in increasing address order, otherwise it will start at the end and iterate in decreasing address order- See Also:
PropertyMap.getPropertyIterator(ghidra.program.model.address.Address, boolean)
-
applyValue
public void applyValue(PropertyVisitor visitor, Address addr)
Description copied from interface:PropertyMapApplies a property value at the indicated address without knowing its type (String, int, long, etc.) by using the property visitor.- Specified by:
applyValuein interfacePropertyMap- Parameters:
visitor- the property visitor that lets you apply the property without knowing its specific type ahead of time.addr- the address where the property is to be applied.- See Also:
PropertyMap.applyValue(ghidra.util.prop.PropertyVisitor, ghidra.program.model.address.Address)
-
moveRange
public void moveRange(Address start, Address end, Address newStart)
Description copied from interface:PropertyMapMoves the properties defined in the range from the start address thru the end address to now be located beginning at the newStart address. The moved properties will be located at the same relative location to the newStart address as they were previously to the start address.- Specified by:
moveRangein interfacePropertyMap- Parameters:
start- the start of the range to move.end- the end of the range to move.newStart- the new start location of the range of properties after the move.- See Also:
PropertyMap.moveRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address, ghidra.program.model.address.Address)
-
saveProperties
public void saveProperties(java.io.ObjectOutputStream oos, Address start, Address end) throws java.io.IOExceptionSave the properties in the given range to output stream.- Parameters:
oos- output stream to write tostart- start address in the rangeend- end address in the range- Throws:
java.io.IOException- if there a problem doing the write
-
restoreProperties
public void restoreProperties(java.io.ObjectInputStream ois) throws java.io.IOException, java.lang.ClassNotFoundExceptionRestore properties from the given input stream.- Parameters:
ois- input stream- Throws:
java.io.IOException- if there is a problem reading from the streamjava.lang.ClassNotFoundException- if the class for the object being read is not in the class path
-
saveAll
public void saveAll(java.io.ObjectOutputStream out) throws java.io.IOExceptionWrite all properties in the map to the given output stream.- Throws:
java.io.IOException- if there is a problem writing to the stream
-
restoreAll
public void restoreAll(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundExceptionRestore properties read from the given input stream.- Parameters:
in- input stream- Throws:
java.io.IOException- if there is a problem reading from the streamjava.lang.ClassNotFoundException- if the class for the object being read is not in the class path
-
-