public class EndTagTypeGenericImplementation extends EndTagType
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:
IsStatic
property.
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.
StartTagTypeGenericImplementation
NORMAL, UNREGISTERED
Modifier | Constructor and Description |
---|---|
protected |
EndTagTypeGenericImplementation(java.lang.String description,
java.lang.String startDelimiter,
java.lang.String closingDelimiter,
boolean isServerTag,
boolean isStatic)
Constructs a new
EndTagTypeGenericImplementation object based on the specified properties. |
Modifier and Type | Method and Description |
---|---|
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.
|
java.lang.String |
generateHTML(java.lang.String startTagName)
|
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.
|
protected boolean |
isStatic()
Indicates whether the end tag text is static.
|
constructEndTag, getCorrespondingStartTagType
protected EndTagTypeGenericImplementation(java.lang.String description, java.lang.String startDelimiter, java.lang.String closingDelimiter, boolean isServerTag, boolean isStatic)
EndTagTypeGenericImplementation
object based on the specified properties.
The purpose of the isStatic
parameter is explained in the IsStatic
property description.
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.protected final boolean isStatic()
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 "</&>
".
true
if the end tag text is static, otherwise false
.public java.lang.String getEndTagName(java.lang.String startTagName)
This implementation overrides the default implementation in EndTagType.getEndTagName(String startTagName)
.
If the value of the IsStatic
property is false
, it returns simply returns startTagName
, as in the default implementation.
If the value of the IsStatic
property is true
, it returns this end tag type's name prefix.
Note that the startTagName
parameter should include the start tag's name prefix if it has one.
getEndTagName
in class EndTagType
startTagName
- the name of a corresponding start tag, including its name prefix.public java.lang.String generateHTML(java.lang.String startTagName)
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.
generateHTML
in class EndTagType
startTagName
- the name of a corresponding start tag, including its name prefix.protected Tag constructTagAt(Source source, int pos)
This default implementation checks the source text for a match according to the following criteria:
If the value of the IsStatic
property is false
, 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 becomes getNamePrefix()
+"name"
.
If the value of the IsStatic
property is true
, this implementation ensures that the
source text matches the static expression:
getStartDelimiter()
+
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.
constructTagAt
in class TagType
source
- the Source
document.pos
- the position in the source document.null
if it does not meet the criteria.