Changeset 11435 in josm for trunk/src/org
- Timestamp:
- 2017-01-07T00:56:52+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r11373 r11435 538 538 public void put(String key, String value) { 539 539 Map<String, String> originalKeys = getKeys(); 540 if (key == null || Utils. strip(key).isEmpty())540 if (key == null || Utils.isStripEmpty(key)) 541 541 return; 542 542 else if (value == null) { -
trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java
r11416 r11435 274 274 // Update text, hide prefixing label if empty 275 275 if (label != null) { 276 label.setVisible(text != null && !Utils. strip(text).isEmpty());276 label.setVisible(text != null && !Utils.isStripEmpty(text)); 277 277 } 278 278 textArea.setText(text); -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r11387 r11435 965 965 966 966 private void updateOkButtonState() { 967 buttons.get(0).setEnabled(!Utils. strip(tfURL.getText()).isEmpty());967 buttons.get(0).setEnabled(!Utils.isStripEmpty(tfURL.getText())); 968 968 } 969 969 -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r10702 r11435 25 25 import org.openstreetmap.josm.data.DataSource; 26 26 import org.openstreetmap.josm.data.coor.LatLon; 27 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 27 28 import org.openstreetmap.josm.data.osm.Changeset; 28 29 import org.openstreetmap.josm.data.osm.DataSet; … … 41 42 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 42 43 import org.openstreetmap.josm.tools.CheckParameterUtil; 44 import org.openstreetmap.josm.tools.Utils; 43 45 import org.openstreetmap.josm.tools.date.DateUtils; 44 46 … … 377 379 if (key == null || value == null) { 378 380 throwException(tr("Missing key or value attribute in tag.")); 381 } else if (Utils.isStripEmpty(key) && t instanceof AbstractPrimitive) { 382 // #14199: Empty keys as ignored by AbstractPrimitive#put, but it causes problems to fix existing data 383 // Drop the tag on import, but flag the primitive as modified 384 ((AbstractPrimitive) t).setModified(true); 379 385 } else { 380 386 t.put(key.intern(), value.intern()); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r11394 r11435 735 735 736 736 /** 737 * Determines if the given String would be empty if stripped. 738 * This is an efficient alternative to {@code strip(s).isEmpty()} that avoids to create useless String object. 739 * @param str The string to test 740 * @return {@code true} if the stripped version of {@code s} would be empty. 741 * @since 11435 742 */ 743 public static boolean isStripEmpty(String str) { 744 if (str != null) { 745 for (int i = 0; i < str.length(); i++) { 746 if (!isStrippedChar(str.charAt(i), DEFAULT_STRIP)) { 747 return false; 748 } 749 } 750 } 751 return true; 752 } 753 754 /** 737 755 * An alternative to {@link String#trim()} to effectively remove all leading 738 756 * and trailing white characters, including Unicode ones. … … 774 792 boolean leadingSkipChar = true; 775 793 while (leadingSkipChar && start < end) { 776 char c = str.charAt(start); 777 leadingSkipChar = Character.isWhitespace(c) || Character.isSpaceChar(c) || stripChar(skipChars, c); 794 leadingSkipChar = isStrippedChar(str.charAt(start), skipChars); 778 795 if (leadingSkipChar) { 779 796 start++; … … 782 799 boolean trailingSkipChar = true; 783 800 while (trailingSkipChar && end > start + 1) { 784 char c = str.charAt(end - 1); 785 trailingSkipChar = Character.isWhitespace(c) || Character.isSpaceChar(c) || stripChar(skipChars, c); 801 trailingSkipChar = isStrippedChar(str.charAt(end - 1), skipChars); 786 802 if (trailingSkipChar) { 787 803 end--; … … 790 806 791 807 return str.substring(start, end); 808 } 809 810 private static boolean isStrippedChar(char c, final char ... skipChars) { 811 return Character.isWhitespace(c) || Character.isSpaceChar(c) || stripChar(skipChars, c); 792 812 } 793 813
Note:
See TracChangeset
for help on using the changeset viewer.