Last change
on this file since 11355 was 8856, checked in by Don-vip, 9 years ago |
fix #11957 - partial revert of r8851 - do not replace Stack by ArrayDeque because of different iteration behaviour + add unit test
|
-
Property svn:eol-style
set to
native
|
File size:
1.4 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions.upload;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.util.ArrayList;
|
---|
7 | import java.util.List;
|
---|
8 | import java.util.Stack;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.data.osm.Relation;
|
---|
11 |
|
---|
12 | public class CyclicUploadDependencyException extends Exception {
|
---|
13 | private final Stack<Relation> cycle;
|
---|
14 |
|
---|
15 | public CyclicUploadDependencyException(Stack<Relation> cycle) {
|
---|
16 | this.cycle = cycle;
|
---|
17 | }
|
---|
18 |
|
---|
19 | protected String formatRelation(Relation r) {
|
---|
20 | StringBuilder sb = new StringBuilder();
|
---|
21 | if (r.getName() != null) {
|
---|
22 | sb.append('\'').append(r.getName()).append('\'');
|
---|
23 | } else if (!r.isNew()) {
|
---|
24 | sb.append(r.getId());
|
---|
25 | } else {
|
---|
26 | sb.append("relation@").append(r.hashCode());
|
---|
27 | }
|
---|
28 | return sb.toString();
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override
|
---|
32 | public String getMessage() {
|
---|
33 | StringBuilder sb = new StringBuilder();
|
---|
34 | sb.append(tr("Cyclic dependency between relations:"))
|
---|
35 | .append('[');
|
---|
36 | for (int i = 0; i < cycle.size(); i++) {
|
---|
37 | if (i > 0) {
|
---|
38 | sb.append(',');
|
---|
39 | }
|
---|
40 | sb.append(formatRelation(cycle.get(i)));
|
---|
41 | }
|
---|
42 | sb.append(']');
|
---|
43 | return sb.toString();
|
---|
44 | }
|
---|
45 |
|
---|
46 | public List<Relation> getCyclicUploadDependency() {
|
---|
47 | return new ArrayList<>(cycle);
|
---|
48 | }
|
---|
49 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.