📄 starttagtype.java
字号:
* This can be represented by the following expression that is always <code>true</code> given an arbitrary {@linkplain Element element}
* that has an end tag:
* <p>
* <code>element.</code>{@link Element#getStartTag() getStartTag()}<code>.</code>{@link StartTag#getStartTagType() getStartTagType()}<code>.</code>{@link #getCorrespondingEndTagType()}<code>==element.</code>{@link Element#getEndTag() getEndTag()}<code>.</code>{@link EndTag#getEndTagType() getEndTagType()}
* <p>
* <dl>
* <dt>Standard Tag Type Values:</dt>
* <dd>
* <table class="bordered" style="margin: 15px" cellspacing="0">
* <tr><th>Start Tag Type<th>Corresponding End Tag Type
* <tr><td>{@link StartTagType#UNREGISTERED}<td><code>null</code>
* <tr><td>{@link StartTagType#NORMAL}<td>{@link EndTagType#NORMAL}
* <tr><td>{@link StartTagType#COMMENT}<td><code>null</code>
* <tr><td>{@link StartTagType#XML_DECLARATION}<td><code>null</code>
* <tr><td>{@link StartTagType#XML_PROCESSING_INSTRUCTION}<td><code>null</code>
* <tr><td>{@link StartTagType#DOCTYPE_DECLARATION}<td><code>null</code>
* <tr><td>{@link StartTagType#MARKUP_DECLARATION}<td><code>null</code>
* <tr><td>{@link StartTagType#CDATA_SECTION}<td><code>null</code>
* <tr><td>{@link StartTagType#SERVER_COMMON}<td><code>null</code>
* <tr><td>{@link StartTagType#SERVER_COMMON_ESCAPED}<td><code>null</code>
* </table>
* </dl>
* <dl>
* <dt>Extended Tag Type Values:</dt>
* <dd>
* <table class="bordered" style="margin: 15px" cellspacing="0">
* <tr><th>Start Tag Type<th>Corresponding End Tag Type
* <tr><td>{@link MicrosoftTagTypes#DOWNLEVEL_REVEALED_CONDITIONAL_COMMENT}<td><code>null</code>
* <tr><td>{@link PHPTagTypes#PHP_SCRIPT}<td>{@link EndTagType#NORMAL}
* <tr><td>{@link PHPTagTypes#PHP_SHORT}<td><code>null</code>
* <tr><td>{@link PHPTagTypes#PHP_STANDARD}<td><code>null</code>
* <tr><td>{@link MasonTagTypes#MASON_COMPONENT_CALL}<td><code>null</code>
* <tr><td>{@link MasonTagTypes#MASON_COMPONENT_CALLED_WITH_CONTENT}<td>{@link MasonTagTypes#MASON_COMPONENT_CALLED_WITH_CONTENT_END}
* <tr><td>{@link MasonTagTypes#MASON_NAMED_BLOCK}<td>{@link MasonTagTypes#MASON_NAMED_BLOCK_END}
* </table>
* </dl>
*
* @return the {@linkplain EndTagType type} of {@linkplain EndTag end tag} required to pair with a {@linkplain StartTag start tag} of this type to form an {@link Element}.
* @see EndTagType#getCorrespondingStartTagType()
*/
public final EndTagType getCorrespondingEndTagType() {
return correspondingEndTagType;
}
/**
* Indicates whether a start tag of this type contains {@linkplain Attributes attributes}.
* <br />(<a href="TagType.html#Property">property</a> method)
* <p>
* The attributes start at the end of the {@linkplain Tag#getName() name} and continue until the
* {@linkplain #getClosingDelimiter() closing delimiter} is encountered. If the character sequence representing the
* closing delimiter occurs within a quoted attribute value it is not recognised as the end of the tag.
* <p>
* The {@link #atEndOfAttributes(Source, int pos, boolean isClosingSlashIgnored)} method can be overridden to provide more control
* over where the attributes end.
* <p>
* <dl>
* <dt>Standard Tag Type Values:</dt>
* <dd>
* <table class="bordered" style="margin: 15px" cellspacing="0">
* <tr><th>Start Tag Type<th>Has Attributes
* <tr><td>{@link StartTagType#UNREGISTERED}<td><code>false</code>
* <tr><td>{@link StartTagType#NORMAL}<td><code>true</code>
* <tr><td>{@link StartTagType#COMMENT}<td><code>false</code>
* <tr><td>{@link StartTagType#XML_DECLARATION}<td><code>true</code>
* <tr><td>{@link StartTagType#XML_PROCESSING_INSTRUCTION}<td><code>false</code>
* <tr><td>{@link StartTagType#DOCTYPE_DECLARATION}<td><code>false</code>
* <tr><td>{@link StartTagType#MARKUP_DECLARATION}<td><code>false</code>
* <tr><td>{@link StartTagType#CDATA_SECTION}<td><code>false</code>
* <tr><td>{@link StartTagType#SERVER_COMMON}<td><code>false</code>
* <tr><td>{@link StartTagType#SERVER_COMMON_ESCAPED}<td><code>false</code>
* </table>
* </dl>
* <dl>
* <dt>Extended Tag Type Values:</dt>
* <dd>
* <table class="bordered" style="margin: 15px" cellspacing="0">
* <tr><th>Start Tag Type<th>Has Attributes
* <tr><td>{@link MicrosoftTagTypes#DOWNLEVEL_REVEALED_CONDITIONAL_COMMENT}<td><code>false</code>
* <tr><td>{@link PHPTagTypes#PHP_SCRIPT}<td><code>true</code>
* <tr><td>{@link PHPTagTypes#PHP_SHORT}<td><code>false</code>
* <tr><td>{@link PHPTagTypes#PHP_STANDARD}<td><code>false</code>
* <tr><td>{@link MasonTagTypes#MASON_COMPONENT_CALL}<td><code>false</code>
* <tr><td>{@link MasonTagTypes#MASON_COMPONENT_CALLED_WITH_CONTENT}<td><code>false</code>
* <tr><td>{@link MasonTagTypes#MASON_NAMED_BLOCK}<td><code>false</code>
* </table>
* </dl>
*
* @return <code>true</code> if a start tag of this type contains {@linkplain Attributes attributes}, otherwise <code>false</code>.
*/
public final boolean hasAttributes() {
return hasAttributes;
}
/**
* Indicates whether a valid {@linkplain Tag#isXMLName(CharSequence) XML tag name} is required directly after the {@linkplain #getNamePrefix() prefix}.
* <br />(<a href="TagType.html#Property">property</a> method)
* <p>
* If this property is <code>true</code>, the {@linkplain Tag#getName() name} of the tag consists of the
* {@linkplain #getNamePrefix() prefix} followed by an {@linkplain Tag#isXMLName(CharSequence) XML tag name}.
* <p>
* If this property is <code>false</code>, the {@linkplain Tag#getName() name} of the tag consists of only the
* {@linkplain #getNamePrefix() prefix}.
* <p>
* <dl>
* <dt>Standard Tag Type Values:</dt>
* <dd>
* <table class="bordered" style="margin: 15px" cellspacing="0">
* <tr><th>Start Tag Type<th>Name After Prefix Required
* <tr><td>{@link StartTagType#UNREGISTERED}<td><code>false</code>
* <tr><td>{@link StartTagType#NORMAL}<td><code>true</code>
* <tr><td>{@link StartTagType#COMMENT}<td><code>false</code>
* <tr><td>{@link StartTagType#XML_DECLARATION}<td><code>false</code>
* <tr><td>{@link StartTagType#XML_PROCESSING_INSTRUCTION}<td><code>true</code>
* <tr><td>{@link StartTagType#DOCTYPE_DECLARATION}<td><code>false</code>
* <tr><td>{@link StartTagType#MARKUP_DECLARATION}<td><code>true</code>
* <tr><td>{@link StartTagType#CDATA_SECTION}<td><code>false</code>
* <tr><td>{@link StartTagType#SERVER_COMMON}<td><code>false</code>
* <tr><td>{@link StartTagType#SERVER_COMMON_ESCAPED}<td><code>false</code>
* </table>
* </dl>
* <dl>
* <dt>Extended Tag Type Values:</dt>
* <dd>
* <table class="bordered" style="margin: 15px" cellspacing="0">
* <tr><th>Start Tag Type<th>Name After Prefix Required
* <tr><td>{@link MicrosoftTagTypes#DOWNLEVEL_REVEALED_CONDITIONAL_COMMENT}<td><code>true</code>
* <tr><td>{@link PHPTagTypes#PHP_SCRIPT}<td><code>false</code>
* <tr><td>{@link PHPTagTypes#PHP_SHORT}<td><code>false</code>
* <tr><td>{@link PHPTagTypes#PHP_STANDARD}<td><code>false</code>
* <tr><td>{@link MasonTagTypes#MASON_COMPONENT_CALL}<td><code>false</code>
* <tr><td>{@link MasonTagTypes#MASON_COMPONENT_CALLED_WITH_CONTENT}<td><code>false</code>
* <tr><td>{@link MasonTagTypes#MASON_NAMED_BLOCK}<td><code>true</code>
* </table>
* </dl>
*
* @return <code>true</code> if a valid {@linkplain Tag#isXMLName(CharSequence) XML tag name} is required directly after the {@linkplain #getNamePrefix() prefix}, otherwise <code>false</code>.
*/
public final boolean isNameAfterPrefixRequired() {
return isNameAfterPrefixRequired;
}
/**
* Indicates whether the specified source document position is at the end of a tag's {@linkplain Attributes attributes}.
* <br />(<a href="TagType.html#DefaultImplementation">default implementation</a> method)
* <p>
* This method is called internally while parsing {@linkplain Attributes attributes} to detect where they should end.
* <p>
* It can be assumed that the specified position is not inside a quoted attribute value.
* <p>
* The default implementation simply compares the {@linkplain ParseText parse text} at the specified
* position with the {@linkplain #getClosingDelimiter() closing delimiter}, and is equivalent to:<br />
* <code>source.</code>{@link Source#getParseText() getParseText()}<code>.containsAt(</code>{@link #getClosingDelimiter() getClosingDelimiter()}<code>,pos)</code>
* <p>
* The <code>isClosingSlashIgnored</code> parameter is only relevant in the {@link #NORMAL} start tag type,
* which makes use of it to cater for the '<code>/</code>' character that can occur before the
* {@linkplain #getClosingDelimiter() closing delimiter} in {@linkplain StartTag#isEmptyElementTag() empty-element tags}.
* It's value is always <code>false</code> when passed to other start tag types.
*
* @param source the {@link Source} document.
* @param pos the character position in the source document.
* @param isClosingSlashIgnored indicates whether the {@linkplain StartTag#getName() name} of the {@linkplain StartTag start tag} being tested is incompatible with an {@linkplain StartTag#isEmptyElementTag() empty-element tag}.
* @return <code>true</code> if the specified source document position is at the end of a tag's {@linkplain Attributes attributes}, otherwise <code>false</code>.
*/
public boolean atEndOfAttributes(final Source source, final int pos, final boolean isClosingSlashIgnored) {
return source.getParseText().containsAt(getClosingDelimiter(),pos);
}
/**
* Internal method for the construction of a {@link StartTag} object if this type.
* <br />(<a href="TagType.html#ImplementationAssistance">implementation assistance</a> method)
* <p>
* Intended for use from within the {@link #constructTagAt(Source,int) constructTagAt(Source, int pos)} method.
*
* @param source the {@link Source} document.
* @param begin the character position in the source document where the tag {@linkplain Segment#getBegin() begins}.
* @param end the character position in the source document where the tag {@linkplain Segment#getEnd() ends}.
* @param name the {@linkplain Tag#getName() name} of the tag.
* @param attributes the {@linkplain StartTag#getAttributes() attributes} of the tag.
* @return the new {@link StartTag} object.
*/
protected final StartTag constructStartTag(final Source source, final int begin, final int end, final String name, final Attributes attributes) {
return new StartTag(source,begin,end,this,name,attributes);
}
/**
* Internal method for the parsing of {@link Attributes}.
* <br />(<a href="TagType.html#ImplementationAssistance">implementation assistance</a> method)
* <p>
* Intended for use from within the {@link #constructTagAt(Source,int) constructTagAt(Source, int pos)} method.
* <p>
* The returned {@link Attributes} segment begins at <code>startTagBegin+1+tagName.length()</code>,
* and ends straight after the last attribute found before the tag's {@linkplain #getClosingDelimiter() closing delimiter}.
* <p>
* Only returns <code>null</code> if the segment contains a major syntactical error
* or more than the {@linkplain Attributes#getDefaultMaxErrorCount() default maximum} number of
* minor syntactical errors.
*
* @param source the {@link Source} document.
* @param startTagBegin the position in the source document at which the start tag is to begin.
* @param tagName the {@linkplain StartTag#getName() name} of the start tag to be constructed.
* @return the {@link Attributes} of the start tag to be constructed, or <code>null</code> if too many errors occur while parsing.
*/
protected final Attributes parseAttributes(final Source source, final int startTagBegin, final String tagName) {
return Attributes.construct(source,startTagBegin,this,tagName);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -