public class Template
extends java.lang.Object
Variable
constructor.format(Request, Response)
and
parse(String, Request)
.Resolver
,
URI Template
specificationModifier and Type | Field and Description |
---|---|
static int |
MODE_EQUALS
Mode where all characters must match the template and size be identical.
|
static int |
MODE_STARTS_WITH
Mode where characters at the beginning must match the template.
|
Constructor and Description |
---|
Template(java.lang.String pattern)
Default constructor.
|
Template(java.lang.String pattern,
int matchingMode)
Constructor.
|
Template(java.lang.String pattern,
int matchingMode,
int defaultType,
java.lang.String defaultDefaultValue,
boolean defaultRequired,
boolean defaultFixed)
Constructor.
|
Template(java.lang.String pattern,
int matchingMode,
int defaultType,
java.lang.String defaultDefaultValue,
boolean defaultRequired,
boolean defaultFixed,
boolean encodingVariables)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
format(java.util.Map<java.lang.String,?> values)
Creates a formatted string based on the given map of values.
|
java.lang.String |
format(Request request,
Response response)
Creates a formatted string based on the given request and response.
|
java.lang.String |
format(Resolver<?> resolver)
Creates a formatted string based on the given variable resolver.
|
Variable |
getDefaultVariable()
Returns the default variable.
|
java.util.logging.Logger |
getLogger()
Returns the logger to use.
|
int |
getMatchingMode()
Returns the matching mode to use when parsing a formatted reference.
|
java.lang.String |
getPattern()
Returns the pattern to use for formatting or parsing.
|
java.util.List<java.lang.String> |
getVariableNames()
Returns the list of variable names in the template.
|
java.util.Map<java.lang.String,Variable> |
getVariables()
Returns the modifiable map of variable descriptors.
|
boolean |
isEncodingVariables()
Indicates if the variables must be encoded when formatting the template.
|
int |
match(java.lang.String formattedString)
Indicates if the current pattern matches the given formatted string.
|
int |
parse(java.lang.String formattedString,
java.util.Map<java.lang.String,java.lang.Object> variables)
Attempts to parse a formatted reference.
|
int |
parse(java.lang.String formattedString,
java.util.Map<java.lang.String,java.lang.Object> variables,
boolean loggable)
Attempts to parse a formatted reference.
|
int |
parse(java.lang.String formattedString,
Request request)
Attempts to parse a formatted reference.
|
void |
setDefaultVariable(Variable defaultVariable)
Sets the variable to use, if no variable is given.
|
void |
setEncodingVariables(boolean encodingVariables)
Indicates if the variables must be encoded when formatting the template.
|
void |
setLogger(java.util.logging.Logger logger)
Sets the logger to use.
|
void |
setMatchingMode(int matchingMode)
Sets the matching mode to use when parsing a formatted reference.
|
void |
setPattern(java.lang.String pattern)
Sets the pattern to use for formatting or parsing.
|
void |
setVariables(java.util.Map<java.lang.String,Variable> variables)
Sets the modifiable map of variables.
|
public static final int MODE_EQUALS
public static final int MODE_STARTS_WITH
public Template(java.lang.String pattern)
pattern
- The pattern to use for formatting or parsing.public Template(java.lang.String pattern, int matchingMode)
pattern
- The pattern to use for formatting or parsing.matchingMode
- The matching mode to use when parsing a formatted reference.public Template(java.lang.String pattern, int matchingMode, int defaultType, java.lang.String defaultDefaultValue, boolean defaultRequired, boolean defaultFixed)
pattern
- The pattern to use for formatting or parsing.matchingMode
- The matching mode to use when parsing a formatted reference.defaultType
- The default type of variables with no descriptor.defaultDefaultValue
- The default value for null variables with no descriptor.defaultRequired
- The default required flag for variables with no descriptor.defaultFixed
- The default fixed value for variables with no descriptor.public Template(java.lang.String pattern, int matchingMode, int defaultType, java.lang.String defaultDefaultValue, boolean defaultRequired, boolean defaultFixed, boolean encodingVariables)
pattern
- The pattern to use for formatting or parsing.matchingMode
- The matching mode to use when parsing a formatted reference.defaultType
- The default type of variables with no descriptor.defaultDefaultValue
- The default value for null variables with no descriptor.defaultRequired
- The default required flag for variables with no descriptor.defaultFixed
- The default fixed value for variables with no descriptor.encodingVariables
- True if the variables must be encoded when formatting the
template.public java.lang.String format(java.util.Map<java.lang.String,?> values)
values
- The values to use when formatting.Resolver.createResolver(Map)
public java.lang.String format(Request request, Response response)
request
- The request to use as a model.response
- The response to use as a model.Resolver.createResolver(Request, Response)
public java.lang.String format(Resolver<?> resolver)
resolver
- The variable resolver to use.public Variable getDefaultVariable()
public java.util.logging.Logger getLogger()
public int getMatchingMode()
public java.lang.String getPattern()
public java.util.List<java.lang.String> getVariableNames()
public java.util.Map<java.lang.String,Variable> getVariables()
public boolean isEncodingVariables()
public int match(java.lang.String formattedString)
formattedString
- The formatted string to match.public int parse(java.lang.String formattedString, java.util.Map<java.lang.String,java.lang.Object> variables)
formattedString
- The string to parse.variables
- The map of variables to update.Reference.decode(String)
public int parse(java.lang.String formattedString, java.util.Map<java.lang.String,java.lang.Object> variables, boolean loggable)
formattedString
- The string to parse.variables
- The map of variables to update.loggable
- True if the parsing should be logged.Reference.decode(String)
public int parse(java.lang.String formattedString, Request request)
formattedString
- The string to parse.request
- The request to update.Reference.decode(String)
public void setDefaultVariable(Variable defaultVariable)
defaultVariable
- public void setEncodingVariables(boolean encodingVariables)
encodingVariables
- True if the variables must be encoded when formatting the
template.public void setLogger(java.util.logging.Logger logger)
logger
- The logger to use.public void setMatchingMode(int matchingMode)
matchingMode
- The matching mode to use when parsing a formatted reference.public void setPattern(java.lang.String pattern)
pattern
- The pattern to use for formatting or parsing.public void setVariables(java.util.Map<java.lang.String,Variable> variables)
variables
- The modifiable map of variables.Copyright © 2005-2024 Restlet.