/** * Get a Vector of strings associated with the given configuration * key. * * @param key The configuration key. * @return The associated Vector. * @throws ClassCastException is thrown if the key maps to an * object that is not a Vector. */ public Vector getVector(String key) { return getVector(key, null); }
/** * Get a Vector of strings associated with the given configuration * key. * * @param key The configuration key. * @return The associated Vector. * @throws ClassCastException is thrown if the key maps to an * object that is not a Vector. */ public Vector getVector(String key) { return getVector(key, null); }
return defaults.getVector(key, defaultValue); } else { return ((defaultValue == null) ? new Vector() : defaultValue);
return defaults.getVector(key, defaultValue); } else { return ((defaultValue == null) ? new Vector() : defaultValue);
public void testMultipleSameKey2() throws Exception { ExtendedProperties ep1 = new ExtendedProperties(); /* initialize using: one=a,b one=c,d */ String s1 = "one=a,b\none=c,d\n"; byte[] bytes = s1.getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ep1.load(bais); assertEquals(1, ep1.size()); assertEquals(4, ep1.getVector("one").size()); assertEquals("a", ep1.getVector("one").get(0)); assertEquals("b", ep1.getVector("one").get(1)); assertEquals("c", ep1.getVector("one").get(2)); assertEquals("d", ep1.getVector("one").get(3)); assertEquals(4, ep1.getList("one").size()); assertEquals("a", ep1.getList("one").get(0)); assertEquals("b", ep1.getList("one").get(1)); assertEquals("c", ep1.getList("one").get(2)); assertEquals("d", ep1.getList("one").get(3)); }
public void testMultipleSameKey3() throws Exception { ExtendedProperties ep1 = new ExtendedProperties(); /* initialize using: one=a,b one=c */ String s1 = "one=a,b\none=c\n"; byte[] bytes = s1.getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ep1.load(bais); assertEquals(1, ep1.size()); assertEquals(3, ep1.getVector("one").size()); assertEquals("a", ep1.getVector("one").get(0)); assertEquals("b", ep1.getVector("one").get(1)); assertEquals("c", ep1.getVector("one").get(2)); assertEquals(3, ep1.getList("one").size()); assertEquals("a", ep1.getList("one").get(0)); assertEquals("b", ep1.getList("one").get(1)); assertEquals("c", ep1.getList("one").get(2)); }
public void testMultipleSameKey1() throws Exception { ExtendedProperties ep1 = new ExtendedProperties(); /* initialize using: one=a one=b,c */ String s1 = "one=a\none=b,c\n"; byte[] bytes = s1.getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ep1.load(bais); assertEquals(1, ep1.size()); assertEquals(3, ep1.getVector("one").size()); assertEquals("a", ep1.getVector("one").get(0)); assertEquals("b", ep1.getVector("one").get(1)); assertEquals("c", ep1.getVector("one").get(2)); assertEquals(3, ep1.getList("one").size()); assertEquals("a", ep1.getList("one").get(0)); assertEquals("b", ep1.getList("one").get(1)); assertEquals("c", ep1.getList("one").get(2)); }
assertEquals(1, ep1.size()); assertEquals(1, ep1.getVector("one").size()); assertEquals("a", ep1.getVector("one").get(0)); assertEquals(1, ep1.size()); assertEquals(2, ep1.getVector("one").size()); assertEquals("a", ep1.getVector("one").get(0)); assertEquals(Boolean.TRUE, ep1.getVector("one").get(1)); assertEquals(1, ep1.size()); assertEquals(4, ep1.getVector("one").size()); assertEquals("a", ep1.getVector("one").get(0)); assertEquals(Boolean.TRUE, ep1.getVector("one").get(1)); assertEquals("c", ep1.getVector("one").get(2)); assertEquals("d", ep1.getVector("one").get(3));
assertTrue("This returns array", (eprop.getVector("number") instanceof java.util.Vector)); assertTrue("This returns array", (eprop.getList("number") instanceof java.util.List)); assertTrue("This returns vector", (eprop.getVector("prop.string") instanceof java.util.Vector)); assertTrue("This returns list", (eprop.getList("prop.string") instanceof java.util.List)); assertTrue("This returns array for subset", (subEprop.getVector("string") instanceof java.util.Vector)); assertTrue("This returns array for subset", (subEprop.getList("string") instanceof java.util.List));
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); } } } } }
/** * Get a Vector of strings associated with the given configuration * key. * * @param key The configuration key. * @return The associated Vector. * @throws ClassCastException is thrown if the key maps to an * object that is not a Vector. */ public Vector getVector(String key) { return getVector(key, null); }
/** * Get a Vector of strings associated with the given configuration * key. * * @param key The configuration key. * @return The associated Vector. * @throws ClassCastException is thrown if the key maps to an * object that is not a Vector. */ public Vector getVector(String key) { return getVector(key, null); }
/** * Get a Vector of strings associated with the given configuration * key. * * @param key The configuration key. * @return The associated Vector. * @throws ClassCastException is thrown if the key maps to an * object that is not a Vector. */ public Vector getVector(String key) { return getVector(key, null); }
/** * Get a Vector of strings associated with the given configuration * key. * * @param key The configuration key. * @return The associated Vector. * @throws ClassCastException is thrown if the key maps to an * object that is not a Vector. */ public Vector getVector(String key) { return getVector(key, null); }
/** * Get a Vector of strings associated with the given configuration * key. * * @param key The configuration key. * @return The associated Vector. * @throws ClassCastException is thrown if the key maps to an * object that is not a Vector. */ public Vector getVector(String key) { return getVector(key, null); }
public class WebAppFileResourceLoader extends FileResourceLoader { private Logger log= LoggerFactory.getLogger(WebAppFileResourceLoader.class); @Override public void init(ExtendedProperties configuration) { String webAppRootPath= (String) this.rsvc.getApplicationAttribute(WEB_APP_ROOT); if (webAppRootPath!=null) { Vector<String> pathsVector = configuration.getVector("path"); Vector<String> tempVector = new Vector<String>(pathsVector.size()); for (String path : pathsVector) { log.debug("path:{}", path); tempVector.add(webAppRootPath + File.separator + path); } configuration.clearProperty("path"); for (String path : tempVector) { configuration.addProperty("path", path); } } super.init(configuration); }
public void init( ExtendedProperties configuration) { rsvc.info("FileResourceLoader : initialization starting."); paths = configuration.getVector("path"); /* * lets tell people what paths we will be using */ int sz = paths.size(); for( int i=0; i < sz; i++) { rsvc.info("FileResourceLoader : adding path '" + (String) paths.get(i) + "'"); } rsvc.info("FileResourceLoader : initialization complete."); }
@SuppressWarnings("unchecked") @Override public void init(ExtendedProperties configuration) { paths.addAll( configuration.getVector("path") ); // unicode files may have a BOM marker at the start, but Java // has problems recognizing the UTF-8 bom. Enabling unicode will // recognize all unicode boms. unicode = configuration.getBoolean("unicode", false); if (log.isDebugEnabled()) { log.debug("Do unicode file recognition: " + unicode); } if (log.isDebugEnabled()) { // trim spaces from all paths StringUtils.trimStrings(paths); // this section lets tell people what paths we will be using int sz = paths.size(); for( int i=0; i < sz; i++) { log.debug("MyClasspathResourceLoader : adding path '" + (String) paths.get(i) + "'"); } log.trace("MyClasspathResourceLoader : initialization complete."); } }