Renders the alternate text of the specified start tag.
A return value of null
indicates that the alternate text is not to be rendered at all.
The default implementation of this method returns null
if the alt
attribute of the specified start tag is missing or empty, or if the
specified start tag is from an
HTMLElementName#AREA element.
In all other cases it returns the value of the alt
attribute enclosed in square brackets […]
.
See the documentation of the
#setIncludeAlternateText(boolean) method for an example of how alternate text is rendered by the default implementation.
This method can be overridden in a subclass to customise the rendering of alternate text.
Rendering of alternate text can be disabled completely without overriding this method by setting the
#setIncludeAlternateText(boolean) property to false
.
Example:
To render alternate text with double angle quotation marks instead of square brackets:
Renderer renderer=new Renderer(segment) {
public String renderAlternateText(StartTag startTag) {
if (startTag.getName()==HTMLElementName.AREA) return null;
String alt=startTag.getAttributeValue("alt");
if (alt==null || alt.length()==0) return null;
return ''+alt+'';
}
};
String renderedSegment=renderer.toString();