|
|||||||||
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)
Create a URLTemplate from a url-template-config template. |
|
URLTemplate(String template,
String name)
Create a URLTemplate from a url-template-config template. |
|
URLTemplate(URLTemplate template)
Copy constructor to create a URLTemplate from an existing URLTemplate. |
Method Summary | |
---|---|
protected void |
appendToResult(InternalStringBuilder result,
String value)
|
String |
format()
Return the String representation of the URL after replacing the tokens in the template with their associated values. |
String |
format(boolean removeUnsetTokens)
Return the String representation of the URL after replacing the tokens in the template with their associated values. |
String |
getName()
|
String |
getTemplate()
Retrieve the String form of the template. |
void |
setName(String name)
|
void |
setTemplate(String template)
Reset the String form of the template. |
void |
substitute(Map 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 URL after replacing the tokens in the template with their associated values. |
boolean |
verify(Collection knownTokens,
Collection requiredTokens)
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)
template
- the string form of the template from url-template-config.public URLTemplate(String template, String name)
template
- the string form of the template from url-template-config.name
- the name of the templatepublic 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 setName(String name)
public String getName()
public boolean verify(Collection knownTokens, Collection 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}
If the template does not contain the required tokens or if the format of a known token is incorrect, this method will log the error and return false.
Should call verify after creating a new template.
knownTokens
- the collection of known tokens (Strings) for a valid template.requiredTokens
- the collection of required tokens (Strings) in a valid template.
public void substitute(Map tokensAndValues)
public void substitute(String token, String value)
public void substitute(String token, int value)
public String toString()
toString
in class Object
public String format()
public String format(boolean removeUnsetTokens)
true
, then the unset
template tokens are removed. Otherwise, do not cleanup
the unset tokens.
removeUnsetTokens
- flag to tell URLTemplate to remove
or leave the unset tokens in the URL.
protected void appendToResult(InternalStringBuilder result, String value)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |