HTML.Attribute
is not Serializable
. For some reason Java developers decided not to add serialization support to HTML.Attribute
as well as HTML.Tag
. The most probable reason is that HTMLDocument
which uses them is serialized into HTML text, and thus there's no need to serialize Java objects directly.
It's easy to fix, really. Create your own attribute:
public final class LinkAttribute implements Serializable {
private static final long serialVersionUID = -472010305643114209L;
public static final LinkAttribute HREF = new LinkAttribute("href");
private final String name;
private LinkAttribute(final String name) {
this.name = name;
}
public boolean equals(final Object o) {
return o instanceof LinkAttribute
? name.equals(((LinkAttribute) o).name)
: false;
}
public int hashCode() {
return name.hashCode();
}
public String toString() {
return name;
}
}
This is roughly the implementation of HTML.Attribute
class, with Serializable
interface added.
Use LinkAttribute.HREF
everywhere you used HTML.Attribute.HREF
.