java.lang.Object |
↳ |
java.util.Dictionary<K, V> |
|
↳ |
java.util.Hashtable<K, V> |
|
|
↳ |
java.util.Properties |
|
|
|
↳ |
com.microstrategy.utils.SmartProperties |
Class Overview
SmartProperties simplifies file persistence handling by using the
FileFinder
to locate the properties file.
Resolution of the file path is described in setPath(String)
.
Summary
[Expand]
Inherited Fields |
From class
java.util.Properties
protected
Properties |
defaults |
|
|
Public Methods |
synchronized
boolean
|
canSave()
|
synchronized
InputStream
|
getInputStream()
Returns the InputStream for the properties file.
|
synchronized
String
|
getPath()
|
synchronized
Enumeration<Object>
|
keys()
|
synchronized
void
|
load()
|
synchronized
void
|
save()
Persists the state of the properties object.
|
synchronized
void
|
save(String headerComment)
Persists the state of the properties object.
|
synchronized
void
|
setPath(String propertiesFilePath)
Sets the path of the properties file.
|
Protected Methods |
synchronized
OutputStream
|
getOutputStream()
Returns the OutputStream for the properties file.
|
[Expand]
Inherited Methods |
From class
java.util.Properties
String
|
getProperty(String arg0, String arg1)
|
String
|
getProperty(String arg0)
|
void
|
list(PrintStream arg0)
|
void
|
list(PrintWriter arg0)
|
synchronized
void
|
load(InputStream arg0)
|
synchronized
void
|
load(Reader arg0)
|
synchronized
void
|
loadFromXML(InputStream arg0)
|
Enumeration<?>
|
propertyNames()
|
void
|
save(OutputStream arg0, String arg1)
|
synchronized
Object
|
setProperty(String arg0, String arg1)
|
void
|
store(OutputStream arg0, String arg1)
|
void
|
store(Writer arg0, String arg1)
|
void
|
storeToXML(OutputStream arg0, String arg1, String arg2)
|
void
|
storeToXML(OutputStream arg0, String arg1)
|
Set<String>
|
stringPropertyNames()
|
|
From class
java.util.Hashtable
synchronized
void
|
clear()
|
synchronized
Object
|
clone()
|
synchronized
boolean
|
contains(Object arg0)
|
synchronized
boolean
|
containsKey(Object arg0)
|
boolean
|
containsValue(Object arg0)
|
synchronized
Enumeration<V>
|
elements()
|
Set<Entry<K, V>>
|
entrySet()
|
synchronized
boolean
|
equals(Object arg0)
|
synchronized
V
|
get(Object arg0)
|
synchronized
int
|
hashCode()
|
synchronized
boolean
|
isEmpty()
|
Set<K>
|
keySet()
|
synchronized
Enumeration<K>
|
keys()
|
synchronized
V
|
put(K arg0, V arg1)
|
synchronized
void
|
putAll(Map<? extends K, ? extends V> arg0)
|
void
|
rehash()
|
synchronized
V
|
remove(Object arg0)
|
synchronized
int
|
size()
|
synchronized
String
|
toString()
|
Collection<V>
|
values()
|
|
From class
java.util.Dictionary
abstract
Enumeration<V>
|
elements()
|
abstract
V
|
get(Object arg0)
|
abstract
boolean
|
isEmpty()
|
abstract
Enumeration<K>
|
keys()
|
abstract
V
|
put(K arg0, V arg1)
|
abstract
V
|
remove(Object arg0)
|
abstract
int
|
size()
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
From interface
java.util.Map
abstract
void
|
clear()
|
abstract
boolean
|
containsKey(Object arg0)
|
abstract
boolean
|
containsValue(Object arg0)
|
abstract
Set<Entry<K, V>>
|
entrySet()
|
abstract
boolean
|
equals(Object arg0)
|
abstract
V
|
get(Object arg0)
|
abstract
int
|
hashCode()
|
abstract
boolean
|
isEmpty()
|
abstract
Set<K>
|
keySet()
|
abstract
V
|
put(K arg0, V arg1)
|
abstract
void
|
putAll(Map<? extends K, ? extends V> arg0)
|
abstract
V
|
remove(Object arg0)
|
abstract
int
|
size()
|
abstract
Collection<V>
|
values()
|
|
Public Constructors
public
SmartProperties
(String propertiesFilePath)
Parameters
propertiesFilePath |
Location of the properties file. |
Throws
IOException
| Thrown when error occurs during loading the properties file.
|
public
SmartProperties
(String propertiesFilePath, Properties defaultProperties)
Public Methods
public
synchronized
boolean
canSave
()
Returns
- whether the properties can be persisted by checking the security manager as well as file permissions
public
synchronized
InputStream
getInputStream
()
Returns the InputStream for the properties file. Please invoke
one of the save
methods to synchronize changes first.
Returns
- the InputStream for the properties file.
Throws
FileNotFoundException
| if the properties file could not be found
|
public
synchronized
String
getPath
()
Returns
- The file path of the properties file.
public
synchronized
Enumeration<Object>
keys
()
public
synchronized
void
load
()
public
synchronized
void
save
()
Persists the state of the properties object. If the properties
object isEmpty, save will delete the properties file.
Throws
IOException
| When error occurs during storing the states into the properties file.
|
public
synchronized
void
save
(String headerComment)
Persists 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
IOException
| When error occurs during storing the states into the properties file.
|
public
synchronized
void
setPath
(String propertiesFilePath)
Sets 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
IOException
| Thrown when error occurs during loading the properties file. |
FileNotFoundException
| if file could not be located
|
Protected Methods
protected
synchronized
OutputStream
getOutputStream
()
Returns the OutputStream for the properties file.
Returns
- the OutputStream for the properties file.
Throws
FileNotFoundException
| if the properties file could not be found
|