public class CompositeTagScanner extends TagScanner
public Tag scan(Tag tag, Lexer lexer, NodeList stack) throws ParserException
An initial test is performed for an empty XML tag, in which case the start tag and end tag of the returned tag are the same and it has no children.
If it's not an empty XML tag, the lexer is repeatedly asked for subsequent nodes until an end tag is found or a node is encountered that matches the tag ender set or end tag ender set. In the latter case, a virtual end tag is created. Each node found that is not the end tag is added to the list of children. The end tag is special and not a child.
Nodes that also have a CompositeTagScanner as their scanner are recursed into, which provides the nested structure of an HTML page. This method operates in two possible modes, depending on a private boolean. It can recurse on the JVM stack, which has caused some overflow problems in the past, or it can use the supplied stack argument to nest scanning of child tags within itself. The former is left as an option in the code, mostly to help subsequent modifiers visualize what the internal nesting is doing.
scan
在接口中 Scanner
scan
在类中 TagScanner
tag
- The tag this scanner is responsible for.lexer
- The source of subsequent nodes.stack
- The parse stack. May contain pending tags that enclose
this tag.ParserException
- if an unrecoverable problem occurs.public final boolean isTagToBeEndedFor(Tag current, Tag tag)
current
- The tag that might need to be ended.tag
- The candidate tag that might end the current one.true
if the name of the given tag is a member of
the appropriate list.