public class JSONStoreCollection
extends java.lang.Object
Constructor and Description |
---|
JSONStoreCollection(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
void |
addData(org.json.JSONArray dataArray) |
void |
addData(org.json.JSONArray dataArray,
JSONStoreAddOptions opts) |
void |
addData(org.json.JSONObject object_to_add)
Add data and create a new document in the collection.
|
void |
addData(org.json.JSONObject object_to_add,
JSONStoreAddOptions opts) |
void |
addData(java.util.List object_to_add) |
void |
addData(java.util.List data,
JSONStoreAddOptions options)
Add data and create a new document in the collection.
|
int |
changeData(org.json.JSONObject[] data)
Change a list of documents in the collection.
|
int |
changeData(org.json.JSONObject[] data,
JSONStoreChangeOptions options)
Change a list of documents in the collection.
|
int |
changeData(java.util.List data)
Change a list of documents in the collection.
|
int |
changeData(java.util.List data,
JSONStoreChangeOptions options)
Change a list of documents in the collection.
|
void |
clearCollection()
Removes all documents from a collection, but does not destroy the collection.
|
int |
countAllDirtyDocuments()
Count the number of dirty documents in the collection.
|
int |
countAllDocuments()
Count the number of documents in the collection.
|
int |
countDocuments(JSONStoreQueryParts query)
Count the number of documents in the collection that are based on the given query.
|
int |
countDocuments(JSONStoreQueryParts query,
JSONStoreCountOptions options)
Count the number of documents in the collection that are based on the given query.
|
java.util.List |
findAllDirtyDocuments()
Find all the dirty documents in the collection.
|
java.util.List |
findAllDocuments()
Find all documents in the collection.
|
java.util.List |
findAllDocuments(JSONStoreFindOptions options)
Find all documents in the collection.
|
org.json.JSONObject |
findDocumentById(int id)
Find a document in the collection based on the given ID.
|
java.util.List |
findDocuments(JSONStoreQueryParts query)
Find documents in the collection that are based on the given query.
|
java.util.List |
findDocuments(JSONStoreQueryParts query,
JSONStoreFindOptions options)
Find documents in the collection that are based on the given query.
|
java.util.List |
findDocumentsById(int[] ids)
Find documents in the collection that have the given ID.
|
java.util.List |
findDocumentsById(java.util.List ids)
Find all documents in the collection that have the given ids.
|
java.util.Map |
getAdditionalSearchFields()
Get a map of the additional search fields for this collection.
|
protected java.util.Map |
getAllSearchFields()
Get a map of all search fields for this collection.
|
java.lang.String |
getName()
Get the name of this collection.
|
java.util.Map |
getSearchFields()
Return a map of search fields from the collection.
|
boolean |
hasAdditionalSearchField(java.lang.String additional_search_field)
Determines if the collection contains the given additional search field.
|
boolean |
hasSearchField(java.lang.String search_field)
Determine if a collection contains the given search field.
|
boolean |
isDocumentDirty(int id)
Determine if a document is dirty or not.
|
int |
markDocumentClean(org.json.JSONObject document)
Mark a document in the collection clean.
|
int |
markDocumentsClean(org.json.JSONObject[] documents)
Mark an array of documents in the collection clean.
|
int |
markDocumentsClean(java.util.List documents)
Mark a list of documents in the collection clean.
|
void |
removeCollection()
Permanently deletes all the documents that are stored in a collection and destroys
the collection.
|
int |
removeDocumentById(java.lang.Integer id)
Remove a document from a collection that is based on the given id.
|
int |
removeDocumentById(java.lang.Integer id,
JSONStoreRemoveOptions options)
Remove a document from the collection that is based on the given id.
|
int |
removeDocumentsById(java.util.List document_ids)
Remove list of documents from the collection that are based on the given ids.
|
int |
removeDocumentsById(java.util.List document_ids,
JSONStoreRemoveOptions options)
Remove list of documents from the collection that are based on the given ids.
|
int |
replaceDocument(org.json.JSONObject document)
Replace a document in the collection.
|
int |
replaceDocument(org.json.JSONObject document,
JSONStoreReplaceOptions options)
Replace a document in the collection.
|
int |
replaceDocuments(java.util.List documents)
Replace a list of documents in the collection.
|
int |
replaceDocuments(java.util.List documents,
JSONStoreReplaceOptions options)
Replace a list of documents in the collection.
|
void |
setAdditionalSearchField(java.lang.String key,
SearchFieldType type)
Set an additional search field for the collection.
|
void |
setSearchField(java.lang.String key,
SearchFieldType type)
Set a search field for the collection.
|
boolean |
wasReopened()
Determine if the collection was reopened when it was initialized.
|
public JSONStoreCollection(java.lang.String name) throws JSONStoreInvalidSchemaException
JSONStoreInvalidSchemaException
public java.lang.String getName()
public boolean wasReopened()
public java.util.Map getSearchFields()
public void setSearchField(java.lang.String key, SearchFieldType type)
key
- The name of the search field to add. Only useful before the collection
is opened.type
- The type of the search field.SearchFieldType
public boolean hasSearchField(java.lang.String search_field)
search_field
- The name of the search field to look up.public void setAdditionalSearchField(java.lang.String key, SearchFieldType type)
key
- The name of the additional search field to add. Only useful before
the collection is opened.type
- The type of the search field.SearchFieldType
public java.util.Map getAdditionalSearchFields()
public boolean hasAdditionalSearchField(java.lang.String additional_search_field)
additional_search_field
- The name of the additional search field to check for existence.protected java.util.Map getAllSearchFields()
public void removeCollection() throws JSONStoreRemoveCollectionException, JSONStoreDatabaseClosedException, JSONStoreTransactionFailureException
JSONStoreRemoveCollectionException
- An error occurred when finding the collection to remove (may have
already been removed).JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to remove
the collection.JSONStoreTransactionFailureException
- A transaction is in process and cannot be accessed to remove the
collection.public void clearCollection() throws JSONStoreDatabaseClosedException
JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to clear
the collection.public int changeData(org.json.JSONObject[] data) throws JSONStoreChangeException, JSONStoreDatabaseClosedException, org.json.JSONException
data
- An array of data to update documents in the collection.JSONStoreChangeException
- An exception occurred when performing the change operation, and the
operation failed.JSONStoreDatabaseClosedException
- The JSONStore database is closed and cannot be accessed to execute
the change operation.org.json.JSONException
public int changeData(org.json.JSONObject[] data, JSONStoreChangeOptions options) throws JSONStoreChangeException, JSONStoreDatabaseClosedException, org.json.JSONException
data
- A JSONObject array of data to update documents in the collection or add
(if addNew option is enabled).options
- Optional change options that are used to manipulate the change operation.JSONStoreChangeException
- An exception occurred when performing the change operation, and the
operation failed.JSONStoreDatabaseClosedException
- The JSONStore database is closed and cannot be accessed to execute
the change operation.org.json.JSONException
public int changeData(java.util.List data) throws JSONStoreChangeException, JSONStoreDatabaseClosedException, org.json.JSONException
data
- A list of data to update documents in the collection.JSONStoreChangeException
- An exception occurred when performing the change operation, and the
operation failed.JSONStoreDatabaseClosedException
- The JSONStore database is closed and cannot be accessed to execute
the change operation.org.json.JSONException
public int changeData(java.util.List data, JSONStoreChangeOptions options) throws JSONStoreChangeException, JSONStoreDatabaseClosedException
data
- A list of data to update documents in the collection or add (if addNew
option is enabled).options
- Optional change options that are used to manipulate the change operation.JSONStoreChangeException
- An exception occurred when performing the change operation, and the
operation failed.JSONStoreDatabaseClosedException
- The JSONStore database is closed and cannot be accessed to execute
the change operation.public org.json.JSONObject findDocumentById(int id) throws JSONStoreDatabaseClosedException, JSONStoreFindException
id
- The unique id that is associated with a document in the database (the _id
search field).JSONStoreFindException
- There was an error executing the find operation.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
execute the find.public java.util.List findDocumentsById(int[] ids) throws JSONStoreDatabaseClosedException, JSONStoreFindException
ids
- An array of unique ids that are associated with a document in the database (the _id
search field).JSONStoreFindException
- There was an error executing the find operation.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
execute the find.public java.util.List findDocumentsById(java.util.List ids) throws JSONStoreDatabaseClosedException, JSONStoreFindException
ids
- A list of unique ids that are associated with a document in the database (the _id
search field).JSONStoreFindException
- There was an error executing the find operation.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
execute the find.public java.util.List findAllDirtyDocuments() throws JSONStoreFindException, JSONStoreDatabaseClosedException
JSONStoreFindException
- An error occurred when trying to execute the find.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
execute the find.public java.util.List findAllDocuments() throws JSONStoreFindException, JSONStoreDatabaseClosedException
JSONStoreFindException
- An error occurred when trying to execute the find.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
execute the find.public java.util.List findAllDocuments(JSONStoreFindOptions options) throws JSONStoreFindException, JSONStoreDatabaseClosedException
options
- Additional options to modify the count operation.JSONStoreFindException
- An error occurred when trying to execute the find.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
execute the find.public java.util.List findDocuments(JSONStoreQueryParts query) throws JSONStoreFindException, JSONStoreFilterException, JSONStoreDatabaseClosedException
query
- The find query that restricts the search.JSONStoreFindException
- An error occurred when trying to execute the find.JSONStoreFilterException
- An error occurred when trying to apply a filter to the query.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
execute the find.public java.util.List findDocuments(JSONStoreQueryParts query, JSONStoreFindOptions options) throws JSONStoreFindException, JSONStoreFilterException, JSONStoreDatabaseClosedException
query
- The find query that restricts the search.options
- Additional options to modify the count operation.JSONStoreFindException
- An error occurred when trying to execute the find.JSONStoreFilterException
- An error occurred when trying to apply a filter to the query.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
execute the find.public boolean isDocumentDirty(int id) throws JSONStoreDirtyCheckException, JSONStoreDatabaseClosedException
id
- The unique identifier of the document to check.JSONStoreDirtyCheckException
- An error occurred when checking to see if the document is dirty.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to check
if the document is dirty.public int markDocumentsClean(org.json.JSONObject[] documents) throws JSONStoreMarkCleanException, JSONStoreDatabaseClosedException
documents
- An array of documents to clean in the collection.JSONStoreMarkCleanException
- An error occurred when trying to clean the documents that were passed.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to mark
the documents clean.public int markDocumentsClean(java.util.List documents) throws JSONStoreMarkCleanException, JSONStoreDatabaseClosedException
documents
- A list of documents to clean in the collection.JSONStoreMarkCleanException
- An error occurred when trying to clean the documents that were passed.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to mark
the documents clean.public int markDocumentClean(org.json.JSONObject document) throws JSONStoreMarkCleanException, JSONStoreDatabaseClosedException
document
- A document to clean in the collection.JSONStoreMarkCleanException
- An error occurred when trying to clean the documents that were passed.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to mark
the documents clean.public int countAllDocuments() throws JSONStoreCountException, JSONStoreDatabaseClosedException
JSONStoreCountException
- A failure occurred when trying to determine the count.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
perform the count.public int countDocuments(JSONStoreQueryParts query) throws JSONStoreCountException, JSONStoreDatabaseClosedException
query
- The count query that limits the count scope.JSONStoreCountException
- A failure occurred when trying to determine the count.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
perform the count.public int countDocuments(JSONStoreQueryParts query, JSONStoreCountOptions options) throws JSONStoreCountException, JSONStoreDatabaseClosedException
query
- The find query that limits the count scope.options
- Additional options to modify the count operation.JSONStoreCountException
- A failure occurred when trying to determine the count.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
perform the count.public int countAllDirtyDocuments() throws JSONStoreDatabaseClosedException, JSONStoreCountException
JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
perform the count.JSONStoreCountException
- A failure occurred when trying to determine the count.public void addData(org.json.JSONObject object_to_add) throws JSONStoreAddException, JSONStoreDatabaseClosedException
object_to_add
- The data for a new document to be added to the collection. The document must contain search
field keys.JSONStoreAddException
- Thrown if the document could not be added to the collection.
Commonly thrown if search fields are missing in the document.
The message contains the reason.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
perform the add.public void addData(java.util.List data, JSONStoreAddOptions options) throws JSONStoreAddException, JSONStoreDatabaseClosedException
data
- The data for a new document to be added to the collection. The document must contain search
field keys.options
- Additional options to modify the add operation.JSONStoreAddException
- Thrown if the document could not be added to the collection.
Commonly thrown if search fields are missing in the document.
The message contains the reason.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
perform the add.public void addData(org.json.JSONObject object_to_add, JSONStoreAddOptions opts) throws JSONStoreAddException, JSONStoreDatabaseClosedException
JSONStoreAddException
JSONStoreDatabaseClosedException
public void addData(java.util.List object_to_add) throws JSONStoreAddException, JSONStoreDatabaseClosedException
JSONStoreAddException
JSONStoreDatabaseClosedException
public void addData(org.json.JSONArray dataArray) throws JSONStoreAddException, JSONStoreDatabaseClosedException
JSONStoreAddException
JSONStoreDatabaseClosedException
public void addData(org.json.JSONArray dataArray, JSONStoreAddOptions opts) throws JSONStoreAddException, JSONStoreDatabaseClosedException
JSONStoreAddException
JSONStoreDatabaseClosedException
public int removeDocumentById(java.lang.Integer id) throws JSONStoreRemoveException, JSONStoreDatabaseClosedException
id
- the integer idJSONStoreRemoveException
- Thrown if the document could not be removed to the collection.
Commonly thrown if search fields are missing in the document.
The message contains the reason.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
perform the remove.public int removeDocumentById(java.lang.Integer id, JSONStoreRemoveOptions options) throws JSONStoreRemoveException, JSONStoreDatabaseClosedException
id
- the integer idoptions
- Additional options to modify the remove operation.JSONStoreRemoveException
- Thrown if the document could not be removed to the collection.
Commonly thrown if search fields are missing in the document.
The message contains the reason.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
perform the remove.public int removeDocumentsById(java.util.List document_ids) throws JSONStoreRemoveException, JSONStoreDatabaseClosedException
document_ids
- A list of document ids.JSONStoreRemoveException
- Thrown if the document could not be removed to the collection.
Commonly thrown if search fields are missing in the document.
The message contains the reason.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
perform the remove.public int removeDocumentsById(java.util.List document_ids, JSONStoreRemoveOptions options) throws JSONStoreRemoveException, JSONStoreDatabaseClosedException
document_ids
- A list of document ids.options
- Additional options to modify the remove operation.JSONStoreRemoveException
- Thrown if the document could not be removed to the collection.
Commonly thrown if search fields are missing in the document.
The message contains the reason.JSONStoreDatabaseClosedException
- The JSONStore database is closed, and cannot be accessed to
perform the remove.public int replaceDocument(org.json.JSONObject document) throws JSONStoreReplaceException, JSONStoreDatabaseClosedException
document
- A JSONObject that represents the document to update in the collection.
The document's '_id' is used to determine which document to
replace.JSONStoreReplaceException
- The document could not be replaced. The message contains the reason.JSONStoreDatabaseClosedException
- The collection is currently closed.public int replaceDocument(org.json.JSONObject document, JSONStoreReplaceOptions options) throws JSONStoreReplaceException, JSONStoreDatabaseClosedException
document
- A JSONObject that represents the document to update in the collection.
The document's '_id' is used to determine which document to
replace.options
- Additional options to modify the replace operation.JSONStoreReplaceException
- The document could not be replaced. The message contains the reason.JSONStoreDatabaseClosedException
- The collection is currently closed.public int replaceDocuments(java.util.List documents) throws JSONStoreDatabaseClosedException, JSONStoreReplaceException
documents
- A List that contains JSONObjects that represent the documents to update
in the collection. The document's '_id' is used to determine which
document to replace. If all documents could not be updated, a
rollback is performed to a state where no documents were updated.JSONStoreReplaceException
- The document could not be replaced. The message contains the reason.JSONStoreDatabaseClosedException
- The collection is currently closed.public int replaceDocuments(java.util.List documents, JSONStoreReplaceOptions options) throws JSONStoreDatabaseClosedException, JSONStoreReplaceException
documents
- A List that contains JSONObjects that represent the documents to update
in the collection. The document's '_id' is used to determine which
document to replace. If all documents could not be updated, a
rollback is performed to a state where no documents were updated.options
- Additional options to modify the replace operation.JSONStoreReplaceException
- The document could not be replaced. The message contains the reason.JSONStoreDatabaseClosedException
- The collection is currently closed.
© Copyright IBM Corp. 2006, 2015. All Rights Reserved.