net.walend.property
Class SubsetPropertySource

java.lang.Object
  |
  +--net.walend.property.SubsetPropertySource
All Implemented Interfaces:
PropertySource

public class SubsetPropertySource
extends java.lang.Object
implements PropertySource

This class allows access to subsets of a larger PropertySource without constant reuse of the prefix.

Since:
20001130
Author:
David Walend

Field Summary
private  PropertySource parent
           
private  java.lang.String prefix
           
 
Constructor Summary
protected SubsetPropertySource(java.lang.String prefix, PropertySource parent)
           
 
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.
private  boolean isKeyForSubset(java.lang.String key)
           
private  java.lang.String makeKey(java.lang.String key)
           
 java.util.Iterator propertyIterator()
          Return an iterator of property keys.
private  java.lang.String removePrefix(java.lang.String key)
           
 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

parent

private PropertySource parent

prefix

private java.lang.String prefix
Constructor Detail

SubsetPropertySource

protected SubsetPropertySource(java.lang.String prefix,
                               PropertySource parent)
Method Detail

makeKey

private java.lang.String makeKey(java.lang.String key)

isKeyForSubset

private boolean isKeyForSubset(java.lang.String key)

removePrefix

private java.lang.String removePrefix(java.lang.String key)

getProperty

public java.lang.String getProperty(java.lang.String key)
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