com.github.fge.uritemplate.render
Class ValueRenderer

java.lang.Object
  extended by com.github.fge.uritemplate.render.ValueRenderer
Direct Known Subclasses:
MultiValueRenderer, StringRenderer

public abstract class ValueRenderer
extends Object

Main rendering class

The algorithm used for rendering is centered around this class,and is adapted from the algorithm suggested in the RFC's appendix.

Eventually, rendering can be viewed as joining a list of rendered strings with the expression type separator; if the resulting list is empty, the end result is the empty string; otherwise, it is the expression's prefix string (if any) followed by the joined list of rendered strings.

This class renders one variable value according to the expression type and value type. The rendering method returns a list, which can be empty.

See Also:
ExpressionType

Field Summary
protected  String ifEmpty
          Substitution string for an empty value/list member/map value
protected  boolean named
          Whether variable values are named during expansion
 
Constructor Summary
protected ValueRenderer(ExpressionType type)
          Constructor
 
Method Summary
protected  String pctEncode(String s)
          Render a string value, doing character percent-encoding where needed
abstract  List<String> render(VariableSpec varspec, VariableValue value)
          Render a value given a varspec and value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

named

protected final boolean named
Whether variable values are named during expansion

See Also:
ExpressionType.isNamed()

ifEmpty

protected final String ifEmpty
Substitution string for an empty value/list member/map value

See Also:
ExpressionType.getIfEmpty()
Constructor Detail

ValueRenderer

protected ValueRenderer(ExpressionType type)
Constructor

Parameters:
type - the expression type
Method Detail

render

public abstract List<String> render(VariableSpec varspec,
                                    VariableValue value)
                             throws URITemplateException
Render a value given a varspec and value

Parameters:
varspec - the varspec
value - the matching variable value
Returns:
a list of rendered strings
Throws:
URITemplateException - illegal expansion

pctEncode

protected final String pctEncode(String s)
Render a string value, doing character percent-encoding where needed

The character set on which to perform percent encoding is dependent on the expression type.

Parameters:
s - the string to encode
Returns:
an encoded string
See Also:
ExpressionType.isRawExpand()