Package org.fife.ui.rsyntaxtextarea
Class RtfToText
java.lang.Object
org.fife.ui.rsyntaxtextarea.RtfToText
Gets the plain text version of RTF documents.
This is used by StyledTextTransferable
to return the plain text
version of the transferable when the receiver does not support RTF.
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private StringBuilder
private boolean
private Reader
private StringBuilder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
convert()
Converts the RTF text read from this converter'sReader
into plain text.private void
Ends a control word.static String
getPlainText
(byte[] rtf) Converts the contents of the specified byte array representing an RTF document into plain text.static String
getPlainText
(File file) Converts the contents of the specified RTF file to plain text.static String
Converts the contents of the specified input stream to plain text.private static String
Converts the contents of the specifiedReader
to plain text.static String
getPlainText
(String rtf) Converts the contents of the specified String to plain text.private static boolean
isUnicodeEscape
(String controlWord)
-
Field Details
-
r
-
sb
-
controlWord
-
blockCount
private int blockCount -
inControlWord
private boolean inControlWord
-
-
Constructor Details
-
RtfToText
Private constructor.- Parameters:
r
- The reader to read RTF text from.
-
-
Method Details
-
convert
Converts the RTF text read from this converter'sReader
into plain text. It is the caller's responsibility to close the reader after this method is called.- Returns:
- The plain text.
- Throws:
IOException
- If an IO error occurs.
-
endControlWord
private void endControlWord()Ends a control word. Checks whether it is a common one that affects the plain text output (such as "par
" or "tab
") and updates the text buffer accordingly. -
isUnicodeEscape
-
getPlainText
Converts the contents of the specified byte array representing an RTF document into plain text.- Parameters:
rtf
- The byte array representing an RTF document.- Returns:
- The contents of the RTF document, in plain text.
- Throws:
IOException
- If an IO error occurs.
-
getPlainText
Converts the contents of the specified RTF file to plain text.- Parameters:
file
- The RTF file to convert.- Returns:
- The contents of the file, in plain text.
- Throws:
IOException
- If an IO error occurs.
-
getPlainText
Converts the contents of the specified input stream to plain text. The input stream will be closed when this method returns.- Parameters:
in
- The input stream to convert. This will be closed when this method returns.- Returns:
- The contents of the stream, in plain text.
- Throws:
IOException
- If an IO error occurs.
-
getPlainText
Converts the contents of the specifiedReader
to plain text.- Parameters:
r
- TheReader
. This will be closed when this method returns.- Returns:
- The contents of the
Reader
, in plain text. - Throws:
IOException
- If an IO error occurs.
-
getPlainText
Converts the contents of the specified String to plain text.- Parameters:
rtf
- A string whose contents represent an RTF document.- Returns:
- The contents of the String, in plain text.
- Throws:
IOException
- If an IO error occurs.
-