Changeset 5772 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r5691 r5772 35 35 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 36 36 import org.openstreetmap.josm.tools.Shortcut; 37 import org.openstreetmap.josm.tools.Utils; 37 38 38 39 /** … … 119 120 if (dialog.getValue() != 1) return; 120 121 remindUploadAddressHistory(uploadAddresses); 121 openUrl(layer.isSelected(), uploadAddresses.getText()); 122 openUrl(layer.isSelected(), Utils.strip(uploadAddresses.getText())); 122 123 } 123 124 -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r5589 r5772 573 573 return connection; 574 574 } 575 576 /** 577 * An alternative to {@link String#trim()} to effectively remove all leading and trailing white characters, including Unicode ones. 578 * @see <a href="http://closingbraces.net/2008/11/11/javastringtrim/">Java’s String.trim has a strange idea of whitespace</a> 579 * @see <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4080617">JDK bug 4080617</a> 580 * @param str The string to strip 581 * @return <code>str</code>, without leading and trailing characters, according to 582 * {@link Character#isWhitespace(char)} and {@link Character#isSpaceChar(char)}. 583 * @since 5772 584 */ 585 public static String strip(String str) { 586 if (str == null || str.isEmpty()) { 587 return str; 588 } 589 int start = 0, end = str.length(); 590 boolean leadingWhite = true; 591 while (leadingWhite && start < end) { 592 char c = str.charAt(start); 593 if (leadingWhite = (Character.isWhitespace(c) || Character.isSpaceChar(c))) { 594 start++; 595 } 596 } 597 boolean trailingWhite = true; 598 while (trailingWhite && end > start+1) { 599 char c = str.charAt(end-1); 600 if (trailingWhite = (Character.isWhitespace(c) || Character.isSpaceChar(c))) { 601 end--; 602 } 603 } 604 return str.substring(start, end); 605 } 575 606 }
Note:
See TracChangeset
for help on using the changeset viewer.