From 024932d4c4b7a94d3168f85a2deed7bb35d6c3fa Mon Sep 17 00:00:00 2001 From: andrzej Date: Thu, 27 Mar 2008 20:01:20 +0000 Subject: [PATCH] Implement propertyNames in the Properties object returned by getFilteredProperties so that it works with getSubProperties. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2283 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/util/PropertiesUtil.java | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/java/com/samskivert/util/PropertiesUtil.java b/src/java/com/samskivert/util/PropertiesUtil.java index 62e401be..ba906087 100644 --- a/src/java/com/samskivert/util/PropertiesUtil.java +++ b/src/java/com/samskivert/util/PropertiesUtil.java @@ -3,7 +3,7 @@ // // samskivert library - useful routines for java programs // Copyright (C) 2001-2007 Michael Bayne -// +// // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation; either version 2.1 of the License, or @@ -121,9 +121,36 @@ public class PropertiesUtil return source.getProperty(dprefix + key, source.getProperty(key, defaultValue)); } + public Enumeration propertyNames () { + return new Enumeration() { + public boolean hasMoreElements () { + return next != null; + } + public Object nextElement () { + Object onext = next; + next = findNext(); + return onext; + } + protected Object findNext () { + while (senum.hasMoreElements()) { + String name = (String)senum.nextElement(); + if (!name.startsWith(dprefix)) { + return name; + } + name = name.substring(dprefix.length()); + if (!source.containsKey(name)) { + return name; + } + } + return null; + } + protected Enumeration senum = source.propertyNames(); + protected Object next = findNext(); + }; + } }; } - + /** * A helper function used by the {@link #getSubProperties} methods. */