ModeShape Distribution 3.5.0.Final

org.modeshape.jcr.federation.spi
Interface DocumentWriter

All Superinterfaces:
PageWriter
All Known Implementing Classes:
FederatedDocumentWriter

public interface DocumentWriter
extends PageWriter

A writer which can create and manipulate the structure of EditableDocument instances, that should be used by connectors when they want to return the information regarding external nodes.


Field Summary
 
Fields inherited from interface org.modeshape.jcr.federation.spi.PageWriter
UNKNOWN_TOTAL_SIZE
 
Method Summary
 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.
 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.
 DocumentWriter 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.
 DocumentWriter writeAdditionalDocument(String id)
          Some connectors may want to pre-generate additional documents when Connector.getDocumentById(String) is called.
 
Methods inherited from interface org.modeshape.jcr.federation.spi.PageWriter
document
 

Method Detail

setId

DocumentWriter setId(String id)
Sets an identifier string on the underlying document.

Parameters:
id - the identifier of the document; may not be null
Returns:
this writer; never null

setPrimaryType

DocumentWriter setPrimaryType(String name)
Sets the primary type of the underlying document.

Parameters:
name - the name of the primary type for the node; may not be null
Returns:
this writer; never null

setPrimaryType

DocumentWriter setPrimaryType(Name name)
Sets the primary type of the underlying document.

Parameters:
name - the name of the primary type for the node; may not be null
Returns:
this writer; never null

addMixinType

DocumentWriter addMixinType(String name)
Adds a mixin type to the underlying document.

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

DocumentWriter addMixinType(Name name)
Adds a mixin type to the underlying document.

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

addProperty

DocumentWriter addProperty(String name,
                           Object value)
Adds a property with the given name and value to the underlying document's properties.

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

DocumentWriter addProperty(Name name,
                           Object value)
Adds a property with the given name and value to the underlying document's properties.

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

DocumentWriter addProperty(String name,
                           Object[] values)
Adds a multi-value property with the given name to the underlying document's properties.

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

DocumentWriter addProperty(Name name,
                           Object[] values)
Adds a multi-value property with the given name to the underlying document's properties.

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

DocumentWriter addProperty(String name,
                           Object firstValue,
                           Object... additionalValues)
Adds a multi-value property with the given name to the underlying document's properties.

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

DocumentWriter addProperty(Name name,
                           Object firstValue,
                           Object... additionalValues)
Adds a multi-value property with the given name to the underlying document's properties.

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

DocumentWriter addProperties(Map<Name,Property> properties)
Adds a map of properties to the the underlying document's properties.

Parameters:
properties - a map of properties keyed by their name; may not be null
Returns:
this writer; never null

addPropertyValue

DocumentWriter addPropertyValue(String name,
                                Object value)
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.

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

DocumentWriter addPropertyValue(Name name,
                                Object value)
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.

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

setProperties

DocumentWriter setProperties(Map<Name,Property> properties)
Replaces the underlying document's properties with the one from the given map.

Parameters:
properties - a map of properties keyed by their name; may not be null
Returns:
this writer; never null

setParents

DocumentWriter setParents(String... parentIds)
Sets the ids of one or more parents on the underlying document. If any parents previously existed, they will be replaced.

Parameters:
parentIds - the array of parent identifiers
Returns:
this writer; never null

setParent

DocumentWriter setParent(String parentId)
Sets the id of the parent of the underlying document. If any parents previously existed, they will be replaced.

Parameters:
parentId - the identifier of the parent; may not be null
Returns:
this writer; never null

setParents

DocumentWriter setParents(List<String> parentIds)
Sets the ids of one or more parents on the underlying document. If any parents previously existed, they will be replaced.

Parameters:
parentIds - the list of parent identifiers; may not be null
Returns:
this writer; never null

setCacheTtlSeconds

DocumentWriter setCacheTtlSeconds(int seconds)
Sets the value, in seconds, of the amount of the time the underlying document should be cached.

Parameters:
seconds - the number of seconds the document should be cached by the repository.
Returns:
this writer; never null

setNotQueryable

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.

Returns:
this writer; never null

addChild

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 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

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 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

DocumentWriter removeChild(String id)
Description copied from interface: PageWriter
Remove a child from this document.

Specified by:
removeChild in interface PageWriter
Parameters:
id - the identifier of the child
Returns:
this writer; never null

setChildren

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 PageWriter
Parameters:
children - a list of EditableDocument instances each describing a single child; may not be null
Returns:
this writer; never null

setChildren

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 PageWriter
Parameters:
children - a map of (childId, childName) pairs; may not be null
Returns:
this writer; never null

addPage

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 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

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 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)

writeAdditionalDocument

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(String). The resulting additional document will be included automatically when the Connector returns the top-level document.

Parameters:
id - the identifier of the additional document; may not be null
Returns:
the writer for the additional document; never null

ModeShape Distribution 3.5.0.Final

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