Package net.carcdr.ycrdt
Interface YArray
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this array and releases resources.getDoc(int index) Gets a subdocument at the specified index.getDoc(YTransaction txn, int index) Gets a subdocument at the specified index within a transaction.doublegetDouble(int index) Gets a double value at the specified index.doublegetDouble(YTransaction txn, int index) Gets a double value at the specified index within a transaction.getString(int index) Gets a string value at the specified index.getString(YTransaction txn, int index) Gets a string value at the specified index within a transaction.voidInserts a subdocument at the specified index.voidinsertDoc(YTransaction txn, int index, YDoc subdoc) Inserts a subdocument at the specified index within a transaction.voidinsertDouble(int index, double value) Inserts a double at the specified index.voidinsertDouble(YTransaction txn, int index, double value) Inserts a double at the specified index within a transaction.voidinsertString(int index, String value) Inserts a string at the specified index.voidinsertString(YTransaction txn, int index, String value) Inserts a string at the specified index within a transaction.booleanisClosed()Checks if this array has been closed.intlength()Returns the length of the array.intlength(YTransaction txn) Returns the length of the array within a transaction.Registers an observer for changes to this array.voidAppends a subdocument to the end.voidpushDoc(YTransaction txn, YDoc subdoc) Appends a subdocument to the end within a transaction.voidpushDouble(double value) Appends a double to the end.voidpushDouble(YTransaction txn, double value) Appends a double to the end within a transaction.voidpushString(String value) Appends a string to the end.voidpushString(YTransaction txn, String value) Appends a string to the end within a transaction.voidremove(int index, int length) Removes elements at the specified range.voidremove(YTransaction txn, int index, int length) Removes elements at the specified range within a transaction.toJson()Returns a JSON representation of this array.toJson(YTransaction txn) Returns a JSON representation of this array within a transaction.
-
Method Details
-
length
int length()Returns the length of the array.- Returns:
- the number of elements
-
length
Returns the length of the array within a transaction.- Parameters:
txn- the transaction- Returns:
- the number of elements
-
getString
Gets a string value at the specified index.- Parameters:
index- the index- Returns:
- the string value
-
getString
Gets a string value at the specified index within a transaction.- Parameters:
txn- the transactionindex- the index- Returns:
- the string value
-
insertString
Inserts a string at the specified index.- Parameters:
index- the indexvalue- the value to insert
-
insertString
Inserts a string at the specified index within a transaction.- Parameters:
txn- the transactionindex- the indexvalue- the value to insert
-
pushString
-
pushString
Appends a string to the end within a transaction.- Parameters:
txn- the transactionvalue- the value to append
-
getDouble
double getDouble(int index) Gets a double value at the specified index.- Parameters:
index- the index- Returns:
- the double value
-
getDouble
Gets a double value at the specified index within a transaction.- Parameters:
txn- the transactionindex- the index- Returns:
- the double value
-
insertDouble
void insertDouble(int index, double value) Inserts a double at the specified index.- Parameters:
index- the indexvalue- the value to insert
-
insertDouble
Inserts a double at the specified index within a transaction.- Parameters:
txn- the transactionindex- the indexvalue- the value to insert
-
pushDouble
void pushDouble(double value) Appends a double to the end.- Parameters:
value- the value to append
-
pushDouble
Appends a double to the end within a transaction.- Parameters:
txn- the transactionvalue- the value to append
-
getDoc
Gets a subdocument at the specified index.- Parameters:
index- the index- Returns:
- the subdocument
-
getDoc
Gets a subdocument at the specified index within a transaction.- Parameters:
txn- the transactionindex- the index- Returns:
- the subdocument
-
insertDoc
Inserts a subdocument at the specified index.- Parameters:
index- the indexsubdoc- the subdocument to insert
-
insertDoc
Inserts a subdocument at the specified index within a transaction.- Parameters:
txn- the transactionindex- the indexsubdoc- the subdocument to insert
-
pushDoc
Appends a subdocument to the end.- Parameters:
subdoc- the subdocument to append
-
pushDoc
Appends a subdocument to the end within a transaction.- Parameters:
txn- the transactionsubdoc- the subdocument to append
-
remove
void remove(int index, int length) Removes elements at the specified range.- Parameters:
index- the start indexlength- the number of elements to remove
-
remove
Removes elements at the specified range within a transaction.- Parameters:
txn- the transactionindex- the start indexlength- the number of elements to remove
-
toJson
-
toJson
Returns a JSON representation of this array within a transaction.- Parameters:
txn- the transaction- Returns:
- the JSON string
-
observe
Registers an observer for changes to this array.- Parameters:
observer- the observer to register- Returns:
- a subscription handle for unregistering
-
close
void close()Closes this array and releases resources.- Specified by:
closein interfaceAutoCloseable
-
isClosed
boolean isClosed()Checks if this array has been closed.- Returns:
- true if closed, false otherwise
-