Home » openjdk-7 » javax » swing » text » rtf » [javadoc | source]
javax.swing.text.rtf
class: RTFReader [javadoc | source]
java.lang.Object
   java.io.OutputStream
      javax.swing.text.rtf.AbstractFilter
         javax.swing.text.rtf.RTFParser
            javax.swing.text.rtf.RTFReader

All Implemented Interfaces:
    Flushable, Closeable

Takes a sequence of RTF tokens and text and appends the text described by the RTF to a StyledDocument (the target). The RTF is lexed from the character stream by the RTFParser which is this class's superclass. This class is an indirect subclass of OutputStream. It must be closed in order to guarantee that all of the text has been sent to the text acceptor.
Nested Class Summary:
interface  RTFReader.Destination  An interface (could be an entirely abstract class) describing a destination. The RTF reader always has a current destination which is where text is sent. 
class  RTFReader.DiscardingDestination  This data-sink class is used to implement ignored destinations (e.g. {\*\blegga blah blah blah} ) It accepts all keywords and text but does nothing with them. 
class  RTFReader.FonttblDestination  Reads the fonttbl group, inserting fonts into the RTFReader's fontTable dictionary. 
class  RTFReader.ColortblDestination  Reads the colortbl group. Upon end-of-group, the RTFReader's color table is set to an array containing the read colors. 
class  RTFReader.StylesheetDestination  Handles the stylesheet keyword. Styles are read and sorted into the three style arrays in the RTFReader. 
class  RTFReader.InfoDestination  Handles the info group. Currently no info keywords are recognized so this is a subclass of DiscardingDestination. 
abstract class  RTFReader.AttributeTrackingDestination  RTFReader.TextHandlingDestination is an abstract RTF destination which simply tracks the attributes specified by the RTF control words in internal form and can produce acceptable AttributeSets for the current character, paragraph, and section attributes. It is up to the subclasses to determine what is done with the actual text. 
abstract class  RTFReader.TextHandlingDestination  RTFReader.TextHandlingDestination provides basic text handling functionality. Subclasses must implement:
deliverText()
to handle a run of text with the same attributes
finishParagraph()
to end the current paragraph and set the paragraph's attributes
endSection()
to end the current section
 
class  RTFReader.DocumentDestination  RTFReader.DocumentDestination is a concrete subclass of TextHandlingDestination which appends the text to the StyledDocument given by the target ivar of the containing RTFReader. 
Field Summary
 StyledDocument target    The object to which the parsed text is sent. 
 Dictionary<Object, Object> parserState    Miscellaneous information about the parser's state. This dictionary is saved and restored when an RTF group begins or ends. 
 Destination rtfDestination    This is the "dst" item from parserState. rtfDestination is the current rtf destination. It is cached in an instance variable for speed. 
 MutableAttributeSet documentAttributes    This holds the current document attributes. 
 Dictionary<Integer, String> fontTable    This Dictionary maps Integer font numbers to String font names. 
 Color[] colorTable    This array maps color indices to Color objects. 
 Style[] characterStyles    This array maps character style numbers to Style objects. 
 Style[] paragraphStyles    This array maps paragraph style numbers to Style objects. 
 Style[] sectionStyles    This array maps section style numbers to Style objects. 
 int rtfversion    This is the RTF version number, extracted from the \rtf keyword. The version information is currently not used. 
 boolean ignoreGroupIfUnknownKeyword    true to indicate that if the next keyword is unknown, the containing group should be ignored. 
 int skippingCharacters    The parameter of the most recently parsed \\ucN keyword, used for skipping alternative representations after a Unicode character. 
static  Dictionary<String, String> textKeywords    textKeywords maps RTF keywords to single-character strings, for those keywords which simply insert some text. 
static final  String TabAlignmentKey     
static final  String TabLeaderKey     
static  Dictionary<String, char> characterSets     
static  boolean useNeXTForAnsi     
Fields inherited from javax.swing.text.rtf.RTFParser:
level,  binaryBuf,  warnings,  rtfSpecialsTable
Fields inherited from javax.swing.text.rtf.AbstractFilter:
translationTable,  specialsTable,  latin1TranslationTable,  noSpecialsTable,  allSpecialsTable
Constructor:
 public RTFReader(StyledDocument destination) 
    Creates a new RTFReader instance. Text will be sent to the specified TextAcceptor.
    Parameters:
    destination - The TextAcceptor which is to receive the text.
Method from javax.swing.text.rtf.RTFReader Summary:
begingroup,   close,   defaultColor,   defineCharacterSet,   endgroup,   getCharacterSet,   handleBinaryBlob,   handleKeyword,   handleKeyword,   handleText,   readCharset,   readCharset,   setCharacterSet,   setRTFDestination
Methods from javax.swing.text.rtf.RTFParser:
begingroup,   close,   endgroup,   flush,   handleBinaryBlob,   handleKeyword,   handleKeyword,   handleText,   handleText,   warning,   write,   write,   writeSpecial
Methods from javax.swing.text.rtf.AbstractFilter:
readFromReader,   readFromStream,   write,   write,   write,   write,   writeSpecial
Methods from java.io.OutputStream:
close,   flush,   write,   write,   write
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.text.rtf.RTFReader Detail:
 public  void begingroup() 
    Called by the superclass when a new RTF group is begun. This implementation saves the current parserState, and gives the current destination a chance to save its own state.
 public  void close() throws IOException 
    Called by the user when there is no more input (i.e., at the end of the RTF file.)
 Color defaultColor() 
    The default color for text which has no specified color.
 public static  void defineCharacterSet(String name,
    char[] table) 
    Adds a character set to the RTFReader's list of known character sets
 public  void endgroup() 
    Called by the superclass when the current RTF group is closed. This restores the parserState saved by begingroup() as well as invoking the endgroup method of the current destination.
 public static Object getCharacterSet(String name) throws IOException 
    Looks up a named character set. A character set is a 256-entry array of characters, mapping unsigned byte values to their Unicode equivalents. The character set is loaded if necessary.
 public  void handleBinaryBlob(byte[] data) 
    Called when the RTFParser encounters a bin keyword in the RTF stream.
 public boolean handleKeyword(String keyword) 
    Handles a parameterless RTF keyword. This is called by the superclass (RTFParser) when a keyword is found in the input stream.
 public boolean handleKeyword(String keyword,
    int parameter) 
    Handles an RTF keyword and its integer parameter. This is called by the superclass (RTFParser) when a keyword is found in the input stream.
 public  void handleText(String text) 
    Handles any pure text (containing no control characters) in the input stream. Called by the superclass.
 static char[] readCharset(InputStream strm) throws IOException 
    Parses a character set from an InputStream. The character set must contain 256 decimal integers, separated by whitespace, with no punctuation. B- and C- style comments are allowed.
 static char[] readCharset(URL href) throws IOException 
 public  void setCharacterSet(String name) 
    setCharacterSet sets the current translation table to correspond with the named character set. The character set is loaded if necessary.
 protected  void setRTFDestination(Destination newDestination)