Package jsonvalues
Class JsBinary
- java.lang.Object
-
- jsonvalues.JsBinary
-
- All Implemented Interfaces:
JsValue
public class JsBinary extends java.lang.Object implements JsValue
Represents an array of bytes. This type is not part of the Json specification. It it serialized into a string using Base64 encoding scheme. A JsBinary and a JsStr are equals if the string is the array of bytes encoded in base64.byte[] bytes = "foo".getBytes(); String base64 = Base64.getEncoder().encodeToString(bytes); JsBinary.of(bytes).equals(JsStr.of(base64)); // true
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
int
hashCode()
int
id()
boolean
isBinary()
static JsBinary
of(byte[] bytes)
Creates a JsBinary from an array of bytesstatic JsBinary
of(java.lang.String base64)
Creates a JsBinary from an array of bytes encoded as a string in base64java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsonvalues.JsValue
ifNothing, ifNull, isArray, isArray, isBigDec, isBigDec, isBigInt, isBigInt, isBool, isDecimal, isDouble, isDouble, isFalse, isInstant, isInstant, isInt, isInt, isIntegral, isJson, isJson, isLong, isLong, isNothing, isNotJson, isNotNothing, isNotNull, isNotNumber, isNull, isNumber, isObj, isObj, isSameType, isStr, isStr, isTrue, toJsArray, toJsBigDec, toJsBigInt, toJsBinary, toJsBool, toJsDouble, toJsInstant, toJsInt, toJsLong, toJsNumber, toJsObj, toJson, toJsStr
-
-
-
-
Field Detail
-
ID
public static final int ID
- See Also:
- Constant Field Values
-
value
public final byte[] value
-
-
Method Detail
-
of
public static JsBinary of(byte[] bytes)
Creates a JsBinary from an array of bytes- Parameters:
bytes
- the array of bytes- Returns:
- an immutable JsBinary
-
of
public static JsBinary of(java.lang.String base64)
Creates a JsBinary from an array of bytes encoded as a string in base64- Parameters:
base64
- the string- Returns:
- an immutable JsBinary
- Throws:
java.lang.IllegalArgumentException
- ifbase64
is not in valid Base64 scheme
-
isBinary
public boolean isBinary()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-