Class XMLWorker
java.lang.Object
com.itextpdf.tool.xml.XMLWorker
- All Implemented Interfaces:
XMLParserListener
The implementation of the
Important Note: This class the XMLWorker stores 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.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static ThreadLocal<WorkerContextImpl> protected final booleanprotected final Pipeline<?> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Triggered when parsing is finished and the stream will be closed.protected static voidvoidTriggered for comments that are found.protected TagCreates a new Tag object from the given parameters.voidendElement(String tag, String ns) Triggered on a closing tag.protected TagReturns the current tag.protected static WorkerContextReturns the local WorkerContext, beware: could be a newly initialized one, ifclose()orcloseLocalWC()has been called before.protected booleanvoidinit()Triggered when parsing has started.voidTriggered on an opening tag.voidThis method passes encountered text to the pipeline via thePipeline.content(WorkerContext, Tag, String, ProcessObject)method.voidunknownText(String text) Triggered for text found outside root tag.
-
Field Details
-
rootpPipe
-
context
-
parseHtml
protected final boolean parseHtml
-
-
Constructor Details
-
XMLWorker
Constructs a new XMLWorker- Parameters:
pipeline- the pipelineparseHtml- true if this XMLWorker is parsing HTML, this actually just means: convert all tags to lowercase.
-
-
Method Details
-
init
public void init()Description copied from interface:XMLParserListenerTriggered when parsing has started.- Specified by:
initin interfaceXMLParserListener
-
startElement
Description copied from interface:XMLParserListenerTriggered on an opening tag.- Specified by:
startElementin interfaceXMLParserListener- Parameters:
tag- the tag of the elementattr- the attributes found on the tagns- the namespace or empty String
-
createTag
-
endElement
Description copied from interface:XMLParserListenerTriggered on a closing tag.- Specified by:
endElementin interfaceXMLParserListener- Parameters:
tag- the tagns- the namespace or empty String
-
text
This method passes encountered text to the pipeline via thePipeline.content(WorkerContext, Tag, String, ProcessObject)method.- Specified by:
textin interfaceXMLParserListener- Parameters:
text- the text
-
unknownText
Description copied from interface:XMLParserListenerTriggered for text found outside root tag.- Specified by:
unknownTextin interfaceXMLParserListener- Parameters:
text- the text
-
comment
Description copied from interface:XMLParserListenerTriggered for comments that are found.- Specified by:
commentin interfaceXMLParserListener- Parameters:
comment- the comment
-
close
public void close()Description copied from interface:XMLParserListenerTriggered when parsing is finished and the stream will be closed.- Specified by:
closein interfaceXMLParserListener
-
getCurrentTag
-
getLocalWC
Returns the local WorkerContext, beware: could be a newly initialized one, ifclose()orcloseLocalWC()has been called before.- Returns:
- the local WorkerContext
-
closeLocalWC
protected static void closeLocalWC() -
ignoreCdata
protected boolean ignoreCdata()
-