net.walend.property
Class SimplePropertySource

java.lang.Object
  |
  +--net.walend.property.SimplePropertySource
All Implemented Interfaces:
PropertySource
Direct Known Subclasses:
DirectorPropertySource

public class SimplePropertySource
extends java.lang.Object
implements PropertySource

This simple class implements PropertySource around a standard property file.

Since:
20001130
Author:
David Walend

Field Summary
private static java.lang.String prefix
           
private  java.lang.String propertiesPath
           
private  java.util.Properties props
           
 
Constructor Summary
SimplePropertySource(java.lang.String propertySourceName)
           
 
Method Summary
 java.lang.String getPrefix()
          Return the String prefix for this PropertySource.
 java.lang.String getProperty(java.lang.String key)
          If the property isn't there, return null.
 java.lang.String getProperty(java.lang.String key, java.lang.String def)
          If the property isn't there, return default.
 java.lang.String getPropertySafely(java.lang.String key)
           
 PropertySource getSubsetPropertySource(java.lang.String keyPrefix)
          Return a PropertySource that contains the subset of these properties based on the prefix.
 java.util.Iterator propertyIterator()
          Return an iterator of property keys.
 void setProperty(java.lang.String key, java.lang.String value)
          Add or change the value of a property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

props

private java.util.Properties props

propertiesPath

private java.lang.String propertiesPath

prefix

private static final java.lang.String prefix
Constructor Detail

SimplePropertySource

public SimplePropertySource(java.lang.String propertySourceName)
Parameters:
propertySourceName - The name of the property source file. Set the path to this property by using a system property (-DpropertySourceName=propertySourcePath). If the constructor does not find a system property named propertySourceName, it uses propertySourceName as the path.
Method Detail

getProperty

public java.lang.String getProperty(java.lang.String key)
Deprecated. Please use getProperty or getPropertySafely.

Description copied from interface: PropertySource
If the property isn't there, return null.

Specified by:
getProperty in interface PropertySource

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String def)
Description copied from interface: PropertySource
If the property isn't there, return default.

Specified by:
getProperty in interface PropertySource

getPropertySafely

public java.lang.String getPropertySafely(java.lang.String key)
Specified by:
getPropertySafely in interface PropertySource

propertyIterator

public java.util.Iterator propertyIterator()
Description copied from interface: PropertySource
Return an iterator of property keys.

Specified by:
propertyIterator in interface PropertySource

getPrefix

public java.lang.String getPrefix()
Description copied from interface: PropertySource
Return the String prefix for this PropertySource.

Specified by:
getPrefix in interface PropertySource

getSubsetPropertySource

public PropertySource getSubsetPropertySource(java.lang.String keyPrefix)
Description copied from interface: PropertySource
Return a PropertySource that contains the subset of these properties based on the prefix.

Specified by:
getSubsetPropertySource in interface PropertySource

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Description copied from interface: PropertySource
Add or change the value of a property.

Specified by:
setProperty in interface PropertySource


Copyright (c) 2000, 2001, David Walend