Class PropertySet

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected PropertySet​(java.lang.String name, int numPageBits, java.lang.Class<?> objectClass)
      Construct a PropertyMap
      protected PropertySet​(java.lang.String name, java.lang.Class<?> objectClass)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void applyValue​(PropertyVisitor visitor, long addr)
      Based upon the type of property manager that this is, the appropriate visit() method will be called within the PropertyVisitor.
      abstract int getDataSize()
      Returns the size (in bytes) of the data that is stored in this property set.
      long getFirstPropertyIndex()
      Get the first index where a property value exists.
      protected long getIndex​(long pageID, short offset)
      Create an index from the pageID and the offset in the page.
      long getLastPropertyIndex()
      Get the last index where a property value exists.
      java.lang.String getName()
      Get the name for this property manager.
      long getNextPropertyIndex​(long index)
      Get the next index where the property value exists.
      java.lang.Class<?> getObjectClass()
      Returns property object class associated with this set.
      protected ghidra.util.prop.PropertyPage getOrCreatePage​(long pageID)  
      protected ghidra.util.prop.PropertyPage getPage​(long pageId)  
      protected long getPageID​(long index)
      Extract the page ID from the given index.
      protected 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.
      LongIterator getPropertyIterator()
      Returns an iterator over the indices having the given property value.
      LongIterator getPropertyIterator​(long start)
      Returns an iterator over the indices having the given property value.
      LongIterator getPropertyIterator​(long start, boolean before)
      Returns an iterator over the indices having the given property value.
      LongIterator getPropertyIterator​(long start, long end)
      Creates an iterator over all the indexes that have this property within the given range.
      LongIterator 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 restoreAll​(java.io.ObjectInputStream in)
      Restores all properties values from the input stream.
      void restoreProperties​(java.io.ObjectInputStream ois)
      Restores all the properties from the input stream.
      protected abstract void restoreProperty​(java.io.ObjectInputStream ois, long addr)  
      void saveAll​(java.io.ObjectOutputStream out)
      Saves all properties to the given output stream.
      void saveProperties​(java.io.ObjectOutputStream oos, long start, long end)
      Saves all property values between start and end to the output stream
      protected abstract void saveProperty​(java.io.ObjectOutputStream oos, long addr)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • propertyPageIndex

        protected ghidra.util.prop.PropertyPageIndex propertyPageIndex
      • pageSize

        protected short pageSize
      • numProperties

        protected int numProperties
    • Constructor Detail

      • PropertySet

        protected PropertySet​(java.lang.String name,
                              java.lang.Class<?> objectClass)
      • PropertySet

        protected PropertySet​(java.lang.String name,
                              int numPageBits,
                              java.lang.Class<?> 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.
    • Method Detail

      • 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

        public java.lang.String getName()
        Get the name for this property manager.
      • getObjectClass

        public java.lang.Class<?> getObjectClass()
        Returns property object class associated with this set.
      • getPage

        protected ghidra.util.prop.PropertyPage getPage​(long pageId)
      • getOrCreatePage

        protected ghidra.util.prop.PropertyPage getOrCreatePage​(long pageID)
      • 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 range
        end - 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

        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

        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

        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

        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

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

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

        protected abstract void saveProperty​(java.io.ObjectOutputStream oos,
                                             long addr)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • restoreProperty

        protected abstract void restoreProperty​(java.io.ObjectInputStream ois,
                                                long addr)
                                         throws java.io.IOException,
                                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • getPropertyIterator

        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

        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

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

        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

        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

        public void saveProperties​(java.io.ObjectOutputStream oos,
                                   long start,
                                   long end)
                            throws java.io.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:
        java.io.IOException - if an I/O error occurs on the write.
      • restoreProperties

        public void restoreProperties​(java.io.ObjectInputStream ois)
                               throws java.io.IOException,
                                      java.lang.ClassNotFoundException
        Restores all the properties from the input stream. Any existing properties will first be removed.
        Parameters:
        ois - the input stream.
        Throws:
        java.io.IOException - if I/O error occurs.
        java.lang.ClassNotFoundException - if the a class cannot be determined for the property value.
      • saveAll

        public void saveAll​(java.io.ObjectOutputStream out)
                     throws java.io.IOException
        Saves all properties to the given output stream.
        Parameters:
        out - the output stream.
        Throws:
        java.io.IOException - I/O error occurs while writing output.
      • restoreAll

        public void restoreAll​(java.io.ObjectInputStream in)
                        throws java.io.IOException,
                               java.lang.ClassNotFoundException
        Restores all properties values from the input stream.
        Parameters:
        in - the input stream.
        Throws:
        java.io.IOException - if I/O error occurs while reading from stream.
        java.lang.ClassNotFoundException - if the a class cannot be determined for the property value.
      • applyValue

        public abstract void applyValue​(PropertyVisitor visitor,
                                        long addr)
        Based upon the type of property manager that this is, the appropriate visit() method will be called within the PropertyVisitor.
        Parameters:
        visitor - object implementing the PropertyVisitor interface.
        addr - the address of where to visit (get) the property.