org.modeshape.jcr.federation

## Class FederatedDocumentWriter

- java.lang.Object
- - org.modeshape.jcr.federation.FederatedDocumentWriter

- All Implemented Interfaces:
    DocumentWriter, PageWriter

      public class FederatedDocumentWriter
      extends Object
      implements DocumentWriter

  Default implementation of the `DocumentWriter` interface.

- - ### Field Summary

    - ### Fields inherited from interface org.modeshape.jcr.federation.spi.PageWriter

      `UNKNOWN_TOTAL_SIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FederatedDocumentWriter(DocumentTranslator translator)`
    `FederatedDocumentWriter(DocumentTranslator translator, Document document)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `DocumentWriter` | `addChild(String id, Name name)` Add a child with the given id and name to the underlying document.
    `DocumentWriter` | `addChild(String id, String name)` Add a child with the given id and name to the underlying document.
    `DocumentWriter` | `addMixinType(Name name)` Adds a mixin type to the underlying document.
    `DocumentWriter` | `addMixinType(String name)` Adds a mixin type to the underlying document.
    `DocumentWriter` | `addPage(String parentId, int nextPageOffset, long blockSize, long totalChildCount)` Create a reference to a separate page of children in its underlying document.
    `DocumentWriter` | `addPage(String parentId, String nextPageOffset, long blockSize, long totalChildCount)` Create a reference to a separate page of children in its underlying document.
    `DocumentWriter` | `addProperties(Map<Name,Property> properties)` Adds a map of properties to the the underlying document's properties.
    `DocumentWriter` | `addProperty(Name name, Object value)` Adds a property with the given name and value to the underlying document's properties.
    `DocumentWriter` | `addProperty(Name name, Object[] values)` Adds a multi-value property with the given name to the underlying document's properties.
    `DocumentWriter` | `addProperty(Name name, Object firstValue, Object... additionalValues)` Adds a multi-value property with the given name to the underlying document's properties.
    `DocumentWriter` | `addProperty(String name, Object value)` Adds a property with the given name and value to the underlying document's properties.
    `DocumentWriter` | `addProperty(String name, Object[] values)` Adds a multi-value property with the given name to the underlying document's properties.
    `DocumentWriter` | `addProperty(String name, Object firstValue, Object... additionalValues)` Adds a multi-value property with the given name to the underlying document's properties.
    `DocumentWriter` | `addPropertyValue(Name name, Object value)` Adds an additional value to an existing property with the given name.
    `DocumentWriter` | `addPropertyValue(String name, Object value)` Adds an additional value to an existing property with the given name.
    `EditableDocument` | `document()` Returns the underlying document.
    `protected Name` | `nameFrom(String name)`
    `DocumentWriter` | `removeChild(String id)` Remove a child from this document.
    `DocumentWriter` | `setCacheTtlSeconds(int seconds)` Sets the value, in seconds, of the amount of the time the underlying document should be cached.
    `DocumentWriter` | `setChildren(LinkedHashMap<String,Name> children)` Set an ordered of (childId, childName) for the underlying document.
    `DocumentWriter` | `setChildren(List<? extends Document> children)` Set the list of children for the underlying document.
    `FederatedDocumentWriter` | `setId(String id)` Sets an identifier string on the underlying document.
    `DocumentWriter` | `setNotQueryable()` Sets a flag on the underlying document which indicates that it should not be indexed (and therefore will not appear in queries) by the repository.
    `DocumentWriter` | `setParent(String parentId)` Sets the id of the parent of the underlying document.
    `DocumentWriter` | `setParents(List<String> parentIds)` Sets the ids of one or more parents on the underlying document.
    `DocumentWriter` | `setParents(String... parentIds)` Sets the ids of one or more parents on the underlying document.
    `DocumentWriter` | `setPrimaryType(Name name)` Sets the primary type of the underlying document.
    `DocumentWriter` | `setPrimaryType(String name)` Sets the primary type of the underlying document.
    `DocumentWriter` | `setProperties(Map<Name,Property> properties)` Replaces the underlying document's properties with the one from the given map.
    `protected DocumentTranslator` | `translator()`
    `DocumentWriter` | `writeAdditionalDocument(String id)` Some connectors may want to pre-generate additional documents when `Connector.getDocumentById(String)` is called.

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

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

- - ### Constructor Detail

    - #### FederatedDocumentWriter

          public FederatedDocumentWriter(DocumentTranslator translator,
                                 Document document)

    - #### FederatedDocumentWriter

          public FederatedDocumentWriter(DocumentTranslator translator)

  - ### Method Detail

    - #### setId

          public FederatedDocumentWriter setId(String id)

      Description copied from interface: `DocumentWriter`
      Sets an identifier string on the underlying document.
      Specified by:
        `setId` in interface `DocumentWriter`
      Parameters:
        `id` - the identifier of the document; may not be null
      Returns:
        this writer; never null

    - #### nameFrom

          protected final Name nameFrom(String name)

    - #### setPrimaryType

          public DocumentWriter setPrimaryType(Name name)

      Description copied from interface: `DocumentWriter`
      Sets the primary type of the underlying document.
      Specified by:
        `setPrimaryType` in interface `DocumentWriter`
      Parameters:
        `name` - the name of the primary type for the node; may not be null
      Returns:
        this writer; never null

    - #### setPrimaryType

          public DocumentWriter setPrimaryType(String name)

      Description copied from interface: `DocumentWriter`
      Sets the primary type of the underlying document.
      Specified by:
        `setPrimaryType` in interface `DocumentWriter`
      Parameters:
        `name` - the name of the primary type for the node; may not be null
      Returns:
        this writer; never null

    - #### addMixinType

          public DocumentWriter addMixinType(Name name)

      Description copied from interface: `DocumentWriter`
      Adds a mixin type to the underlying document.
      Specified by:
        `addMixinType` in interface `DocumentWriter`
      Parameters:
        `name` - the name of a node type that should be added as a mixin for the node; may not be null
      Returns:
        this writer; never null

    - #### addMixinType

          public DocumentWriter addMixinType(String name)

      Description copied from interface: `DocumentWriter`
      Adds a mixin type to the underlying document.
      Specified by:
        `addMixinType` in interface `DocumentWriter`
      Parameters:
        `name` - the name of a node type that should be added as a mixin for the node; may not be null
      Returns:
        this writer; never null

    - #### addPropertyValue

          public DocumentWriter addPropertyValue(Name name,
                                        Object value)

      Description copied from interface: `DocumentWriter`
      Adds an additional value to an existing property with the given name. If such a property does not yet exist, this will create the property.
      Specified by:
        `addPropertyValue` in interface `DocumentWriter`
      Parameters:
        `name` - the name of the property; may not be null
        `value` - the new value that should be added to the property; may not be null
      Returns:
        this writer; never null

    - #### addPropertyValue

          public DocumentWriter addPropertyValue(String name,
                                        Object value)

      Description copied from interface: `DocumentWriter`
      Adds an additional value to an existing property with the given name. If such a property does not yet exist, this will create the property.
      Specified by:
        `addPropertyValue` in interface `DocumentWriter`
      Parameters:
        `name` - the name of the property; may not be null
        `value` - the new value that should be added to the property; may not be null
      Returns:
        this writer; never null

    - #### addProperty

          public DocumentWriter addProperty(String name,
                                   Object value)

      Description copied from interface: `DocumentWriter`
      Adds a property with the given name and value to the underlying document's properties.
      Specified by:
        `addProperty` in interface `DocumentWriter`
      Parameters:
        `name` - the name of the property; may not be null
        `value` - the value for the property; may not be null
      Returns:
        this writer; never null

    - #### addProperty

          public DocumentWriter addProperty(String name,
                                   Object[] values)

      Description copied from interface: `DocumentWriter`
      Adds a multi-value property with the given name to the underlying document's properties.
      Specified by:
        `addProperty` in interface `DocumentWriter`
      Parameters:
        `name` - a name of the property; may not be null
        `values` - the values for the property; may not be null but may be empty
      Returns:
        this writer; never null

    - #### addProperty

          public DocumentWriter addProperty(String name,
                                   Object firstValue,
                                   Object... additionalValues)

      Description copied from interface: `DocumentWriter`
      Adds a multi-value property with the given name to the underlying document's properties.
      Specified by:
        `addProperty` in interface `DocumentWriter`
      Parameters:
        `name` - the name of the property; may not be null
        `firstValue` - the first value for the property; may not be null
        `additionalValues` - additional values for the property
      Returns:
        this writer; never null

    - #### addProperty

          public DocumentWriter addProperty(Name name,
                                   Object value)

      Description copied from interface: `DocumentWriter`
      Adds a property with the given name and value to the underlying document's properties.
      Specified by:
        `addProperty` in interface `DocumentWriter`
      Parameters:
        `name` - the name of the property; may not be null
        `value` - a value for the property; may not be null
      Returns:
        this writer; never null

    - #### addProperty

          public DocumentWriter addProperty(Name name,
                                   Object[] values)

      Description copied from interface: `DocumentWriter`
      Adds a multi-value property with the given name to the underlying document's properties.
      Specified by:
        `addProperty` in interface `DocumentWriter`
      Parameters:
        `name` - the name of the property; may not be null
        `values` - the values for the property; may not be null but may be empty
      Returns:
        this writer; never null

    - #### addProperty

          public DocumentWriter addProperty(Name name,
                                   Object firstValue,
                                   Object... additionalValues)

      Description copied from interface: `DocumentWriter`
      Adds a multi-value property with the given name to the underlying document's properties.
      Specified by:
        `addProperty` in interface `DocumentWriter`
      Parameters:
        `name` - the name of the property; may not be null
        `firstValue` - the first value for the property; may not be null
        `additionalValues` - additional values for the property
      Returns:
        this writer; never null

    - #### addProperties

          public DocumentWriter addProperties(Map<Name,Property> properties)

      Description copied from interface: `DocumentWriter`
      Adds a map of properties to the the underlying document's properties.
      Specified by:
        `addProperties` in interface `DocumentWriter`
      Parameters:
        `properties` - a map of properties keyed by their name; may not be null
      Returns:
        this writer; never null

    - #### addChild

          public DocumentWriter addChild(String id,
                                Name name)

      Description copied from interface: `PageWriter`
      Add a child with the given id and name to the underlying document.
      Specified by:
        `addChild` in interface `DocumentWriter`
      Specified by:
        `addChild` in interface `PageWriter`
      Parameters:
        `id` - the new child's id; may not be null
        `name` - the new child's name; may not be null
      Returns:
        this writer; never null

    - #### addChild

          public DocumentWriter addChild(String id,
                                String name)

      Description copied from interface: `PageWriter`
      Add a child with the given id and name to the underlying document.
      Specified by:
        `addChild` in interface `DocumentWriter`
      Specified by:
        `addChild` in interface `PageWriter`
      Parameters:
        `id` - the new child's id; may not be null
        `name` - the new child's name; may not be null
      Returns:
        this writer; never null

    - #### removeChild

          public DocumentWriter removeChild(String id)

      Description copied from interface: `PageWriter`
      Remove a child from this document.
      Specified by:
        `removeChild` in interface `DocumentWriter`
      Specified by:
        `removeChild` in interface `PageWriter`
      Parameters:
        `id` - the identifier of the child
      Returns:
        this writer; never null

    - #### setProperties

          public DocumentWriter setProperties(Map<Name,Property> properties)

      Description copied from interface: `DocumentWriter`
      Replaces the underlying document's properties with the one from the given map.
      Specified by:
        `setProperties` in interface `DocumentWriter`
      Parameters:
        `properties` - a map of properties keyed by their name; may not be null
      Returns:
        this writer; never null

    - #### setChildren

          public DocumentWriter setChildren(List<? extends Document> children)

      Description copied from interface: `PageWriter`
      Set the list of children for the underlying document. If children previously existed, they will be replaced.
      Specified by:
        `setChildren` in interface `DocumentWriter`
      Specified by:
        `setChildren` in interface `PageWriter`
      Parameters:
        `children` - a list of `EditableDocument` instances each describing a single child; may not be null
      Returns:
        this writer; never null

    - #### setChildren

          public DocumentWriter setChildren(LinkedHashMap<String,Name> children)

      Description copied from interface: `PageWriter`
      Set an ordered of (childId, childName) for the underlying document. If children previously existed, they will be replaced.

      The passed map does not contain any explicit information about same name siblings, so a connector would need to handle that logic.

      Specified by:
        `setChildren` in interface `DocumentWriter`
      Specified by:
        `setChildren` in interface `PageWriter`
      Parameters:
        `children` - a map of (childId, childName) pairs; may not be null
      Returns:
        this writer; never null

    - #### setParents

          public DocumentWriter setParents(String... parentIds)

      Description copied from interface: `DocumentWriter`
      Sets the ids of one or more parents on the underlying document. If any parents previously existed, they will be replaced.
      Specified by:
        `setParents` in interface `DocumentWriter`
      Parameters:
        `parentIds` - the array of parent identifiers
      Returns:
        this writer; never null

    - #### setParent

          public DocumentWriter setParent(String parentId)

      Description copied from interface: `DocumentWriter`
      Sets the id of the parent of the underlying document. If any parents previously existed, they will be replaced.
      Specified by:
        `setParent` in interface `DocumentWriter`
      Parameters:
        `parentId` - the identifier of the parent; may not be null
      Returns:
        this writer; never null

    - #### setCacheTtlSeconds

          public DocumentWriter setCacheTtlSeconds(int seconds)

      Description copied from interface: `DocumentWriter`
      Sets the value, in seconds, of the amount of the time the underlying document should be cached.
      Specified by:
        `setCacheTtlSeconds` in interface `DocumentWriter`
      Parameters:
        `seconds` - the number of seconds the document should be cached by the repository.
      Returns:
        this writer; never null

    - #### setNotQueryable

          public DocumentWriter setNotQueryable()

      Description copied from interface: `DocumentWriter`
      Sets a flag on the underlying document which indicates that it should not be indexed (and therefore will not appear in queries) by the repository.
      Specified by:
        `setNotQueryable` in interface `DocumentWriter`
      Returns:
        this writer; never null

    - #### setParents

          public DocumentWriter setParents(List<String> parentIds)

      Description copied from interface: `DocumentWriter`
      Sets the ids of one or more parents on the underlying document. If any parents previously existed, they will be replaced.
      Specified by:
        `setParents` in interface `DocumentWriter`
      Parameters:
        `parentIds` - the list of parent identifiers; may not be null
      Returns:
        this writer; never null

    - #### document

          public EditableDocument document()

      Description copied from interface: `PageWriter`
      Returns the underlying document.
      Specified by:
        `document` in interface `PageWriter`
      Returns:
        an `EditableDocument` instance; never null

    - #### addPage

          public DocumentWriter addPage(String parentId,
                               int nextPageOffset,
                               long blockSize,
                               long totalChildCount)

      Description copied from interface: `PageWriter`
      Create a reference to a separate page of children in its underlying document. The underlying document can be either the document of an external node, or the document of another page.
      Specified by:
        `addPage` in interface `DocumentWriter`
      Specified by:
        `addPage` in interface `PageWriter`
      Parameters:
        `parentId` - a `non-null` String representing the identifier of the parent (owning) document
        `nextPageOffset` - a `non-null` int representing a numeric offset of the next page.
        `blockSize` - an integer which indicates the size of the next block of children
        `totalChildCount` - an integer which indicates the total number of children; should be `PageWriter.UNKNOWN_TOTAL_SIZE` if the number of children is unknown, too large to compute efficiently, or to signal that the repository should use the `Connector.getChildReference(String, String)` method to find the child reference for a parent and a (supposed) child node.
      Returns:
        the current writer instance
      See Also:
        `Connector.getChildReference(String, String)`

    - #### addPage

          public DocumentWriter addPage(String parentId,
                               String nextPageOffset,
                               long blockSize,
                               long totalChildCount)

      Description copied from interface: `PageWriter`
      Create a reference to a separate page of children in its underlying document. The underlying document can be either the document of an external node, or the document of another page.
      Specified by:
        `addPage` in interface `DocumentWriter`
      Specified by:
        `addPage` in interface `PageWriter`
      Parameters:
        `parentId` - a `non-null` String representing the identifier of the parent (owning) document
        `nextPageOffset` - a `non-null` String representing the offset of the next page. The meaning of the offset isn't defined and it's up to each connector to define it.
        `blockSize` - an integer which indicates the size of the next block of children
        `totalChildCount` - an integer which indicates the total number of children; should be `PageWriter.UNKNOWN_TOTAL_SIZE` if the number of children is unknown, too large to compute efficiently, or to signal that the repository should use the `Connector.getChildReference(String, String)` method to find the child reference for a parent and a (supposed) child node.
      Returns:
        the current writer instance
      See Also:
        `Connector.getChildReference(String, String)`

    - #### translator

          protected DocumentTranslator translator()

    - #### writeAdditionalDocument

          public DocumentWriter writeAdditionalDocument(String id)

      Some connectors may want to pre-generate additional documents when `Connector.getDocumentById(String)` is called. In such a case, the connector can use this method to obtain a writer for an additional document and use it in much the same was as `Connector.newDocument(java.lang.String)`.
      Specified by:
        `writeAdditionalDocument` in interface `DocumentWriter`
      Parameters:
        `id` - the identifier of the additional document; may not be null
      Returns:
        the writer for the additional document; never null

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