📄 cmshtmltagremovefactory.java
字号:
/**
* @see org.htmlparser.Tag#getStartingLineNumber()
*/
public int getStartingLineNumber() {
return m_decorated.getStartingLineNumber();
}
/**
* @see org.htmlparser.Node#getStartPosition()
*/
public int getStartPosition() {
return m_decorated.getStartPosition();
}
/**
* @see org.htmlparser.Tag#getTagName()
*/
public String getTagName() {
return m_decorated.getTagName();
}
/**
* @see org.htmlparser.Node#getText()
*/
public String getText() {
return m_decorated.getText();
}
/**
* @see org.htmlparser.Tag#getThisScanner()
*/
public Scanner getThisScanner() {
return m_decorated.getThisScanner();
}
/**
* @see org.htmlparser.Tag#isEmptyXmlTag()
*/
public boolean isEmptyXmlTag() {
return m_decorated.isEmptyXmlTag();
}
/**
* @see org.htmlparser.Tag#isEndTag()
*/
public boolean isEndTag() {
return m_decorated.isEndTag();
}
/**
* @see org.htmlparser.Tag#removeAttribute(java.lang.String)
*/
public void removeAttribute(String arg0) {
m_decorated.removeAttribute(arg0);
}
/**
* @see org.htmlparser.Tag#setAttribute(java.lang.String, java.lang.String)
*/
public void setAttribute(String arg0, String arg1) {
m_decorated.setAttribute(arg0, arg1);
}
/**
* @see org.htmlparser.Tag#setAttribute(java.lang.String, java.lang.String, char)
*/
public void setAttribute(String arg0, String arg1, char arg2) {
m_decorated.setAttribute(arg0, arg1, arg2);
}
/**
* @see org.htmlparser.Tag#setAttributeEx(org.htmlparser.Attribute)
*/
public void setAttributeEx(Attribute arg0) {
m_decorated.setAttributeEx(arg0);
}
/**
*
* @deprecated
*
* @see org.htmlparser.Tag#setAttributes(java.util.Hashtable)
*/
public void setAttributes(Hashtable arg0) {
m_decorated.setAttributes(arg0);
}
/**
* @see org.htmlparser.Tag#setAttributesEx(java.util.Vector)
*/
public void setAttributesEx(Vector arg0) {
m_decorated.setAttributesEx(arg0);
}
/**
* @see org.htmlparser.Node#setChildren(org.htmlparser.util.NodeList)
*/
public void setChildren(NodeList arg0) {
m_decorated.setChildren(arg0);
}
/**
* @see org.htmlparser.Tag#setEmptyXmlTag(boolean)
*/
public void setEmptyXmlTag(boolean arg0) {
m_decorated.setEmptyXmlTag(arg0);
}
/**
* @see org.htmlparser.Node#setEndPosition(int)
*/
public void setEndPosition(int arg0) {
m_decorated.setEndPosition(arg0);
}
/**
* @see org.htmlparser.Tag#setEndTag(org.htmlparser.Tag)
*/
public void setEndTag(Tag arg0) {
m_decorated.setEndTag(arg0);
}
/**
* @see org.htmlparser.Node#setPage(org.htmlparser.lexer.Page)
*/
public void setPage(Page arg0) {
m_decorated.setPage(arg0);
}
/**
* @see org.htmlparser.Node#setParent(org.htmlparser.Node)
*/
public void setParent(Node arg0) {
m_decorated.setParent(arg0);
}
/**
* @see org.htmlparser.Node#setStartPosition(int)
*/
public void setStartPosition(int arg0) {
m_decorated.setStartPosition(arg0);
}
/**
* @see org.htmlparser.Tag#setTagName(java.lang.String)
*/
public void setTagName(String arg0) {
m_decorated.setTagName(arg0);
}
/**
* @see org.htmlparser.Node#setText(java.lang.String)
*/
public void setText(String arg0) {
m_decorated.setText(arg0);
}
/**
* @see org.htmlparser.Tag#setThisScanner(org.htmlparser.scanners.Scanner)
*/
public void setThisScanner(Scanner arg0) {
m_decorated.setThisScanner(arg0);
}
/**
* @see org.htmlparser.Node#toHtml()
*/
public String toHtml() {
return m_decorated.toHtml();
}
/**
* @see org.htmlparser.Node#toPlainTextString()
*/
public String toPlainTextString() {
return m_decorated.toPlainTextString();
}
/**
* @see org.htmlparser.Node#toString()
*/
public String toString() {
return m_decorated.toString();
}
}
/** The log object for this class. */
private static final Log LOG = CmsLog.getLog(CmsHtmlTagRemoveFactory.class);
/** Generated serial version UID. */
private static final long serialVersionUID = 6961158563666656633L;
/** The tags to hide from the node visitors. */
private Set m_invisibleTags;
/**
* Create a new factory with all tags registered.
* <p>
*
*/
public CmsHtmlTagRemoveFactory() {
super();
m_invisibleTags = new TreeSet();
}
/**
* Add a tag that will be invisible for {@link NodeVisitor} instances.
* <p>
*
* Not only "this" tag will be invisible but all parsed Tags that have the same name (case
* insensitive).
* <p>
*
* @param tag the tag that will be invisible for all {@link NodeVisitor} instances.
*
* @return true if the tag was added to the internal set of tags to remove, false if not (was
* contained before, has no name,...).
*/
public boolean addTagRemoval(Tag tag) {
boolean result = false;
String tagName = tag.getTagName();
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(tagName)) {
result = m_invisibleTags.add(tagName.toLowerCase());
}
return result;
}
/**
* @see org.htmlparser.PrototypicalNodeFactory#createTagNode(org.htmlparser.lexer.Page, int,
* int, java.util.Vector)
*/
public Tag createTagNode(Page arg0, int arg1, int arg2, Vector arg3) {
try {
String tagName = ((Attribute)arg3.get(0)).getName().toLowerCase();
// end tags have names like "/a"....
if (tagName.charAt(0) == '/') {
tagName = tagName.substring(1);
}
Tag result = super.createTagNode(arg0, arg1, arg2, arg3);
if (m_invisibleTags.contains(tagName)) {
result = new CmsInvisibleTag(result);
}
return result;
} catch (RuntimeException rte) {
if (LOG.isErrorEnabled()) {
// log here, as htmlparser 1.5 did swallow exceptions from here and threw NPEs from
// other places
LOG.error(rte);
}
throw rte;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -