public abstract class CborTextString extends CborObject
| Modifier and Type | Method and Description |
|---|---|
abstract byte[][] |
byteArrayValue() |
CborTextString |
copy()
Creates an independent, deep copy of this data item.
|
static CborTextString |
create(byte[] array) |
static CborTextString |
create(byte[][] arrays,
int[] offsets,
int[] lengths,
int tag,
boolean isIndefiniteLength) |
static CborTextString |
create(byte[] array,
int offset,
int length) |
static CborTextString |
create(byte[] array,
int offset,
int length,
int tag,
boolean isIndefiniteLength) |
static CborTextString |
create(String string) |
static CborTextString |
create(String string,
int tag) |
boolean |
equals(Object obj) |
int |
getAdditionalInformation()
Returns the object's "additional information" value.
|
int |
getMajorType()
Returns the object's "Major Type", as defined by RFC7049.
|
int |
hashCode() |
abstract boolean |
isIndefiniteLength() |
boolean |
isValidJson()
Indicates if this data item can be losslessly converted to a JSON fragment.
|
abstract String |
stringValue() |
String |
toJavaObject()
Converts the given data item into a standard java object representation.
|
<T> T |
toJavaObject(Class<T> clazz)
Attempts to convert this data item to a java object with a specific class.
|
String |
toJsonString()
Returns a representation of this data item as JSON text.
|
String |
toString()
Describes this data item using CBOR diagnostic notation.
|
String |
toString(int ignore)
Describes this data item using CBOR diagnostic notation at the given indentation level.
|
createFromCborByteArray, createFromCborByteArray, createFromJavaObject, getTag, toCborByteArraypublic static CborTextString create(byte[][] arrays, int[] offsets, int[] lengths, int tag, boolean isIndefiniteLength)
public static CborTextString create(byte[] array, int offset, int length, int tag, boolean isIndefiniteLength)
public static CborTextString create(byte[] array, int offset, int length)
public static CborTextString create(byte[] array)
public static CborTextString create(String string, int tag)
public static CborTextString create(String string)
public abstract String stringValue()
public abstract byte[][] byteArrayValue()
public final int getMajorType()
CborObjectgetMajorType in class CborObjectCborMajorType,
CborObject.getAdditionalInformation()public int getAdditionalInformation()
CborObjectgetAdditionalInformation in class CborObjectCborObject.getMajorType()public abstract boolean isIndefiniteLength()
public final boolean isValidJson()
CborObjectNote that, with few exceptions, tags are not considered in this determination, since CborObject.toJsonString()
will strip out tags anyway.
isValidJson in class CborObjecttrue if this object could be rendered as JSON, false otherwise.public CborTextString copy()
CborObjectcopy in class CborObjectCborObjectpublic final String toJsonString()
CborObjectThe result is guaranteed to be syntactically-valid RFC8259 JSON text. In the event that there is
no JSON text representation for the underlying data item, its value will be replaced with a
placeholder JSON value (usually "null"). This condition can be detected beforehand
using CborObject.isValidJson().
Note that, in some pre-RFC8259 contexts, this method could be described as returning a
"JSON fragment" unless the data item was of the types CborMap (for a JSON
object) or CborArray (for a JSON array).
toJsonString in class CborObjectString containing representation of this data item as JSON textCborObject.isValidJson(),
RFC8259public String toJavaObject()
CborObjectTags are largely ignored, except in cases where the tag itself has defined behavior when
converting to JSON, like CborTag.EXPECTED_BASE16 and CborTag.EXPECTED_BASE64.
The resulting object type is dependent on the data item:
CborMap → Map<Object,Object>
CborArray → Collection<Object>
CborFloat → Float/Double
CborInteger → Integer/Long
CborTextString → String
CborByteString → byte[]
CborSimple.TRUE/CborSimple.FALSE → Boolean
CborSimple values → null
The returned value is a wholly independent copy.
toJavaObject in class CborObjectCborObject.createFromJavaObject(Object)public <T> T toJavaObject(Class<T> clazz) throws CborConversionException
CborObjectUnlike CborObject.toJavaObject(), this method will introspect into tags to figure out
conversions to BigInteger and URI. Unknown tags are ignored.
This method will return the most expressive result that satisfies the clazz
parameter. For example, if the data item is a CborByteString tagged CborTag.BIGNUM_POS, calling this method with different classes will lead to different
results:
toJavaObject(byte[].class would return a byte[]
toJavaObject(Object.class would return a BigInteger
toJavaObject(BigInteger.class would return a BigInteger
toJavaObject(URI.class would throw CborConversionException
Whereas this method called an untagged CborByteString would behave like this:
toJavaObject(byte[].class would return a byte[]
toJavaObject(Object.class would return a byte[]
toJavaObject(BigInteger.class would throw CborConversionException
toJavaObject(URI.class would throw CborConversionException
toJavaObject in class CborObjectclazz - The desired class of the returned objectclazz or null if this data item was
CborSimple.NULL or CborSimple.UNDEFINED.CborConversionException - if the underlying data item could not be represented as an
instance of clazz.public String toString(int ignore)
CborObjectThe output is similar to that of CborObject.toJsonString() except that it also includes tag
and encoding information that is CBOR-specific.
The returned string is intended as a diagnostic aid and not intended to be machine-readable.
toString in class CborObjectignore - the indentation level of the string to output. A negative value
indicates no newlines or whitespace should be added.String describing the data item.CborObject.toString()public String toString()
CborObjectNo additional whitespace is added for readability.
The output is similar to that of CborObject.toJsonString() except that it also includes tag
and encoding information that is CBOR-specific.
The returned string is intended as a diagnostic aid and not intended to be machine-readable.
toString in class CborObjectString describing the data item.CborObject.toString(int)Copyright © 2018–2023. All rights reserved.