org.infinispan.schematic.internal

## Class CacheSchematicDb

- java.lang.Object
- - org.infinispan.schematic.internal.CacheSchematicDb

- All Implemented Interfaces:
    Lifecycle, SchematicDb

      public class CacheSchematicDb
      extends Object
      implements SchematicDb

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `CacheSchematicDb.ResultsCollector`
    `protected class` | `CacheSchematicDb.SchematicEntryProxyFuture`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CacheSchematicDb(Cache<String,SchematicEntry> store)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsKey(String key)` Determine whether the database contains an entry with the supplied key.
    `protected CacheSchematicDb.SchematicEntryProxyFuture` | `future(String key, NotifyingFuture<SchematicEntry> future, boolean isRemoved)`
    `SchematicEntry` | `get(String key)` Get the entry with the supplied key.
    `Cache<String,SchematicEntry>` | `getCache()` Get the cache that backs this schematic database.
    `String` | `getDescription()` Get the description of this database.
    `String` | `getName()` Get the name of this database.
    `SchemaLibrary` | `getSchemaLibrary()` Get the reference to the SchemaLibrary for this database.
    `boolean` | `isExplicitLockingEnabled()` Return whether explicit `locking` is used when editing `document content` or `metadata`.
    `boolean` | `lock(Collection<String> keys)` Lock all of the documents with the given keys.
    `protected SchematicEntry` | `proxy(String key, SchematicEntry entry)`
    `SchematicEntry` | `put(Document entryDocument)` Store the supplied document and metadata at the given key.
    `SchematicEntry` | `put(String key, Binary binaryContent, Document metadata)` Store the supplied binary value and metadata at the given key.
    `SchematicEntry` | `put(String key, Document document, Document metadata)` Store the supplied document and metadata at the given key.
    `SchematicEntry` | `putIfAbsent(Document entryDocument)` Store the supplied document and metadata at the given key.
    `SchematicEntry` | `putIfAbsent(String key, Binary binaryContent, Document metadata)` Store the supplied document and metadata at the given key.
    `SchematicEntry` | `putIfAbsent(String key, Document document, Document metadata)` Store the supplied document and metadata at the given key.
    `SchematicEntry` | `remove(String key)` Remove the existing document at the given key.
    `protected SchematicEntry` | `removedResult(String key, SchematicEntry entry)`
    `SchematicEntry` | `replace(String key, Binary binaryContent, Document metadata)` Replace the existing document and metadata at the given key with the document that is supplied.
    `SchematicEntry` | `replace(String key, Document document, Document metadata)` Replace the existing document and metadata at the given key with the document that is supplied.
    `protected CacheSchemaLibrary` | `schemaLibrary(boolean createIfMissing)`
    `void` | `start()`
    `void` | `stop()`
    `SchemaLibrary.Results` | `validate(String key)` Validate the JSON document store at the specified key.
    `Map<String,SchemaLibrary.Results>` | `validate(String firstKey, String... additionalKeys)` Execute a Map-Reduce task to validate all JSON documents stored within this database, using this database's `JSON Schema library`.
    `Map<String,SchemaLibrary.Results>` | `validateAll()` Validate all JSON documents stored within this database, using this database's `JSON Schema library`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CacheSchematicDb

          public CacheSchematicDb(Cache<String,SchematicEntry> store)

  - ### Method Detail

    - #### getName

          public String getName()

      Description copied from interface: `SchematicDb`
      Get the name of this database.
      Specified by:
        `getName` in interface `SchematicDb`
      Returns:
        the library name; never null

    - #### getDescription

          public String getDescription()

      Description copied from interface: `SchematicDb`
      Get the description of this database.
      Specified by:
        `getDescription` in interface `SchematicDb`
      Returns:
        the library description; never null

    - #### getCache

          public Cache<String,SchematicEntry> getCache()

      Description copied from interface: `SchematicDb`
      Get the cache that backs this schematic database.
      Specified by:
        `getCache` in interface `SchematicDb`
      Returns:
        the Infinispan cache; never null

    - #### start

          public void start()

      Specified by:
        `start` in interface `Lifecycle`

    - #### stop

          public void stop()

      Specified by:
        `stop` in interface `Lifecycle`

    - #### getSchemaLibrary

          public SchemaLibrary getSchemaLibrary()

      Description copied from interface: `SchematicDb`
      Get the reference to the SchemaLibrary for this database.
      Specified by:
        `getSchemaLibrary` in interface `SchematicDb`
      Returns:
        the schema library; never null

    - #### schemaLibrary

          protected CacheSchemaLibrary schemaLibrary(boolean createIfMissing)

    - #### validateAll

          public Map<String,SchemaLibrary.Results> validateAll()

      Description copied from interface: `SchematicDb`
      Validate all JSON documents stored within this database, using this database's `JSON Schema library`. This method works even when the database is distributed, and it blocks until the task is completed.
      Specified by:
        `validateAll` in interface `SchematicDb`
      Returns:
        the map of document keys to validation results for all of the JSON documents in the database that are affiliated with a schema and that had at least one validation error or warning

    - #### validate

          public Map<String,SchemaLibrary.Results> validate(String firstKey,
                                                   String... additionalKeys)

      Description copied from interface: `SchematicDb`
      Execute a Map-Reduce task to validate all JSON documents stored within this database, using this database's `JSON Schema library`. This method works even when the database is distributed, and it blocks until the task is completed.
      Specified by:
        `validate` in interface `SchematicDb`
      Parameters:
        `firstKey` - the first key of the document that is to be validated
        `additionalKeys` - the additional keys of the documents that are to be validated
      Returns:
        the map of document keys to validation results for all of the JSON documents in the database that are affiliated with a schema and that had at least one validation error or warning

    - #### validate

          public SchemaLibrary.Results validate(String key)

      Description copied from interface: `SchematicDb`
      Validate the JSON document store at the specified key.
      Specified by:
        `validate` in interface `SchematicDb`
      Parameters:
        `key` - the key or identifier for the document
      Returns:
        the validation results; or null if there is no JSON document for the given key

    - #### proxy

          protected SchematicEntry proxy(String key,
                             SchematicEntry entry)

    - #### removedResult

          protected SchematicEntry removedResult(String key,
                                     SchematicEntry entry)

    - #### future

          protected CacheSchematicDb.SchematicEntryProxyFuture future(String key,
                                                          NotifyingFuture<SchematicEntry> future,
                                                          boolean isRemoved)

    - #### get

          public SchematicEntry get(String key)

      Description copied from interface: `SchematicDb`
      Get the entry with the supplied key.
      Specified by:
        `get` in interface `SchematicDb`
      Parameters:
        `key` - the key or identifier for the document
      Returns:
        the entry, or null if there was no document with the supplied key

    - #### containsKey

          public boolean containsKey(String key)

      Description copied from interface: `SchematicDb`
      Determine whether the database contains an entry with the supplied key.
      Specified by:
        `containsKey` in interface `SchematicDb`
      Parameters:
        `key` - the key or identifier for the document
      Returns:
        true if the database contains an entry with this key, or false otherwise

    - #### put

          public SchematicEntry put(String key,
                           Document document,
                           Document metadata)

      Description copied from interface: `SchematicDb`
      Store the supplied document and metadata at the given key.
      Specified by:
        `put` in interface `SchematicDb`
      Parameters:
        `key` - the key or identifier for the document
        `document` - the document that is to be stored
        `metadata` - the metadata that is to be stored; may be null if there is no metadata
      Returns:
        the entry previously stored at this key, or null if there was no entry with the supplied key
      See Also:
        `SchematicDb.put(String, Binary, Document)`, `SchematicDb.putIfAbsent(String, Binary, Document)`, `SchematicDb.putIfAbsent(String, Document, Document)`

    - #### put

          public SchematicEntry put(String key,
                           Binary binaryContent,
                           Document metadata)

      Description copied from interface: `SchematicDb`
      Store the supplied binary value and metadata at the given key.
      Specified by:
        `put` in interface `SchematicDb`
      Parameters:
        `key` - the key or identifier for the document
        `binaryContent` - the binary content that is to be stored
        `metadata` - the metadata that is to be stored; may be null if there is no metadata
      Returns:
        the entry that was previously stored at this key, or null if there was no entry with the supplied key

    - #### put

          public SchematicEntry put(Document entryDocument)

      Description copied from interface: `SchematicDb`
      Store the supplied document and metadata at the given key.
      Specified by:
        `put` in interface `SchematicDb`
      Parameters:
        `entryDocument` - the document that contains the metadata document, content document, and key
      Returns:
        the entry previously stored at this key, or null if there was no entry with the supplied key
      See Also:
        `SchematicDb.put(String, Binary, Document)`, `SchematicDb.putIfAbsent(String, Binary, Document)`, `SchematicDb.putIfAbsent(String, Document, Document)`

    - #### putIfAbsent

          public SchematicEntry putIfAbsent(String key,
                                   Document document,
                                   Document metadata)

      Description copied from interface: `SchematicDb`
      Store the supplied document and metadata at the given key.
      Specified by:
        `putIfAbsent` in interface `SchematicDb`
      Parameters:
        `key` - the key or identifier for the document
        `document` - the document that is to be stored
        `metadata` - the metadata that is to be stored; may be null if there is no metadata
      Returns:
        the existing entry for the supplied key, or null if there was no entry and the put was successful

    - #### putIfAbsent

          public SchematicEntry putIfAbsent(String key,
                                   Binary binaryContent,
                                   Document metadata)

      Description copied from interface: `SchematicDb`
      Store the supplied document and metadata at the given key.
      Specified by:
        `putIfAbsent` in interface `SchematicDb`
      Parameters:
        `key` - the key or identifier for the document
        `binaryContent` - the binary content that is to be stored
        `metadata` - the metadata that is to be stored; may be null if there is no metadata
      Returns:
        the existing entry for the supplied key, or null if there was no entry and the put was successful

    - #### putIfAbsent

          public SchematicEntry putIfAbsent(Document entryDocument)

      Description copied from interface: `SchematicDb`
      Store the supplied document and metadata at the given key.
      Specified by:
        `putIfAbsent` in interface `SchematicDb`
      Parameters:
        `entryDocument` - the document that contains the metadata document, content document, and key
      Returns:
        the existing entry for the supplied key, or null if there was no entry and the put was successful
      See Also:
        `SchematicDb.put(String, Binary, Document)`, `SchematicDb.putIfAbsent(String, Binary, Document)`, `SchematicDb.putIfAbsent(String, Document, Document)`

    - #### replace

          public SchematicEntry replace(String key,
                               Document document,
                               Document metadata)

      Description copied from interface: `SchematicDb`
      Replace the existing document and metadata at the given key with the document that is supplied. This method does nothing if there is not an existing entry at the given key.
      Specified by:
        `replace` in interface `SchematicDb`
      Parameters:
        `key` - the key or identifier for the document
        `document` - the new document that is to replace the existing document (or binary content)
        `metadata` - the metadata that is to be stored with the replacement document; may be null if there is no metadata for the replacement
      Returns:
        the entry that was replaced, or null if nothing was replaced

    - #### replace

          public SchematicEntry replace(String key,
                               Binary binaryContent,
                               Document metadata)

      Description copied from interface: `SchematicDb`
      Replace the existing document and metadata at the given key with the document that is supplied. This method does nothing if there is not an existing document at the given key.
      Specified by:
        `replace` in interface `SchematicDb`
      Parameters:
        `key` - the key or identifier for the document
        `binaryContent` - the binary content that is to replace the existing binary content (or document)
        `metadata` - the metadata that is to be stored with the replacement content; may be null if there is no metadata for the replacement
      Returns:
        the entry that was replaced, or null if nothing was replaced

    - #### remove

          public SchematicEntry remove(String key)

      Description copied from interface: `SchematicDb`
      Remove the existing document at the given key.
      Specified by:
        `remove` in interface `SchematicDb`
      Parameters:
        `key` - the key or identifier for the document
      Returns:
        the entry that was removed, or null if there was no document with the supplied key

    - #### lock

          public boolean lock(Collection<String> keys)

      Description copied from interface: `SchematicDb`
      Lock all of the documents with the given keys. This must be called within the context of an existing transaction, and all locks will be held until the completion of the transaction.
      Specified by:
        `lock` in interface `SchematicDb`
      Parameters:
        `keys` - the set of keys identifying the documents that are to be locked
      Returns:
        true if the documents were locked (or if locking is not required), or false if not all of the documents could be locked

    - #### isExplicitLockingEnabled

          public boolean isExplicitLockingEnabled()

      Description copied from interface: `SchematicDb`
      Return whether explicit `locking` is used when editing `document content` or `metadata`. If this method returns true, then it may be useful to `preemptively lock` documents that will be modified during a transactions.
      Specified by:
        `isExplicitLockingEnabled` in interface `SchematicDb`
      Returns:
        true if explicit locking is enabled, or false otherwise

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.