HTML Parser Home Page

org.htmlparser
Class PrototypicalNodeFactory

java.lang.Object
  extended byorg.htmlparser.PrototypicalNodeFactory
All Implemented Interfaces:
NodeFactory, Serializable
Direct Known Subclasses:
StringNodeFactory

public class PrototypicalNodeFactory
extends Object
implements Serializable, NodeFactory

A node factory based on the prototype pattern. This factory uses the prototype pattern to generate new Tag nodes. Prototype tags, in the form of undifferentiated tags are held in a hash table. On a

See Also:
Serialized Form

Field Summary
protected  Map mBlastocyst
          The list of tags to return at the top level.
 
Constructor Summary
PrototypicalNodeFactory()
          Create a new factory with all but DOM tags registered.
PrototypicalNodeFactory(boolean empty)
          Create a new factory with no registered tags.
PrototypicalNodeFactory(Tag tag)
          Create a new factory with the given tag as the only one registered.
PrototypicalNodeFactory(Tag[] tags)
          Create a new factory with the given tags registered.
 
Method Summary
 void clear()
          Clean out the registry.
 Node createRemarkNode(Page page, int start, int end)
          Create a new remark node.
 Node createStringNode(Page page, int start, int end)
          Create a new string node.
 Node createTagNode(Page page, int start, int end, Vector attributes)
          Create a new tag node.
 Tag get(String id)
          Gets a tag from the registry.
 Tag put(String id, Tag tag)
          Adds a tag to the registry.
 void registerTag(Tag tag)
           
 PrototypicalNodeFactory registerTags()
           
 Tag remove(String id)
          Remove a tag from the registry.
 void unregisterTag(Tag tag)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mBlastocyst

protected Map mBlastocyst
The list of tags to return at the top level. The list is keyed by tag name.

Constructor Detail

PrototypicalNodeFactory

public PrototypicalNodeFactory()
Create a new factory with all but DOM tags registered.


PrototypicalNodeFactory

public PrototypicalNodeFactory(boolean empty)
Create a new factory with no registered tags.


PrototypicalNodeFactory

public PrototypicalNodeFactory(Tag tag)
Create a new factory with the given tag as the only one registered.


PrototypicalNodeFactory

public PrototypicalNodeFactory(Tag[] tags)
Create a new factory with the given tags registered.

Method Detail

put

public Tag put(String id,
               Tag tag)
Adds a tag to the registry.

Parameters:
id - The name under which to register the tag.
tag - The tag to be returned from a createTag(id) call.
Returns:
The tag previously registered with that id, or null if none.

get

public Tag get(String id)
Gets a tag from the registry.

Parameters:
id - The name of the tag to return.
Returns:
The tag registered under the id name or null if none.

remove

public Tag remove(String id)
Remove a tag from the registry.

Parameters:
id - The name of the tag to remove.
Returns:
The tag that was registered with that id.

clear

public void clear()
Clean out the registry.


registerTag

public void registerTag(Tag tag)

unregisterTag

public void unregisterTag(Tag tag)

registerTags

public PrototypicalNodeFactory registerTags()

createStringNode

public Node createStringNode(Page page,
                             int start,
                             int end)
Create a new string node.

Specified by:
createStringNode in interface NodeFactory
Parameters:
page - The page the node is on.
start - The beginning position of the string.
end - The ending positiong of the string.

createRemarkNode

public Node createRemarkNode(Page page,
                             int start,
                             int end)
Create a new remark node.

Specified by:
createRemarkNode in interface NodeFactory
Parameters:
page - The page the node is on.
start - The beginning position of the remark.
end - The ending positiong of the remark.

createTagNode

public Node createTagNode(Page page,
                          int start,
                          int end,
                          Vector attributes)
                   throws ParserException
Create a new tag node. Note that the attributes vector contains at least one element, which is the tag name (standalone attribute) at position zero. This can be used to decide which type of node to create, or gate other processing that may be appropriate.

Specified by:
createTagNode in interface NodeFactory
Parameters:
page - The page the node is on.
start - The beginning position of the tag.
end - The ending positiong of the tag.
attributes - The attributes contained in this tag.
Throws:
ParserException

© 2004 Somik Raha
Mar 14, 2004

HTML Parser is an open source library released under LGPL.
SourceForge.net