au.id.jericho.lib.html

Class EndTagTypeGenericImplementation


public class EndTagTypeGenericImplementation
extends EndTagType

Provides a generic implementation of the abstract EndTagType class based on the most common end tag behaviour.

This class is only of interest to users who wish to create custom tag types.

The differences between this class and its abstract superclass EndTagType are:

Most of the predefined end tag types are implemented using this class or a subclass of it.

See Also:
StartTagTypeGenericImplementation

Field Summary

Fields inherited from class au.id.jericho.lib.html.EndTagType

NORMAL, UNREGISTERED

Constructor Summary

EndTagTypeGenericImplementation(String description, String startDelimiter, String closingDelimiter, boolean isServerTag, boolean isStatic)
Constructs a new EndTagTypeGenericImplementation object based on the specified properties.

Method Summary

protected Tag
constructTagAt(Source source, int pos)
Constructs a tag of this type at the specified position in the specified source document if it matches all of the required features.
String
generateHTML(String startTagName)
Generates the HTML text of an end tag of this type given the name of a corresponding start tag.
protected boolean
isStatic()
Indicates whether the end tag text is static.

Methods inherited from class au.id.jericho.lib.html.EndTagType

constructEndTag, generateHTML, getCorrespondingStartTagType

Methods inherited from class au.id.jericho.lib.html.TagType

constructTagAt, deregister, getClosingDelimiter, getDescription, getNamePrefix, getRegisteredTagTypes, getStartDelimiter, getTagTypesIgnoringEnclosedMarkup, isServerTag, isValidPosition, register, setTagTypesIgnoringEnclosedMarkup, tagEncloses, toString

Constructor Details

EndTagTypeGenericImplementation

protected EndTagTypeGenericImplementation(String description,
                                          String startDelimiter,
                                          String closingDelimiter,
                                          boolean isServerTag,
                                          boolean isStatic)
Constructs a new EndTagTypeGenericImplementation object based on the specified properties.
(
implementation assistance method)

The purpose of the isStatic parameter is explained in the IsStatic property description.

Parameters:
description - a description of the new end tag type useful for debugging purposes.
startDelimiter - the start delimiter of the new end tag type.
closingDelimiter - the closing delimiter of the new end tag type.
isServerTag - indicates whether the new end tag type is a server tag.
isStatic - determines whether the end tag text is static.

Method Details

constructTagAt

protected Tag constructTagAt(Source source,
                             int pos)
Constructs a tag of this type at the specified position in the specified source document if it matches all of the required features.
(default implementation method)

This default implementation ensures that the source text matches the possible output of the generateHTML(String startTagName) method.

If the value of the IsStatic property is false, this implementation ensures that the source text matches the expression:
getStartTagDelimiter()+"name"+getClosingDelimiter()
where name is a valid XML tag name. The name of the constructed end tag becomes getNamePrefix()+"name".

If the value of the IsStatic property is true, this implementation ensures that the source text matches the static expression:
getStartTagDelimiter()+getClosingDelimiter()
The name of the constructed end tag is the value of the getNamePrefix() method.

See TagType.constructTagAt(Source, int pos) for more important information about this method.

Overrides:
constructTagAt in interface TagType
Parameters:
source - the Source document.
pos - the position in the source document.
Returns:
a tag of this type at the specified position in the specified source document if it meets all of the required features, or null if it does not meet the criteria.

generateHTML

public String generateHTML(String startTagName)
Generates the HTML text of an end tag of this type given the name of a corresponding start tag.
(property method)

This implementation overrides the default implementation in EndTagType.generateHTML(String startTagName).

If the value of the IsStatic property is false, it returns the same string as the default implementation:
getStartTagDelimiter()+startTagName+getClosingDelimiter().

If the value of the IsStatic property is true, it returns the cached static string:
getStartDelimiter()+getClosingDelimiter().

Overrides:
generateHTML in interface EndTagType
Parameters:
startTagName - the name of a corresponding start tag.
Returns:
the HTML text of an end tag of this type given the name of a corresponding start tag.

isStatic

protected final boolean isStatic()
Indicates whether the end tag text is static.
(property and implementation assistance method)

The purpose of this property is to determine the behaviour of the generateHTML(String startTagName) method.

If this property is true, the end tag text is constant for all tags of this type.

If this property is false, the end tag text includes the name of the corresponding start tag.

MasonTagTypes.MASON_COMPONENT_CALLED_WITH_CONTENT_END is the only predefined end tag for which this property is true. All tags of this type have the constant tag text "</&>".

Returns:
true if the end tag text is static, otherwise false.