public class PrototypicalNodeFactory extends java.lang.Object implements java.io.Serializable, NodeFactory
构造器和说明 |
---|
PrototypicalNodeFactory()
Create a new factory with all tags registered.
|
PrototypicalNodeFactory(boolean empty)
Create a new factory.
|
PrototypicalNodeFactory(Tag tag)
Create a new factory with the given tag as the only registered tag.
|
PrototypicalNodeFactory(Tag[] tags)
Create a new factory with the given tags registered.
|
限定符和类型 | 方法和说明 |
---|---|
void |
clear()
Clean out the registry.
|
Remark |
createRemarkNode(Page page,
int start,
int end)
Create a new remark node.
|
Text |
createStringNode(Page page,
int start,
int end)
Create a new string node.
|
Tag |
createTagNode(Page page,
int start,
int end,
java.util.Vector attributes)
Create a new tag node.
|
Tag |
get(java.lang.String id)
Gets a tag from the registry.
|
Remark |
getRemarkPrototype()
Get the object that is cloned to generate remark nodes.
|
java.util.Set |
getTagNames()
Get the list of tag names.
|
Tag |
getTagPrototype()
Get the object that is cloned to generate tag nodes.
|
Text |
getTextPrototype()
Get the object that is cloned to generate text nodes.
|
Tag |
put(java.lang.String id,
Tag tag)
Adds a tag to the registry.
|
void |
registerTag(Tag tag)
Register a tag.
|
PrototypicalNodeFactory |
registerTags()
Register all known tags in the tag package.
|
Tag |
remove(java.lang.String id)
Remove a tag from the registry.
|
void |
setRemarkPrototype(Remark remark)
Set the object to be used to generate remark nodes.
|
void |
setTagPrototype(Tag tag)
Set the object to be used to generate tag nodes.
|
void |
setTextPrototype(Text text)
Set the object to be used to generate text nodes.
|
void |
unregisterTag(Tag tag)
Unregister a tag.
|
public PrototypicalNodeFactory()
PrototypicalNodeFactory(false)
.public PrototypicalNodeFactory(boolean empty)
empty
- If true
, creates an empty factory,
otherwise create a new factory with all tags registered.public PrototypicalNodeFactory(Tag tag)
tag
- The single tag to register in the otherwise empty factory.public PrototypicalNodeFactory(Tag[] tags)
tags
- The tags to register in the otherwise empty factory.public Tag put(java.lang.String id, Tag tag)
id
- The name under which to register the tag.
For proper operation, the id should be uppercase so it
will be matched by a Map lookup.tag
- The tag to be returned from a createTagNode(org.htmlparser.lexer.Page, int, int, java.util.Vector)
call.null
if none.public Tag get(java.lang.String id)
id
- The name of the tag to return.id
name,
or null
if none.public Tag remove(java.lang.String id)
id
- The name of the tag to remove.id
,
or null
if none.public void clear()
public java.util.Set getTagNames()
public void registerTag(Tag tag)
id
that the
tag has (i.e. all names returned by tag.getIds()
.
For proper operation, the ids are converted to uppercase so they will be matched by a Map lookup.
tag
- The tag to register.public void unregisterTag(Tag tag)
id
the tag has.
The ids are converted to uppercase to undo the operation of registerTag.
tag
- The tag to unregister.public PrototypicalNodeFactory registerTags()
tag package
by
calling registerTag()
.public Text getTextPrototype()
Text
nodes.setTextPrototype(org.htmlparser.Text)
public void setTextPrototype(Text text)
text
- The prototype for Text
nodes.
If null
the prototype is set to the default
(TextNode
).getTextPrototype()
public Remark getRemarkPrototype()
Remark
nodes.setRemarkPrototype(org.htmlparser.Remark)
public void setRemarkPrototype(Remark remark)
remark
- The prototype for Remark
nodes.
If null
the prototype is set to the default
(RemarkNode
).getRemarkPrototype()
public Tag getTagPrototype()
createTagNode(org.htmlparser.lexer.Page, int, int, java.util.Vector)
when no
specific tag is found in the list of registered tags.Tag
nodes.setTagPrototype(org.htmlparser.Tag)
public void setTagPrototype(Tag tag)
createTagNode(org.htmlparser.lexer.Page, int, int, java.util.Vector)
when no
specific tag is found in the list of registered tags.tag
- The prototype for Tag
nodes.
If null
the prototype is set to the default
(TagNode
).getTagPrototype()
public Text createStringNode(Page page, int start, int end)
createStringNode
在接口中 NodeFactory
page
- The page the node is on.start
- The beginning position of the string.end
- The ending position of the string.public Remark createRemarkNode(Page page, int start, int end)
createRemarkNode
在接口中 NodeFactory
page
- The page the node is on.start
- The beginning position of the remark.end
- The ending positiong of the remark.public Tag createTagNode(Page page, int start, int end, java.util.Vector attributes)
createTagNode
在接口中 NodeFactory
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.