org.infinispan.schematic.internal

## Class CacheSchemaLibrary

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

- All Implemented Interfaces:
    Lifecycle, DocumentLibrary, SchemaLibrary

      public class CacheSchemaLibrary
      extends Object
      implements SchemaLibrary, Lifecycle

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `CacheSchemaLibrary.SchemaListener`
    `protected class` | `CacheSchemaLibrary.WrappedFuture`

    - ### Nested classes/interfaces inherited from interface org.infinispan.schematic.SchemaLibrary

      `SchemaLibrary.MismatchedTypeProblem, SchemaLibrary.Problem, SchemaLibrary.ProblemType, SchemaLibrary.Results`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CacheSchemaLibrary(Cache<String,SchematicEntry> schemaStore)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Document` | `convertValues(Document document, SchemaLibrary.Results results)` Look for fields within the document (including nested documents) whose values are not of the expected type for the given schema, but whose values can be converted into the expected type.
    `Document` | `convertValues(Document document, String schemaUri)` Look for fields within the document (including nested documents) whose values are not of the expected type for the given schema, but whose values can be converted into the expected type.
    `protected Document` | `document(SchematicEntry entry)`
    `protected NotifyingFuture<Document>` | `future(NotifyingFuture<SchematicEntry> original)`
    `Document` | `get(String key)` Get the document with the supplied key.
    `String` | `getName()` Get the name of this library.
    `Document` | `put(String key, Document document)` Store the supplied document at the given key.
    `Document` | `putIfAbsent(String key, Document document)` Store the supplied document at the given key.
    `Document` | `remove(String key)` Remove the existing document at the given key.
    `Document` | `replace(String key, Document document)` Replace the existing document at the given key with the document that is supplied.
    `void` | `start()`
    `void` | `stop()`
    `protected Cache<String,SchematicEntry>` | `store()`
    `SchemaLibrary.Results` | `validate(Document document, String schemaUri)` Validate the supplied document against the JSON Schema with the supplied URI.

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

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

- - ### Constructor Detail

    - #### CacheSchemaLibrary

          public CacheSchemaLibrary(Cache<String,SchematicEntry> schemaStore)

  - ### Method Detail

    - #### start

          public void start()

      Specified by:
        `start` in interface `Lifecycle`

    - #### stop

          public void stop()

      Specified by:
        `stop` in interface `Lifecycle`

    - #### store

          protected Cache<String,SchematicEntry> store()

    - #### getName

          public String getName()

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

    - #### get

          public Document get(String key)

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

    - #### put

          public Document put(String key,
                     Document document)

      Description copied from interface: `DocumentLibrary`
      Store the supplied document at the given key.
      Specified by:
        `put` in interface `DocumentLibrary`
      Parameters:
        `key` - the key or identifier for the document
        `document` - the document that is to be stored
      Returns:
        the document that was previously stored at this key, or null if there was no document with the supplied key

    - #### putIfAbsent

          public Document putIfAbsent(String key,
                             Document document)

      Description copied from interface: `DocumentLibrary`
      Store the supplied document at the given key.
      Specified by:
        `putIfAbsent` in interface `DocumentLibrary`
      Parameters:
        `key` - the key or identifier for the document
        `document` - the document that is to be stored
      Returns:
        the document that was previously stored at this key, or null if there was no document with the supplied key

    - #### replace

          public Document replace(String key,
                         Document document)

      Description copied from interface: `DocumentLibrary`
      Replace the existing document at the given key with the document that is supplied. This method does nothing if there is no document at the given key.
      Specified by:
        `replace` in interface `DocumentLibrary`
      Parameters:
        `key` - the key or identifier for the document
        `document` - the document that is to replace the existing document
      Returns:
        the document that was replaced, or null if nothing was replaced

    - #### remove

          public Document remove(String key)

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

    - #### validate

          public SchemaLibrary.Results validate(Document document,
                                       String schemaUri)

      Description copied from interface: `SchemaLibrary`
      Validate the supplied document against the JSON Schema with the supplied URI.
      Specified by:
        `validate` in interface `SchemaLibrary`
      Parameters:
        `document` - the document to be validated; may not be null
        `schemaUri` - the URI of the JSON Schema that should be used to validate the document; may not be null
      Returns:
        the results of the validation; never null

    - #### convertValues

          public Document convertValues(Document document,
                               SchemaLibrary.Results results)

      Description copied from interface: `SchemaLibrary`
      Look for fields within the document (including nested documents) whose values are not of the expected type for the given schema, but whose values can be converted into the expected type.

      This is often useful when the results from `SchemaLibrary.validate(Document, String)` contain only `mismatched type errors`. In such a case, the document can be converted and the resulting document will likely satisfy the schema.

      Specified by:
        `convertValues` in interface `SchemaLibrary`
      Parameters:
        `document` - the document to be validated; may not be null
        `results` - the results from the `SchemaLibrary.validate(Document, String)` call; may not be null
      Returns:
        the converted document, or the same input `document` if the

    - #### convertValues

          public Document convertValues(Document document,
                               String schemaUri)

      Description copied from interface: `SchemaLibrary`
      Look for fields within the document (including nested documents) whose values are not of the expected type for the given schema, but whose values can be converted into the expected type.

      This method is similar to `SchemaLibrary.convertValues(Document, Results)`, except that this method automatically runs a JSON Schema validation to obtain the results. If you've already `validated` the document, then instead of calling this method (which would validate a second time) try calling `SchemaLibrary.convertValues(Document, Results)`.

      Specified by:
        `convertValues` in interface `SchemaLibrary`
      Parameters:
        `document` - the document to be validated; may not be null
        `schemaUri` - the URI of the JSON Schema that should be used to validate the document; may not be null
      Returns:
        the converted document, or the same input `document` if the

    - #### document

          protected Document document(SchematicEntry entry)

    - #### future

          protected NotifyingFuture<Document> future(NotifyingFuture<SchematicEntry> original)

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