Changeset 34835 in osm for applications/editors/josm/plugins
- Timestamp:
- 2019-01-17T07:55:16+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/o5m/src/org/openstreetmap/josm/plugins/o5m/io/O5mReader.java
r34827 r34835 8 8 import java.io.IOException; 9 9 import java.io.InputStream; 10 import java.nio.charset.StandardCharsets; 10 11 import java.util.ArrayList; 11 12 import java.util.Collection; … … 39 40 */ 40 41 public class O5mReader extends AbstractReader { 41 p ublicIllegalDataException exception = null;42 private IllegalDataException exception = null; 42 43 private boolean discourageUpload; 43 44 … … 80 81 private BufferedInputStream fis; 81 82 private InputStream is; 82 private ByteArrayInputStream bis;83 83 84 84 // buffer for byte -> String conversions … … 94 94 private int bytesToRead; 95 95 // total number of bytes read from stream 96 long countBytes;96 private long countBytes; 97 97 98 98 // for delta calculations … … 103 103 private long lastTs; 104 104 private long lastChangeSet; 105 private int lastLon, lastLat; 105 private int lastLon; 106 private int lastLat; 106 107 private int version; 107 108 private User osmUser; … … 175 176 } 176 177 ioPos = 0; 177 bis = new ByteArrayInputStream(ioBuf, 0, bytesToRead); 178 is = bis; 178 is = new ByteArrayInputStream(ioBuf, 0, bytesToRead); 179 179 break; 180 default: 180 default: break; 181 181 } 182 182 } … … 229 229 ds.addDataSource(new DataSource(b, header)); 230 230 } else { 231 Logging.error("Invalid Bounds: " +b);231 Logging.error("Invalid Bounds: " + b); 232 232 } 233 233 } … … 235 235 /** 236 236 * read a node data set 237 * @throws IOException in case of I/O error 238 */ 239 private void readNode() throws IOException { 237 */ 238 private void readNode() { 240 239 if (exception != null) 241 240 return; … … 285 284 /** 286 285 * read a way data set 287 * @throws IOException in case of I/O error 288 */ 289 private void readWay() throws IOException { 286 */ 287 private void readWay() { 290 288 if (exception != null) 291 289 return; … … 333 331 /** 334 332 * read a relation data set 335 * @throws IOException in case of I/O error 336 */ 337 private void readRel() throws IOException { 333 */ 334 private void readRel() { 338 335 if (exception != null) 339 336 return; … … 387 384 } 388 385 389 private Map<String, String> readTags() throws IOException{386 private Map<String, String> readTags() { 390 387 Map<String, String> keys = new HashMap<>(); 391 388 while (bytesToRead > 0) { … … 424 421 * Read version, time stamp and change set and author. 425 422 * We are not interested in the values, but we have to maintain the string table. 426 * @throws IOException in case of I/O error 427 */ 428 private void readVersionTsAuthor() throws IOException { 423 */ 424 private void readVersionTsAuthor() { 429 425 stringPair[0] = null; 430 426 stringPair[1] = null; … … 442 438 /** 443 439 * Read author . 444 * @throws IOException in case of I/O error 445 */ 446 private void readAuthor() throws IOException { 440 */ 441 private void readAuthor() { 447 442 int stringRef = readUnsignedNum32(); 448 443 if (stringRef == 0) { … … 465 460 466 461 if (b == 0) 467 stringPair[1] = new String(cnvBuffer, start, buffPos-1, "UTF-8");462 stringPair[1] = new String(cnvBuffer, start, buffPos-1, StandardCharsets.UTF_8); 468 463 } 469 464 long bytes = toReadStart - bytesToRead; … … 472 467 } else 473 468 setStringRefPair(stringRef); 474 if (stringPair[0] != null && stringPair[0].isEmpty() == false) {469 if (stringPair[0] != null && !stringPair[0].isEmpty()) { 475 470 long uid = Long.parseLong(stringPair[0]); 476 471 osmUser = User.createOsmUser(uid, stringPair[1]); … … 482 477 * read object type ("0".."2") concatenated with role (single string) 483 478 * @return 0..3 for type (3 means unknown) 484 * @throws IOException in case of I/O error 485 */ 486 private int readRelRef() throws IOException { 479 */ 480 private int readRelRef() { 487 481 int refType = -1; 488 482 long toReadStart = bytesToRead; … … 505 499 506 500 if (b == 0) 507 stringPair[1] = new String(cnvBuffer, start, buffPos-1, "UTF-8");501 stringPair[1] = new String(cnvBuffer, start, buffPos-1, StandardCharsets.UTF_8); 508 502 } 509 503 long bytes = toReadStart - bytesToRead; … … 525 519 /** 526 520 * read a string pair (see o5m definition) 527 * @throws IOException in case of I/O error 528 */ 529 private void readStringPair() throws IOException { 521 */ 522 private void readStringPair() { 530 523 int stringRef = readUnsignedNum32(); 531 524 if (stringRef == 0) { … … 540 533 541 534 if (b == 0) { 542 stringPair[cnt] = new String(cnvBuffer, start, buffPos-start-1, "UTF-8");535 stringPair[cnt] = new String(cnvBuffer, start, buffPos-start-1, StandardCharsets.UTF_8); 543 536 ++cnt; 544 537 start = buffPos; … … 570 563 throw new IOException(tr("unsupported header")); 571 564 } 572 header = new String(ioBuf, 0, 3, "UTF-8");565 header = new String(ioBuf, 0, 3, StandardCharsets.UTF_8); 573 566 } 574 567 … … 707 700 * Exception thrown after user cancellation. 708 701 */ 702 @SuppressWarnings("serial") 709 703 private static final class O5mParsingCancelException extends Exception implements ImportCancelException { 710 704 O5mParsingCancelException(String msg) {
Note:
See TracChangeset
for help on using the changeset viewer.