org.codehaus.swizzle.stream
Class StreamLexer

java.lang.Object
  extended by org.codehaus.swizzle.stream.StreamLexer

public class StreamLexer
extends java.lang.Object

Version:
$Revision$ $Date$

Constructor Summary
StreamLexer(java.io.InputStream in)
           
 
Method Summary
 java.lang.String readToken(java.lang.String string)
          Deprecated. Experimental, the api of this class may change
 java.lang.String readToken(java.lang.String begin, java.lang.String end)
          Deprecated. Experimental, the api of this class may change
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamLexer

public StreamLexer(java.io.InputStream in)
Method Detail

readToken

public java.lang.String readToken(java.lang.String begin,
                                  java.lang.String end)
                           throws java.lang.Exception
Deprecated. Experimental, the api of this class may change

Seeks in the stream till it finds the start token, reads into a buffer till it finds the end token, then returns the token (the buffer) as a String. Given the input stream contained the sequence "123ABC456EFG" InputStream in ... StreamLexer lexer = new StreamLexer(in); String token = lexer.readToken("3","C"); // returns the string "AB" char character = (char)in.read(); // returns the character '4' Does not support regular expression matching.

Parameters:
begin - start token
end - end token
Returns:
the token inbetween the start and end token or null if the end of the stream was reached
Throws:
java.lang.Exception

readToken

public java.lang.String readToken(java.lang.String string)
                           throws java.lang.Exception
Deprecated. Experimental, the api of this class may change

Seeks in the stream till it finds and has completely read the token, then stops. Useful for seeking up to a certain point in the stream. Given the input stream contained the sequence "000[A]111[B]222[C]345[D]" InputStream in ... StreamLexer lexer = new StreamLexer(in); String token = lexer.readToken("222"); // returns the string "222" token = lexer.readToken("[", "]"); // returns the string "C" char character = (char)in.read(); // returns the character '3' Does not support regular expression matching.

Parameters:
string - the token to find in the stream
Returns:
the token if found in the stream or null if the stream was reached (i.e. the token was not found)
Throws:
java.lang.Exception


Copyright © 2007. All Rights Reserved.