Package org.htmlcleaner
Class TagTransformation
java.lang.Object
org.htmlcleaner.TagTransformation
Describes how specified tag is transformed to another one, or is ignored during parsing
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTagTransformation
(String sourceTag) Creates new tag transformation in which specified tag will be skipped (ignored) during parsing process.TagTransformation
(String sourceTag, String destTag) Creates new tag transformation from source tag to target tag preserving all source tag attributes.TagTransformation
(String sourceTag, String destTag, boolean preserveSourceAttributes) Creates new tag transformation from source tag to target tag specifying whether source tag attributes are preserved. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttributePatternTransformation
(Pattern attNamePattern, String transformationDesc) void
addAttributePatternTransformation
(Pattern attNamePattern, Pattern attValuePattern, String transformationDesc) void
addAttributePatternTransformation
(AttributeTransformation attributeTransformation) void
addAttributeTransformation
(String targetAttName) Adds new attribute transformation in which destination attrbute will not exists (simply removes it from list of attributes).void
addAttributeTransformation
(String targetAttName, String transformationDesc) Adds new attribute transformation to this tag transformation.applyTagTransformations
(Map<String, String> attributes) evaluateTemplate
(String template, Map<String, String> variables) Evaluates string template for specified map of variables.(package private) String
(package private) String
(package private) boolean
(package private) boolean
-
Field Details
-
VAR_START
-
VAR_END
-
sourceTag
-
destTag
-
preserveSourceAttributes
private boolean preserveSourceAttributes -
attributeTransformations
-
attributePatternTransformations
-
-
Constructor Details
-
TagTransformation
public TagTransformation() -
TagTransformation
Creates new tag transformation from source tag to target tag specifying whether source tag attributes are preserved.- Parameters:
sourceTag
- Name of the tag to be transformed.destTag
- Name of tag to which source tag is to be transformed.preserveSourceAttributes
- Tells whether source tag attributes are preserved in transformation.
-
TagTransformation
Creates new tag transformation from source tag to target tag preserving all source tag attributes.- Parameters:
sourceTag
- Name of the tag to be transformed.destTag
- Name of tag to which source tag is to be transformed.
-
TagTransformation
Creates new tag transformation in which specified tag will be skipped (ignored) during parsing process.- Parameters:
sourceTag
-
-
-
Method Details
-
addAttributeTransformation
Adds new attribute transformation to this tag transformation. It tells how destination attribute will look like. Small templating mechanism is used to describe attribute value: all names between ${ and } inside the template are evaluated against source tag attributes. That way one can make attribute values consist of mix of source tag attributes.- Parameters:
targetAttName
- Name of the destination attributetransformationDesc
- Template describing attribute value.
-
addAttributePatternTransformation
-
addAttributePatternTransformation
-
addAttributePatternTransformation
- Parameters:
attributeTransformation
-
-
addAttributeTransformation
Adds new attribute transformation in which destination attrbute will not exists (simply removes it from list of attributes).- Parameters:
targetAttName
-
-
hasAttributeTransformations
boolean hasAttributeTransformations() -
getSourceTag
String getSourceTag() -
getDestTag
String getDestTag() -
isPreserveSourceAttributes
boolean isPreserveSourceAttributes() -
getAttributeTransformations
-
applyTagTransformations
- Parameters:
attributes
-
-
evaluateTemplate
Evaluates string template for specified map of variables. Template string can contain dynamic parts in the form of ${VARNAME}. Each such part is replaced with value of the variable if such exists in the map, or with empty string otherwise.- Parameters:
template
- Template stringvariables
- Map of variables (can be null)- Returns:
- Evaluated string
-