public class JsonWriter
extends java.lang.Object
| Constructor and Description |
|---|
JsonWriter(JsonDBConfig dbConfig,
CollectionMetaData cmd,
java.lang.String collectionName,
java.io.File collectionFile) |
| Modifier and Type | Method and Description |
|---|---|
<T> boolean |
appendToJsonFile(java.util.Collection<T> collection,
java.util.Collection<? extends T> batchToSave)
A utility method that appends the provided collection of objects to the end of collection
file in a atomic way
|
<T> boolean |
appendToJsonFile(java.util.Collection<T> collection,
java.lang.Object objectToSave)
A utility method that appends the provided object to the end of collection
file in a atomic way
|
<T> boolean |
removeFromJsonFile(java.util.Map<java.lang.Object,T> collection,
java.lang.Object id)
A utility method that substracts the provided Ids and writes rest of the collection to
file in a atomic way
|
<T> boolean |
removeFromJsonFile(java.util.Map<java.lang.Object,T> collection,
java.util.Set<java.lang.Object> removeIds)
A utility method that subtracts the provided Ids and writes rest of the collection to
file in a atomic way
|
<T> boolean |
renameKeyInJsonFile(java.util.Collection<T> collection,
boolean ignoreReadonly,
java.lang.String oldKey,
java.lang.String newKey)
A utility method renames a particular key for the entire contents of .json in a atomic way
|
<T> boolean |
reWriteJsonFile(java.util.Collection<T> collection,
boolean ignoreReadonly)
A utility method that completely replaces the contents of .json with the provided collection
in a atomic way
|
<T> boolean |
updateInJsonFile(java.util.Map<java.lang.Object,T> collection,
java.util.Map<java.lang.Object,T> modifiedObjects)
A utility method that updates the provided collection of objects into the existing collection
file in a atomic way
|
<T> boolean |
updateInJsonFile(java.util.Map<java.lang.Object,T> collection,
java.lang.Object id,
T objectToSave)
A utility method that updates the provided collection of objects into the existing collection
file in a atomic way
|
public JsonWriter(JsonDBConfig dbConfig, CollectionMetaData cmd, java.lang.String collectionName, java.io.File collectionFile) throws java.io.IOException
java.io.IOExceptionpublic <T> boolean appendToJsonFile(java.util.Collection<T> collection,
java.lang.Object objectToSave)
T - Type annotated with Document annotation
and member of the baseScanPackagecollection - existing collectionobjectToSave - new Object that is being inserted or updated.public <T> boolean appendToJsonFile(java.util.Collection<T> collection,
java.util.Collection<? extends T> batchToSave)
T - Type annotated with Document annotation
and member of the baseScanPackagecollection - existing collectionbatchToSave - collection of objects to append.public <T> boolean removeFromJsonFile(java.util.Map<java.lang.Object,T> collection,
java.lang.Object id)
T - Type annotated with Document annotation
and member of the baseScanPackagecollection - existing collectionid - id of objects to be removed.public <T> boolean removeFromJsonFile(java.util.Map<java.lang.Object,T> collection,
java.util.Set<java.lang.Object> removeIds)
T - Type annotated with Document annotation
and member of the baseScanPackagecollection - existing collectionremoveIds - ids of objects to be removed.public <T> boolean updateInJsonFile(java.util.Map<java.lang.Object,T> collection,
java.lang.Object id,
T objectToSave)
T - Type annotated with Document annotation
and member of the baseScanPackagecollection - existing collectionid - the id of object to saveobjectToSave - the actual object to save.public <T> boolean updateInJsonFile(java.util.Map<java.lang.Object,T> collection,
java.util.Map<java.lang.Object,T> modifiedObjects)
T - Type annotated with Document annotation
and member of the baseScanPackagecollection - existing collectionmodifiedObjects - objects to update.public <T> boolean reWriteJsonFile(java.util.Collection<T> collection,
boolean ignoreReadonly)
T - Type annotated with Document annotation
and member of the baseScanPackagecollection - existing collectionignoreReadonly - force rewrite even if the collection is marked readonly this is necessary for schemaupdate.public <T> boolean renameKeyInJsonFile(java.util.Collection<T> collection,
boolean ignoreReadonly,
java.lang.String oldKey,
java.lang.String newKey)
T - Type annotated with Document annotation
and member of the baseScanPackagecollection - existing collectionignoreReadonly - force rewrite even if the collection is marked readonly this is necessary for schemaupdate.oldKey - String representing the old key/fieldnewKey - String representing the new key/field