Package com.microstrategy.utils
Class SmartProperties
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable<java.lang.Object,java.lang.Object>
-
- java.util.Properties
-
- com.microstrategy.utils.SmartProperties
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map<java.lang.Object,java.lang.Object>
public class SmartProperties extends java.util.PropertiesSmartProperties simplifies file persistence handling by using theFileFinderto locate the properties file. Resolution of the file path is described insetPath(String).- Since:
- MicroStrategy Web 7.3.1 or earlier
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SmartProperties(java.lang.String propertiesFilePath)Constructor.SmartProperties(java.lang.String propertiesFilePath, java.util.Properties defaultProperties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanSave()java.io.InputStreamgetInputStream()Returns theInputStreamfor the properties file.protected java.io.OutputStreamgetOutputStream()Returns theOutputStreamfor the properties file.java.lang.StringgetPath()java.util.Enumeration<java.lang.Object>keys()voidload()voidsave()Persists the state of the properties object.voidsave(java.lang.String headerComment)Persists the state of the properties object.voidsetPath(java.lang.String propertiesFilePath)Sets the path of the properties file.-
Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
-
-
-
Constructor Detail
-
SmartProperties
public SmartProperties(java.lang.String propertiesFilePath) throws java.io.IOExceptionConstructor. Resolution of the file path is described insetPath(String).- Parameters:
propertiesFilePath- Location of the properties file.- Throws:
java.io.IOException- Thrown when error occurs during loading the properties file.
-
SmartProperties
public SmartProperties(java.lang.String propertiesFilePath, java.util.Properties defaultProperties) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
setPath
public void setPath(java.lang.String propertiesFilePath) throws java.io.IOExceptionSets the path of the properties file. This will not load new properties from the file, nor will it save the current state. If the file name omits the ".properties" suffix, one will be appended.
Resolution steps as follows:
- Fully qualified path provided. A new file will be created if it does not already exist.
- Relative path or file name provided. Attempt classpath lookup - file must not be inside a JAR.
- Parameters:
propertiesFilePath- Location of the properties file.- Throws:
java.io.IOException- Thrown when error occurs during loading the properties file.java.io.FileNotFoundException- if file could not be located
-
getPath
public java.lang.String getPath()
- Returns:
- The file path of the properties file.
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.FileNotFoundExceptionReturns theInputStreamfor the properties file. Please invoke one of thesavemethods to synchronize changes first.- Returns:
- the
InputStreamfor the properties file. - Throws:
java.io.FileNotFoundException- if the properties file could not be found
-
getOutputStream
protected java.io.OutputStream getOutputStream() throws java.io.FileNotFoundExceptionReturns theOutputStreamfor the properties file.- Returns:
- the
OutputStreamfor the properties file. - Throws:
java.io.FileNotFoundException- if the properties file could not be found
-
save
public void save(java.lang.String headerComment) throws java.io.IOExceptionPersists the state of the properties object. If the properties object isEmpty, save will delete the properties file.- Parameters:
headerComment- Preamble comment in the properties file.- Throws:
java.io.IOException- When error occurs during storing the states into the properties file.
-
save
public void save() throws java.io.IOExceptionPersists the state of the properties object. If the properties object isEmpty, save will delete the properties file.- Throws:
java.io.IOException- When error occurs during storing the states into the properties file.
-
canSave
public boolean canSave()
- Returns:
- whether the properties can be persisted by checking the security manager as well as file permissions
- Since:
- MicroStrategy Web 8.0.1
-
load
public void load() throws java.io.IOException- Throws:
java.io.IOException
-
keys
public java.util.Enumeration<java.lang.Object> keys()
- Overrides:
keysin classjava.util.Properties- Since:
- MicroStrategy Web 9.0.0
-
-