|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.restlet.util.Template
public class Template
String template with a model is based on a request. Supports both formatting
and parsing. The template variables can be inserted using the "{name}" syntax
and described using the modifiable map of variable descriptors. When no
descriptor is found for a given variable, the template logic uses its default
variable property initialized using the default Variable constructor.
| Model property | Variable name | Content type |
|---|---|---|
| request.confidential | c | boolean (true|false) |
| request.clientInfo.address | cia | String |
| request.clientInfo.agent | cig | String |
| request.challengeResponse.identifier | cri | String |
| request.challengeResponse.scheme | crs | String |
| request.entity.characterSet | ecs | String |
| response.entity.characterSet | ECS | String |
| request.entity.encoding | ee | String |
| response.entity.encoding | EE | String |
| request.entity.expirationDate | eed | Date (HTTP format) |
| response.entity.expirationDate | EED | Date (HTTP format) |
| request.entity.language | el | String |
| response.entity.language | EL | String |
| request.entity.modificationDate | emd | Date (HTTP format) |
| response.entity.modificationDate | EMD | Date (HTTP format) |
| request.entity.mediaType | emt | String |
| response.entity.mediaType | EMT | String |
| request.entity.size | es | Integer |
| response.entity.size | ES | Integer |
| request.entity.tag | et | String |
| response.entity.tag | ET | String |
| request.referrerRef | f* | Reference (see table below variable name sub-parts) |
| request.hostRef | h* | Reference (see table below variable name sub-parts) |
| request.method | m | String |
| request.rootRef | o* | Reference (see table below variable name sub-parts) |
| request.protocol | p | String |
| request.resourceRef | r* | Reference (see table below variable name sub-parts) |
| response.redirectRef | R* | Reference (see table below variable name sub-parts) |
| response.status | S | Integer |
| response.serverInfo.address | SIA | String |
| response.serverInfo.agent | SIG | String |
| response.serverInfo.port | SIP | Integer |
| Reference property | Sub-part name | Content type |
|---|---|---|
| authority | a | String |
| baseRef | b* | Reference |
| relativePart | e | String |
| fragment | f | String |
| hostIdentifier | h | String |
| identifier | i | String |
| path | p | String |
| query | q | String |
| remainingPart | r | String |
| Field Summary | |
|---|---|
static int |
MODE_EQUALS
|
static int |
MODE_STARTS_WITH
|
| Constructor Summary | |
|---|---|
Template(Logger logger,
String pattern)
Default constructor. |
|
Template(Logger logger,
String pattern,
int matchingMode)
Constructor. |
|
Template(Logger logger,
String pattern,
int matchingMode,
int defaultType,
String defaultDefaultValue,
boolean defaultRequired,
boolean defaultFixed)
Constructor. |
|
| Method Summary | |
|---|---|
String |
format(Map<String,Object> variables)
Creates a formatted string based on the given request. |
String |
format(Request request,
Response response)
Creates a formatted string based on the given request. |
Variable |
getDefaultVariable()
Returns the default variable. |
Logger |
getLogger()
Returns the logger to use. |
int |
getMatchingMode()
Returns the matching mode to use when parsing a formatted reference. |
String |
getPattern()
Returns the pattern to use for formatting or parsing. |
Map<String,Variable> |
getVariables()
Returns the modifiable map of variables. |
int |
match(String formattedString)
Indicates if the current pattern matches the given formatted string. |
int |
parse(String formattedString,
Map<String,Object> variables)
Attempts to parse a formatted reference. |
int |
parse(String formattedString,
Request request)
Attempts to parse a formatted reference. |
void |
setMatchingMode(int matchingMode)
Sets the matching mode to use when parsing a formatted reference. |
void |
setPattern(String pattern)
Sets the pattern to use for formatting or parsing. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MODE_STARTS_WITH
public static final int MODE_EQUALS
| Constructor Detail |
|---|
public Template(Logger logger,
String pattern)
logger - The logger to use.pattern - The pattern to use for formatting or parsing.
public Template(Logger logger,
String pattern,
int matchingMode)
logger - The logger to use.pattern - The pattern to use for formatting or parsing.matchingMode - The matching mode to use when parsing a formatted
reference.
public Template(Logger logger,
String pattern,
int matchingMode,
int defaultType,
String defaultDefaultValue,
boolean defaultRequired,
boolean defaultFixed)
logger - The logger to use.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.| Method Detail |
|---|
public String format(Request request,
Response response)
request - The request to use as a model.response - The response to use as a model.
public String format(Map<String,Object> variables)
variables - The variables to use when formatting.
public Variable getDefaultVariable()
public Logger getLogger()
public int getMatchingMode()
public String getPattern()
public Map<String,Variable> getVariables()
public int match(String formattedString)
formattedString - The formatted string to match.
public int parse(String formattedString,
Request request)
formattedString - The string to parse.request - The request to update.
Reference.decode(String)
public int parse(String formattedString,
Map<String,Object> variables)
formattedString - The string to parse.variables - The map of variables to update.
Reference.decode(String)public void setPattern(String pattern)
pattern - The pattern to use for formatting or parsing.public void setMatchingMode(int matchingMode)
matchingMode - The matching mode to use when parsing a formatted
reference.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||