commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 26853] New: - Improving MapDynamicPropertyHandler
Date Wed, 11 Feb 2004 11:30:06 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26853>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26853

Improving MapDynamicPropertyHandler

           Summary: Improving MapDynamicPropertyHandler
           Product: Commons
           Version: Nightly Builds
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: JXPath
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: ydu@zurich.ibm.com


in: org.apache.commons.jxpath.MapDynamicPropertyHandler

If the following code:
    public String[] getPropertyNames(Object object) {
        Map map = (Map) object;
        String names[] = new String[map.size()];
        Iterator it = map.keySet().iterator();
        for (int i = 0; i < names.length; i++) {
            names[i] = String.valueOf(it.next());
        }
        return names;
    }

could be replaced by:
	public String[] getPropertyNames(Object object) {
		Set keys = ((Map) object).keySet();
		String names[] = new String[keys.size()];
		Iterator it = keys.iterator();
		for (int i = 0; i < names.length; i++) {
			names[i] = String.valueOf(it.next());
		}
		return names;
	}


This would permit to support very special cases where Map.keySet().size() !=
Map.size() [which, I know, does not conform to the Map API]. 
Anyway, in general, it is better to compute the size on the Set we are actually
using and not on another one related to it...

Thanks,

Yann Duponchel.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message