org.tinyjee.maven.dim.extensions
Class PropertiesLoader

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<String,Object>
              extended by org.tinyjee.maven.dim.extensions.PropertiesLoader
All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>
Direct Known Subclasses:
PropertiesLoader

public class PropertiesLoader
extends LinkedHashMap<String,Object>

PropertiesLoader is a 'source-class' compatible helper class that can load a properties file and add or overwrite the request properties by the properties contained in the file.

Usage:

%{include|source=template.vm|source-class=org.tinyjee.maven.dim.extensions.PropertiesLoader|properties=props.(xml|properties)}
or when using the alias:
%{include|source=template.vm|source-properties=props.(xml|properties)}

Version:
1.0
Author:
Juergen_Kellerer, 2010-09-08
See Also:
Serialized Form

Nested Class Summary
static class PropertiesLoader.AliasHandler
          Implements the "PARAM_ALIAS" alias functionality.
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
static String OUT_PARAM_LOADED_PROPERTIES
          Is filled with the loaded Properties instance.
static String OUT_PARAM_LOADED_PROPERTY_KEYS
          Is filled with a sorted, regex-enabled list of property keys (= new SelectableArrayList<String>(new TreeSet<String>(properties.keySet()));).
static String PARAM_ALIAS
          Defines a shortcut for the request properties 'source-class' and 'properties'.
static String PARAM_PROPERTIES
          Sets the path to the properties file to load inside the request parameters.
 
Constructor Summary
PropertiesLoader(File baseDir, Map<String,Object> requestParams)
          Constructs a new properties loader searching for properties using the given base path.
 
Method Summary
 
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, get, removeEldestEntry
 
Methods inherited from class java.util.HashMap
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Field Detail

PARAM_ALIAS

public static final String PARAM_ALIAS
Defines a shortcut for the request properties 'source-class' and 'properties'.

If this parameter is present inside the request parameters list, the system will effectively behave as if 'source-class' and 'properties' where set separately.

See Also:
Constant Field Values

PARAM_PROPERTIES

public static final String PARAM_PROPERTIES
Sets the path to the properties file to load inside the request parameters.

The specified file is retrieved in exactly the same way as if the "source" parameter would have been used (see Macro reference).

Note: Properties can use the traditional .properties or the newer .xml format. Format selection is performed by file extension.

See Also:
Constant Field Values

OUT_PARAM_LOADED_PROPERTIES

public static final String OUT_PARAM_LOADED_PROPERTIES
Is filled with the loaded Properties instance.

Note: All loaded properties are exposed in the standard scope as request properties and are accessible like any other parameters specified with the macro call.
This additional map based access allows to query properties whose names are not compatible with the variable naming scheme and it also allows to iterate all loaded properties using $loadedProperties.entrySet().

See Also:
Constant Field Values

OUT_PARAM_LOADED_PROPERTY_KEYS

public static final String OUT_PARAM_LOADED_PROPERTY_KEYS
Is filled with a sorted, regex-enabled list of property keys (= new SelectableArrayList<String>(new TreeSet<String>(properties.keySet()));).

See Also:
Constant Field Values
Constructor Detail

PropertiesLoader

public PropertiesLoader(File baseDir,
                        Map<String,Object> requestParams)
Constructs a new properties loader searching for properties using the given base path.

Parameters:
baseDir - the base dir to of the maven module.
requestParams - the request params of the macro call.