org.infinispan.schematic

## Interface SchematicEntry

- All Superinterfaces:
    Cloneable
  All Known Implementing Classes:
    FederatedSchematicEntry, ImmutableSchematicValue, SchematicEntryLiteral, SchematicEntryProxy

      public interface SchematicEntry
      extends Cloneable

  A value used to store user's content (often a JSON document or a binary value) and metadata as an entry in a SchematicDb. These values also offer fine-grained locking and serialization of the value.
  Since:
    5.1
  See Also:
    `SchematicEntryLookup`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `SchematicEntry.FieldName`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Document` | `asDocument()` Get the representation of this entry as a document, which will include the `metadata` and `content` as nested documents.
    `EditableDocument` | `editDocumentContent()` Get an `editable document`, when the content is a `document`.
    `EditableDocument` | `editMetadata()` Get an `editable metadata document`.
    `Object` | `getContent()` Return this value's content.
    `Binary` | `getContentAsBinary()` Get this value's content, if it is a Binary object.
    `Document` | `getContentAsDocument()` Get this value's content, if it is a Document object.
    `String` | `getContentType()` Get the media type describing the content.
    `Document` | `getMetadata()` Get the metadata associated with this value.
    `boolean` | `hasBinaryContent()` Return `true` if the `getContent()` method would return a Binary (or `getContentAsBinary()` would return a non-null value).
    `boolean` | `hasDocumentContent()` Return `true` if the `getContent()` method would return a Document (or `getContentAsDocument()` would return a non-null value).
    `void` | `setContent(Binary content, Document metadata, String defaultContentType)` Set the content for this value to be the supplied `Binary` data described by the supplied content type.
    `void` | `setContent(Document content, Document metadata, String defaultContentType)` Set the content for this value to be the supplied Document and set the content type to be " `application/json`".

- - ### Method Detail

    - #### getMetadata

          Document getMetadata()

      Get the metadata associated with this value.
      Returns:
        the metadata document; never null

    - #### getContentType

          String getContentType()

      Get the media type describing the content.
      Returns:
        the media type; never null

    - #### getContent

          Object getContent()

      Return this value's content. The result will either be a `Document` or `Binary`. Note that this method will return a non-null value only if the `hasDocumentContent()` method returns `true`.
      Returns:
        the content, represented as a `Document` object, or null if there is no content

    - #### getContentAsDocument

          Document getContentAsDocument()

      Get this value's content, if it is a Document object. This method will always return a non-null Document if `hasDocumentContent()` returns `true`, and is therefore equivalent to the following:

           return hasDocumentContent() ? (Document)getContent() : null;

      Returns:
        the `Document` content, or null if there is no content or the content is a `Binary` value

    - #### getContentAsBinary

          Binary getContentAsBinary()

      Get this value's content, if it is a Binary object. This method will always return a non-null Binary if `hasDocumentContent()` returns `false`, and is therefore equivalent to the following:

           return hasDocumentContent() ? (Binary)getContent() : null;

      Returns:
        the `Binary` content, or null if there is no content or if the content is a `Document`

    - #### hasDocumentContent

          boolean hasDocumentContent()

      Return `true` if the `getContent()` method would return a Document (or `getContentAsDocument()` would return a non-null value).

      This is equivalent to the following:

           return getContent() instanceof Document;

      Returns:
        `true` if the content is a Document, or `false` otherwise

    - #### hasBinaryContent

          boolean hasBinaryContent()

      Return `true` if the `getContent()` method would return a Binary (or `getContentAsBinary()` would return a non-null value).

      This is equivalent to the following:

           return getContent() instanceof Binary;

      Returns:
        `true` if the content is a Binary value, or `false` otherwise

    - #### setContent

          void setContent(Document content,
                        Document metadata,
                        String defaultContentType)

      Set the content for this value to be the supplied Document and set the content type to be " `application/json`".
      Parameters:
        `content` - the Document representing the JSON content; may not be null
        `metadata` - the Document representing the metadata; may be null
        `defaultContentType` - the value for the MIME type describing the content that should be used if the metadata does not already contain a "contentType" field, and typically `Schematic.ContentTypes.JSON`, `Schematic.ContentTypes.JSON_SCHEMA` , or `Schematic.ContentTypes.BSON`; may not be null

    - #### setContent

          void setContent(Binary content,
                        Document metadata,
                        String defaultContentType)

      Set the content for this value to be the supplied `Binary` data described by the supplied content type.
      Parameters:
        `content` - the Binary representation of the content; may not be null
        `metadata` - the Document representing the metadata; may be null
        `defaultContentType` - the value for the MIME type describing the content that should be used if the metadata does not already contain a "contentType" field, and typically `Schematic.ContentTypes.JSON`, `Schematic.ContentTypes.JSON_SCHEMA` , or `Schematic.ContentTypes.BSON`; may not be null

    - #### editMetadata

          EditableDocument editMetadata()

      Get an `editable metadata document`. The client is expected to make these edits within the context of a transaction, and the edits will be saved when the transaction is committed.
      Returns:
        the editable representation of the document
      See Also:
        `editDocumentContent()`

    - #### editDocumentContent

          EditableDocument editDocumentContent()

      Get an `editable document`, when the content is a `document`. The client is expected to make these edits within the context of a transaction, and the edits will be saved when the transaction is committed.
      Returns:
        the editable representation of the content document
      See Also:
        `editMetadata()`

    - #### asDocument

          Document asDocument()

      Get the representation of this entry as a document, which will include the `metadata` and `content` as nested documents.
      Returns:
        the entry's representation as a document

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