water.api
Class RequestBuilders.Builder

java.lang.Object
  extended by water.api.RequestBuilders.Builder
Direct Known Subclasses:
RequestBuilders.ArrayBuilder, RequestBuilders.ElementBuilder, RequestBuilders.ObjectBuilder
Enclosing class:
RequestBuilders

public abstract static class RequestBuilders.Builder
extends java.lang.Object

An abstract class to build the HTML page automatically from JSON. The idea is that every JSON element in the response structure (dot separated) may be a unique context that might be displayed in a different way. By creating specialized builders and assigning them to the JSON element contexts you can build arbitrarily complex HTML page. The basic builders for elements, arrays, array rows and elements inside array rows are provided by default. Each builder can also specify default builders for its components to make sure for instance that tables in arrays do not recurse and so on.


Constructor Summary
RequestBuilders.Builder()
           
 
Method Summary
static java.lang.String addToContext(java.lang.String oldContext, java.lang.String name)
          Adds the given element name to the existing context.
abstract  java.lang.String build(RequestBuilders.Response response, com.google.gson.JsonElement element, java.lang.String contextName)
          Override this method to provide HTML for the given json element.
 RequestBuilders.Builder defaultBuilder(com.google.gson.JsonElement element)
          Returns the default builders.
static java.lang.String elementName(java.lang.String context)
          For a given context returns the element name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestBuilders.Builder

public RequestBuilders.Builder()
Method Detail

build

public abstract java.lang.String build(RequestBuilders.Response response,
                                       com.google.gson.JsonElement element,
                                       java.lang.String contextName)
Override this method to provide HTML for the given json element. The arguments are the response object, the element whose HTML should be produced and the contextName of the element.


addToContext

public static java.lang.String addToContext(java.lang.String oldContext,
                                            java.lang.String name)
Adds the given element name to the existing context. Dot concatenates the names.


elementName

public static java.lang.String elementName(java.lang.String context)
For a given context returns the element name. That is the last word after a dot, or the full string if dot is not present.


defaultBuilder

public RequestBuilders.Builder defaultBuilder(com.google.gson.JsonElement element)
Returns the default builders. These are element builder, object builder and array builder.