Class HTMLFactory
- java.lang.Object
-
- it.unimi.dsi.parser.HTMLFactory
-
- All Implemented Interfaces:
ParsingFactory
public class HTMLFactory extends Object implements ParsingFactory
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
getElement(MutableString)andgetAttribute(MutableString).This class is a singleton, and its only instance is accessible using the public field
INSTANCE.The relationship between this class and
Element/Attributeis 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
Elements andAttributes and register them locally. The static initialisation code inElementandAttributecreates elements such asElement.Ausing 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 HTMLFactoryINSTANCE
-
Method Summary
Modifier and Type Method Description AttributegetAttribute(MutableString name)Returns theAttributeassociated to a name.ElementgetElement(MutableString name)Returns theElementassociated to a name.EntitygetEntity(MutableString name)Returns theEntityassociated to a name.
-
-
-
Field Detail
-
INSTANCE
public static final HTMLFactory INSTANCE
-
-
Method Detail
-
getElement
public Element getElement(MutableString name)
Description copied from interface:ParsingFactoryReturns theElementassociated to a name.- Specified by:
getElementin interfaceParsingFactory- Parameters:
name- the name of an element type.- Returns:
- the corresponding interned
Elementobject.
-
getAttribute
public Attribute getAttribute(MutableString name)
Description copied from interface:ParsingFactoryReturns theAttributeassociated to a name.- Specified by:
getAttributein interfaceParsingFactory- Parameters:
name- the name of an attribute.- Returns:
- the corresponding interned
Attributeobject.
-
getEntity
public Entity getEntity(MutableString name)
Description copied from interface:ParsingFactoryReturns theEntityassociated to a name.- Specified by:
getEntityin interfaceParsingFactory- Parameters:
name- the name of an entity.- Returns:
- the corresponding interned
Entityobject.
-
-