public abstract class ValueRenderer extends Object
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.
ExpressionType| Modifier and Type | Field and Description |
|---|---|
protected String |
ifEmpty
Substitution string for an empty value/list member/map value
|
protected boolean |
named
Whether variable values are named during expansion
|
| Modifier | Constructor and Description |
|---|---|
protected |
ValueRenderer(ExpressionType type)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
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
|
protected final boolean named
ExpressionType.isNamed()protected final String ifEmpty
ExpressionType.getIfEmpty()protected ValueRenderer(ExpressionType type)
type - the expression typepublic abstract List<String> render(VariableSpec varspec, VariableValue value) throws URITemplateException
varspec - the varspecvalue - the matching variable valueURITemplateException - illegal expansionprotected final String pctEncode(String s)
The character set on which to perform percent encoding is dependent on the expression type.
s - the string to encodeExpressionType.isRawExpand()