|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectURLTemplate
public class URLTemplate
The class to format a URL defined by url-template-config template given by values for a set of tokens.
Nested Class Summary | |
---|---|
protected class |
URLTemplate.TemplateItem
|
Constructor Summary | |
---|---|
URLTemplate(String template,
Collection<String> knownTokens,
Collection<String> requiredTokens)
Create a URLTemplate from a url-template-config template. |
|
URLTemplate(URLTemplate template)
Copy constructor to create a URLTemplate from an existing URLTemplate. |
Method Summary | |
---|---|
String |
getTemplate()
Retrieve the String form of the template. |
void |
setTemplate(String template)
Reset the String form of the template. |
void |
substitute(Map<String,String> tokensAndValues)
Replace a set of tokens in the template with a corresponding set of values. |
void |
substitute(String token,
int value)
Replace a single token in the template with a corresponding int value. |
void |
substitute(String token,
String value)
Replace a single token in the template with a corresponding String value. |
String |
toString()
Return the String representation of the template after replacing all tokens with their associated values.. |
void |
verify()
Verification will ensure the URL template conforms to a valid format for known tokens and contains the required tokens. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public URLTemplate(String template, Collection<String> knownTokens, Collection<String> requiredTokens)
Allow clients to define a set of required and known tokens for the template verification. Tokens are expected to be qualified in braces. E.g. {url:path}
The template verification will ensure the URL template conforms to a valid format for known tokens and contains the required tokens.
Should call verify after creating a new template.
template
- the string form of the template from url-template-config.knownTokens
- The set of known tokens for a valid template.requiredTokens
- The set of required tokens in a valid template.public URLTemplate(URLTemplate template)
Note that this is not truly a complete copy because the Map of the replacement values for the given tokens is not copied. This copy will just have an empty map of token values so that it is "cleared" and ready to format another URL.
template
- the URLTemplate to copy.Method Detail |
---|
public void setTemplate(String template)
Should call verify after setting a new template.
template
- the string form of the template from url-template-config.public String getTemplate()
public void verify() throws IllegalStateException
IllegalStateException
public void substitute(Map<String,String> tokensAndValues)
public void substitute(String token, String value)
public void substitute(String token, int value)
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |