com.couchbase.client.protocol.views
Class DesignDocument<T>

java.lang.Object
  extended by com.couchbase.client.protocol.views.DesignDocument<T>

public class DesignDocument<T>
extends java.lang.Object

The DesignDocument represents a design document stored and retrieved from a Couchbase cluster.


Constructor Summary
DesignDocument(java.lang.String name)
          Create a new DesignDocument with a name.
DesignDocument(java.lang.String name, java.util.List<ViewDesign> views, java.util.List<SpatialViewDesign> spatialViews)
          Create a new DesignDocument with a name and (spatial) views.
 
Method Summary
 java.lang.String getLanguage()
          Get the language of the views.
 java.lang.String getName()
          Get the name of the design document.
 java.util.List<SpatialViewDesign> getSpatialViews()
          Return a list of all stored spatial views.
 java.util.List<ViewDesign> getViews()
          Get the list of the associated view designs.
 DesignDocument setName(java.lang.String n)
          Set the name of the design document.
 DesignDocument setSpatialView(SpatialViewDesign spatialView)
          Add a single spatial view to the list of stored DpatialViewDesign objects.
 DesignDocument setSpatialViews(java.util.List<SpatialViewDesign> sv)
          Set a list of SpatialViewDesigns.
 DesignDocument setView(ViewDesign view)
          Add a single view to the list of stored ViewDesign objects.
 DesignDocument setViews(java.util.List<ViewDesign> v)
          Set a list of ViewDesigns.
 java.lang.String toJson()
          Create a JSON representation of the design document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DesignDocument

public DesignDocument(java.lang.String name)
Create a new DesignDocument with a name. If this constructor is used, the various set methods for the views need to be used in order to provide at least one view. A design document without a view is not allowed and will return an exception when casted into a JSON string.

Parameters:
name - the name of the DesignDocument.

DesignDocument

public DesignDocument(java.lang.String name,
                      java.util.List<ViewDesign> views,
                      java.util.List<SpatialViewDesign> spatialViews)
Create a new DesignDocument with a name and (spatial) views. It is possible to pass null for either views or spatialViews. In this case, no views of that type will be created.

Parameters:
name - the name of the DesignDocument.
views - a list of ViewDesigns, which represent the views.
spatialViews - a list of SpatialViewDesigns, which represent the spatial views.
Method Detail

getLanguage

public java.lang.String getLanguage()
Get the language of the views.

Returns:
the language of the views.

getName

public java.lang.String getName()
Get the name of the design document.

Returns:
the name of the design document.

getViews

public java.util.List<ViewDesign> getViews()
Get the list of the associated view designs.

Returns:
a list of the associated view designs.

setViews

public DesignDocument setViews(java.util.List<ViewDesign> v)
Set a list of ViewDesigns.

Parameters:
v - the list of ViewDesign objects representing the views.
Returns:
the current object instance.

setView

public DesignDocument setView(ViewDesign view)
Add a single view to the list of stored ViewDesign objects.

Parameters:
view - a single view to be added.
Returns:
the current object instance.

getSpatialViews

public java.util.List<SpatialViewDesign> getSpatialViews()
Return a list of all stored spatial views.

Returns:
the list of stored spatial views.

setSpatialViews

public DesignDocument setSpatialViews(java.util.List<SpatialViewDesign> sv)
Set a list of SpatialViewDesigns.

Parameters:
sv - the list of SpatialViewDesign objects.
Returns:
the current object instance.

setSpatialView

public DesignDocument setSpatialView(SpatialViewDesign spatialView)
Add a single spatial view to the list of stored DpatialViewDesign objects.

Parameters:
spatialView - a single spatial view to be added.
Returns:
the current object instance.

setName

public DesignDocument setName(java.lang.String n)
Set the name of the design document.

Parameters:
n - the name of the design document.
Returns:
the current object instance.

toJson

public java.lang.String toJson()
Create a JSON representation of the design document. This JSON representation mirrors the needed format of the Couchbase server implementation.

Returns:
the JSON representation of the design document.
Throws:
java.lang.RuntimeException - when no view or no name is set.


Copyright © 2006-2009 Dustin Sallings, 2009-2012 Couchbase, Inc.