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

public abstract class ValueMap<T> extends Object implements Serializable
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 Details Link icon

    • noValueException Link icon

      protected static final NoValueException noValueException
    • propertyPageIndex Link icon

      protected ghidra.util.map.ValueStoragePageIndex propertyPageIndex
    • pageSize Link icon

      protected short pageSize
    • numProperties Link icon

      protected int numProperties
  • Constructor Details Link icon

    • ValueMap Link icon

      protected ValueMap(String name, Class<T> objectClass)
    • ValueMap Link icon

      protected ValueMap(String name, int numPageBits, Class<T> objectClass)
      Construct a PropertyMap
      Parameters:
      name - property name
      numPageBits - 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 Link icon

    • getDataSize Link icon

      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 Link icon

      public String getName()
      Get the name for this property manager.
    • getObjectClass Link icon

      public Class<T> getObjectClass()
      Returns property object class associated with this set.
    • getPage Link icon

      protected ghidra.util.map.ValueStoragePage<T> getPage(long pageId)
    • getOrCreatePage Link icon

      protected ghidra.util.map.ValueStoragePage<T> getOrCreatePage(long pageID)
    • intersects Link icon

      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 Link icon

      public boolean removeRange(long start, long end)
      Removes all property values within a given range.
      Parameters:
      start - begin range
      end - end range, inclusive
      Returns:
      true if any property value was removed; return false otherwise.
    • remove Link icon

      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 Link icon

      public boolean hasProperty(long index)
      returns whether there is a property value at index.
      Parameters:
      index - the long representation of an address.
    • getNextPropertyIndex Link icon

      public long getNextPropertyIndex(long index) throws NoSuchIndexException
      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 Link icon

      public long getPreviousPropertyIndex(long index) throws NoSuchIndexException
      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 Link icon

      public long getFirstPropertyIndex() throws NoSuchIndexException
      Get the first index where a property value exists.
      Throws:
      NoSuchIndexException - when there is no property value for any index.
    • getLastPropertyIndex Link icon

      public long getLastPropertyIndex() throws NoSuchIndexException
      Get the last index where a property value exists.
      Throws:
      NoSuchIndexException - thrown if there is no address having the property value.
    • getSize Link icon

      public int getSize()
      Get the number of properties in the set.
      Returns:
      the number of properties
    • getPageID Link icon

      protected final long getPageID(long index)
      Extract the page ID from the given index.
      Parameters:
      index - the long representation of an address.
    • getPageOffset Link icon

      protected final short getPageOffset(long index)
      Extract the page offset from the given index.
      Parameters:
      index - the long representation of an address.
    • getIndex Link icon

      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 Link icon

      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 move
      end - the end of the property range to move
      newStart - the new beginning of the property range after the move
    • moveIndex Link icon

      protected abstract void moveIndex(long from, long to)
    • saveProperty Link icon

      protected abstract void saveProperty(ObjectOutputStream oos, long addr) throws IOException
      Throws:
      IOException
    • restoreProperty Link icon

      protected abstract void restoreProperty(ObjectInputStream ois, long addr) throws IOException, ClassNotFoundException
      Throws:
      IOException
      ClassNotFoundException
    • getPropertyIterator Link icon

      public LongIterator getPropertyIterator(long start, long end)
      Creates an iterator over all the indexes that have this property within the given range.
      Parameters:
      start - The start address to search
      end - The end address to search
      Returns:
      LongIterator Iterator over indexes that have properties.
    • getPropertyIterator Link icon

      public LongIterator getPropertyIterator(long start, long end, boolean atStart)
      Creates an iterator over all the indexes that have this property within the given range.
      Parameters:
      start - The start address to search
      end - The end address to search
      atStart - 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 Link icon

      public LongIterator getPropertyIterator()
      Returns an iterator over the indices having the given property value.
    • getPropertyIterator Link icon

      public LongIterator getPropertyIterator(long start)
      Returns an iterator over the indices having the given property value.
      Parameters:
      start - the starting index for the iterator.
    • getPropertyIterator Link icon

      public LongIterator getPropertyIterator(long start, boolean before)
      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 Link icon

      public void saveProperties(ObjectOutputStream oos, long start, long end) throws IOException
      Saves all property values between start and end to the output stream
      Parameters:
      oos - the output stream
      start - 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 Link icon

      public void restoreProperties(ObjectInputStream ois) throws IOException, ClassNotFoundException
      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.