Changeset 15440 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-10-07T21:32:54+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
r15113 r15440 16 16 import java.util.Locale; 17 17 import java.util.Map; 18 import java.util.Objects; 18 19 import java.util.Optional; 19 20 import java.util.function.Predicate; … … 711 712 @Override 712 713 public boolean match(Tagged osm) { 713 714 714 if (keyPattern != null) { 715 if (!osm.hasKeys()) 716 return false; 717 718 /* The string search will just get a key like 719 * 'highway' and look that up as osm.get(key). But 720 * since we're doing a regex match we'll have to loop 721 * over all the keys to see if they match our regex, 722 * and only then try to match against the value 723 */ 724 725 for (String k: osm.keySet()) { 726 String v = osm.get(k); 727 728 Matcher matcherKey = keyPattern.matcher(k); 729 boolean matchedKey = matcherKey.find(); 730 731 if (matchedKey) { 732 Matcher matcherValue = valuePattern.matcher(v); 733 boolean matchedValue = matcherValue.find(); 734 735 if (matchedValue) 715 if (osm.hasKeys()) { 716 // The string search will just get a key like 'highway' and look that up as osm.get(key). 717 // But since we're doing a regex match we'll have to loop over all the keys to see if they match our regex, 718 // and only then try to match against the value 719 for (String k: osm.keySet()) { 720 if (keyPattern.matcher(k).find() && valuePattern.matcher(osm.get(k)).find()) { 736 721 return true; 737 }738 }739 } else {740 String mv;741 742 if ("timestamp".equals(key) && osm instanceof OsmPrimitive) {743 mv = DateUtils.fromTimestamp(((OsmPrimitive) osm).getRawTimestamp());744 } else {745 mv = osm.get(key);746 if (!caseSensitive && mv == null) {747 for (String k: osm.keySet()) {748 if (key.equalsIgnoreCase(k)) {749 mv = osm.get(k);750 break;751 }752 722 } 753 723 } 754 724 } 755 756 if (mv == null) 757 return false; 758 759 String v1 = caseSensitive ? mv : mv.toLowerCase(Locale.ENGLISH); 760 String v2 = caseSensitive ? value : value.toLowerCase(Locale.ENGLISH); 761 762 v1 = Normalizer.normalize(v1, Normalizer.Form.NFC); 763 v2 = Normalizer.normalize(v2, Normalizer.Form.NFC); 764 return v1.indexOf(v2) != -1; 765 } 766 725 } else { 726 String mv = getMv(osm); 727 if (mv != null) { 728 String v1 = Normalizer.normalize(caseSensitive ? mv : mv.toLowerCase(Locale.ENGLISH), Normalizer.Form.NFC); 729 String v2 = Normalizer.normalize(caseSensitive ? value : value.toLowerCase(Locale.ENGLISH), Normalizer.Form.NFC); 730 return v1.indexOf(v2) != -1; 731 } 732 } 767 733 return false; 768 734 } 769 735 736 private String getMv(Tagged osm) { 737 String mv; 738 if ("timestamp".equals(key) && osm instanceof OsmPrimitive) { 739 mv = DateUtils.fromTimestamp(((OsmPrimitive) osm).getRawTimestamp()); 740 } else { 741 mv = osm.get(key); 742 if (!caseSensitive && mv == null) { 743 for (String k: osm.keySet()) { 744 if (key.equalsIgnoreCase(k)) { 745 mv = osm.get(k); 746 break; 747 } 748 } 749 } 750 } 751 return mv; 752 } 753 770 754 @Override 771 755 public String toString() { … … 775 759 @Override 776 760 public int hashCode() { 777 final int prime = 31; 778 int result = 1; 779 result = prime * result + (caseSensitive ? 1231 : 1237); 780 result = prime * result + ((key == null) ? 0 : key.hashCode()); 781 result = prime * result + ((keyPattern == null) ? 0 : keyPattern.hashCode()); 782 result = prime * result + ((value == null) ? 0 : value.hashCode()); 783 result = prime * result + ((valuePattern == null) ? 0 : valuePattern.hashCode()); 784 return result; 761 return Objects.hash(caseSensitive, key, keyPattern, value, valuePattern); 785 762 } 786 763 … … 792 769 return false; 793 770 KeyValue other = (KeyValue) obj; 794 if (caseSensitive != other.caseSensitive) 795 return false; 796 if (key == null) { 797 if (other.key != null) 798 return false; 799 } else if (!key.equals(other.key)) 800 return false; 801 if (keyPattern == null) { 802 if (other.keyPattern != null) 803 return false; 804 } else if (!keyPattern.equals(other.keyPattern)) 805 return false; 806 if (value == null) { 807 if (other.value != null) 808 return false; 809 } else if (!value.equals(other.value)) 810 return false; 811 if (valuePattern == null) { 812 if (other.valuePattern != null) 813 return false; 814 } else if (!valuePattern.equals(other.valuePattern)) 815 return false; 816 return true; 771 return caseSensitive == other.caseSensitive 772 && Objects.equals(key, other.key) 773 && Objects.equals(keyPattern, other.keyPattern) 774 && Objects.equals(value, other.value) 775 && Objects.equals(valuePattern, other.valuePattern); 817 776 } 818 777 } -
trunk/src/org/openstreetmap/josm/gui/widgets/QuadStateCheckBox.java
r15437 r15440 45 45 private final transient QuadStateDecorator cbModel; 46 46 private State[] allowed; 47 private final MouseListener mouseAdapter = new MouseAdapter() {47 private final transient MouseListener mouseAdapter = new MouseAdapter() { 48 48 @Override 49 49 public void mousePressed(MouseEvent e) {
Note:
See TracChangeset
for help on using the changeset viewer.