org.neo4j.remote
Class RemoteResponse.ResponseBuilder

java.lang.Object
  extended by org.neo4j.remote.RemoteResponse.ResponseBuilder
All Implemented Interfaces:
ResponseVisitor
Enclosing class:
RemoteResponse<T>

public static final class RemoteResponse.ResponseBuilder
extends Object
implements ResponseVisitor

Factory for creating RemoteResponse objects.

Author:
Tobias Ivarsson

Constructor Summary
RemoteResponse.ResponseBuilder()
           
 
Method Summary
 RemoteResponse<Boolean> buildBooleanResponse(boolean value)
          Create a response for a boolean request.
<T> RemoteResponse<T>
buildErrorResponse(Exception ex)
          Create an error response for any request.
 RemoteResponse<IterableSpecification<NodeSpecification>> buildFinalNodeResponse(long size, NodeSpecification... nodes)
          Create a final response for a node iterator request.
 RemoteResponse<IterableSpecification<RelationshipSpecification>> buildFinalRelationshipResponse(RelationshipSpecification... relationships)
          Create a final response for a relationship iterator request.
 RemoteResponse<IterableSpecification<String>> buildFinalStringResponse(String... strings)
          Create a final response for a string iterator request.
 RemoteResponse<Integer> buildIntegerResponse(int value)
          Create a response for an integer request.
 RemoteResponse<NodeSpecification> buildNodeResponse(long id)
          Create a response for a node request.
 RemoteResponse<IterableSpecification<NodeSpecification>> buildPartialNodeResponse(int moreToken, long size, NodeSpecification... nodes)
          Create a partial response for a node iterator request.
 RemoteResponse<IterableSpecification<RelationshipSpecification>> buildPartialRelationshipResponse(int moreToken, RelationshipSpecification... relationships)
          Create a partial response for a relationship iterator request.
 RemoteResponse<IterableSpecification<String>> buildPartialStringResponse(int moreToken, String... strings)
          Create a partial response for a string iterator request.
 RemoteResponse<Object> buildPropertyResponse(Object value)
          Create a response for a property request.
 RemoteResponse<RelationshipSpecification> buildRelationshipResponse(long id, String typeName, long startNode, long endNode)
          Create a response for a relationship request.
 RemoteResponse<Void> buildVoidResponse()
          Create a response for a void request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteResponse.ResponseBuilder

public RemoteResponse.ResponseBuilder()
Method Detail

buildNodeResponse

public RemoteResponse<NodeSpecification> buildNodeResponse(long id)
Create a response for a node request.

Parameters:
id - the id of the node.
Returns:
The response for the node request.

buildRelationshipResponse

public RemoteResponse<RelationshipSpecification> buildRelationshipResponse(long id,
                                                                           String typeName,
                                                                           long startNode,
                                                                           long endNode)
Create a response for a relationship request.

Parameters:
id - the id of the relationship.
typeName - the type name of the relationship.
startNode - the node id of the relationship start node.
endNode - the node id of the relationship end node.
Returns:
The response for the relationship request.

buildPropertyResponse

public RemoteResponse<Object> buildPropertyResponse(Object value)
Create a response for a property request.

Parameters:
value - the value of the property.
Returns:
The response for the property request.

buildBooleanResponse

public RemoteResponse<Boolean> buildBooleanResponse(boolean value)
Create a response for a boolean request.

Parameters:
value - the result.
Returns:
The response for the boolean request.

buildIntegerResponse

public RemoteResponse<Integer> buildIntegerResponse(int value)
Create a response for an integer request.

Parameters:
value - the result.
Returns:
The response for the integer request.

buildPartialStringResponse

public RemoteResponse<IterableSpecification<String>> buildPartialStringResponse(int moreToken,
                                                                                String... strings)
Create a partial response for a string iterator request.

Parameters:
moreToken - the token used to get the further parts of the iterator.
strings - the strings to return in this batch.
Returns:
The partial response for the string iterator request.

buildFinalStringResponse

public RemoteResponse<IterableSpecification<String>> buildFinalStringResponse(String... strings)
Create a final response for a string iterator request.

Parameters:
strings - the strings to return in this batch.
Returns:
The partial response for the string iterator request.

buildPartialNodeResponse

public RemoteResponse<IterableSpecification<NodeSpecification>> buildPartialNodeResponse(int moreToken,
                                                                                         long size,
                                                                                         NodeSpecification... nodes)
Create a partial response for a node iterator request.

Parameters:
moreToken - the token used to get the further parts of the iterator.
size - the total size of the iterable or a negative number for unknown.
nodes - the nodes to return in this batch.
Returns:
The partial response for the node iterator request.

buildFinalNodeResponse

public RemoteResponse<IterableSpecification<NodeSpecification>> buildFinalNodeResponse(long size,
                                                                                       NodeSpecification... nodes)
Create a final response for a node iterator request.

Parameters:
size - the total size of the iterable or a negative number for unknown.
nodes - the nodes to return in this batch.
Returns:
The partial response for the node iterator request.

buildPartialRelationshipResponse

public RemoteResponse<IterableSpecification<RelationshipSpecification>> buildPartialRelationshipResponse(int moreToken,
                                                                                                         RelationshipSpecification... relationships)
Create a partial response for a relationship iterator request.

Parameters:
moreToken - the token used to get the further parts of the iterator.
relationships - the relationships to return in this batch.
Returns:
The partial response for the relationship iterator request.

buildFinalRelationshipResponse

public RemoteResponse<IterableSpecification<RelationshipSpecification>> buildFinalRelationshipResponse(RelationshipSpecification... relationships)
Create a final response for a relationship iterator request.

Parameters:
relationships - the relationships to return in this batch.
Returns:
The partial response for the relationship iterator request.

buildVoidResponse

public RemoteResponse<Void> buildVoidResponse()
Create a response for a void request.

Returns:
The response for the void request.

buildErrorResponse

public <T> RemoteResponse<T> buildErrorResponse(Exception ex)
Create an error response for any request.

Type Parameters:
T - the type of the original request.
Parameters:
ex - the exception that occurred during the processing of the request.
Returns:
The error response for the request.


Copyright © 2010 Neo4j. All Rights Reserved.