org.htmlcleaner
Class TagInfo
java.lang.Object
org.htmlcleaner.TagInfo
public class TagInfo
- extends Object
Class contains information about single HTML tag.
It also contains rules for tag balancing. For each tag, list of dependant
tags may be defined. There are several kinds of dependancies used to reorder
tags:
-
fatal tags - required outer tag - the tag will be ignored during
parsing (will be skipped) if this fatal tag is missing. For example, most web
browsers ignore elements TD, TR, TBODY if they are not in the context of TABLE tag.
-
required enclosing tags - if there is no such, it is implicitely
created. For example if TD is out of TR - open TR is created before.
-
forbidden tags - it is not allowed to occure inside - for example
FORM cannot be inside other FORM and it will be ignored during cleanup.
-
allowed children tags - for example TR allowes TD and TH. If there
are some dependant allowed tags defined then cleaner ignores other tags, treating
them as unallowed, unless they are in some other relationship with this tag.
-
higher level tags - for example for TR higher tags are THEAD, TBODY, TFOOT.
-
tags that must be closed and copied - for example, in
<a href="#"><div>....
tag A must be closed before DIV but
copied again inside DIV.
-
tags that must be closed before closing this tag and copied again after -
for example, in
<i><b>at</i> first</b> text
tag B must be closed before closing I, but it must be copied again after resulting
finally in sequence: <i><b>at</b></i><b> first</b> text
.
Tag TR for instance (table row) may define the following dependancies:
- fatal tag is
table
- required enclosing tag is
tbody
- allowed children tags are
td,th
- higher level tags are
thead,tfoot
- tags that muste be closed before are
tr,td,th,caption,colgroup
meaning the following:
tr
must be in context of table
, otherwise it will be ignored,
tr
may can be directly inside tbody
, tfoot
and thead
,
otherwise tbody
will be implicitely created in front of it.
tr
can contain td
and th
, all other tags and content will be pushed out of current
limiting context, in the case of html tables, in front of enclosing table
tag.
- if previous open tag is one of
tr
, caption
or colgroup
, it will be implicitely closed.
Constructor Summary |
TagInfo(String name,
int contentType,
int belongsTo,
boolean depricated,
boolean unique,
boolean ignorePermitted)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HEAD_AND_BODY
protected static final int HEAD_AND_BODY
- See Also:
- Constant Field Values
HEAD
protected static final int HEAD
- See Also:
- Constant Field Values
BODY
protected static final int BODY
- See Also:
- Constant Field Values
CONTENT_ALL
protected static final int CONTENT_ALL
- See Also:
- Constant Field Values
CONTENT_NONE
protected static final int CONTENT_NONE
- See Also:
- Constant Field Values
CONTENT_TEXT
protected static final int CONTENT_TEXT
- See Also:
- Constant Field Values
TagInfo
public TagInfo(String name,
int contentType,
int belongsTo,
boolean depricated,
boolean unique,
boolean ignorePermitted)
defineFatalTags
public void defineFatalTags(String commaSeparatedListOfTags)
defineRequiredEnclosingTags
public void defineRequiredEnclosingTags(String commaSeparatedListOfTags)
defineForbiddenTags
public void defineForbiddenTags(String commaSeparatedListOfTags)
defineAllowedChildrenTags
public void defineAllowedChildrenTags(String commaSeparatedListOfTags)
defineHigherLevelTags
public void defineHigherLevelTags(String commaSeparatedListOfTags)
defineCloseBeforeCopyInsideTags
public void defineCloseBeforeCopyInsideTags(String commaSeparatedListOfTags)
defineCloseInsideCopyAfterTags
public void defineCloseInsideCopyAfterTags(String commaSeparatedListOfTags)
defineCloseBeforeTags
public void defineCloseBeforeTags(String commaSeparatedListOfTags)
getName
public String getName()
setName
public void setName(String name)
getContentType
public int getContentType()
getMustCloseTags
public Set getMustCloseTags()
setMustCloseTags
public void setMustCloseTags(Set mustCloseTags)
getHigherTags
public Set getHigherTags()
setHigherTags
public void setHigherTags(Set higherTags)
getChildTags
public Set getChildTags()
setChildTags
public void setChildTags(Set childTags)
getPermittedTags
public Set getPermittedTags()
setPermittedTags
public void setPermittedTags(Set permittedTags)
getCopyTags
public Set getCopyTags()
setCopyTags
public void setCopyTags(Set copyTags)
getContinueAfterTags
public Set getContinueAfterTags()
setContinueAfterTags
public void setContinueAfterTags(Set continueAfterTags)
getRequiredParent
public String getRequiredParent()
setRequiredParent
public void setRequiredParent(String requiredParent)
getBelongsTo
public int getBelongsTo()
setBelongsTo
public void setBelongsTo(int belongsTo)
getFatalTag
public String getFatalTag()
setFatalTag
public void setFatalTag(String fatalTag)
isDeprecated
public boolean isDeprecated()
setDeprecated
public void setDeprecated(boolean deprecated)
isUnique
public boolean isUnique()
setUnique
public void setUnique(boolean unique)
isIgnorePermitted
public boolean isIgnorePermitted()
isEmptyTag
public boolean isEmptyTag()
setIgnorePermitted
public void setIgnorePermitted(boolean ignorePermitted)
Copyright © 2006-2011. All Rights Reserved.