Package org.webpki.cbor
Class CBORTag
java.lang.Object
org.webpki.cbor.CBORObject
org.webpki.cbor.CBORTag
- All Implemented Interfaces:
Cloneable,Comparable<CBORObject>
Class for holding CBOR
The reserved tags are verified for correctness during decoding as well
as when created programmatically.
#6.n (tag) objects.
Tagged objects are based on CBOR major type 6. This implementation accepts multiple variants of tags:
| Type | Diagnostic Notation | Comment |
|---|---|---|
| General Purpose | nnn(CBOR object) |
Arbitrary CBOR tag |
Reserved DateTime |
0(ISO date string) |
See getDateTime() |
Reserved EpochTime |
1(Time stamp) |
See getEpochTime() |
Reserved COTX |
1010([Text string,
CBOR object]) |
See getCOTXObject() |
Note that the bigint type is dealt with
as a specific primitive, in spite of being a tagged object.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCOTX tag: 1010static final intDATE_TIME tag: 0static final intEPOCH_TIME tag: 1 -
Constructor Summary
ConstructorsConstructorDescriptionCBORTag(long tagNumber, CBORObject object) Creates a CBOR tagged object.CBORTag(String typeUrl, CBORObject object) Creates a COTX object. -
Method Summary
Modifier and TypeMethodDescriptionget()Get tagged CBOR object.GetCOTXobject.Get ISOdate/timeobject.Get UNIXEpochtime object.longGet tag number.Methods inherited from class org.webpki.cbor.CBORObject
checkForUnread, clone, compareTo, encode, equals, getArray, getBigInteger, getBoolean, getBytes, getExtendedFloat64, getFloat16, getFloat32, getFloat64, getInt128, getInt16, getInt32, getInt53, getInt64, getInt8, getMap, getSimple, getString, getTag, getUint128, getUint16, getUint32, getUint64, getUint8, hashCode, isNull, scan, toDiagnostic, toString
-
Field Details
-
RESERVED_TAG_DATE_TIME
public static final int RESERVED_TAG_DATE_TIMEDATE_TIME tag: 0- See Also:
-
RESERVED_TAG_EPOCH_TIME
public static final int RESERVED_TAG_EPOCH_TIMEEPOCH_TIME tag: 1- See Also:
-
RESERVED_TAG_COTX
public static final int RESERVED_TAG_COTXCOTX tag: 1010- See Also:
-
-
Constructor Details
-
CBORTag
Creates a COTX object.The purpose of the
COTXtag is to provide a generic way of adding an object type identifier in the form of a URL or other text data to CBOR objects. Example:1010(["https://example.com/myobject", {
"amount": "145.00",
"currency": "USD"
}])- Parameters:
typeUrl- Type URL (or other string)object- Object
-
CBORTag
Creates a CBOR tagged object.- Parameters:
tagNumber- Tag numberobject- Object- Throws:
CBORExceptionIllegalArgumentException
-
-
Method Details
-
get
Get tagged CBOR object.- Returns:
- object
-
getDateTime
Get ISOdate/timeobject.This method assumes that a valid CBOR tag 0 has been found, otherwise a
CBORExceptionis thrown.- Overrides:
getDateTimein classCBORObject- Returns:
Instant- Throws:
CBORException- See Also:
-
getEpochTime
Get UNIXEpochtime object.This method assumes that a valid CBOR tag 1 has been found, otherwise a
CBORExceptionis thrown.- Overrides:
getEpochTimein classCBORObject- Returns:
Instant- Throws:
CBORException- See Also:
-
getCOTXObject
GetCOTXobject.This method assumes that a valid
COTXtag has been found, otherwise aCBORExceptionis thrown.- Returns:
COTXObject- Throws:
CBORException- See Also:
-
getTagNumber
public long getTagNumber()Get tag number.- Returns:
- Tag number
-