Class PropertiesMap
- java.lang.Object
-
- org.onehippo.forge.properties.bean.PropertiesMap
-
public class PropertiesMap extends Object implements Map<String,String>
Bean representing a properties document that holds a map of name/value pairs. In an HST Component, a bean like this can be created with a PropertiesBean object as argument and subsequently set on the request for access in jsp. Example 1:
Example 2:// get a document named "properties" at same level as current bean Properties propertiesDoc = this.getContentBean(request).getParentBean().getBean("properties", Properties.class); if (propertiesDoc != null) { request.setAttribute("properties", new PropertiesMap(new PropertiesBean(propertiesDoc))); }
Example 3:There is also a Spring instantiated PropertiesManager present with which beans can be gotten from content: ComponentManager componentManager = HstServices.getComponentManager();; this.propertiesManager = componentManager.getComponent(PropertiesManager.class.getName()); Map<String, String> properties = new PropertiesMap(this.propertiesManager.getPropertiesBean(this.getSiteContentBaseBean(request)));
Because it is a map, access in jsp can be done using direct expression language notation like "labels['label.header']"There is also a static utility class that creates PropertiesMaps. Map<String, String> properties = PropertiesUtil.toMap(this.propertiesManager.getPropertiesBean(this.getSiteContentBaseBean(request)));
-
-
Constructor Summary
Constructors Constructor Description PropertiesMap(Collection<PropertiesBean> propertiesCol)
Create a new map with multiple properties beans.PropertiesMap(PropertiesBean properties)
Create a new map with a properties bean.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<String,String>>
entrySet()
String
get(Object key)
boolean
isEmpty()
Set<String>
keySet()
String
put(String arg0, String arg1)
void
putAll(Map<? extends String,? extends String> arg0)
String
remove(Object arg0)
int
size()
Collection<String>
values()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
PropertiesMap
public PropertiesMap(PropertiesBean properties)
Create a new map with a properties bean.
-
PropertiesMap
public PropertiesMap(Collection<PropertiesBean> propertiesCol)
Create a new map with multiple properties beans. Note that properties are not overwritten, so in case of duplicates the first entered remains!
-
-
Method Detail
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<String,String>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<String,String>
-
-