org.apache.openjpa.persistence.jest
Class TokenReplacedStream

java.lang.Object
  extended by org.apache.openjpa.persistence.jest.TokenReplacedStream

public class TokenReplacedStream
extends Object

Reads from an input stream and writes to an output stream after replacing matched tokens by their counterpart.

Author:
Pinaki Poddar

Nested Class Summary
static class TokenReplacedStream.Pattern
           
 
Constructor Summary
TokenReplacedStream()
           
 
Method Summary
(package private)  int match(char c, TokenReplacedStream.Pattern... patterns)
          Match the given character to all patterns and return the index of highest match.
(package private)  TokenReplacedStream.Pattern matched(TokenReplacedStream.Pattern... patterns)
          Gets the pattern if any in matched state
 void replace(InputStream in, Writer out, String... prs)
          Read the given input stream and replaces the tokens as it reads.
(package private)  void reset(TokenReplacedStream.Pattern... patterns)
          Resets all the patterns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenReplacedStream

public TokenReplacedStream()
Method Detail

replace

public void replace(InputStream in,
                    Writer out,
                    String... prs)
             throws IOException
Read the given input stream and replaces the tokens as it reads. The replaced stream is written to the given output stream.

Parameters:
in - a non-null input stream
out - a character oriented writer
replacements - an even number of Strings. Any occurrence of the even-indexed i-th String in the input stream will be replaced by the (i+1)-th String in the output writer.
Throws:
IOException

match

int match(char c,
          TokenReplacedStream.Pattern... patterns)
Match the given character to all patterns and return the index of highest match.

Parameters:
c - a character to match
patterns - an array of patterns
Returns:
-1 if character matched no pattern

matched

TokenReplacedStream.Pattern matched(TokenReplacedStream.Pattern... patterns)
Gets the pattern if any in matched state

Parameters:
patterns -
Returns:

reset

void reset(TokenReplacedStream.Pattern... patterns)
Resets all the patterns.

Parameters:
patterns -


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.