aboutsummaryrefslogtreecommitdiff
path: root/libjava/javax
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2005-04-19 09:24:15 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2005-04-19 09:24:15 +0000
commitf5c273065a35be668be2c935b31be04d8a2c1198 (patch)
tree9d26de755a19328b162906526f1ff15d2854f2fd /libjava/javax
parent2b22418b2b79b3181606e48aed3fcaf330ec70c5 (diff)
downloadgcc-f5c273065a35be668be2c935b31be04d8a2c1198.zip
gcc-f5c273065a35be668be2c935b31be04d8a2c1198.tar.gz
gcc-f5c273065a35be668be2c935b31be04d8a2c1198.tar.bz2
ControlWordToken.java, [...]: New files.
2005-04-19 Michael Koch <konqueror@gmx.de> * javax/swing/text/rtf/ControlWordToken.java, javax/swing/text/rtf/RTFEditorKit.java, javax/swing/text/rtf/RTFParseException.java, javax/swing/text/rtf/RTFParser.java, javax/swing/text/rtf/RTFScanner.java, javax/swing/text/rtf/TextToken.java, javax/swing/text/rtf/Token.java: New files. * Makefile.am: Added new files. * Makefile.in: Regenerated. From-SVN: r98393
Diffstat (limited to 'libjava/javax')
-rw-r--r--libjava/javax/swing/text/rtf/ControlWordToken.java86
-rw-r--r--libjava/javax/swing/text/rtf/RTFEditorKit.java114
-rw-r--r--libjava/javax/swing/text/rtf/RTFParseException.java65
-rw-r--r--libjava/javax/swing/text/rtf/RTFParser.java195
-rw-r--r--libjava/javax/swing/text/rtf/RTFScanner.java268
-rw-r--r--libjava/javax/swing/text/rtf/TextToken.java65
-rw-r--r--libjava/javax/swing/text/rtf/Token.java91
7 files changed, 884 insertions, 0 deletions
diff --git a/libjava/javax/swing/text/rtf/ControlWordToken.java b/libjava/javax/swing/text/rtf/ControlWordToken.java
new file mode 100644
index 0000000..043cae4
--- /dev/null
+++ b/libjava/javax/swing/text/rtf/ControlWordToken.java
@@ -0,0 +1,86 @@
+/* ControlWordToken.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text.rtf;
+
+/**
+ * A special {@link Token} that represents a control word in RTF like
+ * '\deff0' where 'deff' is the name of the control word and '0' is an
+ * optional parameter.
+ *
+ * @author Roman Kennke (roman@ontographics.com)
+ */
+class ControlWordToken extends Token
+{
+
+ /**
+ * The name of the control word.
+ */
+ public String name;
+
+ /**
+ * The optional parameter of the control word. Absence of a parameter is
+ * expressed through Integer.MIN_VALUE.
+ */
+ public int param;
+
+ /**
+ * Constructs a new ControlWordToken with the specified name and without
+ * a parameter.
+ *
+ * @param name the name of the control word
+ */
+ public ControlWordToken(String name)
+ {
+ this(name, Integer.MIN_VALUE);
+ }
+
+
+ /**
+ * Constructs a new ControlWordToken with the specified name and parameter.
+ *
+ * @param name the name of the control word
+ */
+ public ControlWordToken(String name, int param)
+ {
+ super(Token.CONTROL_WORD);
+ this.name = name;
+ this.param = param;
+ }
+
+}
diff --git a/libjava/javax/swing/text/rtf/RTFEditorKit.java b/libjava/javax/swing/text/rtf/RTFEditorKit.java
new file mode 100644
index 0000000..8a6e88a
--- /dev/null
+++ b/libjava/javax/swing/text/rtf/RTFEditorKit.java
@@ -0,0 +1,114 @@
+/* RTFEditorKit.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text.rtf;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.StyledEditorKit;
+
+/**
+ * Provides support for RTF data for use in
+ * {@link javax.swing.JEditorPane}s.
+ *
+ * @author Roman Kennke (roman@ontographics.com)
+ */
+public class RTFEditorKit
+ extends StyledEditorKit
+{
+
+ /**
+ * Constructs a new RTFEditorKit.
+ */
+ public RTFEditorKit()
+ {
+ super();
+ }
+
+ /**
+ * Returns the MIME content type. In the case of RTFEditorKit this is
+ * &apos;text/rtf&apos;
+ *
+ * @return the MIME content type for RTFEditorKit
+ */
+ public String getContentType()
+ {
+ return "text/rtf";
+ }
+
+ /**
+ * Reads RTF data from <code>stream</code> into <code>doc</code> at the
+ * specified position <code>pos</code>.
+ *
+ * @param stream the {@link InputStream} from where we read RTF data
+ * @param doc the {@link Document} into which we read the RTF data
+ * @param pos the position where to start
+ *
+ * @throws IOException if an IO error occurs
+ * @throws BadLocationException if the position is not valid
+ */
+ public void read(InputStream stream, Document doc, int pos)
+ throws IOException, BadLocationException
+ {
+ RTFParser parser = new RTFParser(stream, doc, pos);
+ parser.parse();
+ }
+
+
+ /**
+ * Reads RTF data from <code>reader</code> into <code>doc</code> at the
+ * specified position <code>pos</code>.
+ *
+ * @param reader the {@link Reader} from where we read RTF data
+ * @param doc the {@link Document} into which we read the RTF data
+ * @param pos the position where to start
+ *
+ * @throws IOException if an IO error occurs
+ * @throws BadLocationException if the position is not valid
+ */
+ public void read(Reader reader, Document doc, int pos)
+ throws IOException, BadLocationException
+ {
+ RTFParser parser = new RTFParser(reader, doc, pos);
+ parser.parse();
+ }
+}
diff --git a/libjava/javax/swing/text/rtf/RTFParseException.java b/libjava/javax/swing/text/rtf/RTFParseException.java
new file mode 100644
index 0000000..dba51d2
--- /dev/null
+++ b/libjava/javax/swing/text/rtf/RTFParseException.java
@@ -0,0 +1,65 @@
+/* RTFParseException.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text.rtf;
+
+/**
+ * Indicates a parsing error during RTF processing.
+ *
+ * @author Roman Kennke (roman@ontographics.com)
+ */
+class RTFParseException
+ extends RuntimeException
+{
+ /**
+ * Constructs a new RTFParseException without message.
+ */
+ public RTFParseException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new RTFParseException with the specified message.
+ */
+ public RTFParseException(String message)
+ {
+ super(message);
+ }
+
+}
diff --git a/libjava/javax/swing/text/rtf/RTFParser.java b/libjava/javax/swing/text/rtf/RTFParser.java
new file mode 100644
index 0000000..fe837fb
--- /dev/null
+++ b/libjava/javax/swing/text/rtf/RTFParser.java
@@ -0,0 +1,195 @@
+/* RTFParser.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text.rtf;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+
+/**
+ * Parses an RTF file into a {@link Document}. The parser utilizes
+ * {@link RTFScanner}.
+ *
+ * @author Roman Kennke (roman@ontographics.com)
+ */
+class RTFParser
+{
+
+ /**
+ * Our scanner.
+ */
+ private RTFScanner scanner;
+
+ /**
+ * The document into which we parse.
+ */
+ private Document doc;
+
+ /**
+ * The current position.
+ */
+ private int pos;
+
+ /**
+ * Constructs a new RTFParser for the specified document and position,
+ * without initializing the scanner. This is only used internally.
+ *
+ * @param doc the {@link Document} into which we should parse
+ * @param pos the position to start
+ */
+ private RTFParser(Document doc, int pos)
+ {
+ this.doc = doc;
+ this.pos = pos;
+ }
+
+ /**
+ * Constructs a new RTFParser for the specified <code>stream</code>.
+ *
+ * @param stream the stream from which we parse
+ * @param doc the {@link Document} into which we should parse
+ * @param pos the position to start
+ */
+ public RTFParser(InputStream stream, Document doc, int pos)
+ {
+ this(doc, pos);
+ scanner = new RTFScanner(stream);
+ }
+
+ /**
+ * Constructs a new RTFParser for the specified <code>reader</code>.
+ *
+ * @param reader the reader from which we parse
+ * @param doc the {@link Document} into which we should parse
+ * @param pos the position to start
+ */
+ public RTFParser(Reader reader, Document doc, int pos)
+ {
+ this(doc, pos);
+ scanner = new RTFScanner(reader);
+ }
+
+ /**
+ * Returns the {@link Document} in which we parsed the RTF data.
+ *
+ * @return the {@link Document} in which we parsed the RTF data
+ */
+ public Document getDocument()
+ {
+ return doc;
+ }
+
+ /**
+ * Starts the parsing process.
+ */
+ public void parse()
+ throws IOException, BadLocationException
+ {
+ parseFile();
+ }
+
+ /**
+ * The parse rules for &lt;file&gt;.
+ */
+ private void parseFile()
+ throws IOException, BadLocationException
+ {
+ Token t1 = scanner.readToken();
+ if (t1.type != Token.LCURLY)
+ throw new RTFParseException("expected left curly braces");
+
+ parseHeader();
+ parseDocument();
+
+ Token t2 = scanner.readToken();
+ if (t2.type != Token.RCURLY)
+ throw new RTFParseException("expected right curly braces");
+
+ }
+
+ /**
+ * The parse rules for &lt;header&gt;.
+ *
+ * TODO: implement this properly
+ */
+ private void parseHeader()
+ //throws IOException, BadLocationException
+ {
+ // TODO add parse rules here
+ }
+
+
+ /**
+ * The parse rules for &lt;document&gt;.
+ *
+ * TODO: implement this properly
+ */
+ private void parseDocument()
+ throws IOException, BadLocationException
+ {
+ // !!! TODO !!!
+ // This simply emits every TEXT Token as text to the document
+ // which is plain stupid
+
+ boolean eof = false;
+
+ do {
+ Token token = scanner.readToken();
+ switch (token.type)
+ {
+ case Token.TEXT:
+ TextToken textToken = (TextToken) token;
+ doc.insertString(pos, textToken.text, null);
+ pos += textToken.text.length();
+ break;
+ case Token.EOF:
+ eof = true;
+ break;
+ default:
+ // FIXME
+ break;
+ }
+ } while (!eof);
+
+ }
+
+}
diff --git a/libjava/javax/swing/text/rtf/RTFScanner.java b/libjava/javax/swing/text/rtf/RTFScanner.java
new file mode 100644
index 0000000..d964a43
--- /dev/null
+++ b/libjava/javax/swing/text/rtf/RTFScanner.java
@@ -0,0 +1,268 @@
+/* RTFScanner.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text.rtf;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+/**
+ * Provides a scanner that scans an {@link InputStream} for tokens of the
+ * RTF syntax.
+ *
+ * This scanner is based upon the RTF specification 1.6
+ * available at:
+ *
+ * <a
+ * href="http://msdn.microsoft.com/library/en-us/dnrtfspec/html/rtfspec.asp">
+ * RTF specification at MSDN</a>
+ *
+ * @author Roman Kennke (roman@ontographics.com)
+ */
+class RTFScanner
+{
+
+ /**
+ * The reader from which we read the RTF data.
+ */
+ private Reader in;
+
+ /**
+ * This is used to constuct strings from the read in chars.
+ */
+ private StringBuffer buffer;
+
+ /**
+ * Constructs a new RTFScanner without initializing the {@link Reader}.
+ */
+ private RTFScanner()
+ {
+ buffer = new StringBuffer();
+ }
+
+ /**
+ * Constructs a new RTFScanner for the given {@link InputStream}.
+ * The stream is wrapped into an {@link InputStreamReader} and if it's
+ * not yet buffered then the Reader is wrapped in a {@link BufferedReader}
+ *
+ * @param stream the {@link InputStream} to read RTF data from
+ */
+ public RTFScanner(InputStream stream)
+ {
+ this();
+ InputStreamReader reader = new InputStreamReader(stream);
+ in = new BufferedReader(reader);
+ }
+
+ /**
+ * Constructs a new RTFScanner for the given {@link Reader}.
+ *
+ * If the reader is not an instance of {@link BufferedReader} then it
+ * is wrapped into a BufferedReader.
+ *
+ * @param reader the {@link BufferedReader} to read RTF data from
+ */
+ public RTFScanner(Reader reader)
+ {
+ this();
+ if (reader instanceof BufferedReader)
+ {
+ in = reader;
+ }
+ else
+ {
+ in = new BufferedReader(reader);
+ }
+ }
+
+ /**
+ * Reads in the next {@link Token} from the stream.
+ *
+ * @return the read {@link Token}
+ *
+ * @throws IOException if the underlying stream has problems
+ */
+ public Token readToken()
+ throws IOException
+ {
+ Token token = null;
+
+ int c = in.read();
+ switch(c)
+ {
+ case -1:
+ token = new Token(Token.EOF);
+ break;
+
+ case '{':
+ token = new Token(Token.LCURLY);
+ break;
+
+ case '}':
+ token = new Token(Token.RCURLY);
+ break;
+
+ case '\\':
+ buffer.delete(0, buffer.length());
+ buffer.append((char) c);
+ token = readControlWord();
+ break;
+
+ default:
+ buffer.delete(0, buffer.length());
+ buffer.append((char) c);
+ token = readText();
+ break;
+ }
+
+ return token;
+ }
+
+ /**
+ * Reads in a control word and optional parameter.
+ *
+ * @return the read in control word as {@link ControlWordToken}
+ *
+ * @throws IOException if the underlying stream has problems
+ */
+ private Token readControlWord()
+ throws IOException
+ {
+ // this flag indicates if we are still reading the name or are already
+ // in the parameter
+ boolean readingName = true;
+ String name = null;
+ String param = null;
+
+ while (true)
+ {
+ in.mark(1);
+ int c = in.read();
+
+ // check for 'a'..'z'
+ if (readingName && (c >= 'a') && (c <= 'z'))
+ {
+ buffer.append((char) c);
+ }
+ else if ((c >= '0') && (c <= '9'))
+ {
+ // if the last char was in the name, then finish reading the name
+ if (readingName)
+ {
+ name = buffer.toString();
+ buffer.delete(0, buffer.length());
+ readingName = false;
+ }
+ buffer.append((char) c);
+ }
+ else
+ {
+ // if we were in the name, then finish this
+ if (readingName)
+ {
+ name = buffer.toString();
+ }
+ // otherwise finish the parameter
+ else
+ {
+ param = buffer.toString();
+ }
+
+ // clear up
+ buffer.delete(0, buffer.length());
+ // reset input buffer to last char
+ in.reset();
+ // break while loop
+ break;
+ }
+ }
+
+ ControlWordToken token = null;
+
+ if (param == null)
+ token = new ControlWordToken(name);
+ else
+ token =new ControlWordToken(name, Integer.parseInt(param));
+
+ return token;
+
+ }
+
+ /**
+ * Reads in a block of text.
+ *
+ * @return the token for the text
+ */
+ private Token readText()
+ throws IOException
+ {
+
+ boolean readingText = true;
+ while (readingText)
+ {
+ in.mark(1);
+ int c = in.read();
+ switch(c)
+ {
+ case '\\':
+ case '{':
+ case '}':
+ case -1:
+ readingText = false;
+ in.reset();
+ break;
+
+ default:
+ buffer.append((char) c);
+ break;
+ }
+
+ }
+
+ String text = buffer.toString();
+ Token token = new TextToken(text);
+
+ buffer.delete(0, buffer.length());
+
+ return token;
+
+ }
+}
diff --git a/libjava/javax/swing/text/rtf/TextToken.java b/libjava/javax/swing/text/rtf/TextToken.java
new file mode 100644
index 0000000..e326792
--- /dev/null
+++ b/libjava/javax/swing/text/rtf/TextToken.java
@@ -0,0 +1,65 @@
+/* TextToken.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text.rtf;
+
+/**
+ * A special {@link Token} that represents a piece of text in RTF.
+ *
+ * @author Roman Kennke (roman@ontographics.com)
+ */
+class TextToken extends Token
+{
+
+ /**
+ * The text.
+ */
+ public String text;
+
+ /**
+ * Constructs a new TextToken with the specified textual data.
+ *
+ * @param text the text for this token
+ */
+ public TextToken(String text)
+ {
+ super(Token.TEXT);
+ this.text = text;
+ }
+
+}
diff --git a/libjava/javax/swing/text/rtf/Token.java b/libjava/javax/swing/text/rtf/Token.java
new file mode 100644
index 0000000..a7a9552
--- /dev/null
+++ b/libjava/javax/swing/text/rtf/Token.java
@@ -0,0 +1,91 @@
+/* Token.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text.rtf;
+
+/**
+ * Represents a simple token that the RTFScanner can read. A simple
+ * only has a type (like LCURLY or RCURLY). More complex tokens may
+ * attach data to the token.
+ *
+ * @author Roman Kennke (roman@ontographics.com)
+ */
+class Token
+{
+
+ /**
+ * This special type inidicates the end of the input stream.
+ */
+ public static final int EOF = -1;
+
+ /**
+ * A left curly brace '{'.
+ */
+ public static final int LCURLY = 1;
+
+ /**
+ * A right curly brace '}'.
+ */
+ public static final int RCURLY = 2;
+
+ /**
+ * A control word like '\rtf1'. Tokens with this type are represented
+ * through the subclass {@link ControlWordToken}.
+ */
+ public static final int CONTROL_WORD = 3;
+
+ /**
+ * A token that contains text. This is represented through the subclass
+ * {@link TextToken}.
+ */
+ public static final int TEXT = 4;
+
+
+ /** The token type. */
+ public int type;
+
+ /**
+ * Constructs a new Token with the specified type.
+ *
+ * @param type the Token type
+ */
+ public Token(int type)
+ {
+ this.type = type;
+ }
+}