Renders the hyperlink URL from the specified
StartTag.
A return value of null
indicates that the hyperlink URL should not be rendered at all.
The default implementation of this method returns null
if the href
attribute of the specified start tag
starts with "javascript:
", is a relative or invalid URI, or is missing completely.
In all other cases it returns the value of the href
attribute enclosed in angle brackets.
See the documentation of the
#setIncludeHyperlinkURLs(boolean) method for an example of how a hyperlink is rendered by the default implementation.
This method can be overridden in a subclass to customise the rendering of hyperlink URLs.
Rendering of hyperlink URLs can be disabled completely without overriding this method by setting the
#setIncludeHyperlinkURLs(boolean) property to false
.
Example:
To render hyperlink URLs without the enclosing angle brackets:
Renderer renderer=new Renderer(segment) {
public String renderHyperlinkURL(StartTag startTag) {
String href=startTag.getAttributeValue("href");
if (href==null || href.startsWith("javascript:")) return null;
try {
URI uri=new URI(href);
if (!uri.isAbsolute()) return null;
} catch (URISyntaxException ex) {
return null;
}
return href;
}
};
String renderedSegment=renderer.toString();