Class OdfTextExtractor
- java.lang.Object
-
- org.odftoolkit.odfdom.dom.DefaultElementVisitor
-
- org.odftoolkit.odfdom.incubator.doc.text.OdfTextExtractor
-
- All Implemented Interfaces:
ElementVisitor
- Direct Known Subclasses:
OdfEditableTextExtractor
public class OdfTextExtractor extends DefaultElementVisitor
It's a sub class of DefaultElementVisitor. It provides a method to get the display text of a single element.If you pass the content root as the parameter, the whole document content will be returned, without any tag information.
It implements part of white space handling fuctions: text:p, text:h, text:s, text:tab, text:linebreak are processed according to ODF specification.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringBuilder
mTextBuilder
protected static char
NewLineChar
protected static char
TabChar
-
Constructor Summary
Constructors Modifier Constructor Description protected
OdfTextExtractor()
Default constructorprotected
OdfTextExtractor(OdfElement element)
Constructor with an ODF element as paramter
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
appendElementText(OdfElement ele)
Append the text content of this element to string buffer.String
getText()
Return the text content as a stringstatic OdfTextExtractor
newOdfTextExtractor(OdfElement element)
An instance of OdfTextExtractor will be created to extract the text content of an ODF element.void
visit(TextHElement ele)
A method to visit "text:h" elementsvoid
visit(TextLineBreakElement ele)
A method to visit "text:line-break" elementsvoid
visit(TextPElement ele)
A method to visit "text:p" elementsvoid
visit(TextSElement ele)
A method to visit "text:s" elementsvoid
visit(TextTabElement ele)
A method to visit "text:tab" elementsvoid
visit(OdfElement element)
Visit odf element and process some operations-
Methods inherited from class org.odftoolkit.odfdom.dom.DefaultElementVisitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
-
-
-
-
Field Detail
-
mTextBuilder
protected StringBuilder mTextBuilder
-
NewLineChar
protected static final char NewLineChar
- See Also:
- Constant Field Values
-
TabChar
protected static final char TabChar
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OdfTextExtractor
protected OdfTextExtractor()
Default constructor
-
OdfTextExtractor
protected OdfTextExtractor(OdfElement element)
Constructor with an ODF element as paramter- Parameters:
element
- the ODF element whose text would be extracted.
-
-
Method Detail
-
appendElementText
protected void appendElementText(OdfElement ele)
Append the text content of this element to string buffer.- Parameters:
ele
- the ODF element whose text will be appended.
-
newOdfTextExtractor
public static OdfTextExtractor newOdfTextExtractor(OdfElement element)
An instance of OdfTextExtractor will be created to extract the text content of an ODF element.- Parameters:
element
- the ODF element whose text will be extracted.- Returns:
- An instance of OdfTextExtractor
-
visit
public void visit(OdfElement element)
Description copied from interface:ElementVisitor
Visit odf element and process some operations- Specified by:
visit
in interfaceElementVisitor
- Specified by:
visit
in classDefaultElementVisitor
- Parameters:
element
- ODF element
-
visit
public void visit(TextPElement ele)
Description copied from class:DefaultElementVisitor
A method to visit "text:p" elements- Overrides:
visit
in classDefaultElementVisitor
- Parameters:
ele
- - an instance of TextPElement
-
visit
public void visit(TextHElement ele)
Description copied from class:DefaultElementVisitor
A method to visit "text:h" elements- Overrides:
visit
in classDefaultElementVisitor
- Parameters:
ele
- - an instance of TextHElement
-
visit
public void visit(TextSElement ele)
Description copied from class:DefaultElementVisitor
A method to visit "text:s" elements- Overrides:
visit
in classDefaultElementVisitor
- Parameters:
ele
- - an instance of TextSElement
-
visit
public void visit(TextTabElement ele)
Description copied from class:DefaultElementVisitor
A method to visit "text:tab" elements- Overrides:
visit
in classDefaultElementVisitor
- Parameters:
ele
- - an instance of TextTabElement
-
visit
public void visit(TextLineBreakElement ele)
Description copied from class:DefaultElementVisitor
A method to visit "text:line-break" elements- Overrides:
visit
in classDefaultElementVisitor
- Parameters:
ele
- - an instance of TextLineBreakElement
-
getText
public String getText()
Return the text content as a string- Returns:
- the text content as a string
-
-