- Timestamp:
- 2018-12-09T20:06:53+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r14311 r14535 420 420 } 421 421 422 protected String detectErrorMessage(String data) { 422 /** 423 * Tries do detect an error message from given string. 424 * @param data string to analyze 425 * @return error message if detected, or null 426 * @since 14535 427 */ 428 public String detectErrorMessage(String data) { 423 429 Matcher m = HttpClient.getTomcatErrorMatcher(data); 424 430 return m.matches() ? m.group(1).replace("'", "''") : null; -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r14311 r14535 67 67 * @param downloadExecutor that will be executing the jobs 68 68 */ 69 70 69 public TMSCachedTileLoaderJob(TileLoaderListener listener, Tile tile, 71 70 ICacheAccess<String, BufferedImageCacheEntry> cache, … … 321 320 322 321 @Override 323 p rotectedString detectErrorMessage(String data) {322 public String detectErrorMessage(String data) { 324 323 Matcher m = SERVICE_EXCEPTION_PATTERN.matcher(data); 325 324 return m.matches() ? removeCdata(Utils.strip(m.group(1))) : super.detectErrorMessage(data); -
trunk/src/org/openstreetmap/josm/io/AbstractReader.java
r14119 r14535 14 14 import java.util.Map; 15 15 import java.util.Map.Entry; 16 import java.util.OptionalLong; 16 17 import java.util.function.Consumer; 17 18 … … 323 324 throw new IllegalDataException(e); 324 325 } finally { 326 OptionalLong minId = externalIdMap.values().stream().mapToLong(AbstractPrimitive::getUniqueId).min(); 327 if (minId.isPresent() && minId.getAsLong() < AbstractPrimitive.currentUniqueId()) { 328 AbstractPrimitive.advanceUniqueId(minId.getAsLong()); 329 } 325 330 progressMonitor.finishTask(); 326 331 progressMonitor.removeCancelListener(cancelListener); … … 604 609 } 605 610 611 @SuppressWarnings("unchecked") 612 private <T extends OsmPrimitive> T buildPrimitive(PrimitiveData pd) { 613 OsmPrimitive p; 614 if (pd.getUniqueId() < AbstractPrimitive.currentUniqueId()) { 615 p = pd.getType().newInstance(pd.getUniqueId(), true); 616 } else { 617 p = pd.getType().newVersionedInstance(pd.getId(), pd.getVersion()); 618 } 619 p.setVisible(pd.isVisible()); 620 p.load(pd); 621 externalIdMap.put(pd.getPrimitiveId(), p); 622 return (T) p; 623 } 624 606 625 private Node addNode(NodeData nd, NodeReader nodeReader) throws IllegalDataException { 607 Node n = new Node(nd.getId(), nd.getVersion()); 608 n.setVisible(nd.isVisible()); 609 n.load(nd); 626 Node n = buildPrimitive(nd); 610 627 nodeReader.accept(n); 611 externalIdMap.put(nd.getPrimitiveId(), n);612 628 return n; 613 629 } … … 615 631 protected final Node parseNode(double lat, double lon, CommonReader commonReader, NodeReader nodeReader) 616 632 throws IllegalDataException { 617 NodeData nd = new NodeData( );633 NodeData nd = new NodeData(0); 618 634 LatLon ll = null; 619 635 if (areLatLonDefined(lat, lon)) { … … 654 670 655 671 protected final Way parseWay(CommonReader commonReader, WayReader wayReader) throws IllegalDataException { 656 WayData wd = new WayData( );672 WayData wd = new WayData(0); 657 673 commonReader.accept(wd); 658 Way w = new Way(wd.getId(), wd.getVersion()); 659 w.setVisible(wd.isVisible()); 660 w.load(wd); 661 externalIdMap.put(wd.getPrimitiveId(), w); 674 Way w = buildPrimitive(wd); 662 675 663 676 Collection<Long> nodeIds = new ArrayList<>(); … … 672 685 673 686 protected final Relation parseRelation(CommonReader commonReader, RelationReader relationReader) throws IllegalDataException { 674 RelationData rd = new RelationData( );687 RelationData rd = new RelationData(0); 675 688 commonReader.accept(rd); 676 Relation r = new Relation(rd.getId(), rd.getVersion()); 677 r.setVisible(rd.isVisible()); 678 r.load(rd); 679 externalIdMap.put(rd.getPrimitiveId(), r); 689 Relation r = buildPrimitive(rd); 680 690 681 691 Collection<RelationMemberData> members = new ArrayList<>(); -
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r14480 r14535 5 5 6 6 import java.io.BufferedReader; 7 import java.io.ByteArrayOutputStream;8 7 import java.io.Closeable; 9 8 import java.io.File; … … 245 244 */ 246 245 public byte[] getByteContent() throws IOException { 247 try (InputStream is = getInputStream()) { 248 ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 249 int nRead; 250 byte[] data = new byte[8192]; 251 while ((nRead = is.read(data, 0, data.length)) != -1) { 252 buffer.write(data, 0, nRead); 253 } 254 buffer.flush(); 255 return buffer.toByteArray(); 256 } 246 return Utils.readBytesFromStream(getInputStream()); 257 247 } 258 248 -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r14483 r14535 1447 1447 try { 1448 1448 ByteArrayOutputStream bout = new ByteArrayOutputStream(stream.available()); 1449 byte[] buffer = new byte[ 2048];1449 byte[] buffer = new byte[8192]; 1450 1450 boolean finished = false; 1451 1451 do {
Note:
See TracChangeset
for help on using the changeset viewer.