it.unimi.dsi.parser
Class HTMLFactory

java.lang.Object
  extended by 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) 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:

To this purpose, this class exports packagewise some static factory methods that create Elements and Attributes 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
static HTMLFactory INSTANCE
           
 
Method Summary
 Attribute getAttribute(MutableString name)
          Returns the Attribute associated to a name.
 Element getElement(MutableString name)
          Returns the Element associated to a name.
 Entity getEntity(MutableString name)
          Returns the Entity associated to a name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final HTMLFactory INSTANCE
Method Detail

getElement

public Element getElement(MutableString name)
Description copied from interface: ParsingFactory
Returns the Element associated to a name.

Specified by:
getElement in interface ParsingFactory
Parameters:
name - the name of an element type.
Returns:
the corresponding interned Element object.

getAttribute

public Attribute getAttribute(MutableString name)
Description copied from interface: ParsingFactory
Returns the Attribute associated to a name.

Specified by:
getAttribute in interface ParsingFactory
Parameters:
name - the name of an attribute.
Returns:
the corresponding interned Attribute object.

getEntity

public Entity getEntity(MutableString name)
Description copied from interface: ParsingFactory
Returns the Entity associated to a name.

Specified by:
getEntity in interface ParsingFactory
Parameters:
name - the name of an entity.
Returns:
the corresponding interned Entity object.