2362N/A * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * <b>RTFParser</b> is a subclass of <b>AbstractFilter</b> which understands basic RTF syntax 0N/A * and passes a stream of control words, text, and begin/end group 0N/A * indications to its subclass. 0N/A * Normally programmers will only use <b>RTFFilter</b>, a subclass of this class that knows what to 0N/A * do with the tokens this class parses. 0N/A * @see AbstractFilter 0N/A /** The current RTF group nesting level. */ 0N/A // read their parameters 0N/A /** A stream to which to write warnings and debugging information 0N/A * while parsing. This is set to <code>System.out</code> to log 0N/A * any anomalous information to stdout. */ 0N/A // value for the 'state' variable 0N/A private final int S_text =
0;
// reading random text 0N/A private final int S_token =
2;
// reading a multicharacter token 0N/A /** Implemented by subclasses to interpret a parameter-less RTF keyword. 0N/A * The keyword is passed without the leading '/' or any delimiting 0N/A /** Implemented by subclasses to interpret a keyword with a parameter. 0N/A * @param keyword The keyword, as with <code>handleKeyword(String)</code>. 0N/A * @param parameter The parameter following the keyword. */ 0N/A /** Implemented by subclasses to interpret text from the RTF stream. */ 0N/A /** Implemented by subclasses to handle the contents of the \bin keyword. */ 0N/A /** Implemented by subclasses to react to an increase 0N/A * in the nesting level. */ 0N/A /** Implemented by subclasses to react to the end of a group. */ 0N/A // table of non-text characters in rtf 0N/A //warnings = System.out; 0N/A // TODO: Handle wrapup at end of file correctly. 0N/A break;
// unadorned newlines are ignored 0N/A /* currentCharacters is already an empty stringBuffer */ 0N/A // Parameter following? 0N/A // Non-space delimiters get included in the text 0N/A /* TODO: Test correct behavior of \bin keyword */ 0N/A // Delimiters here are interpreted as text too 0N/A /** Flushes any buffered but not yet written characters. 0N/A * Subclasses which override this method should call this 0N/A * method <em>before</em> flushing 0N/A * any of their own buffers. */ 0N/A /** Closes the parser. Currently, this simply does a <code>flush()</code>, 0N/A * followed by some minimal consistency checks. */ 0N/A /* TODO: any sane way to handle termination in a non-S_text state? */ 0N/A /* this will cause subclasses to behave more reasonably