Package org.webpki.cbor
Class CBORArray
java.lang.Object
org.webpki.cbor.CBORObject
org.webpki.cbor.CBORArray
- All Implemented Interfaces:
Cloneable
,Comparable<CBORObject>
Class for holding CBOR
[]
(array) objects.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(CBORObject object) Add object to the CBOR array.get
(int index) Get object at a specific position in the CBOR array.int
size()
Get size of the CBOR array.toArray()
Create shallow copy of the CBOR array.update
(int index, CBORObject object) Update object at a specific position in the CBOR array.Methods inherited from class org.webpki.cbor.CBORObject
checkForUnread, clone, compareTo, encode, equals, getArray, getBigInteger, getBoolean, getBytes, getDateTime, getEpochTime, getFloat16, getFloat32, getFloat64, getInt16, getInt32, getInt64, getInt8, getMap, getSimple, getString, getTag, getUint16, getUint32, getUint64, getUint8, hashCode, isNull, scan, toDiagnosticNotation, toString
-
Constructor Details
-
CBORArray
public CBORArray()Creates an empty CBOR[]
(array).
-
-
Method Details
-
size
public int size()Get size of the CBOR array.- Returns:
- The number of objects in the array
-
get
Get object at a specific position in the CBOR array.- Parameters:
index
- The position (0..size()-1)- Returns:
- CBOR object
- Throws:
IndexOutOfBoundsException
- If the index is out of range.
-
add
Add object to the CBOR array.Also see
update(int, CBORObject)
- Parameters:
object
- Object to be appended to the array.- Returns:
this
-
update
Update object at a specific position in the CBOR array.- Parameters:
index
- The position (0..size()-1
)object
- Object to set- Returns:
- Previous
object
- Throws:
IndexOutOfBoundsException
- If the index is out of range.
-
toArray
Create shallow copy of the CBOR array.- Returns:
- Array of CBOR objects
-