Class CmsHtmlTagRemoveFactory
- java.lang.Object
-
- org.htmlparser.PrototypicalNodeFactory
-
- org.opencms.util.CmsHtmlTagRemoveFactory
-
- All Implemented Interfaces:
java.io.Serializable
,org.htmlparser.NodeFactory
public final class CmsHtmlTagRemoveFactory extends org.htmlparser.PrototypicalNodeFactory
A tag factory for htmlparser that is able to "remove tags".Create an instance, add the
Tag
instances to remove and assign this factory to theParser
before starting a visit. A demo usage is shown inCmsTagReplaceParser
.The tags are not actually removed: They are linked in the document object model tree of the HTML that the parser generates. They just will not accept any
NodeVisitor
instances and therefore be invisible in any output a visitor will generate from the visited tree.The decision whether a tag is removed can be controlled in two ways:
-
addTagRemoval(Tag)
The given tag will be removed ("invisible in the DOM").
-
addTagPreserve(Tag)
The given tag will be kept as-is. The following behaviour happens if this method is used:
-
Once
has been called all Tags that are not added to this method will be removed. We are in include mode then.addTagPreserve(Tag)
-
The Tags provided to
will only have the power to hide exactly the same tags that are given toaddTagRemoval(Tag)
: Deny is stronger than allow.addTagPreserve(Tag)
-
Once
- Since:
- 6.1.8
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CmsHtmlTagRemoveFactory()
Create a new factory with all tags registered.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addTagPreserve(org.htmlparser.Tag tag)
Add a tag that will be visible forNodeVisitor
instances.boolean
addTagRemoval(org.htmlparser.Tag tag)
Add a tag that will be invisible forNodeVisitor
instances.org.htmlparser.Tag
createTagNode(org.htmlparser.lexer.Page arg0, int arg1, int arg2, java.util.Vector arg3)
-
-
-
Constructor Detail
-
CmsHtmlTagRemoveFactory
public CmsHtmlTagRemoveFactory()
Create a new factory with all tags registered.
-
-
Method Detail
-
addTagPreserve
public boolean addTagPreserve(org.htmlparser.Tag tag)
Add a tag that will be visible forNodeVisitor
instances.Not only "this" tag will be visible but all parsed Tags that have the same name (case insensitive).
The given tag will be kept as-is. The following behaviour happens if this method is used:
-
Once
has been called all Tags that are not added to this method will be removed. We are in include mode then.addTagPreserve(Tag)
-
The Tags provided to
will only have the power to hide exactly the same tags that are given toaddTagRemoval(Tag)
: Deny is stronger than allow.addTagPreserve(Tag)
- Parameters:
tag
- the tag that will be visible for allNodeVisitor
instances.- Returns:
- true if the tag was added to the internal set of tags to keep, false if not (was contained before, has no name,...).
-
Once
-
addTagRemoval
public boolean addTagRemoval(org.htmlparser.Tag tag)
Add a tag that will be invisible forNodeVisitor
instances.Not only "this" tag will be invisible but all parsed Tags that have the same name (case insensitive).
- Parameters:
tag
- the tag that will be visible for allNodeVisitor
instances.- Returns:
- true if the tag was added to the internal set of tags to remove, false if not (was contained before, has no name,...).
-
createTagNode
public org.htmlparser.Tag createTagNode(org.htmlparser.lexer.Page arg0, int arg1, int arg2, java.util.Vector arg3)
- Specified by:
createTagNode
in interfaceorg.htmlparser.NodeFactory
- Overrides:
createTagNode
in classorg.htmlparser.PrototypicalNodeFactory
- See Also:
PrototypicalNodeFactory.createTagNode(org.htmlparser.lexer.Page, int, int, java.util.Vector)
-
-