kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 4f462f06dec2ac492ccd1060b0ca28bdd85bc11237d1f47c3a6d9000acfcc6fd |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-10-08 09:48 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-10-08 14:39 +02:00 |
| Parents | 06bb5a363293 |
4 files changed
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +6 −5
| @@ -661,15 +661,16 @@ | ||
| 661 | 661 | |
| 662 | 662 | /** |
| 663 | 663 | * The native protocol version to use, as a number. |
| 664 | - * <p> | |
| 665 | - * This method is provided for backward-compatibility. Whenever possible, | |
| 666 | - * {@link #withProtocolVersion(ProtocolVersion)} should be preferred. | |
| 667 | 664 | * |
| 668 | 665 | * @param version the native protocol version as a number. |
| 669 | 666 | * @return this Builder. |
| 670 | - * @throws DriverInternalError if the number does not correspond to any known native | |
| 671 | - * protocol version. | |
| 667 | + * @throws IllegalArgumentException if the number does not correspond to any known | |
| 668 | + * native protocol version. | |
| 669 | + * | |
| 670 | + * @deprecated This method is provided for backward compatibility. Use | |
| 671 | + * {@link #withProtocolVersion(ProtocolVersion)} instead. | |
| 672 | 672 | */ |
| 673 | + @Deprecated | |
| 673 | 674 | public Builder withProtocolVersion(int version) { |
| 674 | 675 | this.protocolVersion = ProtocolVersion.fromInt(version); |
| 675 | 676 | return this; |
modified driver-core/src/main/java/com/datastax/driver/core/DataType.java +58 −9
| @@ -560,21 +560,27 @@ | ||
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | /** |
| 563 | - * @deprecated This method is no longer supported, will be removed, and simply throws {@link UnsupportedOperationException}. | |
| 563 | + * Serialize a value of this type to bytes, with the given numeric protocol version. | |
| 564 | + * | |
| 565 | + * @throws IllegalArgumentException if {@code protocolVersion} does not correspond to any known version. | |
| 566 | + * | |
| 567 | + * @deprecated This method is provided for backward compatibility. Use | |
| 568 | + * {@link #serialize(Object, ProtocolVersion)} instead. | |
| 564 | 569 | */ |
| 565 | 570 | @Deprecated |
| 566 | - public Object deserialize(ByteBuffer bytes) { | |
| 567 | - throw new UnsupportedOperationException("Method no longer supported; use deserialize(ByteBuffer,ProtocolVersion)"); | |
| 571 | + public ByteBuffer serialize(Object value, int protocolVersion) { | |
| 572 | + return serialize(value, ProtocolVersion.fromInt(protocolVersion)); | |
| 568 | 573 | } |
| 569 | - | |
| 574 | + | |
| 570 | 575 | /** |
| 571 | - * @deprecated Use {@link #deserialize(ByteBuffer,ProtocolVersion)}. | |
| 572 | - * @see #deserialize(ByteBuffer,ProtocolVersion) | |
| 576 | + * @deprecated This method is provided for binary compatibility only. It is no longer supported, will be removed, | |
| 577 | + * and simply throws {@link UnsupportedOperationException}. Use {@link #serialize(Object, ProtocolVersion)} instead. | |
| 573 | 578 | */ |
| 574 | - public Object deserialize(ByteBuffer bytes, int protocolVersion) { | |
| 575 | - return deserialize(bytes, ProtocolVersion.fromInt(protocolVersion)); | |
| 579 | + @Deprecated | |
| 580 | + public ByteBuffer serialize(Object value) { | |
| 581 | + throw new UnsupportedOperationException("Method no longer supported; use serialize(Object,ProtocolVersion)"); | |
| 576 | 582 | } |
| 577 | - | |
| 583 | + | |
| 578 | 584 | /** |
| 579 | 585 | * Deserialize a value of this type from the provided bytes using the given protocol version. |
| 580 | 586 | * |
| @@ -600,6 +606,27 @@ | ||
| 600 | 606 | return codec(protocolVersion).deserialize(bytes); |
| 601 | 607 | } |
| 602 | 608 | |
| 609 | + /** | |
| 610 | + * Deserialize a value of this type from the provided bytes using the given numeric protocol version. | |
| 611 | + * | |
| 612 | + * @throws IllegalArgumentException if {@code protocolVersion} does not correspond to any known version. | |
| 613 | + * | |
| 614 | + * @deprecated This method is provided for backward compatibility. Use | |
| 615 | + * {@link #deserialize(ByteBuffer,ProtocolVersion)} instead. | |
| 616 | + */ | |
| 617 | + public Object deserialize(ByteBuffer bytes, int protocolVersion) { | |
| 618 | + return deserialize(bytes, ProtocolVersion.fromInt(protocolVersion)); | |
| 619 | + } | |
| 620 | + | |
| 621 | + /** | |
| 622 | + * @deprecated This method is provided for binary compatibility only. It is no longer supported, will be removed, | |
| 623 | + * and simply throws {@link UnsupportedOperationException}. Use {@link #deserialize(ByteBuffer, ProtocolVersion)} instead. | |
| 624 | + */ | |
| 625 | + @Deprecated | |
| 626 | + public Object deserialize(ByteBuffer bytes) { | |
| 627 | + throw new UnsupportedOperationException("Method no longer supported; use deserialize(ByteBuffer,ProtocolVersion)"); | |
| 628 | + } | |
| 629 | + | |
| 603 | 630 | /** |
| 604 | 631 | * Serialize an object based on its java class. |
| 605 | 632 | * <p> |
| @@ -639,6 +666,28 @@ | ||
| 639 | 666 | } |
| 640 | 667 | } |
| 641 | 668 | |
| 669 | + /** | |
| 670 | + * Serialize an object based on its java class, with the given numeric protocol version. | |
| 671 | + * | |
| 672 | + * @throws IllegalArgumentException if {@code protocolVersion} does not correspond to any known version. | |
| 673 | + * | |
| 674 | + * @deprecated This method is provided for backward compatibility. Use | |
| 675 | + * {@link #serializeValue(Object, ProtocolVersion)} instead. | |
| 676 | + */ | |
| 677 | + @Deprecated | |
| 678 | + public static ByteBuffer serializeValue(Object value, int protocolVersion) { | |
| 679 | + return serializeValue(value, ProtocolVersion.fromInt(protocolVersion)); | |
| 680 | + } | |
| 681 | + | |
| 682 | + /** | |
| 683 | + * @deprecated This method is provided for binary compatibility only. It is no longer supported, will be removed, | |
| 684 | + * and simply throws {@link UnsupportedOperationException}. Use {@link #serializeValue(Object, ProtocolVersion)} instead. | |
| 685 | + */ | |
| 686 | + @Deprecated | |
| 687 | + public static ByteBuffer serializeValue(Object value) { | |
| 688 | + throw new UnsupportedOperationException("Method no longer supported; use serializeValue(Object,ProtocolVersion)"); | |
| 689 | + } | |
| 690 | + | |
| 642 | 691 | private static class Native extends DataType { |
| 643 | 692 | private Native(DataType.Name name) { |
| 644 | 693 | super(name); |
modified driver-core/src/main/java/com/datastax/driver/core/ProtocolVersion.java +12 −1
| @@ -32,6 +32,9 @@ | ||
| 32 | 32 | V3("2.1.0", 3), |
| 33 | 33 | ; |
| 34 | 34 | |
| 35 | + /** | |
| 36 | + * The most recent protocol version supported by the driver. | |
| 37 | + */ | |
| 35 | 38 | public static ProtocolVersion NEWEST_SUPPORTED = V3; |
| 36 | 39 | |
| 37 | 40 | private final VersionNumber minCassandraVersion; |
| @@ -72,10 +75,18 @@ | ||
| 72 | 75 | INT_TO_VERSION = builder.build(); |
| 73 | 76 | } |
| 74 | 77 | |
| 78 | + /** | |
| 79 | + * Returns the value matching an integer version. | |
| 80 | + * | |
| 81 | + * @param i the version as an integer. | |
| 82 | + * @return the matching enum value. | |
| 83 | + * | |
| 84 | + * @throws IllegalArgumentException if the argument doesn't match any known version. | |
| 85 | + */ | |
| 75 | 86 | public static ProtocolVersion fromInt(int i) { |
| 76 | 87 | ProtocolVersion version = INT_TO_VERSION.get(i); |
| 77 | 88 | if (version == null) |
| 78 | - throw new DriverInternalError("No protocol version matching integer version " + i); | |
| 89 | + throw new IllegalArgumentException("No protocol version matching integer version " + i); | |
| 79 | 90 | return version; |
| 80 | 91 | } |
| 81 | 92 | } |
modified driver-core/src/main/java/com/datastax/driver/core/RegularStatement.java +22 −0
| @@ -58,6 +58,28 @@ | ||
| 58 | 58 | */ |
| 59 | 59 | public abstract ByteBuffer[] getValues(ProtocolVersion protocolVersion); |
| 60 | 60 | |
| 61 | + /** | |
| 62 | + * The values to use for this statement, for the given numeric protocol version. | |
| 63 | + * | |
| 64 | + * @throws IllegalArgumentException if {@code protocolVersion} does not correspond to any known version. | |
| 65 | + * | |
| 66 | + * @deprecated This method is provided for backward compatibility. Use | |
| 67 | + * {@link #getValues(ProtocolVersion)} instead. | |
| 68 | + */ | |
| 69 | + @Deprecated | |
| 70 | + public ByteBuffer[] getValues(int protocolVersion) { | |
| 71 | + return getValues(ProtocolVersion.fromInt(protocolVersion)); | |
| 72 | + } | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * @deprecated This method is provided for binary compatibility only. It is no longer supported, will be removed, | |
| 76 | + * and simply throws {@link UnsupportedOperationException}. Use {@link #getValues(ProtocolVersion)} instead. | |
| 77 | + */ | |
| 78 | + @Deprecated | |
| 79 | + public ByteBuffer[] getValues() { | |
| 80 | + throw new UnsupportedOperationException("Method no longer supported; use getValues(ProtocolVersion)"); | |
| 81 | + } | |
| 82 | + | |
| 61 | 83 | /** |
| 62 | 84 | * Whether or not this statement has values, that is if {@code getValues} |
| 63 | 85 | * will return {@code null} or not. |