Package ghidra.util

# Class PropertyFile

java.lang.Object
ghidra.util.PropertyFile

Direct Known Subclasses:
  `ItemPropertyFile`

public class PropertyFile extends Object
`ItemPropertyFile` provides basic property storage. The file extension used is `PROPERTY_EXT`.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `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)`
  Construct a new or existing PropertyFile.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected boolean`
  `contains(String key)`
  `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.
  `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.
  `File`
  `getParentStorageDirectory()`
  Returns the native parent storage directory containing this PropertyFile..
  `String`
  `getStorageName()`
  Return the native storage name for 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 read-only as reported by underlying native file-system.
  `long`
  `lastModified()`
  Return the time of last modification in number of milliseconds
  `void`
  `moveTo(File newStorageParent, String newStorageName)`
  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`
  `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

- ## Constructor Details

  - ### PropertyFile

    public PropertyFile(File dir, String storageName) throws IOException
    Construct a new or existing PropertyFile. This constructor ignores retained property values for NAME and PARENT path. This constructor will not throw an exception if the file does not exist.
    Parameters:
      `dir` - native directory where this file is stored
      `storageName` - stored property file name (without extension)
    Throws:
      `InvalidObjectException` - if a file parse error occurs
      `IOException` - if an IO error occurs reading an existing file

- ## Method Details

  - ### contains

    protected boolean contains(String key)

  - ### isReadOnly

    public boolean isReadOnly()
    Returns true if file is read-only as reported by underlying native file-system.
    Returns:
      true if file is read-only as reported by underlying native file-system

  - ### getParentStorageDirectory

    public File getParentStorageDirectory()
    Returns the native parent storage directory containing this PropertyFile..
    Returns:
      the native parent storage directory containing this PropertyFile.

  - ### getStorageName

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

  - ### 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` - name of property to be removed

  - ### lastModified

    public long lastModified()
    Return the time of last modification in number of milliseconds
    Returns:
      time of last modification

  - ### 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:
      `InvalidObjectException` - if a file parse error occurs
      `IOException` - thrown if there was a problem reading the file

  - ### moveTo

    public void moveTo(File newStorageParent, String newStorageName) throws DuplicateFileException, IOException
    Move this PropertyFile to the newParent file.
    Parameters:
      `newStorageParent` - new storage parent of the native file
      `newStorageName` - new storage name for this property file
    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.
    Returns:
      true if this file 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`