/** * Set a property, this will replace any previously * set values. Set values is implicitly a call * to clearProperty(key), addProperty(key,value). * * @param key the key to set * @param value the value to set */ public void setProperty(String key, Object value) { clearProperty(key); addProperty(key, value); }
/** * Set a property, this will replace any previously * set values. Set values is implicitly a call * to clearProperty(key), addProperty(key,value). * * @param key the key to set * @param value the value to set */ public void setProperty(String key, Object value) { clearProperty(key); addProperty(key, value); }
addProperty(key, value);
public void testMultipleSameKeyByCode() throws Exception { ExtendedProperties ep1 = new ExtendedProperties(); ep1.addProperty("one", "a"); assertEquals(1, ep1.size()); assertEquals("a", ep1.getList("one").get(0)); ep1.addProperty("one", Boolean.TRUE); assertEquals(1, ep1.size()); assertEquals(Boolean.TRUE, ep1.getList("one").get(1)); ep1.addProperty("one", "c,d"); assertEquals(1, ep1.size());
public void init(VelocityConfiguration configuration) throws Exception { this.loader = configuration.getResourceLoader(); configuration.getProperties().addProperty("userdirective", Escape.class.getName()); configuration.getProperties().addProperty("userdirective", Noescape.class.getName()); }
public void init(VelocityConfiguration configuration) throws Exception { this.loader = configuration.getResourceLoader(); configuration.getProperties().addProperty("userdirective", Escape.class.getName()); configuration.getProperties().addProperty("userdirective", Noescape.class.getName()); }
private void addMacroResources(String path, Resource[] resources) { if (resources != null) { // 必须用vector,否则VelocimacroFactory老代码读不到值 @SuppressWarnings("unchecked") Set<String> macros = createHashSet(properties.getVector(VM_LIBRARY)); for (Resource resource : resources) { if (resource.exists()) { String templateName = null; // 对于多数resource,如ServletResource,ResourceAdapter等,都可以从中取得原始的resourceName if (path != null && resource instanceof ContextResource) { String resourceName = ((ContextResource) resource).getPathWithinContext(); if (resourceName.startsWith(path)) { templateName = resourceName.substring(path.length()); } } // 对于不可取得resourceName的,使用特殊的装载机制。 if (templateName == null) { templateName = getTemplateNameOfPreloadedResource(resource); } if (!macros.contains(templateName)) { properties.addProperty(VM_LIBRARY, templateName); macros.add(templateName); } } } } }
private void addMacroResources(String path, Resource[] resources) { if (resources != null) { // 必须用vector,否则VelocimacroFactory老代码读不到值 @SuppressWarnings("unchecked") Set<String> macros = createHashSet(properties.getVector(VM_LIBRARY)); for (Resource resource : resources) { if (resource.exists()) { String templateName = null; // 对于多数resource,如ServletResource,ResourceAdapter等,都可以从中取得原始的resourceName if (path != null && resource instanceof ContextResource) { String resourceName = ((ContextResource) resource).getPathWithinContext(); if (resourceName.startsWith(path)) { templateName = resourceName.substring(path.length()); } } // 对于不可取得resourceName的,使用特殊的装载机制。 if (templateName == null) { templateName = getTemplateNameOfPreloadedResource(resource); } if (!macros.contains(templateName)) { properties.addProperty(VM_LIBRARY, templateName); macros.add(templateName); } } } } }
eprop.addProperty("number", "2"); assertTrue("This returns array", (eprop.getVector("number") instanceof java.util.Vector)); assertTrue("This returns array", (eprop.getList("number") instanceof java.util.List));
properties.addProperty(RESOURCE_LOADER, "preloaded");
properties.addProperty(RESOURCE_LOADER, "preloaded");
/** * Set a property, this will replace any previously * set values. Set values is implicitly a call * to clearProperty(key), addProperty(key,value). * * @param key the key to set * @param value the value to set */ public void setProperty(String key, Object value) { clearProperty(key); addProperty(key, value); }
/** * Set a property, this will replace any previously * set values. Set values is implicitly a call * to clearProperty(key), addProperty(key,value). * * @param key the key to set * @param value the value to set */ public void setProperty(String key, Object value) { clearProperty(key); addProperty(key, value); }
/** * Set a property, this will replace any previously * set values. Set values is implicitly a call * to clearProperty(key), addProperty(key,value). * * @param key the key to set * @param value the value to set */ public void setProperty(String key, Object value) { clearProperty(key); addProperty(key, value); }
/** * Set a property, this will replace any previously * set values. Set values is implicitly a call * to clearProperty(key), addProperty(key,value). * * @param key the key to set * @param value the value to set */ public void setProperty(String key, Object value) { clearProperty(key); addProperty(key, value); }
/** * Set a property, this will replace any previously * set values. Set values is implicitly a call * to clearProperty(key), addProperty(key,value). * * @param key the key to set * @param value the value to set */ public void setProperty(String key, Object value) { clearProperty(key); addProperty(key, value); }
public void init(VelocityConfiguration configuration) throws Exception { this.loader = configuration.getResourceLoader(); configuration.getProperties().addProperty("userdirective", Escape.class.getName()); configuration.getProperties().addProperty("userdirective", Noescape.class.getName()); }
/** * Append Velocimacro Library into {@link Velocity} {@link Properties} * * @param velocityProperties {@link Velocity} {@link Properties} * @param libraryPath the path of Velocimacro Library */ public static void appendVelocimacroLibrary(Map<String, String> velocityProperties, String libraryPath) { String propertyName = RuntimeConstants.VM_LIBRARY; ExtendedProperties extendedProperties = toSingletonExtendedProperties(velocityProperties, propertyName); extendedProperties.addProperty(propertyName, libraryPath); List<String> listValue = extendedProperties.getList(propertyName); String propertyValue = StringUtils.collectionToCommaDelimitedString(listValue); velocityProperties.put(propertyName, propertyValue); }
/** * Append Velocimacro Library into {@link Velocity} {@link Properties} * * @param velocityProperties {@link Velocity} {@link Properties} * @param libraryPath the path of Velocimacro Library */ public static void appendVelocimacroLibrary(Map<String, String> velocityProperties, String libraryPath) { String propertyName = RuntimeConstants.VM_LIBRARY; ExtendedProperties extendedProperties = toSingletonExtendedProperties(velocityProperties, propertyName); extendedProperties.addProperty(propertyName, libraryPath); List<String> listValue = extendedProperties.getList(propertyName); String propertyValue = StringUtils.collectionToCommaDelimitedString(listValue); velocityProperties.put(propertyName, propertyValue); }