source: josm/src/org/openstreetmap/josm/data/conflict/ConflictItem.java@ 298

Last change on this file since 298 was 298, checked in by imi, 17 years ago
  • added license description to head of each source file
File size: 1.2 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.data.conflict;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Collection;
7import java.util.Map;
8
9import org.openstreetmap.josm.data.osm.OsmPrimitive;
10import org.openstreetmap.josm.gui.ConflictResolver.Resolution;
11
12public abstract class ConflictItem {
13
14 public String my, their;
15 public Resolution resolution = null;
16
17 public final void initialize(Map<OsmPrimitive,OsmPrimitive> conflicts) {
18 my = collectStr(conflicts.keySet());
19 their = collectStr(conflicts.values());
20 }
21
22 abstract public boolean hasConflict(OsmPrimitive key, OsmPrimitive value);
23 abstract protected String str(OsmPrimitive osm);
24 abstract public String key();
25 abstract public void apply(OsmPrimitive target, OsmPrimitive other);
26
27 protected final String collectStr(Collection<OsmPrimitive> c) {
28 String value = null;
29 for (OsmPrimitive osm : c) {
30 String v = str(osm);
31 if (value == null)
32 value = v;
33 else if (!value.equals(v)) {
34 value = "<html><i>&lt;"+tr("different")+"&gt;</i></html>";
35 break;
36 }
37 }
38 return value == null ? "" : value;
39 }
40}
Note: See TracBrowser for help on using the repository browser.