/** * The path property is resolved from the servlet context parameters. When the parameter does not exist, * the <code>defaultValue</code> argument is used instead, so it should not be null. * After the path is resolved, it is interpolated using the JVM system properties and the syntax * defined by the {@link org.crsh.util.Utils#interpolate(String, java.util.Map)} function. * * @param propertyName the property name to resolve * @param defaultValue the default property value * @return the path value */ private String resolvePathProperty(String propertyName, String defaultValue) { String path = context.getInitParameter(propertyName); if (path == null) { path = defaultValue; } return Utils.interpolate(path, System.getProperties()); }
public void testInterpolate() { Map<String,String> context = Collections.singletonMap("foo", "bar"); assertEquals("", Utils.interpolate("", context)); assertEquals("$", Utils.interpolate("$", context)); assertEquals("${foo}", Utils.interpolate("\\${foo}", context)); assertEquals("${", Utils.interpolate("${", context)); assertEquals("${a", Utils.interpolate("${a", context)); assertEquals("bar", Utils.interpolate("${foo}", context)); assertEquals("<bar>", Utils.interpolate("<${foo}>", context)); assertEquals("<bar></bar>", Utils.interpolate("<${foo}></${foo}>", context)); assertEquals("", Utils.interpolate("${bar}", context)); assertEquals("juu", Utils.interpolate("${bar:-juu}", context)); assertEquals("bar", Utils.interpolate("${foo:-juu}", context)); assertEquals("", Utils.interpolate("${bar:-}", context)); assertEquals("juu", Utils.interpolate("${:-juu}", context)); assertEquals(":-", Utils.interpolate("${bar:-:-}", context)); } }
/** * The path property is resolved from the servlet context parameters. When the parameter does not exist, * the <code>defaultValue</code> argument is used instead, so it should not be null. * After the path is resolved, it is interpolated using the JVM system properties and the syntax * defined by the {@link org.crsh.util.Utils#interpolate(String, java.util.Map)} function. * * @param propertyName the property name to resolve * @param defaultValue the default property value * @return the path value */ private String resolvePathProperty(String propertyName, String defaultValue) { String path = context.getInitParameter(propertyName); if (path == null) { path = defaultValue; } return Utils.interpolate(path, System.getProperties()); }
/** * The path property is resolved from the servlet context parameters. When the parameter does not exist, * the <code>defaultValue</code> argument is used instead, so it should not be null. * After the path is resolved, it is interpolated using the JVM system properties and the syntax * defined by the {@link org.crsh.util.Utils#interpolate(String, java.util.Map)} function. * * @param propertyName the property name to resolve * @param defaultValue the default property value * @return the path value */ private String resolvePathProperty(String propertyName, String defaultValue) { String path = context.getInitParameter(propertyName); if (path == null) { path = defaultValue; } return Utils.interpolate(path, System.getProperties()); }