Package org.xipki.util.cbor
Class CborType
- java.lang.Object
-
- org.xipki.util.cbor.CborType
-
public class CborType extends java.lang.ObjectRepresents 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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)intgetAdditionalInfo()intgetMajorType()static java.lang.StringgetName(int mt)Returns a descriptive string for the given major type.inthashCode()booleanisBreakAllowed()booleanisEqualType(int encoded)booleanisEqualType(CborType other)java.lang.StringtoString()static CborTypevalueOf(int i)Decodes a given byte value to aCborTypevalue.
-
-
-
Method Detail
-
getName
public static java.lang.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:
java.lang.IllegalArgumentException- in case the given major type is not supported.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getAdditionalInfo
public int getAdditionalInfo()
- Returns:
- the additional information of this type, as integer value from [0..31].
-
getMajorType
public int getMajorType()
- Returns:
- the major type, as integer value from [0..7].
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
isBreakAllowed
public boolean isBreakAllowed()
- Returns:
trueif this type allows for an infinite-length payload,falseif only definite-length payloads are allowed.
-
isEqualType
public boolean isEqualType(CborType other)
-
isEqualType
public boolean isEqualType(int encoded)
Determines whether the major type of a given byte value (representing an encodedCborType) equals the major type of thisCborType.- Parameters:
encoded- the encoded CBOR type to compare.- Returns:
trueif the given byte value represents the same major type as thisCborType,falseotherwise.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-