Defines the syntax for a tag type that can be recognised by the parser.
This class is the root abstract class common to all tag types, and contains methods to
#register()and
#deregister() tag types as well as various methods to aid in their implementation.
Every tag type is represented by a singleton instance of a class that must be a subclass of either
StartTagType or
EndTagType. These two abstract classes, the only direct descendants of this class,
represent the two major classifications under which every tag type exists.
Because all TagType
instaces must be singletons, the '==
' operator can be used to test for a particular tag type
instead of the equals(Object)
method.
The term predefined tag type refers to any of the tag types defined in this library,
including both standard and extended tag types.
The term standard tag type refers to any of the tag types represented by instances
in static fields of the
StartTagType and
EndTagType subclasses.
Standard tag types are registered by default, and define the tags most commonly found in HTML documents.
The term extended tag type refers to any predefined tag type
that is not a standard tag type.
The
PHPTagTypes and
MasonTagTypes classes contain extended tag types related to their respective server platforms.
The tag types defined within them must be registered by the user before they are recognised by the parser.
The term custom tag type refers to any user-defined tag type, or any tag type that is
not a predefined tag type.
The tag recognition process of the parser gives each tag type a precedence level,
which is primarily determined by the length of its
#getStartDelimiter().
A tag type with a more specific start delimiter is chosen in preference to one with a less specific start delimiter,
assuming they both share the same prefix. If two tag types have exactly the same start delimiter, the one which was
#register() later has the higher precedence.
The two special tag types
StartTagType#UNREGISTERED and
EndTagType#UNREGISTERED represent
tags that do not match the syntax of any other tag type. They have the lowest precedence
of all the tag types. The
Tag#isUnregistered() method provides a detailed explanation of unregistered tags.
See the documentation of the tag parsing process for more information
on how each tag is identified by the parser.
Note that the standard
HTMLElementName do not represent different
tag types. All standard HTML tags have a tag type of
StartTagType#NORMAL or
EndTagType#NORMAL,
and are also referred to as normal tags.
Apart from the registration related methods, all of the methods in this class and its
subclasses relate to the implementation of custom tag types and are not relevant to the majority of users
who just use the predefined tag types.
For perfomance reasons, this library only allows tag types that
#getStartDelimiter()with a '<
' character.
The character following this defines the immediate subclass of the tag type.
An
EndTagType always has a slash ('/
') as the second character, while a
StartTagTypehas any character other than a slash as the second character.
This definition means that tag types which are not intuitively classified as either start tag types or end tag types
(such as an HTML
StartTagType#COMMENT) are mostly classified as start tag types.
Every method in this and the
StartTagType and
EndTagType abstract classes can be categorised
as one of the following:
Properties:
Simple properties (marked final) that were either specified as parameters
during construction or are derived from those parameters.
Abstract implementation methods:
Methods that must be implemented in a subclass.
Default implementation methods:
Methods (not marked final) that implement common behaviour, but may be overridden in a subclass.
Implementation assistance methods:
Protected methods that provide low-level functionality and are only of use within other implementation methods.
Registration related methods:
Utility methods (marked final) relating to the
#register() of tag type instances.