org.rhq.test
Class TokenReplacingReader

java.lang.Object
  extended by java.io.Reader
      extended by org.rhq.test.TokenReplacingReader
All Implemented Interfaces:
Closeable, Readable

public class TokenReplacingReader
extends Reader

Copied from http://tutorials.jenkov.com/java-howto/replace-strings-in-streams-arrays-files.html with fixes to read(char[], int, int) and added support for escaping.

Author:
Lukas Krejci

Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
  TokenReplacingReader(Reader source, Map<String,String> tokens)
           
protected TokenReplacingReader(String source, Map<String,String> tokens, Deque<String> activeTokens, Map<String,String> resolvedTokens)
           
 
Method Summary
 void close()
           
 void mark(int readAheadLimit)
           
 boolean markSupported()
           
 int read()
           
 int read(char[] cbuf)
           
 int read(char[] cbuf, int off, int len)
           
 int read(CharBuffer target)
           
 boolean ready()
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenReplacingReader

public TokenReplacingReader(Reader source,
                            Map<String,String> tokens)

TokenReplacingReader

protected TokenReplacingReader(String source,
                               Map<String,String> tokens,
                               Deque<String> activeTokens,
                               Map<String,String> resolvedTokens)
Method Detail

read

public int read(CharBuffer target)
         throws IOException
Specified by:
read in interface Readable
Overrides:
read in class Reader
Throws:
IOException

read

public int read()
         throws IOException
Overrides:
read in class Reader
Throws:
IOException

read

public int read(char[] cbuf)
         throws IOException
Overrides:
read in class Reader
Throws:
IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
Specified by:
read in class Reader
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class Reader
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Overrides:
skip in class Reader
Throws:
IOException

ready

public boolean ready()
              throws IOException
Overrides:
ready in class Reader
Throws:
IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class Reader

mark

public void mark(int readAheadLimit)
          throws IOException
Overrides:
mark in class Reader
Throws:
IOException

reset

public void reset()
           throws IOException
Overrides:
reset in class Reader
Throws:
IOException


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.