Changeset 2613 in josm for trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java
- Timestamp:
- 2009-12-11T23:07:59+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java
r2512 r2613 2 2 package org.openstreetmap.josm.io; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 4 7 import java.io.InputStream; 8 import java.util.ArrayList; 9 import java.util.Collection; 10 import java.util.Collections; 11 import java.util.Iterator; 5 12 import java.util.List; 6 13 … … 9 16 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 10 17 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 11 import static org.openstreetmap.josm.tools.I18n.tr;12 18 13 19 /** … … 68 74 69 75 /** 70 * Reads t ehchangeset with id <code>id</code> from the server76 * Reads the changeset with id <code>id</code> from the server 71 77 * 72 78 * @param id the changeset id. id > 0 required. … … 104 110 105 111 /** 112 * Reads the changeset with id <code>id</code> from the server 113 * 114 * @param ids the list of ids. Ignored if null. Only load changesets for ids > 0. 115 * @param monitor the progress monitor. Set to {@see NullProgressMonitor#INSTANCE} if null 116 * @return the changeset read 117 * @throws OsmTransferException thrown if something goes wrong 118 * @throws IllegalArgumentException if id <= 0 119 */ 120 public List<Changeset> readChangesets(Collection<Integer> ids, ProgressMonitor monitor) throws OsmTransferException { 121 if (ids == null) 122 return Collections.emptyList(); 123 if (monitor == null) { 124 monitor = NullProgressMonitor.INSTANCE; 125 } 126 try { 127 monitor.beginTask(trn("Downloading {0} changeset ...", "Downloading {0} changesets ...",ids.size(),ids.size())); 128 monitor.setTicksCount(ids.size()); 129 List<Changeset> ret = new ArrayList<Changeset>(); 130 int i=0; 131 for (Iterator<Integer> it = ids.iterator(); it.hasNext(); ) { 132 int id = it.next(); 133 if (id <= 0) { 134 continue; 135 } 136 i++; 137 StringBuffer sb = new StringBuffer(); 138 sb.append("changeset/").append(id); 139 InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true)); 140 if (in == null) 141 return null; 142 monitor.indeterminateSubTask(tr("({0}/{1}) Downloading changeset {0} ...", i,ids.size(), id)); 143 List<Changeset> changesets = OsmChangesetParser.parse(in, monitor.createSubTaskMonitor(1, true)); 144 if (changesets == null || changesets.isEmpty()) { 145 continue; 146 } 147 ret.addAll(changesets); 148 monitor.worked(1); 149 } 150 return ret; 151 } catch(OsmTransferException e) { 152 throw e; 153 } catch(IllegalDataException e) { 154 throw new OsmTransferException(e); 155 } finally { 156 monitor.finishTask(); 157 } 158 } 159 160 /** 106 161 * not implemented yet 107 162 *
Note:
See TracChangeset
for help on using the changeset viewer.
