(ObjectOutput out)
| 487 | } |
| 488 | |
| 489 | private void writeDuration(ObjectOutput out) |
| 490 | throws IOException { |
| 491 | |
| 492 | Duration<?> d = Duration.class.cast(this.obj); |
| 493 | int size = d.getTotalLength().size(); |
| 494 | boolean useLong = false; |
| 495 | |
| 496 | for (int i = 0, n = Math.min(size, 6); i < n; i++ ) { |
| 497 | if (d.getTotalLength().get(i).getAmount() >= 1000) { |
| 498 | useLong = true; |
| 499 | break; |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | int header = DURATION_TYPE; |
| 504 | header <<= 4; |
| 505 | if (useLong) { |
| 506 | header |= 1; |
| 507 | } |
| 508 | out.writeByte(header); |
| 509 | out.writeInt(size); |
| 510 | |
| 511 | for (int i = 0; i < size; i++ ) { |
| 512 | TimeSpan.Item<?> item = d.getTotalLength().get(i); |
| 513 | if (useLong) { |
| 514 | out.writeLong(item.getAmount()); |
| 515 | } else { |
| 516 | out.writeInt((int) item.getAmount()); |
| 517 | } |
| 518 | out.writeObject(item.getUnit()); |
| 519 | } |
| 520 | |
| 521 | if (size > 0) { |
| 522 | out.writeBoolean(d.isNegative()); |
| 523 | } |
| 524 | |
| 525 | } |
| 526 | |
| 527 | private Object readDuration( |
| 528 | ObjectInput in, |
no test coverage detected