public class CleanerProperties extends Object implements HtmlModificationListener
Modifier and Type | Field and Description |
---|---|
static String |
BOOL_ATT_EMPTY |
static String |
BOOL_ATT_SELF |
static String |
BOOL_ATT_TRUE |
static String |
DEFAULT_CHARSET |
Constructor and Description |
---|
CleanerProperties() |
CleanerProperties(ITagInfoProvider tagInfoProvider) |
Modifier and Type | Method and Description |
---|---|
void |
addHtmlModificationListener(HtmlModificationListener listener)
Adds a listener to the list of objects that will be notified about changes that
cleaner does during cleanup process.
|
void |
addPruneTagNodeCondition(ITagNodeCondition condition)
Adds the condition to existing prune tag set.
|
void |
fireConditionModification(ITagNodeCondition condition,
TagNode tagNode)
Fired when cleaner modifies html due to
ITagNodeCondition match. |
void |
fireHtmlError(boolean certainty,
TagNode startTagToken,
ErrorType type)
Fired when cleaner fixes some error in html syntax.
|
void |
fireUglyHtml(boolean certainty,
TagNode startTagToken,
ErrorType errorType)
Fired when cleaner fixes ugly html -- when syntax was correct but task was implemented by weird code.
|
void |
fireUserDefinedModification(boolean certainty,
TagNode tagNode,
ErrorType errorType)
Fired when cleaner modifies html due to user specified rules.
|
String |
getAllowTags() |
Set<ITagNodeCondition> |
getAllowTagSet() |
String |
getBooleanAttributeValues() |
String |
getCharset() |
CleanerTransformations |
getCleanerTransformations() |
int |
getHtmlVersion()
Return the html version
|
String |
getHyphenReplacementInComment() |
String |
getInvalidXmlAttributeNamePrefix()
Get the prefix to use to try to make valid attribute names
|
String |
getPruneTags() |
Set<ITagNodeCondition> |
getPruneTagSet() |
ITagInfoProvider |
getTagInfoProvider() |
String |
getUseCdataFor() |
boolean |
isAddNewlineToHeadAndBody() |
boolean |
isAdvancedXmlEscape() |
boolean |
isAllowHtmlInsideAttributes() |
boolean |
isAllowInvalidAttributeNames()
If false, when outputting XML, if an attribute name is not valid, attempt to
fix it by using a prefix and removing invalid characters.
|
boolean |
isAllowMultiWordAttributes() |
boolean |
isDeserializeEntities() |
boolean |
isIgnoreQuestAndExclam() |
boolean |
isKeepWhitespaceAndCommentsInHead() |
boolean |
isNamespacesAware() |
boolean |
isOmitCdataOutsideScriptAndStyle() |
boolean |
isOmitComments() |
boolean |
isOmitDeprecatedTags() |
boolean |
isOmitDoctypeDeclaration() |
boolean |
isOmitHtmlEnvelope() |
boolean |
isOmitUnknownTags() |
boolean |
isOmitXmlDeclaration() |
boolean |
isRecognizeUnicodeChars() |
boolean |
isTranslateSpecialEntities() |
boolean |
isTransResCharsToNCR() |
boolean |
isTransSpecialEntitiesToNCR() |
boolean |
isTreatDeprecatedTagsAsContent() |
boolean |
isTreatUnknownTagsAsContent() |
boolean |
isTrimAttributeValues() |
boolean |
isUseCdataFor(String useCdataFor) |
boolean |
isUseCdataForScriptAndStyle() |
boolean |
isUseEmptyElementTags() |
void |
reset()
advancedXmlEscape = true;
setUseCdataFor("script,style");
translateSpecialEntities = true;
recognizeUnicodeChars = true;
omitUnknownTags = false;
treatUnknownTagsAsContent = false;
omitDeprecatedTags = false;
treatDeprecatedTagsAsContent = false;
omitComments = false;
omitXmlDeclaration = OptionalOutput.alwaysOutput;
omitDoctypeDeclaration = OptionalOutput.alwaysOutput;
omitHtmlEnvelope = OptionalOutput.alwaysOutput;
useEmptyElementTags = true;
allowMultiWordAttributes = true;
allowHtmlInsideAttributes = false;
ignoreQuestAndExclam = true;
namespacesAware = true;
keepHeadWhitespace = true;
addNewlineToHeadAndBody = true;
hyphenReplacementInComment = "=";
pruneTags = null;
allowTags = null;
booleanAttributeValues = BOOL_ATT_SELF;
collapseNullHtml = CollapseHtml.none
charset = "UTF-8";
trimAttributeValues = true;
tagInfoProvider = HTML5TagProvider.INSTANCE
|
void |
setAddNewlineToHeadAndBody(boolean addNewlineToHeadAndBody) |
void |
setAdvancedXmlEscape(boolean advancedXmlEscape) |
void |
setAllowHtmlInsideAttributes(boolean allowHtmlInsideAttributes) |
void |
setAllowInvalidAttributeNames(boolean allowInvalidAttributeNames)
Set whether to allow invalid attribute names, or to try to fix or omit them
|
void |
setAllowMultiWordAttributes(boolean allowMultiWordAttributes) |
void |
setAllowTags(String allowTags) |
void |
setBooleanAttributeValues(String booleanAttributeValues) |
void |
setCharset(String charset) |
void |
setCleanerTransformations(CleanerTransformations cleanerTransformations) |
void |
setDeserializeEntities(boolean deserializeEntities) |
void |
setHtmlVersion(int version)
Sets the html version according to the parameter.Also,it sets the
tag provider to the appropriate version.
|
void |
setHyphenReplacementInComment(String hyphenReplacementInComment) |
void |
setIgnoreQuestAndExclam(boolean ignoreQuestAndExclam) |
void |
setInvalidXmlAttributeNamePrefix(String invalidXmlAttributePrefix)
Sets the prefix to use for xml attributes that are invalid
|
void |
setKeepWhitespaceAndCommentsInHead(boolean keepHeadWhitespace) |
void |
setNamespacesAware(boolean namespacesAware) |
void |
setOmitCdataOutsideScriptAndStyle(boolean value) |
void |
setOmitComments(boolean omitComments) |
void |
setOmitDeprecatedTags(boolean omitDeprecatedTags) |
void |
setOmitDoctypeDeclaration(boolean omitDoctypeDeclaration) |
void |
setOmitHtmlEnvelope(boolean omitHtmlEnvelope) |
void |
setOmitUnknownTags(boolean omitUnknownTags) |
void |
setOmitXmlDeclaration(boolean omitXmlDeclaration) |
void |
setPruneTags(String pruneTags)
Resets prune tags set and adds tag name conditions to it.
|
void |
setRecognizeUnicodeChars(boolean recognizeUnicodeChars) |
void |
setTranslateSpecialEntities(boolean translateSpecialEntities)
TODO : use
OptionalOutput |
void |
setTransResCharsToNCR(boolean transResCharsToNCR) |
void |
setTransSpecialEntitiesToNCR(boolean transSpecialEntitiesToNCR) |
void |
setTreatDeprecatedTagsAsContent(boolean treatDeprecatedTagsAsContent) |
void |
setTreatUnknownTagsAsContent(boolean treatUnknownTagsAsContent) |
void |
setTrimAttributeValues(boolean trimAttributeValues) |
void |
setUseCdataFor(String useCdataFor) |
void |
setUseCdataForScriptAndStyle(boolean useCdataForScriptAndStyle) |
void |
setUseEmptyElementTags(boolean useEmptyElementTags) |
public static final String DEFAULT_CHARSET
public static final String BOOL_ATT_SELF
public static final String BOOL_ATT_EMPTY
public static final String BOOL_ATT_TRUE
public CleanerProperties()
public CleanerProperties(ITagInfoProvider tagInfoProvider)
tagInfoProvider
- public ITagInfoProvider getTagInfoProvider()
public boolean isAdvancedXmlEscape()
public void setAdvancedXmlEscape(boolean advancedXmlEscape)
public boolean isTransResCharsToNCR()
public void setTransResCharsToNCR(boolean transResCharsToNCR)
public boolean isUseCdataForScriptAndStyle()
public void setUseCdataForScriptAndStyle(boolean useCdataForScriptAndStyle)
public void setUseCdataFor(String useCdataFor)
public String getUseCdataFor()
public boolean isUseCdataFor(String useCdataFor)
public boolean isTranslateSpecialEntities()
public void setTranslateSpecialEntities(boolean translateSpecialEntities)
OptionalOutput
translateSpecialEntities
- public boolean isRecognizeUnicodeChars()
public void setRecognizeUnicodeChars(boolean recognizeUnicodeChars)
public boolean isOmitUnknownTags()
public void setOmitUnknownTags(boolean omitUnknownTags)
public boolean isTreatUnknownTagsAsContent()
public void setTreatUnknownTagsAsContent(boolean treatUnknownTagsAsContent)
public boolean isOmitDeprecatedTags()
public void setOmitDeprecatedTags(boolean omitDeprecatedTags)
public boolean isTreatDeprecatedTagsAsContent()
public void setTreatDeprecatedTagsAsContent(boolean treatDeprecatedTagsAsContent)
public boolean isOmitComments()
public void setOmitComments(boolean omitComments)
public boolean isOmitXmlDeclaration()
public void setOmitXmlDeclaration(boolean omitXmlDeclaration)
public boolean isOmitDoctypeDeclaration()
public void setOmitDoctypeDeclaration(boolean omitDoctypeDeclaration)
public boolean isOmitHtmlEnvelope()
public void setOmitHtmlEnvelope(boolean omitHtmlEnvelope)
public boolean isUseEmptyElementTags()
public void setUseEmptyElementTags(boolean useEmptyElementTags)
public boolean isAllowMultiWordAttributes()
public void setAllowMultiWordAttributes(boolean allowMultiWordAttributes)
public boolean isAllowHtmlInsideAttributes()
public void setAllowHtmlInsideAttributes(boolean allowHtmlInsideAttributes)
public boolean isIgnoreQuestAndExclam()
public void setIgnoreQuestAndExclam(boolean ignoreQuestAndExclam)
public boolean isNamespacesAware()
public void setNamespacesAware(boolean namespacesAware)
public boolean isAddNewlineToHeadAndBody()
public void setAddNewlineToHeadAndBody(boolean addNewlineToHeadAndBody)
public boolean isKeepWhitespaceAndCommentsInHead()
public void setKeepWhitespaceAndCommentsInHead(boolean keepHeadWhitespace)
public String getHyphenReplacementInComment()
public void setHyphenReplacementInComment(String hyphenReplacementInComment)
public String getPruneTags()
public boolean isOmitCdataOutsideScriptAndStyle()
public void setOmitCdataOutsideScriptAndStyle(boolean value)
public boolean isDeserializeEntities()
public void setDeserializeEntities(boolean deserializeEntities)
public void setHtmlVersion(int version)
version
- Number 4 for html4 or 5 for html5public int getHtmlVersion()
public boolean isTrimAttributeValues()
public void setTrimAttributeValues(boolean trimAttributeValues)
public void setPruneTags(String pruneTags)
pruneTags
- public void addPruneTagNodeCondition(ITagNodeCondition condition)
condition
- public Set<ITagNodeCondition> getPruneTagSet()
public String getAllowTags()
public void setAllowTags(String allowTags)
public boolean isTransSpecialEntitiesToNCR()
public void setTransSpecialEntitiesToNCR(boolean transSpecialEntitiesToNCR)
public Set<ITagNodeCondition> getAllowTagSet()
public void setCharset(String charset)
charset
- the charset to setpublic String getCharset()
public String getBooleanAttributeValues()
public void setBooleanAttributeValues(String booleanAttributeValues)
public void reset()
public CleanerTransformations getCleanerTransformations()
public void setCleanerTransformations(CleanerTransformations cleanerTransformations)
public void addHtmlModificationListener(HtmlModificationListener listener)
listener
- -- listener object to be notified of the changes.public void fireConditionModification(ITagNodeCondition condition, TagNode tagNode)
HtmlModificationListener
ITagNodeCondition
match.fireConditionModification
in interface HtmlModificationListener
condition
- that was applied to make the modificationtagNode
- - problematic node.public void fireHtmlError(boolean certainty, TagNode startTagToken, ErrorType type)
HtmlModificationListener
fireHtmlError
in interface HtmlModificationListener
certainty
- - true if change made doesn't hurts end document.startTagToken
- - problematic node.public void fireUglyHtml(boolean certainty, TagNode startTagToken, ErrorType errorType)
HtmlModificationListener
fireUglyHtml
in interface HtmlModificationListener
certainty
- - true if change made doesn't hurts end document.startTagToken
- - problematic node.public void fireUserDefinedModification(boolean certainty, TagNode tagNode, ErrorType errorType)
HtmlModificationListener
fireUserDefinedModification
in interface HtmlModificationListener
certainty
- - true if change made doesn't hurts end document.tagNode
- - problematic node.public String getInvalidXmlAttributeNamePrefix()
public void setInvalidXmlAttributeNamePrefix(String invalidXmlAttributePrefix)
invalidXmlAttributePrefix
- public void setAllowInvalidAttributeNames(boolean allowInvalidAttributeNames)
allowInvalidAttributeNames
- public boolean isAllowInvalidAttributeNames()
Copyright © 2006–2018. All rights reserved.