Package ghidra.util

# Class PropertyFile

java.lang.Object
ghidra.util.PropertyFile

Direct Known Subclasses:
  `IndexedPropertyFile`

public class PropertyFile extends 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 String`
  `name`
  `protected String`
  `parentPath`
  `static final String`
  `PROPERTY_EXT`
  File extension indicating the file is a property file.
  `protected File`
  `propertyFile`
  `protected String`
  `storageName`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PropertyFile(File dir, String storageName, String parentPath, String name)`
  Construct a new or existing PropertyFile.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `delete()`
  Delete the file for this PropertyFile.
  `boolean`
  `equals(Object obj)`
  `boolean`
  `exists()`
  Return whether the file for this PropertyFile exists.
  `boolean`
  `getBoolean(String propertyName, boolean defaultValue)`
  Return the boolean value with the given propertyName.
  `String`
  `getFileID()`
  Returns the FileID associated with this file.
  `File`
  `getFolder()`
  Return the parent file to this PropertyFile.
  `int`
  `getInt(String propertyName, int defaultValue)`
  Return the int value with the given propertyName.
  `long`
  `getLong(String propertyName, long defaultValue)`
  Return the long value with the given propertyName.
  `String`
  `getName()`
  Return the name of this PropertyFile.
  `String`
  `getParentPath()`
  Return the path to the parent of this PropertyFile.
  `String`
  `getPath()`
  Return the path to this PropertyFile.
  `String`
  `getStorageName()`
  Return the storage name of this PropertyFile.
  `String`
  `getString(String propertyName, 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(File newParent, String newStorageName, String newParentPath, String newName)`
  Move this PropertyFile to the newParent file.
  `void`
  `putBoolean(String propertyName, boolean value)`
  Assign the boolean value to the given propertyName.
  `void`
  `putInt(String propertyName, int value)`
  Assign the int value to the given propertyName.
  `void`
  `putLong(String propertyName, long value)`
  Assign the long value to the given propertyName.
  `void`
  `putString(String propertyName, String value)`
  Assign the string value to the given propertyName.
  `void`
  `readState()`
  Read in this PropertyFile into a SaveState object.
  `void`
  `remove(String propertyName)`
  Remove the specified property
  `void`
  `setFileID(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 Details

  - ### PROPERTY_EXT

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

  - ### propertyFile

    protected File propertyFile

  - ### storageName

    protected String storageName

  - ### parentPath

    protected String parentPath

  - ### name

    protected String name

- ## Constructor Details

  - ### PropertyFile

    public PropertyFile(File dir, String storageName, String parentPath, String name) throws 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:
      `IOException`

- ## Method Details

  - ### getName

    public 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 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 String getParentPath()
    Return the path to the parent of this PropertyFile.

  - ### getFolder

    public File getFolder()
    Return the parent file to this PropertyFile.

  - ### getStorageName

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

  - ### getFileID

    public String getFileID()
    Returns the FileID associated with this file.
    Returns:
      FileID associated with this file

  - ### setFileID

    public void setFileID(String fileId)
    Set the FileID associated with this file.
    Parameters:
      `fileId` -

  - ### getInt

    public int getInt(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(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(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(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 String getString(String propertyName, 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(String propertyName, 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(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(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(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 IOException
    Write the contents of this PropertyFile.
    Throws:
      `IOException` - thrown if there was a problem writing the file

  - ### readState

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

  - ### moveTo

    public void moveTo(File newParent, String newStorageName, String newParentPath, String newName) throws DuplicateFileException, 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:
      `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 `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`