| java.lang.Object org.apache.beehive.netui.core.urltemplates.URLTemplate
URLTemplate | public class URLTemplate implements Serializable(Code) | | The class to format a URL defined by url-template-config template
given by values for a set of tokens.
|
Inner Class :protected class TemplateItem implements Serializable | |
Constructor Summary | |
public | URLTemplate(String template) Create a URLTemplate from a url-template-config template. | public | URLTemplate(String template, String name) Create a URLTemplate from a url-template-config template. | public | URLTemplate(URLTemplate template) Copy constructor to create a URLTemplate from an existing URLTemplate.
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. |
Method Summary | |
protected void | appendToResult(InternalStringBuilder result, String value) | public String | format() Return the String representation of the URL after replacing
the tokens in the template with their associated values. | public String | format(boolean removeUnsetTokens) Return the String representation of the URL after replacing
the tokens in the template with their associated values.
If the boolean argument is true , then the unset
template tokens are removed. | public String | getName() | public String | getTemplate() Retrieve the String form of the template. | public void | setName(String name) | public void | setTemplate(String template) Reset the String form of the template.
Should call verify after setting a new template. | public void | substitute(Map tokensAndValues) Replace a set of tokens in the template with a corresponding set of values.
This assumes that there is an ordered one-to-one relationship. | public void | substitute(String token, String value) Replace a single token in the template with a corresponding String value.
Tokens are expected to be qualified in braces. | public void | substitute(String token, int value) Replace a single token in the template with a corresponding int value.
Tokens are expected to be qualified in braces. | public String | toString() Return the String representation of the URL after replacing
the tokens in the template with their associated values. | public 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. |
URLTemplate | public URLTemplate(String template)(Code) | | Create a URLTemplate from a url-template-config template.
Parameters: template - the string form of the template from url-template-config. |
URLTemplate | public URLTemplate(String template, String name)(Code) | | Create a URLTemplate from a url-template-config template.
Parameters: template - the string form of the template from url-template-config. Parameters: name - the name of the template |
URLTemplate | public URLTemplate(URLTemplate template)(Code) | | Copy constructor to create a URLTemplate from an existing URLTemplate.
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.
Parameters: template - the URLTemplate to copy. |
format | public String format()(Code) | | Return the String representation of the URL after replacing
the tokens in the template with their associated values. If
there is no value for a token, the token is discarded/removed.
I.E. It will not be part of the returned String.
the url |
format | public String format(boolean removeUnsetTokens)(Code) | | Return the String representation of the URL after replacing
the tokens in the template with their associated values.
If the boolean argument is true , then the unset
template tokens are removed. Otherwise, do not cleanup
the unset tokens.
Parameters: removeUnsetTokens - flag to tell URLTemplate to removeor leave the unset tokens in the URL. the url |
getTemplate | public String getTemplate()(Code) | | Retrieve the String form of the template.
the string form of the template. |
setTemplate | public void setTemplate(String template)(Code) | | Reset the String form of the template.
Should call verify after setting a new template.
Parameters: template - the string form of the template from url-template-config. |
substitute | public void substitute(Map tokensAndValues)(Code) | | Replace a set of tokens in the template with a corresponding set of values.
This assumes that there is an ordered one-to-one relationship. Tokens are
expected to be qualified in braces. E.g. {url:path}
|
substitute | public void substitute(String token, String value)(Code) | | Replace a single token in the template with a corresponding String value.
Tokens are expected to be qualified in braces. E.g. {url:path}
|
substitute | public void substitute(String token, int value)(Code) | | Replace a single token in the template with a corresponding int value.
Tokens are expected to be qualified in braces. E.g. {url:port}
|
toString | public String toString()(Code) | | Return the String representation of the URL after replacing
the tokens in the template with their associated values. If
there is no value for a token, the token is discarded/removed.
I.E. It will not be part of the returned String.
the url |
verify | public boolean verify(Collection knownTokens, Collection requiredTokens)(Code) | | Verification will ensure the URL template conforms to a valid format
for known tokens and contains the required tokens. It will also parse
the tokens and literal data into a list to improve the replacement
performance when constructing the final URL string.
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.
Parameters: knownTokens - the collection of known tokens (Strings) for a valid template. Parameters: requiredTokens - the collection of required tokens (Strings) in a valid template. true if the template conforms to a valid format, otherwise return false. |
|
|