Class EndTagTypeGenericImplementation
- java.lang.Object
-
- TagType
-
- EndTagType
-
- EndTagTypeGenericImplementation
-
public class EndTagTypeGenericImplementation extends EndTagType
Provides a generic implementation of the abstractEndTagTypeclass 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
EndTagTypeare:- The introduction of the
IsStaticproperty. - The
constructTagAt(Source, int pos)method has a default implementation.
Most of the predefined end tag types are implemented using this class or a subclass of it.
- See Also:
StartTagTypeGenericImplementation
- The introduction of the
-
-
Field Summary
-
Fields inherited from class net.htmlparser.jericho.EndTagType
NORMAL, UNREGISTERED
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedEndTagTypeGenericImplementation(java.lang.String description, java.lang.String startDelimiter, java.lang.String closingDelimiter, boolean isServerTag, boolean isStatic)Constructs a newEndTagTypeGenericImplementationobject based on the specified properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TagconstructTagAt(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.java.lang.StringgenerateHTML(java.lang.String startTagName)java.lang.StringgetEndTagName(java.lang.String startTagName)Returns the end tag name that is required to match a corresponding start tag with the specified name.protected booleanisStatic()Indicates whether the end tag text is static.-
Methods inherited from class net.htmlparser.jericho.EndTagType
constructEndTag, getCorrespondingStartTagType
-
Methods inherited from class net.htmlparser.jericho.TagType
deregister, getClosingDelimiter, getDescription, getNamePrefix, getRegisteredTagTypes, getStartDelimiter, getTagTypesIgnoringEnclosedMarkup, isServerTag, isValidPosition, register, setTagTypesIgnoringEnclosedMarkup, tagEncloses, toString
-
-
-
-
Constructor Detail
-
EndTagTypeGenericImplementation
protected EndTagTypeGenericImplementation(java.lang.String description, java.lang.String startDelimiter, java.lang.String closingDelimiter, boolean isServerTag, boolean isStatic)Constructs a newEndTagTypeGenericImplementationobject based on the specified properties.
(implementation assistance method)The purpose of the
isStaticparameter is explained in theIsStaticproperty 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 Detail
-
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_ENDis the only predefined end tag for which this property istrue. All tags of this type have the constant tag text "</&>".- Returns:
trueif the end tag text is static, otherwisefalse.
-
getEndTagName
public java.lang.String getEndTagName(java.lang.String startTagName)
Returns the end tag name that is required to match a corresponding start tag with the specified name.
(property method)This implementation overrides the default implementation in
EndTagType.getEndTagName(String startTagName).If the value of the
IsStaticproperty isfalse, it returns simply returnsstartTagName, as in the default implementation.If the value of the
IsStaticproperty istrue, it returns this end tag type's name prefix.Note that the
startTagNameparameter should include the start tag's name prefix if it has one.- Overrides:
getEndTagNamein classEndTagType- Parameters:
startTagName- the name of a corresponding start tag, including its name prefix.- Returns:
- the end tag name that is required to match a corresponding start tag with the specified name.
-
generateHTML
public java.lang.String generateHTML(java.lang.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)to improve efficiency in the case of a static end tag type, although the functionality is the same.- Overrides:
generateHTMLin classEndTagType- Parameters:
startTagName- the name of a corresponding start tag, including its name prefix.- Returns:
- the HTML text of an end tag of this type given the name of a corresponding start tag.
-
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 checks the source text for a match according to the following criteria:
If the value of the
IsStaticproperty isfalse, this implementation ensures that the source text matches the expression:
getStartDelimiter()+"name"+optionalWhiteSpace+getClosingDelimiter()
where name is a valid XML tag name, and optionalWhiteSpace is a string of zero or more white space characters. The name of the constructed end tag becomesgetNamePrefix()+"name".If the value of the
IsStaticproperty istrue, this implementation ensures that the source text matches the static expression:
getStartDelimiter()+getClosingDelimiter()
The name of the constructed end tag is the value of thegetNamePrefix()method.See
TagType.constructTagAt(Source, int pos)for more important information about this method.- Specified by:
constructTagAtin classTagType- Parameters:
source- theSourcedocument.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
nullif it does not meet the criteria.
-
-