Implements an
OutputSegment whose content is a list of attribute name/value pairs.
This output segment is designed to replace the original
Attributes segment in the source,
providing a simple means of adding, modifying and removing attributes.
Each instance of this class contains a java.util.Map of name/value pairs which can either be
specified directly in the constructor or initialised to the same entries as the source
Attributes specified in the constructor.
This map can be accessed via the
AttributesOutputSegment.getMap() method, and its entries modified as required before output.
Keys in the map must be String objects, and values must implement the CharSequence interface.
An attribute with no value is represented by a map entry with a null value.
Attribute values are stored unencoded in the map, and are automatically
if necessary during output.
The use of invalid characters in attribute names results in unspecified behaviour.
Note that methods in the Attributes class treat attribute names as case insensitive,
whereas the Map treats them as case sensitive.
Example of Usage:
Source source=new Source(htmlDocument);
Attributes bodyAttributes
=source.findNextStartTag(0,Tag.BODY).getAttributes();
AttributesOutputSegment bodyAttributesOutputSegment
=new AttributesOutputSegment(bodyAttributes,true);
bodyAttributesOutputSegment.getMap().put("bgcolor","green");
OutputDocument outputDocument=new OutputDocument(source);
outputDocument.register(bodyAttributesOutputSegment);
String htmlDocumentWithGreenBackground=outputDocument.toString();
This class has been removed from the public API and the functionality replaced with the
OutputDocument.replace(AttributesMap) and
OutputDocument#replace(Attributes, boolean convertNamesToLowerCase) methods.
See Also: OutputDocument See Also: Attributes |