A parsing factory for (X)HTML.
Warning: for maximum flexibility, the methods of this factory
do not perform case normalisation. If you are parsing HTML, you are invited
to downcase your names before accessing
HTMLFactory.getElement(MutableString)
and
HTMLFactory.getAttribute(MutableString) .
This class is a singleton, and its only instance is accessible using the public field
HTMLFactory.INSTANCE .
The relationship between this class and
Element /
Attribute is a bit
twisted due to the need to accomodate two features:
- (X)HTML interned objects must be accessible directly (see, e.g.,
Element.A );
- (X)HTML interned objects must be put into suitable name-to-object maps.
To this purpose, this class exports packagewise some static factory methods that create
Element s and
Attribute s and register them locally. The static initialisation code in
Element and
Attribute creates elements such as
Element.A using the abovementioned
factory methods.
An alternative implementation could use reflection, but I don't see great advantages.
|