Class EndTagType
- java.lang.Object
-
- TagType
-
- EndTagType
-
- Direct Known Subclasses:
EndTagTypeGenericImplementation
public abstract class EndTagType extends TagType
Defines the syntax for an end tag type.An end tag type is a
TagTypethat starts with the characters '</'.The singleton instances of all the standard end tag types are available in this class as static fields.
Because all
EndTagTypeinstaces must be singletons, the '==' operator can be used to test for a particular tag type instead of theequals(Object)method.- See Also:
StartTagType
-
-
Field Summary
Fields Modifier and Type Field Description static EndTagTypeNORMALThe tag type given to a normal HTML or XML end tag (</name>).static EndTagTypeUNREGISTERED
-
Constructor Summary
Constructors Modifier Constructor Description protectedEndTagType(java.lang.String description, java.lang.String startDelimiter, java.lang.String closingDelimiter, boolean isServerTag)Constructs a newEndTagTypeobject with the specified properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected EndTagconstructEndTag(Source source, int begin, int end, java.lang.String name)Internal method for the construction of anEndTagobject of this type.java.lang.StringgenerateHTML(java.lang.String startTagName)StartTagTypegetCorrespondingStartTagType()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.-
Methods inherited from class net.htmlparser.jericho.TagType
constructTagAt, deregister, getClosingDelimiter, getDescription, getNamePrefix, getRegisteredTagTypes, getStartDelimiter, getTagTypesIgnoringEnclosedMarkup, isServerTag, isValidPosition, register, setTagTypesIgnoringEnclosedMarkup, tagEncloses, toString
-
-
-
-
Field Detail
-
UNREGISTERED
public static final EndTagType UNREGISTERED
The tag type given to an unregistered end tag (</ ... >).See the documentation of the
Tag.isUnregistered()method for details.- Properties:
-
Property/Method Value Description/unregistered StartDelimiter</ClosingDelimiter>IsServerTagfalseNamePrefix(empty string) CorrespondingStartTagTypenullgenerateHTML("StartTagName")</StartTagName> - Example:
</ "This is not recognised as any of the predefined end tag types in this library">
- See Also:
StartTagType.UNREGISTERED
-
NORMAL
public static final EndTagType NORMAL
The tag type given to a normal HTML or XML end tag (</name>).- Properties:
-
Property/Method Value Description/normal StartDelimiter</ClosingDelimiter>IsServerTagfalseNamePrefix(empty string) CorrespondingStartTagTypeStartTagType.NORMALgenerateHTML("StartTagName")</StartTagName> - Example:
</div>
-
-
Constructor Detail
-
EndTagType
protected EndTagType(java.lang.String description, java.lang.String startDelimiter, java.lang.String closingDelimiter, boolean isServerTag)Constructs a newEndTagTypeobject with the specified properties.
(implementation assistance method)As
EndTagTypeis an abstract class, this constructor is only called from sub-class constructors.- 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.
-
-
Method Detail
-
getCorrespondingStartTagType
public StartTagType getCorrespondingStartTagType()
Returns the type of start tag that is usually paired with an end tag of this type to form anElement.
(default implementation method)The default implementation returns
null.This property is informational only and is not used by the parser in any way.
The mapping of end tag type to the corresponding start tag type is in any case one-to-many, which is why the definition emphasises the word "usually". An example of this is the
PHPTagTypes.PHP_SCRIPTstart tag type, whose corresponding end tag type isEndTagType.NORMAL, while the converse is not true.The only predefined end tag type that returns
nullfor this property is the specialUNREGISTEREDend tag type.Although this method is used like a property method, it is implemented as a default implementation method to avoid cyclic references between statically instantiated
StartTagTypeandEndTagTypeobjects.- Standard Tag Type Values:
-
End Tag Type Corresponding Start Tag Type UNREGISTEREDnullNORMALStartTagType.NORMAL
- Extended Tag Type Values:
-
End Tag Type Corresponding Start Tag Type MasonTagTypes.MASON_COMPONENT_CALLED_WITH_CONTENT_ENDMasonTagTypes.MASON_COMPONENT_CALLED_WITH_CONTENTMasonTagTypes.MASON_NAMED_BLOCK_ENDMasonTagTypes.MASON_NAMED_BLOCK
- Returns:
- the type of start tag that is usually paired with an end tag of this type to form an
Element. - See Also:
StartTagType.getCorrespondingEndTagType()
-
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 default implementation simply returns
startTagName.Note that the
startTagNameparameter should include the start tag's name prefix if it has one.- 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 default implementation returns
"</"+getEndTagName(startTagName)+TagType.getClosingDelimiter().Note that the
startTagNameparameter should include the start tag's name prefix if it has one.- 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.
-
constructEndTag
protected final EndTag constructEndTag(Source source, int begin, int end, java.lang.String name)
Internal method for the construction of anEndTagobject of this type.
(implementation assistance method)Intended for use from within the
constructTagAt(Source, int pos)method.
-
-