OSDN Git Service

2006-08-14 Mark Wielaard <mark@klomp.org>
[pf3gnuchains/gcc-fork.git] / libjava / classpath / javax / swing / text / rtf / RTFScanner.java
index 3cdd6e8..060e087 100644 (file)
@@ -71,6 +71,11 @@ class RTFScanner
   private StringBuffer buffer;
 
   /**
+   * Lookahead token.
+   */
+  private Token lastToken;
+
+  /**
    * Constructs a new RTFScanner without initializing the {@link Reader}.
    */
   private RTFScanner()
@@ -120,7 +125,7 @@ class RTFScanner
    *
    * @throws IOException if the underlying stream has problems
    */
-  public Token readToken()
+  private Token readTokenImpl()
     throws IOException
   {
     Token token = null;
@@ -156,6 +161,27 @@ class RTFScanner
     return token;
   }
 
+  Token peekToken()
+    throws IOException
+  {
+    lastToken = readTokenImpl();
+    return lastToken;
+  }
+
+  Token readToken()
+    throws IOException
+  {
+    Token token;
+    if (lastToken != null)
+      {
+        token = lastToken;
+        lastToken = null;
+      }
+    else
+      token = readTokenImpl();
+    return token;
+  }
+
   /**
    * Reads in a control word and optional parameter.
    *