net.sourceforge.argval.utils.impl
Class PropertiesUtilImpl

java.lang.Object
  extended by net.sourceforge.argval.utils.impl.PropertiesUtilImpl
All Implemented Interfaces:
PropertiesUtil

public class PropertiesUtilImpl
extends Object
implements PropertiesUtil

Utility class for the Properties class.

Version:
$Revision: 1.2 $ Last modified: $Date: 2006/11/16 11:23:02 $
Author:
$Author: verha001 $

Field Summary
 
Fields inherited from interface net.sourceforge.argval.utils.PropertiesUtil
PROP_SEP
 
Constructor Summary
PropertiesUtilImpl()
           
 
Method Summary
 Properties addProperties(Properties prop, Class<?> clazz, Properties extraProp)
           
 Properties addProperties(Properties prop, String baseKey, Properties extraProp)
           
 String createKey(String[] keyArray)
          Creates a new key value, by concatinating the key with the two key parts.
 String createKey(String key, String keyPart)
          Creates a new key value, by concatinating the key with the keyPart.
 String createKey(String key, String firstKeyPart, String secondKeyPart)
          Creates a new key value, by concatinating the key with the two key parts.
 Properties getProperties(Class<?> clazz, Properties prop)
           
 Properties getProperties(String baseKey, Properties prop)
          Returns a sub set of Properties, which keys start with the baseKey.
 List<Properties> getPropertiesList(Properties prop, String listPrefixKey)
           
 List<Properties> getPropertiesList(Properties prop, String listPrefixKey, String openingBracket, String closingBracket)
           
 Map<String,Properties> getPropertiesMap(Properties prop, String mapPrefixKey)
           
 Map<String,Properties> getPropertiesMap(Properties prop, String mapPrefixKey, String openingBracket, String closingBracket)
           person[tjeerd].name = Mickey Mouse person[tjeerd].mobile = +31.6.1111 1111 person[esther].name = Donald Duck person[estehr].mobile = +31.6.1111 2222
 List<String> getPropertyAsList(Properties properties, String key)
           
 List<String> getPropertyAsList(Properties properties, String key, String separator)
           
 Set<String> getPropertyAsSet(Properties properties, String key)
          Returns the values of an multiple value property key as a Set instance, which contains all the values.
 Set<String> getPropertyAsSet(Properties properties, String key, String separator)
          Returns the values of an multiple value property key as a Set instance, which contains all the values.
 Properties loadProperties(File propertyFile)
           
 String toString(Properties properties)
          Creates a String which contains all the property key's and their values, separated by the equals sign '='.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesUtilImpl

public PropertiesUtilImpl()
Method Detail

createKey

public String createKey(String key,
                        String keyPart)
Description copied from interface: PropertiesUtil
Creates a new key value, by concatinating the key with the keyPart.

When createKey(current_key, "window") is called it will return the String current_key + PROP_SEP + "window".

Specified by:
createKey in interface PropertiesUtil
Parameters:
key - The existing key, to which the keyPart is added.
keyPart - The key part to add.
Returns:
The new concatinated key.

createKey

public String createKey(String key,
                        String firstKeyPart,
                        String secondKeyPart)
Description copied from interface: PropertiesUtil
Creates a new key value, by concatinating the key with the two key parts.

When createKey(current_key, "window", "name") is called it will return the String current_key + ".window.name".

Specified by:
createKey in interface PropertiesUtil
Parameters:
key - The existing key, to which the keyPart's are added.
firstKeyPart - The key part to add.
secondKeyPart - The key part to add.
Returns:
The new concatinated key.
See Also:
PropertiesUtil.createKey(String, String)

createKey

public String createKey(String[] keyArray)
Description copied from interface: PropertiesUtil
Creates a new key value, by concatinating the key with the two key parts.

When createKey(new String[] {"company", "module", "project"}) is called it will return the String "company.module.project".

Specified by:
createKey in interface PropertiesUtil
Parameters:
keyArray - An array of key parts which need to be concatinated.
Returns:
The new concatinated key.

loadProperties

public Properties loadProperties(File propertyFile)
Specified by:
loadProperties in interface PropertiesUtil

getPropertyAsSet

public Set<String> getPropertyAsSet(Properties properties,
                                    String key)
Description copied from interface: PropertiesUtil
Returns the values of an multiple value property key as a Set instance, which contains all the values. As the separator character of the values, a space character is used.

Specified by:
getPropertyAsSet in interface PropertiesUtil
Parameters:
properties - The Properties instance, from which to get the multiple values.
key - The key under which the values are stored.
Returns:
A Set instances, containing the values, stored under the property key.

getPropertyAsSet

public Set<String> getPropertyAsSet(Properties properties,
                                    String key,
                                    String separator)
Description copied from interface: PropertiesUtil
Returns the values of an multiple value property key as a Set instance, which contains all the values.

Specified by:
getPropertyAsSet in interface PropertiesUtil
Parameters:
properties - The Properties instance, from which to get the multiple values.
key - The key under which the values are stored.
separator - The separator used to separate the values. If null is given, the default space ' ' separator is used.
Returns:
An Set instances, containing the values, stored under the property key.

getPropertyAsList

public List<String> getPropertyAsList(Properties properties,
                                      String key)
Specified by:
getPropertyAsList in interface PropertiesUtil

getPropertyAsList

public List<String> getPropertyAsList(Properties properties,
                                      String key,
                                      String separator)
Specified by:
getPropertyAsList in interface PropertiesUtil

toString

public String toString(Properties properties)
Description copied from interface: PropertiesUtil
Creates a String which contains all the property key's and their values, separated by the equals sign '='. Each property is separated by a line separator.

Specified by:
toString in interface PropertiesUtil
Returns:

getProperties

public Properties getProperties(String baseKey,
                                Properties prop)
Description copied from interface: PropertiesUtil
Returns a sub set of Properties, which keys start with the baseKey. Creating the Properties instance prop:
 web.proxy.hostname = proxy
 web.proxy.port = 8080
 web.application.name = Web application
 
And using the method getProperties("web.proxy", prop) will return a new Properties instance like this:
 hostname = proxy
 port = 8080
 

Specified by:
getProperties in interface PropertiesUtil
Parameters:
baseKey - The key under which the sub set Properties are stored.
prop - The Properties from which the sub set is extracted.
Returns:

getProperties

public Properties getProperties(Class<?> clazz,
                                Properties prop)
Specified by:
getProperties in interface PropertiesUtil

addProperties

public Properties addProperties(Properties prop,
                                String baseKey,
                                Properties extraProp)
Specified by:
addProperties in interface PropertiesUtil

addProperties

public Properties addProperties(Properties prop,
                                Class<?> clazz,
                                Properties extraProp)
Specified by:
addProperties in interface PropertiesUtil

getPropertiesList

public List<Properties> getPropertiesList(Properties prop,
                                          String listPrefixKey)
Specified by:
getPropertiesList in interface PropertiesUtil

getPropertiesList

public List<Properties> getPropertiesList(Properties prop,
                                          String listPrefixKey,
                                          String openingBracket,
                                          String closingBracket)
Specified by:
getPropertiesList in interface PropertiesUtil

getPropertiesMap

public Map<String,Properties> getPropertiesMap(Properties prop,
                                               String mapPrefixKey)
Specified by:
getPropertiesMap in interface PropertiesUtil

getPropertiesMap

public Map<String,Properties> getPropertiesMap(Properties prop,
                                               String mapPrefixKey,
                                               String openingBracket,
                                               String closingBracket)
Description copied from interface: PropertiesUtil
 person[tjeerd].name = Mickey Mouse
 person[tjeerd].mobile = +31.6.1111 1111
 person[esther].name = Donald Duck
 person[estehr].mobile = +31.6.1111 2222
 
 person(01).name = Mickey Mouse
 person(01).mobile = +31.6.1111 1111
 person(02).name = Donald Duck
 person(02).mobile = +31.6.1111 2222
 

Specified by:
getPropertiesMap in interface PropertiesUtil
Returns:


Copyright © 2013 Verhagen Software. All Rights Reserved.