Changeset 4431 in josm for trunk/src/org/openstreetmap/josm/data/osm
- Timestamp:
- 2011-09-17T10:59:32+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r4150 r4431 17 17 18 18 public abstract class AbstractPrimitive implements IPrimitive { 19 19 20 20 private static final AtomicLong idCounter = new AtomicLong(0); 21 21 … … 305 305 } 306 306 } 307 307 308 308 /** 309 309 * Marks this primitive as being modified. … … 373 373 return (flags & FLAG_VISIBLE) != 0; 374 374 } 375 375 376 376 /** 377 377 * Sets whether this primitive is visible, i.e. whether it is known on the server … … 414 414 return (flags & FLAG_INCOMPLETE) != 0; 415 415 } 416 416 417 417 protected String getFlagsAsString() { 418 418 StringBuilder builder = new StringBuilder(); … … 528 528 } 529 529 } 530 530 531 531 /** 532 532 * Remove the given key from the list … … 589 589 } 590 590 591 public final String getIgnoreCase(String key) { 592 String[] keys = this.keys; 593 if (key == null) 594 return null; 595 if (keys == null) 596 return null; 597 for (int i=0; i<keys.length;i+=2) { 598 if (keys[i].equalsIgnoreCase(key)) return keys[i+1]; 599 } 600 return null; 601 } 602 591 603 @Override 592 604 public final Collection<String> keySet() { … … 642 654 */ 643 655 abstract protected void keysChangedImpl(Map<String, String> originalKeys); 644 656 645 657 /** 646 658 * Replies the name of this primitive. The default implementation replies the value … … 680 692 return getName(); 681 693 } 682 683 /**684 * Replies the display name of a primitive formatted by <code>formatter</code>685 *686 * @return the display name687 */688 @Override689 public abstract String getDisplayName(NameFormatter formatter);690 694 691 695 } -
trunk/src/org/openstreetmap/josm/data/osm/IPrimitive.java
r4100 r4431 30 30 int getChangesetId(); 31 31 void setChangesetId(int changesetId); 32 32 33 33 void visit(PrimitiveVisitor visitor); 34 34 String getName(); 35 35 String getLocalName(); 36 String getDisplayName(NameFormatter formatter);37 36 38 37 } -
trunk/src/org/openstreetmap/josm/data/osm/NameFormatter.java
r4100 r4431 5 5 6 6 public interface NameFormatter { 7 String format( INode node);8 String format( IWay way);9 String format( IRelation relation);7 String format(Node node); 8 String format(Way way); 9 String format(Relation relation); 10 10 String format(Changeset changeset); 11 11 -
trunk/src/org/openstreetmap/josm/data/osm/NodeData.java
r4126 r4431 25 25 return lat != Double.NaN && lon != Double.NaN; 26 26 } 27 27 28 28 @Override 29 29 public LatLon getCoor() { … … 77 77 } 78 78 79 @Override80 public String getDisplayName(NameFormatter formatter) {81 return formatter.format(this);82 }83 79 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r4103 r4431 25 25 import org.openstreetmap.josm.tools.CheckParameterUtil; 26 26 import org.openstreetmap.josm.tools.Predicate; 27 import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider; 27 28 28 29 /** … … 36 37 * @author imi 37 38 */ 38 abstract public class OsmPrimitive extends AbstractPrimitive implements Comparable<OsmPrimitive> { 39 abstract public class OsmPrimitive extends AbstractPrimitive implements Comparable<OsmPrimitive>, TemplateEngineDataProvider { 40 private static final String SPECIAL_VALUE_ID = "id"; 41 private static final String SPECIAL_VALUE_LOCAL_NAME = "localname"; 42 39 43 40 44 /** … … 412 416 super.updateFlags(flag, value); 413 417 } 414 418 415 419 @Override 416 420 protected final void updateFlags(int flag, boolean value) { … … 621 625 622 626 String directionDefault = "oneway? | incline=* | aerialway=* | "+ 623 "waterway=stream | waterway=river | waterway=canal | waterway=drain | waterway=rapids | "+624 "\"piste:type\"=downhill | \"piste:type\"=sled | man_made=\"piste:halfpipe\" | "+625 "junction=roundabout";627 "waterway=stream | waterway=river | waterway=canal | waterway=drain | waterway=rapids | "+ 628 "\"piste:type\"=downhill | \"piste:type\"=sled | man_made=\"piste:halfpipe\" | "+ 629 "junction=roundabout"; 626 630 627 631 try { … … 700 704 * Keys handling 701 705 ------------*/ 702 706 703 707 @Override 704 708 public final void setKeys(Map<String, String> keys) { … … 710 714 } 711 715 } 712 716 713 717 @Override 714 718 public final void put(String key, String value) { … … 719 723 writeUnlock(locked); 720 724 } 721 } 722 725 } 726 723 727 @Override 724 728 public final void remove(String key) { … … 739 743 writeUnlock(locked); 740 744 } 741 } 742 745 } 746 743 747 @Override 744 748 protected final void keysChangedImpl(Map<String, String> originalKeys) { … … 857 861 /** 858 862 * <p>Visits {@code visitor} for all referrers.</p> 859 * 863 * 860 864 * @param visitor the visitor. Ignored, if null. 861 865 */ … … 889 893 if (referrers == null) return false; 890 894 checkDataset(); 891 if (referrers instanceof OsmPrimitive) {892 return n<=1 && referrers instanceof Way && ((OsmPrimitive)referrers).dataSet == dataSet;893 }else {894 int counter=0;895 for (OsmPrimitive o : (OsmPrimitive[])referrers) {896 if (dataSet == o.dataSet && o instanceof Way) {897 if (++counter >= n)898 return true;899 }900 }901 return false;895 if (referrers instanceof OsmPrimitive) 896 return n<=1 && referrers instanceof Way && ((OsmPrimitive)referrers).dataSet == dataSet; 897 else { 898 int counter=0; 899 for (OsmPrimitive o : (OsmPrimitive[])referrers) { 900 if (dataSet == o.dataSet && o instanceof Way) { 901 if (++counter >= n) 902 return true; 903 } 904 } 905 return false; 902 906 } 903 907 } … … 1002 1006 1003 1007 return 1004 isDeleted() == other.isDeleted()1005 && isModified() == other.isModified()1006 && timestamp == other.timestamp1007 && version == other.version1008 && isVisible() == other.isVisible()1009 && (user == null ? other.user==null : user==other.user)1010 && changesetId == other.changesetId;1008 isDeleted() == other.isDeleted() 1009 && isModified() == other.isModified() 1010 && timestamp == other.timestamp 1011 && version == other.version 1012 && isVisible() == other.isVisible() 1013 && (user == null ? other.user==null : user==other.user) 1014 && changesetId == other.changesetId; 1011 1015 } 1012 1016 … … 1101 1105 } 1102 1106 1107 /** 1108 * Replies the display name of a primitive formatted by <code>formatter</code> 1109 * 1110 * @return the display name 1111 */ 1112 public abstract String getDisplayName(NameFormatter formatter); 1113 1114 @Override 1115 public Collection<String> getTemplateKeys() { 1116 Collection<String> keySet = keySet(); 1117 List<String> result = new ArrayList<String>(keySet.size() + 2); 1118 result.add(SPECIAL_VALUE_ID); 1119 result.add(SPECIAL_VALUE_LOCAL_NAME); 1120 result.addAll(keySet); 1121 return result; 1122 } 1123 1124 @Override 1125 public Object getTemplateValue(String name, boolean special) { 1126 if (special) { 1127 String lc = name.toLowerCase(); 1128 if (SPECIAL_VALUE_ID.equals(lc)) 1129 return getId(); 1130 else if (SPECIAL_VALUE_LOCAL_NAME.equals(lc)) 1131 return getLocalName(); 1132 else 1133 return null; 1134 1135 } else 1136 return getIgnoreCase(name); 1137 } 1138 1139 @Override 1140 public boolean evaluateCondition(Match condition) { 1141 return condition.match(this); 1142 } 1143 1103 1144 } -
trunk/src/org/openstreetmap/josm/data/osm/RelationData.java
r4100 r4431 62 62 return OsmPrimitiveType.RELATION; 63 63 } 64 65 @Override 64 65 @Override 66 66 public void visit(PrimitiveVisitor visitor) { 67 67 visitor.visit(this); 68 68 } 69 69 70 @Override71 public String getDisplayName(NameFormatter formatter) {72 return formatter.format(this);73 }74 75 70 } -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r4321 r4431 162 162 visitor.visit(this); 163 163 } 164 164 165 165 @Override public void visit(PrimitiveVisitor visitor) { 166 166 visitor.visit(this); … … 453 453 454 454 455 @Override456 455 public String getDisplayName(NameFormatter formatter) { 457 456 return formatter.format(this); -
trunk/src/org/openstreetmap/josm/data/osm/WayData.java
r4100 r4431 4 4 import java.util.ArrayList; 5 5 import java.util.List; 6 6 7 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 7 8 … … 57 58 return OsmPrimitiveType.WAY; 58 59 } 59 60 @Override 60 61 @Override 61 62 public void visit(PrimitiveVisitor visitor) { 62 63 visitor.visit(this); 63 64 } 64 65 65 @Override66 public String getDisplayName(NameFormatter formatter) {67 return formatter.format(this);68 }69 70 66 }
Note:
See TracChangeset
for help on using the changeset viewer.