com.itextpdf.tool.xml
Class XMLWorker

java.lang.Object
  extended by com.itextpdf.tool.xml.XMLWorker
All Implemented Interfaces:
XMLParserListener

public class XMLWorker
extends Object
implements XMLParserListener

The implementation of the XMLParserListener.
Important Note: This class the XMLWorker stores the WorkerContext (Which is a WorkerContextImpl) in a ThreadLocal variable, WorkerContext is confined to threads here.

Author:
redlab_b

Field Summary
protected  boolean parseHtml
           
protected  Pipeline<?> rootpPipe
           
 
Constructor Summary
XMLWorker(Pipeline<?> pipeline, boolean parseHtml)
          Constructs a new XMLWorker
 
Method Summary
 void close()
          Triggered when parsing is finished and the stream will be closed.
 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  WorkerContext getLocalWC()
          Returns the local WorkerContext, beware: could be a newly initialized one, if close() 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootpPipe

protected final Pipeline<?> rootpPipe

parseHtml

protected final boolean parseHtml
Constructor Detail

XMLWorker

public XMLWorker(Pipeline<?> pipeline,
                 boolean parseHtml)
Constructs a new XMLWorker

Parameters:
pipeline - the pipeline
parseHtml - true if this XMLWorker is parsing HTML, this actually just means: convert all tags to lowercase.
Method Detail

init

public void init()
Description copied from interface: XMLParserListener
Triggered when parsing has started.

Specified by:
init in interface XMLParserListener

startElement

public void startElement(String tag,
                         Map<String,String> attr,
                         String ns)
Description copied from interface: XMLParserListener
Triggered on an opening tag.

Specified by:
startElement in interface XMLParserListener
Parameters:
tag - the tag of the element
attr - the attributes found on the tag
ns - the namespace or empty String

createTag

protected Tag createTag(String tag,
                        Map<String,String> attr,
                        String ns)
Creates a new Tag object from the given parameters.

Parameters:
tag - the tag name
attr - the attributes
ns - the namespace if any
Returns:
a Tag

endElement

public void endElement(String tag,
                       String ns)
Description copied from interface: XMLParserListener
Triggered on a closing tag.

Specified by:
endElement in interface XMLParserListener
Parameters:
tag - the tag
ns - the namespace or empty String

text

public void text(String text)
This method passes encountered text to the pipeline via the Pipeline.content(WorkerContext, Tag, String, ProcessObject) method.

Specified by:
text in interface XMLParserListener
Parameters:
text - the text

unknownText

public void unknownText(String text)
Description copied from interface: XMLParserListener
Triggered for text found outside root tag.

Specified by:
unknownText in interface XMLParserListener
Parameters:
text - the text

comment

public void comment(String comment)
Description copied from interface: XMLParserListener
Triggered for comments that are found.

Specified by:
comment in interface XMLParserListener
Parameters:
comment - the comment

close

public void close()
Description copied from interface: XMLParserListener
Triggered when parsing is finished and the stream will be closed.

Specified by:
close in interface XMLParserListener

getCurrentTag

protected Tag getCurrentTag()
Returns the current tag.

Returns:
the current tag

getLocalWC

protected WorkerContext getLocalWC()
Returns the local WorkerContext, beware: could be a newly initialized one, if close() has been called before.

Returns:
the local WorkerContext

ignoreCdata

protected boolean ignoreCdata()


Copyright © 2015. All Rights Reserved.