List of usage examples for org.apache.commons.collections ExtendedProperties get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:org.objectstyle.wolips.thirdparty.velocity.resourceloader.ResourceLoader.java
public void init(ExtendedProperties extendedProperties) { bundle = (Bundle) extendedProperties.get("bundle"); }
From source file:org.opencms.frontend.layoutpage.CmsLayoutPageBean.java
/** * Returns the String value of the xml content defined by the value(s) inside the given extended properties.<p> * /* w w w . j a v a2 s. co m*/ * @param xmlElements the instance of ExtendedProperties for the integrated resource type, e.g. news. * @param key key is used to identify the value inside the given map. * @param xmlContentFileLink the xml content of the integrated file. * @param locale the locale object. * @return the String value of the xml content defined by the value(s) inside the given map. */ protected String getPropertiesValue(ExtendedProperties xmlElements, String key, CmsXmlContent xmlContentFileLink, Locale locale) { Object value = xmlElements.get(key); String result = ""; if (value != null) { if (value instanceof String) { // if value is a String object get the string value from the xml content result = xmlContentFileLink.getStringValue(getCmsObject(), (String) value, locale); } else if (value instanceof Vector) { // if value is a vector iterate over it Iterator it_title = ((Vector) value).iterator(); while (it_title.hasNext()) { String next = (String) it_title.next(); if (!CmsStringUtil.isEmptyOrWhitespaceOnly( xmlContentFileLink.getStringValue(getCmsObject(), next, locale)) && !xmlContentFileLink.getStringValue(getCmsObject(), next, locale).equals("(none)")) { if (result.length() > 1 && result.lastIndexOf(",") != result.length()) { // only append ',' if the result String is already in use result += ","; } // add the String value from the xml content for the given String of the vector result += xmlContentFileLink.getStringValue(getCmsObject(), next, locale); } } } } else { result = ""; } return result; }
From source file:org.opencms.setup.TestCmsSetupBean.java
/** * Tests the method saveProperties.<p> * /*from www. ja v a 2 s .com*/ * @throws IOException if something goes wrong */ public void testSaveProperties() throws IOException { CmsSetupBean bean = new CmsSetupBean(); bean.init("", null, null); String base = getTestDataPath(File.separator + "WEB-INF" + File.separator + "base"); String inputFile = base + CmsSystemInfo.FILE_PROPERTIES; String outputFile = base + "output.properties"; System.out.println("Reading properties from " + inputFile); ExtendedProperties oldProperties = bean.loadProperties(inputFile); System.out.println("Writing properties to " + outputFile); bean.copyFile(inputFile, outputFile); bean.saveProperties(oldProperties, outputFile, false); System.out.println("Checking properties from " + outputFile); ExtendedProperties newProperties = bean.loadProperties(outputFile); Iterator it = oldProperties.entrySet().iterator(); while (it.hasNext()) { Map.Entry e = (Map.Entry) it.next(); String key = (String) e.getKey(); Object obj = e.getValue(); String oldValue = "", newValue = ""; if (obj instanceof Vector) { StringBuffer buf; buf = new StringBuffer(); for (Iterator j = ((Vector) obj).iterator(); j.hasNext();) { buf.append("[" + (String) j.next() + "]"); } oldValue = buf.toString(); buf = new StringBuffer(); for (Iterator j = ((Vector) newProperties.get(key)).iterator(); j.hasNext();) { buf.append("[" + (String) j.next() + "]"); } newValue = buf.toString(); } else { oldValue = (String) obj; newValue = (String) newProperties.get(key); } System.out.println(key); System.out.println(oldValue); System.out.println(newValue); System.out.println("---"); assertEquals(oldValue, newValue); } // clean up - remove generated file File output = new File(outputFile); output.delete(); }
From source file:org.sakaiproject.kernel.proxy.velocity.JcrResourceLoader.java
/** * {@inheritDoc}/*from w w w . j av a 2s . c o m*/ * * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#init(org.apache.commons.collections.ExtendedProperties) */ @Override public void init(ExtendedProperties configuration) { nodeSource = (ProxyNodeSource) configuration.get(ProxyNodeSource.JCR_RESOURCE_LOADER_RESOURCE_SOURCE); if (nodeSource == null) { throw new RuntimeException( "Unable to find a suitable resource source in the extended properties " + configuration); } }
From source file:org.sakaiproject.nakamura.templates.velocity.JcrResourceLoader.java
/** * {@inheritDoc}// w w w .jav a 2 s.c o m * * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#init(org.apache.commons.collections.ExtendedProperties) */ @Override public void init(ExtendedProperties configuration) { nodeSource = (TemplateNodeSource) configuration.get(JCR_RESOURCE_LOADER_RESOURCE_SOURCE); if (nodeSource == null) { throw new RuntimeException( "Unable to find a suitable resource source in the extended properties " + configuration); } }