398 |
|
|
399 |
writer.flush (); |
writer.flush (); |
400 |
} |
} |
|
|
|
|
/** |
|
|
* Internal method called by getProperty() methods. This avoids |
|
|
* recursive calls if getProperty() methods are overwritten in |
|
|
* a subclass. |
|
|
* |
|
|
* @param key the key for the property to fetch |
|
|
* @param defaultValue the defaultValue or <code>null</code> if there |
|
|
* is no default value |
|
|
*/ |
|
|
private String getPropertyInternal(String key, String defaultValue) |
|
|
{ |
|
|
Properties prop = this; |
|
|
// Eliminate tail recursion. |
|
|
do |
|
|
{ |
|
|
String value = (String) prop.get(key); |
|
|
if (value != null) |
|
|
return value; |
|
|
prop = prop.defaults; |
|
|
} |
|
|
while (prop != null); |
|
|
return defaultValue; |
|
|
} |
|
401 |
|
|
402 |
/** |
/** |
403 |
* Gets the property with the specified key in this property list. |
* Gets the property with the specified key in this property list. |
414 |
*/ |
*/ |
415 |
public String getProperty(String key) |
public String getProperty(String key) |
416 |
{ |
{ |
417 |
return getPropertyInternal(key, null); |
Properties prop = this; |
418 |
|
// Eliminate tail recursion. |
419 |
|
do |
420 |
|
{ |
421 |
|
String value = (String) prop.get(key); |
422 |
|
if (value != null) |
423 |
|
return value; |
424 |
|
prop = prop.defaults; |
425 |
|
} |
426 |
|
while (prop != null); |
427 |
|
return null; |
428 |
} |
} |
429 |
|
|
430 |
/** |
/** |
443 |
*/ |
*/ |
444 |
public String getProperty(String key, String defaultValue) |
public String getProperty(String key, String defaultValue) |
445 |
{ |
{ |
446 |
return getPropertyInternal(key, defaultValue); |
String prop = getProperty(key); |
447 |
|
if (prop == null) |
448 |
|
prop = defaultValue; |
449 |
|
return prop; |
450 |
} |
} |
451 |
|
|
452 |
/** |
/** |