Package ghidra.util

Class PropertyFile

  • Direct Known Subclasses:
    IndexedPropertyFile

    public class PropertyFile
    extends java.lang.Object
    Class that represents a file of property names and values. The file extension used is PROPERTY_EXT.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String name  
      protected java.lang.String parentPath  
      static java.lang.String PROPERTY_EXT
      File extension indicating the file is a property file.
      protected java.io.File propertyFile  
      protected java.lang.String storageName  
    • Constructor Summary

      Constructors 
      Constructor Description
      PropertyFile​(java.io.File dir, java.lang.String storageName, java.lang.String parentPath, java.lang.String name)
      Construct a new or existing PropertyFile.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete()
      Delete the file for this PropertyFile.
      boolean equals​(java.lang.Object obj)  
      boolean exists()
      Return whether the file for this PropertyFile exists.
      boolean getBoolean​(java.lang.String propertyName, boolean defaultValue)
      Return the boolean value with the given propertyName.
      java.lang.String getFileID()
      Returns the FileID associated with this file.
      java.io.File getFolder()
      Return the parent file to this PropertyFile.
      int getInt​(java.lang.String propertyName, int defaultValue)
      Return the int value with the given propertyName.
      long getLong​(java.lang.String propertyName, long defaultValue)
      Return the long value with the given propertyName.
      java.lang.String getName()
      Return the name of this PropertyFile.
      java.lang.String getParentPath()
      Return the path to the parent of this PropertyFile.
      java.lang.String getPath()
      Return the path to this PropertyFile.
      java.lang.String getStorageName()
      Return the storage name of this PropertyFile.
      java.lang.String getString​(java.lang.String propertyName, java.lang.String defaultValue)
      Return the string value with the given propertyName.
      int hashCode()  
      boolean isReadOnly()
      Returns true if file is writable
      long lastModified()
      Return the time of last modification in number of milliseconds.
      void moveTo​(java.io.File newParent, java.lang.String newStorageName, java.lang.String newParentPath, java.lang.String newName)
      Move this PropertyFile to the newParent file.
      void putBoolean​(java.lang.String propertyName, boolean value)
      Assign the boolean value to the given propertyName.
      void putInt​(java.lang.String propertyName, int value)
      Assign the int value to the given propertyName.
      void putLong​(java.lang.String propertyName, long value)
      Assign the long value to the given propertyName.
      void putString​(java.lang.String propertyName, java.lang.String value)
      Assign the string value to the given propertyName.
      void readState()
      Read in this PropertyFile into a SaveState object.
      void remove​(java.lang.String propertyName)
      Remove the specified property
      void setFileID​(java.lang.String fileId)
      Set the FileID associated with this file.
      void writeState()
      Write the contents of this PropertyFile.
      • Methods inherited from class java.lang.Object

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

      • PROPERTY_EXT

        public static final java.lang.String PROPERTY_EXT
        File extension indicating the file is a property file.
        See Also:
        Constant Field Values
      • propertyFile

        protected java.io.File propertyFile
      • storageName

        protected java.lang.String storageName
      • parentPath

        protected java.lang.String parentPath
      • name

        protected java.lang.String name
    • Constructor Detail

      • PropertyFile

        public PropertyFile​(java.io.File dir,
                            java.lang.String storageName,
                            java.lang.String parentPath,
                            java.lang.String name)
                     throws java.io.IOException
        Construct a new or existing PropertyFile. This form ignores retained property values for NAME and PARENT path.
        Parameters:
        dir - parent directory
        storageName - stored property file name (without extension)
        parentPath - path to parent
        name - name of the property file
        Throws:
        java.io.IOException
    • Method Detail

      • getName

        public java.lang.String getName()
        Return the name of this PropertyFile. A null value may be returned if this is an older property file and the name was not specified at time of construction.
      • isReadOnly

        public boolean isReadOnly()
        Returns true if file is writable
      • getPath

        public java.lang.String getPath()
        Return the path to this PropertyFile. A null value may be returned if this is an older property file and the name and parentPath was not specified at time of construction.
      • getParentPath

        public java.lang.String getParentPath()
        Return the path to the parent of this PropertyFile.
      • getFolder

        public java.io.File getFolder()
        Return the parent file to this PropertyFile.
      • getStorageName

        public java.lang.String getStorageName()
        Return the storage name of this PropertyFile. This name does not include the property file extension (.prp)
      • getFileID

        public java.lang.String getFileID()
        Returns the FileID associated with this file.
      • setFileID

        public void setFileID​(java.lang.String fileId)
        Set the FileID associated with this file.
        Parameters:
        fileId -
      • getInt

        public int getInt​(java.lang.String propertyName,
                          int defaultValue)
        Return the int value with the given propertyName.
        Parameters:
        propertyName - name of property that is an int
        defaultValue - value to use if the property does not exist
        Returns:
        int value
      • putInt

        public void putInt​(java.lang.String propertyName,
                           int value)
        Assign the int value to the given propertyName.
        Parameters:
        propertyName - name of property to set
        value - value to set
      • getLong

        public long getLong​(java.lang.String propertyName,
                            long defaultValue)
        Return the long value with the given propertyName.
        Parameters:
        propertyName - name of property that is a long
        defaultValue - value to use if the property does not exist
        Returns:
        long value
      • putLong

        public void putLong​(java.lang.String propertyName,
                            long value)
        Assign the long value to the given propertyName.
        Parameters:
        propertyName - name of property to set
        value - value to set
      • getString

        public java.lang.String getString​(java.lang.String propertyName,
                                          java.lang.String defaultValue)
        Return the string value with the given propertyName.
        Parameters:
        propertyName - name of property that is a string
        defaultValue - value to use if the property does not exist
        Returns:
        string value
      • putString

        public void putString​(java.lang.String propertyName,
                              java.lang.String value)
        Assign the string value to the given propertyName.
        Parameters:
        propertyName - name of property to set
        value - value to set
      • getBoolean

        public boolean getBoolean​(java.lang.String propertyName,
                                  boolean defaultValue)
        Return the boolean value with the given propertyName.
        Parameters:
        propertyName - name of property that is a boolean
        defaultValue - value to use if the property does not exist
        Returns:
        boolean value
      • putBoolean

        public void putBoolean​(java.lang.String propertyName,
                               boolean value)
        Assign the boolean value to the given propertyName.
        Parameters:
        propertyName - name of property to set
        value - value to set
      • remove

        public void remove​(java.lang.String propertyName)
        Remove the specified property
        Parameters:
        propertyName -
      • lastModified

        public long lastModified()
        Return the time of last modification in number of milliseconds.
      • writeState

        public void writeState()
                        throws java.io.IOException
        Write the contents of this PropertyFile.
        Throws:
        java.io.IOException - thrown if there was a problem writing the file
      • readState

        public void readState()
                       throws java.io.IOException
        Read in this PropertyFile into a SaveState object.
        Throws:
        java.io.IOException - thrown if there was a problem reading the file
      • moveTo

        public void moveTo​(java.io.File newParent,
                           java.lang.String newStorageName,
                           java.lang.String newParentPath,
                           java.lang.String newName)
                    throws DuplicateFileException,
                           java.io.IOException
        Move this PropertyFile to the newParent file.
        Parameters:
        newParent - new parent of the file
        newStorageName - new storage name
        newParentPath - parent path of the new parent
        newName - new name for this PropertyFile
        Throws:
        java.io.IOException - thrown if there was a problem accessing the
        DuplicateFileException - thrown if a file with the newName already exists
      • exists

        public boolean exists()
        Return whether the file for this PropertyFile exists.
      • delete

        public void delete()
        Delete the file for this PropertyFile.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object