Package org.fife.ui.rsyntaxtextarea
Class RtfToText
- java.lang.Object
-
- org.fife.ui.rsyntaxtextarea.RtfToText
-
final class RtfToText extends java.lang.ObjectGets the plain text version of RTF documents.This is used by
StyledTextTransferableto return the plain text version of the transferable when the receiver does not support RTF.- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private intblockCountprivate java.lang.StringBuildercontrolWordprivate booleaninControlWordprivate java.io.Readerrprivate java.lang.StringBuildersb
-
Constructor Summary
Constructors Modifier Constructor Description privateRtfToText(java.io.Reader r)Private constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.Stringconvert()Converts the RTF text read from this converter'sReaderinto plain text.private voidendControlWord()Ends a control word.static java.lang.StringgetPlainText(byte[] rtf)Converts the contents of the specified byte array representing an RTF document into plain text.static java.lang.StringgetPlainText(java.io.File file)Converts the contents of the specified RTF file to plain text.static java.lang.StringgetPlainText(java.io.InputStream in)Converts the contents of the specified input stream to plain text.private static java.lang.StringgetPlainText(java.io.Reader r)Converts the contents of the specifiedReaderto plain text.static java.lang.StringgetPlainText(java.lang.String rtf)Converts the contents of the specified String to plain text.private static booleanisUnicodeEscape(java.lang.String controlWord)
-
-
-
Method Detail
-
convert
private java.lang.String convert() throws java.io.IOExceptionConverts the RTF text read from this converter'sReaderinto plain text. It is the caller's responsibility to close the reader after this method is called.- Returns:
- The plain text.
- Throws:
java.io.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
private static boolean isUnicodeEscape(java.lang.String controlWord)
-
getPlainText
public static java.lang.String getPlainText(byte[] rtf) throws java.io.IOExceptionConverts 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:
java.io.IOException- If an IO error occurs.
-
getPlainText
public static java.lang.String getPlainText(java.io.File file) throws java.io.IOExceptionConverts 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:
java.io.IOException- If an IO error occurs.
-
getPlainText
public static java.lang.String getPlainText(java.io.InputStream in) throws java.io.IOExceptionConverts 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:
java.io.IOException- If an IO error occurs.
-
getPlainText
private static java.lang.String getPlainText(java.io.Reader r) throws java.io.IOExceptionConverts the contents of the specifiedReaderto plain text.- Parameters:
r- TheReader. This will be closed when this method returns.- Returns:
- The contents of the
Reader, in plain text. - Throws:
java.io.IOException- If an IO error occurs.
-
getPlainText
public static java.lang.String getPlainText(java.lang.String rtf) throws java.io.IOExceptionConverts 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:
java.io.IOException- If an IO error occurs.
-
-