Small updates to SmartConfig.
* Changed the behavior of SmartConfig when setting file type properties. Now it tries to coerce the given value into a File object if it is not already a File object. * Changed the behavior of SmartConfig when retrieving a property without specifying a default value. Now it returns null if the property is not set and no default is given.
This commit is contained in:
parent
08810e88ed
commit
1227d53a14
@ -1,6 +1,6 @@
|
||||
#Tue, 25 Jan 2011 09:33:59 -0600
|
||||
#Mon, 05 Dec 2011 22:11:12 -0600
|
||||
name=jdb-util
|
||||
version=1.3
|
||||
version=1.4
|
||||
lib.local=true
|
||||
|
||||
build.number=3
|
||||
build.number=8
|
||||
|
@ -37,15 +37,15 @@ public class SmartConfig {
|
||||
catch (Exception e) { log.warn("Cannot save config file.", e) }
|
||||
}
|
||||
|
||||
def getProperty(String name) { getProperty(name, "") }
|
||||
def getProperty(String name) { getProperty(name, null) }
|
||||
|
||||
def getProperty(String name, Object defVal) {
|
||||
|
||||
log.trace("Looking up {}", name)
|
||||
|
||||
def val = props.getProperty(name)
|
||||
def val = props[name]
|
||||
|
||||
if (val == null) {
|
||||
if (val == null && defVal != null) {
|
||||
log.trace("Doesn't exists, setting with given default")
|
||||
|
||||
val = defVal
|
||||
@ -83,9 +83,10 @@ public class SmartConfig {
|
||||
|
||||
if (name ==~ /.*([dD]irectory|[dD]ir|[fF]ile)/) {
|
||||
log.trace("Interpreting as a file/directory.")
|
||||
props."$name" = value.canonicalPath
|
||||
if (!(value instanceof File)) { value = new File(value) }
|
||||
props[name] = value.canonicalPath
|
||||
} else {
|
||||
props."$name" = value.toString()
|
||||
props[name] = value.toString()
|
||||
}
|
||||
save()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user