Package com.itextpdf.tool.xml
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 boolean
protected final Pipeline<?>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Triggered when parsing is finished and the stream will be closed.protected static void
void
Triggered for comments that are found.protected Tag
Creates a new Tag object from the given parameters.void
endElement
(String tag, String ns) Triggered on a closing tag.protected Tag
Returns the current tag.protected static WorkerContext
Returns the local WorkerContext, beware: could be a newly initialized one, ifclose()
orcloseLocalWC()
has been called before.protected boolean
void
init()
Triggered when parsing has started.void
Triggered on an opening tag.void
This method passes encountered text to the pipeline via thePipeline.content(WorkerContext, Tag, String, ProcessObject)
method.void
unknownText
(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:XMLParserListener
Triggered when parsing has started.- Specified by:
init
in interfaceXMLParserListener
-
startElement
Description copied from interface:XMLParserListener
Triggered on an opening tag.- Specified by:
startElement
in interfaceXMLParserListener
- Parameters:
tag
- the tag of the elementattr
- the attributes found on the tagns
- the namespace or empty String
-
createTag
Creates a new Tag object from the given parameters.- Parameters:
tag
- the tag nameattr
- the attributesns
- the namespace if any- Returns:
- a Tag
-
endElement
Description copied from interface:XMLParserListener
Triggered on a closing tag.- Specified by:
endElement
in 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:
text
in interfaceXMLParserListener
- Parameters:
text
- the text
-
unknownText
Description copied from interface:XMLParserListener
Triggered for text found outside root tag.- Specified by:
unknownText
in interfaceXMLParserListener
- Parameters:
text
- the text
-
comment
Description copied from interface:XMLParserListener
Triggered for comments that are found.- Specified by:
comment
in interfaceXMLParserListener
- 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 interfaceXMLParserListener
-
getCurrentTag
Returns the current tag.- Returns:
- the current tag
-
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()
-