Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/**
* The interface {@code ArrayValue} represents MessagePack's Array type.
* <p/>
*

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, <p/> is necessary to insert blank lines in Javadoc :)

* MessagePack's Array type can represent sequence of values.
*/
public interface ArrayValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
* The interface {@code BinaryValue} represents MessagePack's Binary type.
* <p/>
*
* MessagePack's Binary type can represent a byte array at most 2<sup>64</sup>-1 bytes.
*
* @see org.msgpack.value.RawValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
* The interface {@code BooleanValue} represents MessagePack's Boolean type.
* <p/>
*
* MessagePack's Boolean type can represent {@code true} or {@code false}.
*/
public interface BooleanValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

/**
* The interface {@code ExtensionValue} represents MessagePack's Extension type.
* <p/>
*
* MessagePack's Extension type can represent represents a tuple of type information and a byte array where type information is an
* integer whose meaning is defined by applications.
* <p/>
*
* As the type information, applications can use 0 to 127 as the application-specific types. -1 to -128 is reserved for MessagePack's future extension.
*/
public interface ExtensionValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
* The interface {@code FloatValue} represents MessagePack's Float type.
* <p/>
*
* MessagePack's Float type can represent IEEE 754 double precision floating point numbers including NaN and infinity. This is same with Java's {@code double} type.
*
* @see org.msgpack.value.NumberValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/**
* The interface {@code IntegerValue} represents MessagePack's Integer type.
* <p/>
*
* MessagePack's Integer type can represent from -2<sup>63</sup> to 2<sup>64</sup>-1.
*/
public interface IntegerValue
Expand Down
6 changes: 3 additions & 3 deletions msgpack-core/src/main/java/org/msgpack/value/MapValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/**
* The interface {@code ArrayValue} represents MessagePack's Map type.
* <p/>
*
* MessagePack's Map type can represent sequence of key-value pairs.
*/
public interface MapValue
Expand All @@ -45,9 +45,9 @@ public interface MapValue

/**
* Returns the key-value pairs as an array of {@code Value}.
* <p/>
*
* Odd elements are keys. Next element of an odd element is a value corresponding to the key.
* <p/>
*
* For example, if this value represents <code>{"k1": "v1", "k2": "v2"}</code>, this method returns ["k1", "v1", "k2", "v2"].
*/
Value[] getKeyValueArray();
Expand Down
12 changes: 9 additions & 3 deletions msgpack-core/src/main/java/org/msgpack/value/RawValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,32 @@ public interface RawValue
{
/**
* Returns the value as {@code byte[]}.
* <p/>
*
* This method copies the byte array.
*/
byte[] asByteArray();

/**
* Returns the value as {@code ByteBuffer}.
* <p/>
*
* Returned ByteBuffer is read-only. See {@code#asReadOnlyBuffer()}.
* This method doesn't copy the byte array as much as possible.
*/
ByteBuffer asByteBuffer();

/**
* Returns the value as {@code String}.
* <p/>
*
* This method throws an exception if the value includes invalid UTF-8 byte sequence.
*
* @throws MessageStringCodingException If this value includes invalid UTF-8 byte sequence.
*/
String asString();

/**
* Returns the value as {@code String}.
*
* This method replaces an invalid UTF-8 byte sequence with <code>U+FFFD replacement character</code>.
*/
String toString();
}
4 changes: 2 additions & 2 deletions msgpack-core/src/main/java/org/msgpack/value/StringValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

/**
* The interface {@code StringValue} represents MessagePack's String type.
* <p/>
*
* MessagePack's String type can represent a UTF-8 string at most 2<sup>64</sup>-1 bytes.
* <p/>
*
* Note that the value could include invalid byte sequences. {@code asString()} method throws {@code MessageTypeStringCodingException} if the value includes invalid byte sequence. {@code toJson()} method replaces an invalid byte sequence with <code>U+FFFD replacement character</code>.
*
* @see org.msgpack.value.RawValue
Expand Down
63 changes: 34 additions & 29 deletions msgpack-core/src/main/java/org/msgpack/value/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,101 +30,101 @@ public interface Value
{
/**
* Returns type of this value.
* <p/>
*
* Note that you can't use <code>instanceof</code> to check type of a value because type of a mutable value is variable.
*/
ValueType getValueType();

/**
* Returns immutable copy of this value.
* <p/>
*
* This method simply returns <code>this</code> without copying the value if this value is already immutable.
*/
ImmutableValue immutableValue();

/**
* Returns true if type of this value is Nil.
* <p/>
*
* If this method returns true, {@code asNilValue} never throws exceptions.
* Note that you can't use <code>instanceof</code> or cast <code>((NilValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*/
boolean isNilValue();

/**
* Returns true if type of this value is Boolean.
* <p/>
*
* If this method returns true, {@code asBooleanValue} never throws exceptions.
* Note that you can't use <code>instanceof</code> or cast <code>((BooleanValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*/
boolean isBooleanValue();

/**
* Returns true if type of this value is Integer or Float.
* <p/>
*
* If this method returns true, {@code asNumberValue} never throws exceptions.
* Note that you can't use <code>instanceof</code> or cast <code>((NumberValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*/
boolean isNumberValue();

/**
* Returns true if type of this value is Integer.
* <p/>
*
* If this method returns true, {@code asIntegerValue} never throws exceptions.
* Note that you can't use <code>instanceof</code> or cast <code>((IntegerValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*/
boolean isIntegerValue();

/**
* Returns true if type of this value is Float.
* <p/>
*
* If this method returns true, {@code asFloatValue} never throws exceptions.
* Note that you can't use <code>instanceof</code> or cast <code>((FloatValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*/
boolean isFloatValue();

/**
* Returns true if type of this value is String or Binary.
* <p/>
*
* If this method returns true, {@code asRawValue} never throws exceptions.
* Note that you can't use <code>instanceof</code> or cast <code>((RawValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*/
boolean isRawValue();

/**
* Returns true if type of this value is Binary.
* <p/>
*
* If this method returns true, {@code asBinaryValue} never throws exceptions.
* Note that you can't use <code>instanceof</code> or cast <code>((BinaryValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*/
boolean isBinaryValue();

/**
* Returns true if type of this value is String.
* <p/>
*
* If this method returns true, {@code asStringValue} never throws exceptions.
* Note that you can't use <code>instanceof</code> or cast <code>((StringValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*/
boolean isStringValue();

/**
* Returns true if type of this value is Array.
* <p/>
*
* If this method returns true, {@code asArrayValue} never throws exceptions.
* Note that you can't use <code>instanceof</code> or cast <code>((ArrayValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*/
boolean isArrayValue();

/**
* Returns true if type of this value is Map.
* <p/>
*
* If this method returns true, {@code asMapValue} never throws exceptions.
* Note that you can't use <code>instanceof</code> or cast <code>((MapValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*/
boolean isMapValue();

/**
* Returns true if type of this an Extension.
* <p/>
*
* If this method returns true, {@code asExtensionValue} never throws exceptions.
* Note that you can't use <code>instanceof</code> or cast <code>((ExtensionValue) thisValue)</code> to check type of a value because
* type of a mutable value is variable.
Expand All @@ -133,7 +133,7 @@ public interface Value

/**
* Returns the value as {@code NilValue}. Otherwise throws {@code MessageTypeCastException}.
* <p/>
*
* Note that you can't use <code>instanceof</code> or cast <code>((NilValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*
* @throws MessageTypeCastException If type of this value is not Nil.
Expand All @@ -142,7 +142,7 @@ public interface Value

/**
* Returns the value as {@code BooleanValue}. Otherwise throws {@code MessageTypeCastException}.
* <p/>
*
* Note that you can't use <code>instanceof</code> or cast <code>((BooleanValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*
* @throws MessageTypeCastException If type of this value is not Boolean.
Expand All @@ -151,7 +151,7 @@ public interface Value

/**
* Returns the value as {@code NumberValue}. Otherwise throws {@code MessageTypeCastException}.
* <p/>
*
* Note that you can't use <code>instanceof</code> or cast <code>((NumberValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*
* @throws MessageTypeCastException If type of this value is not Integer or Float.
Expand All @@ -160,7 +160,7 @@ public interface Value

/**
* Returns the value as {@code IntegerValue}. Otherwise throws {@code MessageTypeCastException}.
* <p/>
*
* Note that you can't use <code>instanceof</code> or cast <code>((IntegerValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*
* @throws MessageTypeCastException If type of this value is not Integer.
Expand All @@ -169,7 +169,7 @@ public interface Value

/**
* Returns the value as {@code FloatValue}. Otherwise throws {@code MessageTypeCastException}.
* <p/>
*
* Note that you can't use <code>instanceof</code> or cast <code>((FloatValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*
* @throws MessageTypeCastException If type of this value is not Float.
Expand All @@ -178,7 +178,7 @@ public interface Value

/**
* Returns the value as {@code RawValue}. Otherwise throws {@code MessageTypeCastException}.
* <p/>
*
* Note that you can't use <code>instanceof</code> or cast <code>((RawValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*
* @throws MessageTypeCastException If type of this value is not Binary or String.
Expand All @@ -187,7 +187,7 @@ public interface Value

/**
* Returns the value as {@code BinaryValue}. Otherwise throws {@code MessageTypeCastException}.
* <p/>
*
* Note that you can't use <code>instanceof</code> or cast <code>((BinaryValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*
* @throws MessageTypeCastException If type of this value is not Binary.
Expand All @@ -196,7 +196,7 @@ public interface Value

/**
* Returns the value as {@code StringValue}. Otherwise throws {@code MessageTypeCastException}.
* <p/>
*
* Note that you can't use <code>instanceof</code> or cast <code>((StringValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*
* @throws MessageTypeCastException If type of this value is not String.
Expand All @@ -205,7 +205,7 @@ public interface Value

/**
* Returns the value as {@code ArrayValue}. Otherwise throws {@code MessageTypeCastException}.
* <p/>
*
* Note that you can't use <code>instanceof</code> or cast <code>((ArrayValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*
* @throws MessageTypeCastException If type of this value is not Array.
Expand All @@ -214,7 +214,7 @@ public interface Value

/**
* Returns the value as {@code MapValue}. Otherwise throws {@code MessageTypeCastException}.
* <p/>
*
* Note that you can't use <code>instanceof</code> or cast <code>((MapValue) thisValue)</code> to check type of a value because type of a mutable value is variable.
*
* @throws MessageTypeCastException If type of this value is not Map.
Expand All @@ -223,7 +223,7 @@ public interface Value

/**
* Returns the value as {@code ExtensionValue}. Otherwise throws {@code MessageTypeCastException}.
* <p/>
*
* Note that you can't use <code>instanceof</code> or cast <code>((ExtensionValue) thisValue)</code> to check type of a value
* because type of a mutable value is variable.
*
Expand All @@ -241,17 +241,22 @@ void writeTo(MessagePacker pk)

/**
* Compares this value to the specified object.
* <p/>
*
* This method returns {@code true} if type and value are equivalent.
* If this value is {@code MapValue} or {@code ArrayValue}, this method check equivalence of elements recursively.
*/
boolean equals(Object obj);

/**
* Returns json representation of this Value for debugging purpose.
* This output json format is subject to change in future.
* Do not write code that depends on the resulting json format.
* Returns json representation of this Value.
*
* Following behavior is not configurable at this release and they might be changed at future releases:
*
* * if a key of MapValue is not string, the key is converted to a string using toString method.
* * NaN and Infinity of DoubleValue are converted to null.
* * ExtensionValue is converted to a 2-element array where first element is a number and second element is the data encoded in hex.
* * BinaryValue is converted to a string using UTF-8 encoding. Invalid byte sequence is replaced with <code>U+FFFD replacement character</code>.
* * Invalid UTF-8 byte sequences in StringValue is replaced with <code>U+FFFD replacement character</code>
*/
String toJson();

}
Loading