public class XMLWorker extends Object implements XMLParserListener
XMLParserListener
.
WorkerContext
(Which is a WorkerContextImpl
) in a ThreadLocal variable, WorkerContext is confined to threads here.
Modifier and Type | Field and Description |
---|---|
protected boolean |
parseHtml |
protected Pipeline> |
rootpPipe |
Constructor and Description |
---|
XMLWorker(Pipeline> pipeline, boolean parseHtml)
Constructs a new XMLWorker
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Triggered when parsing is finished and the stream will be closed.
|
protected static void |
closeLocalWC() |
void |
comment(String comment)
Triggered for comments that are found.
|
protected Tag |
createTag(String tag, Map<String,String> attr, String ns)
Creates a new Tag object from the given parameters.
|
void |
endElement(String tag, String ns)
Triggered on a closing tag.
|
protected Tag |
getCurrentTag()
Returns the current tag.
|
protected static WorkerContext |
getLocalWC()
Returns the local WorkerContext, beware: could be a newly initialized one, if close() or closeLocalWC() has been called before.
|
protected boolean |
ignoreCdata() |
void |
init()
Triggered when parsing has started.
|
void |
startElement(String tag, Map<String,String> attr, String ns)
Triggered on an opening tag.
|
void |
text(String text)
This method passes encountered text to the pipeline via the Pipeline.content(WorkerContext, Tag, String, ProcessObject) method.
|
void |
unknownText(String text)
Triggered for text found outside root tag.
|
protected final Pipeline> rootpPipe
protected final boolean parseHtml
public XMLWorker(Pipeline> pipeline, boolean parseHtml)
pipeline
- the pipeline
parseHtml
- true if this XMLWorker is parsing HTML, this actually just means: convert all tags to lowercase.
public void init()
XMLParserListener
init
in interface XMLParserListener
public void startElement(String tag, Map<String,String> attr, String ns)
XMLParserListener
startElement
in interface XMLParserListener
tag
- the tag of the element
attr
- the attributes found on the tag
ns
- the namespace or empty String
protected Tag createTag(String tag, Map<String,String> attr, String ns)
tag
- the tag name
attr
- the attributes
ns
- the namespace if any
public void endElement(String tag, String ns)
XMLParserListener
endElement
in interface XMLParserListener
tag
- the tag
ns
- the namespace or empty String
public void text(String text)
Pipeline.content(WorkerContext, Tag, String, ProcessObject)
method.
text
in interface XMLParserListener
text
- the text
public void unknownText(String text)
XMLParserListener
unknownText
in interface XMLParserListener
text
- the text
public void comment(String comment)
XMLParserListener
comment
in interface XMLParserListener
comment
- the comment
public void close()
XMLParserListener
close
in interface XMLParserListener
protected Tag getCurrentTag()
protected static WorkerContext getLocalWC()
close()
or closeLocalWC()
has been called before.
protected static void closeLocalWC()
protected boolean ignoreCdata()
Copyright © 2016. All rights reserved.