Class PersistentProperties
java.lang.Object
java.util.Dictionary<K,V>
 
java.util.Hashtable<Object,Object>
 
java.util.Properties
com.inductiveautomation.ignition.common.PersistentProperties
- All Implemented Interfaces:
- Serializable,- Cloneable,- Map<Object,- Object> 
A simple extension of properties that is meant to represent a file based
 property file. The entire property file will be written eventually after a call to
 setProperty(), according to the max storage frequency.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected booleanprotected intprotected booleanprotected ThreadFields inherited from class java.util.Propertiesdefaults
- 
Constructor SummaryConstructorsConstructorDescriptionPersistentProperties(File file, String comments) PersistentProperties(File file, String comments, boolean requireInitial) Creates a new PersistentProperties object.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidgetFile()intReturns the maximum rate at which the file will be written.booleanisNew()keySet()protected voidremoveIntermediate(Object key) voidsetMaxStorageFrequencyMS(int maxStorageFrequencyMS) Sets the maximum rate at which the file will be written.setProperty(String key, String value) setPropertyIntermediate(String key, String value) Sets a property without pesisting the change.voidDo the following to ensure there is always a well-formed file on the HD Write file to temp file Copy temp file to main fileprotected voidTries to call super.loadFromXML with an input stream from this file.Methods inherited from class java.util.Propertiesclear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, replace, replace, replaceAll, save, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
- 
Field Details- 
_savePausedprotected transient boolean _savePaused
- 
maxStorageFrequencyMSprotected int maxStorageFrequencyMS
- 
writeThread
- 
writeQueuedprotected transient boolean writeQueued
 
- 
- 
Constructor Details- 
PersistentProperties- Throws:
- IOException
 
- 
PersistentPropertiesCreates a new PersistentProperties object. The backup file will be "."+filename+".bak" and the clean file will be filename+"_clean".- Parameters:
- requireInitial- Whether or not a valid file or _clean file is required. If false, the constructor will accept the situation where none of the 3 files exist.
- Throws:
- IOException
 
- 
PersistentPropertiespublic PersistentProperties()
 
- 
- 
Method Details- 
getMaxStorageFrequencyMSpublic int getMaxStorageFrequencyMS()Returns the maximum rate at which the file will be written. After a property is set, the file is written immediately, unless the specified time has not passed, in which case the file will be marked as "dirty" and written when the delay expires.Defaults to 500ms. 
- 
setMaxStorageFrequencyMSpublic void setMaxStorageFrequencyMS(int maxStorageFrequencyMS) Sets the maximum rate at which the file will be written. If 0, writes will occur immediately, and in the same thread, instead of asynchronously.
- 
isNewpublic boolean isNew()
- 
getFile
- 
getTempFile
- 
tryLoadTries to call super.loadFromXML with an input stream from this file.- Throws:
- IOException- if anything goes wrong with the load.
 
- 
removeIntermediate
- 
remove
- 
setProperty- Overrides:
- setPropertyin class- Properties
 
- 
setPropertyIntermediateSets a property without pesisting the change.
- 
keySet
- 
storeChangespublic void storeChanges()Do the following to ensure there is always a well-formed file on the HD- Write file to temp file
- Copy temp file to main file
 
- 
potentiallyExecuteWriteprotected void potentiallyExecuteWrite()
- 
copyFile- Throws:
- IOException
 
 
-