public class

CborType

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.encoding.cbor.CborType

Class Overview

Represents the various major types in CBOR, along with their .

The major type is encoded in the upper three bits of each initial byte. The lower 5 bytes represent any additional information.

Summary

Public Methods
boolean equals(Object obj)
int getAdditionalInfo()
int getMajorType()
static String getName(int mt)
Returns a descriptive string for the given major type.
int hashCode()
boolean isBreakAllowed()
boolean isEqualType(CborType other)
Determines whether the major type of a given CborType equals the major type of this CborType.
boolean isEqualType(int encoded)
Determines whether the major type of a given byte value (representing an encoded CborType) equals the major type of this CborType.
String toString()
static CborType valueOf(int i)
Decodes a given byte value to a CborType value.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean equals (Object obj)

public int getAdditionalInfo ()

Returns
  • the additional information of this type, as integer value from [0..31].

public int getMajorType ()

Returns
  • the major type, as integer value from [0..7].

public static String getName (int mt)

Returns a descriptive string for the given major type.

Parameters
mt the major type to return as string, values from [0..7] are supported.
Returns
  • the name of the given major type, as String, never null.
Throws
IllegalArgumentException in case the given major type is not supported.

public int hashCode ()

public boolean isBreakAllowed ()

Returns
  • true if this type allows for an infinite-length payload, false if only definite-length payloads are allowed.

public boolean isEqualType (CborType other)

Determines whether the major type of a given CborType equals the major type of this CborType.

Parameters
other the CborType to compare against, cannot be null.
Returns
  • true if the given CborType is of the same major type as this CborType, false otherwise.
Throws
IllegalArgumentException in case the given argument was null.

public boolean isEqualType (int encoded)

Determines whether the major type of a given byte value (representing an encoded CborType) equals the major type of this CborType.

Parameters
encoded the encoded CBOR type to compare.
Returns
  • true if the given byte value represents the same major type as this CborType, false otherwise.

public String toString ()

public static CborType valueOf (int i)

Decodes a given byte value to a CborType value.

Parameters
i the input byte (8-bit) to decode into a CborType instance.
Returns