Class PropertiesFile

java.lang.Object
net.sourceforge.jnlp.util.PropertiesFile

public class PropertiesFile extends Object
A properties object backed by a specified file without throwing exceptions. The properties are automatically loaded from the file when the first property is requested, but the save method must be called before changes are saved to the file.
Version:
$Revision: 1.4 $
  • Field Details

    • LOG

      private static final Logger LOG
    • delegate

      private final Properties delegate
      actual properties
    • lockableFile

      private final LockableFile lockableFile
      the file to save to
    • lastStore

      private long lastStore
      time of last modification, lazy loaded on getProperty
    • dirty

      private boolean dirty
  • Constructor Details

    • PropertiesFile

      public PropertiesFile(File file)
      Create a properties object backed by the specified file.
      Parameters:
      file - the file to save and load to
    • PropertiesFile

      public PropertiesFile(File file, String header)
      Create a properties object backed by the specified file.
      Parameters:
      file - the file to save and load to
      header - the file header
  • Method Details

    • getProperty

      public String getProperty(String key)
      Returns:
      the value of the specified key, or null if the key does not exist.
    • getProperty

      public String getProperty(String key, String defaultValue)
      Returns:
      the value of the specified key, or the default value if the key does not exist.
    • setProperty

      public Object setProperty(String key, String value)
      Sets the value for the specified key.
      Returns:
      the previous value
    • containsPropertyKey

      public boolean containsPropertyKey(String key)
    • containsPropertyValue

      public boolean containsPropertyValue(String value)
    • clear

      public void clear()
    • remove

      public String remove(String key)
      Removes the key (and its corresponding value) from the properties.
      Returns:
      the previous value
    • entrySet

      public Set<Map.Entry<String,String>> entrySet()
    • getStoreFile

      public File getStoreFile()
      Returns:
      the file backing this properties object.
    • load

      public boolean load()
      Ensures that the file backing these properties has been loaded; call this method before calling any method defined by a superclass.
      Returns:
      true, if file was (re-)loaded false, if file was still current
    • store

      public void store()
      Saves the properties to the file.
    • lock

      public void lock()
    • tryLock

      public boolean tryLock()
    • unlock

      public void unlock()
      Unlocks the file. Does not do anything if not holding the lock.
    • isHeldByCurrentThread

      public boolean isHeldByCurrentThread()