From: Juergen H. <jho...@us...> - 2006-04-21 00:13:54
|
Update of /cvsroot/springframework/spring/src/org/springframework/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19629/src/org/springframework/util Modified Files: Tag: mbranch-1-2 CollectionUtils.java StringUtils.java Log Message: backported fixes and enhancements from 2.0 M4 (HEAD) Index: CollectionUtils.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/util/CollectionUtils.java,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -C2 -d -r1.7 -r1.7.4.1 *** CollectionUtils.java 12 Sep 2005 20:35:33 -0000 1.7 --- CollectionUtils.java 21 Apr 2006 00:13:50 -0000 1.7.4.1 *************** *** 1,4 **** /* ! * Copyright 2002-2005 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); --- 1,4 ---- /* ! * Copyright 2002-2006 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); *************** *** 61,68 **** return false; } Object candidate = null; for (Iterator it = coll.iterator(); it.hasNext();) { Object elem = it.next(); ! if (candidate == null) { candidate = elem; } --- 61,70 ---- return false; } + boolean hasCandidate = false; Object candidate = null; for (Iterator it = coll.iterator(); it.hasNext();) { Object elem = it.next(); ! if (!hasCandidate) { ! hasCandidate = true; candidate = elem; } Index: StringUtils.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/util/StringUtils.java,v retrieving revision 1.43.2.4 retrieving revision 1.43.2.5 diff -C2 -d -r1.43.2.4 -r1.43.2.5 *** StringUtils.java 21 Feb 2006 18:14:52 -0000 1.43.2.4 --- StringUtils.java 21 Apr 2006 00:13:50 -0000 1.43.2.5 *************** *** 203,207 **** } ! String lcStr = str.substring(suffix.length()).toLowerCase(); String lcSuffix = suffix.toLowerCase(); return lcStr.equals(lcSuffix); --- 203,207 ---- } ! String lcStr = str.substring(str.length() - suffix.length()).toLowerCase(); String lcSuffix = suffix.toLowerCase(); return lcStr.equals(lcSuffix); *************** *** 458,473 **** List pathElements = new LinkedList(); int tops = 0; for (int i = pathArray.length - 1; i >= 0; i--) { if (CURRENT_PATH.equals(pathArray[i])) { ! // do nothing } else if (TOP_PATH.equals(pathArray[i])) { tops++; } else { if (tops > 0) { tops--; } else { pathElements.add(0, pathArray[i]); } --- 458,477 ---- List pathElements = new LinkedList(); int tops = 0; + for (int i = pathArray.length - 1; i >= 0; i--) { if (CURRENT_PATH.equals(pathArray[i])) { ! // Points to current directory - drop it. } else if (TOP_PATH.equals(pathArray[i])) { + // Registering top path found. tops++; } else { if (tops > 0) { + // Merging path element with corresponding to top path. tops--; } else { + // Normal path element found. pathElements.add(0, pathArray[i]); } *************** *** 475,478 **** --- 479,487 ---- } + // Remaining top paths need to be retained. + for (int i = 0; i < tops; i++) { + pathElements.add(0, TOP_PATH); + } + return prefix + collectionToDelimitedString(pathElements, FOLDER_SEPARATOR); } *************** *** 482,486 **** * @param path1 First path for comparizon * @param path2 Second path for comparizon ! * @return True if the two paths are equivalent after normalization */ public static boolean pathEquals(String path1, String path2) { --- 491,495 ---- * @param path1 First path for comparizon * @param path2 Second path for comparizon ! * @return whether the two paths are equivalent after normalization */ public static boolean pathEquals(String path1, String path2) { |