Last change
on this file since 6142 was 3083, checked in by bastiK, 14 years ago |
added svn:eol-style=native to source files
|
-
Property svn:eol-style
set to
native
|
File size:
1.4 KB
|
Rev | Line | |
---|
[2512] | 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 Stack<Relation> cycle;
|
---|
| 14 |
|
---|
| 15 | public CyclicUploadDependencyException(Stack<Relation> cycle) {
|
---|
| 16 | super();
|
---|
| 17 | this.cycle = cycle;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | protected String formatRelation(Relation r) {
|
---|
| 21 | StringBuffer sb = new StringBuffer();
|
---|
| 22 | if (r.getName() != null) {
|
---|
| 23 | sb.append("'").append(r.getName()).append("'");
|
---|
| 24 | } else if (!r.isNew()) {
|
---|
| 25 | sb.append(r.getId());
|
---|
| 26 | } else {
|
---|
| 27 | sb.append("relation@").append(r.hashCode());
|
---|
| 28 | }
|
---|
| 29 | return sb.toString();
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | @Override
|
---|
| 33 | public String getMessage() {
|
---|
| 34 | StringBuffer sb = new StringBuffer();
|
---|
| 35 | sb.append(tr("Cyclic dependency between relations:"));
|
---|
| 36 | sb.append("[");
|
---|
| 37 | for (int i=0; i< cycle.size(); i++) {
|
---|
| 38 | if (i >0 ) {
|
---|
| 39 | sb.append(",");
|
---|
| 40 | }
|
---|
| 41 | sb.append(formatRelation(cycle.get(i)));
|
---|
| 42 | }
|
---|
| 43 | sb.append("]");
|
---|
| 44 | return sb.toString();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | public List<Relation> getCyclicUploadDependency() {
|
---|
| 48 | return new ArrayList<Relation>(cycle);
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.