au.id.jericho.lib.html
Class StartTagTypeGenericImplementation
public class StartTagTypeGenericImplementation
Provides a generic implementation of the abstract
StartTagType
class based on the most common start tag behaviour.
This class is only of interest to users who wish to create
custom tag types.
The only external difference between this class and its abstract superclass
StartTagType
is that it provides a default
implementation of the
constructTagAt(Source, int pos)
method.
Most of the
predefined start tag types are implemented using this class or a subclass of it.
StartTagTypeGenericImplementation(String description, String startDelimiter, String closingDelimiter, EndTagType correspondingEndTagType, boolean isServerTag) - Constructs a new
StartTagTypeGenericImplementation object with the specified properties.
|
StartTagTypeGenericImplementation(String description, String startDelimiter, String closingDelimiter, EndTagType correspondingEndTagType, boolean isServerTag, boolean hasAttributes, boolean isNameAfterPrefixRequired) - Constructs a new
StartTagTypeGenericImplementation object with the specified properties.
|
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.
|
protected int | findEnd(Source source, int pos) - Finds the end of a tag of this type, starting from the specified position in the specified source document.
|
constructTagAt , deregister , getClosingDelimiter , getDescription , getNamePrefix , getRegisteredTagTypes , getStartDelimiter , getTagTypesIgnoringEnclosedMarkup , isServerTag , isValidPosition , register , setTagTypesIgnoringEnclosedMarkup , tagEncloses , toString |
StartTagTypeGenericImplementation
protected StartTagTypeGenericImplementation(String description,
String startDelimiter,
String closingDelimiter,
EndTagType correspondingEndTagType,
boolean isServerTag)
StartTagTypeGenericImplementation
protected StartTagTypeGenericImplementation(String description,
String startDelimiter,
String closingDelimiter,
EndTagType correspondingEndTagType,
boolean isServerTag,
boolean hasAttributes,
boolean isNameAfterPrefixRequired)
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 performs the following steps:
-
If a name is required after the prefix, search for a valid
XML tag name directly after the
name prefix using the
Source.findNameEnd(int pos)
method.
If one is found, set the name to include it, otherwise return null
.
-
If the last character of the name prefix is a letter
(indicating that the prefix includes the full name of the tag),
and the character following the prefix in the source text is also a letter
or any other valid XML name character,
return
null
.
Example: the source text "<?xmlt ?>
" should not be recognised as an
XML processing instruction, which has the prefix "<?xml
".
-
If the tag type has attributes, call
parseAttributes(source,pos,name)
to parse them.
Return null
if too many errors occur while parsing the attributes.
-
Find the end of the tag using the
findEnd(Source, int pos)
method,
where pos
is either the end of the attributes segment or the end of the
name depending on whether the tag type has attributes.
Return null
if the end of the tag can not be found.
-
Construct the
StartTag
object using the
constructStartTag(Source, int pos, int end, String name, Attributes)
method with the argument values collected over the previous steps.
See
TagType.constructTagAt(Source, int pos)
for more important information about this method.
- constructTagAt in interface TagType
source
- the Source
document.pos
- the position in the source document.
- 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.
findEnd
protected int findEnd(Source source,
int pos)
Finds the
end of a tag of this type, starting from the specified position in the specified source document.
(
implementation assistance method)
This default implementation simply searches for the first occurrence of the
closing delimiter after the specified position, and returns the position immediately
after the end of it.
If the closing delimiter is not found, the value
-1
is returned.
source
- the Source
document.pos
- the position in the source document.
- the end of a tag of this type, starting from the specified position in the specified source document, or
-1
if the end of the tag can not be found.