Class HTMLFactory
- All Implemented Interfaces:
ParsingFactory
public class HTMLFactory extends Object implements ParsingFactory
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 getElement(MutableString)
and getAttribute(MutableString)
.
This class is a singleton, and its only instance is accessible using the public field
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.
-
Field Summary
Fields Modifier and Type Field Description static HTMLFactory
INSTANCE
-
Method Summary
Modifier and Type Method Description Attribute
getAttribute(MutableString name)
Returns theAttribute
associated to a name.Element
getElement(MutableString name)
Returns theElement
associated to a name.Entity
getEntity(MutableString name)
Returns theEntity
associated to a name.
-
Field Details
-
Method Details
-
getElement
Description copied from interface:ParsingFactory
Returns theElement
associated to a name.- Specified by:
getElement
in interfaceParsingFactory
- Parameters:
name
- the name of an element type.- Returns:
- the corresponding interned
Element
object.
-
getAttribute
Description copied from interface:ParsingFactory
Returns theAttribute
associated to a name.- Specified by:
getAttribute
in interfaceParsingFactory
- Parameters:
name
- the name of an attribute.- Returns:
- the corresponding interned
Attribute
object.
-
getEntity
Description copied from interface:ParsingFactory
Returns theEntity
associated to a name.- Specified by:
getEntity
in interfaceParsingFactory
- Parameters:
name
- the name of an entity.- Returns:
- the corresponding interned
Entity
object.
-