org.jasig.portal.io
Class AbstractTokenReplacementFilter

java.lang.Object
  extended by java.io.Writer
      extended by org.jasig.portal.io.AbstractTokenReplacementFilter
All Implemented Interfaces:
Closeable, Flushable, Appendable
Direct Known Subclasses:
ChannelTitleIncorporationWiterFilter

public abstract class AbstractTokenReplacementFilter
extends Writer

Abstract token replacement filter. Wraps a Writer and can replace tokens as described by the configured prefix and suffix with the value provided by the sub-class for the parsed token.

Version:
$Revision$
Author:
Eric Dalquist

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
AbstractTokenReplacementFilter(Writer wrappedWriter, String prefix, int maxTokenLength, String suffix)
           
 
Method Summary
 void close()
           
 void flush()
           
protected abstract  String replaceToken(String token)
          Called when a token is found and needs to be replaced.
 void write(char[] cbuf, int off, int len)
           
 void write(int c)
           
 
Methods inherited from class java.io.Writer
append, append, append, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTokenReplacementFilter

public AbstractTokenReplacementFilter(Writer wrappedWriter,
                                      String prefix,
                                      int maxTokenLength,
                                      String suffix)
Parameters:
wrappedWriter - Writer to delegate writing to.
Method Detail

replaceToken

protected abstract String replaceToken(String token)
Called when a token is found and needs to be replaced.

Parameters:
token - The found token (text between prefix and suffix)
Returns:
The string to replace the prefix + token + suffix with.

close

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

flush

public final void flush()
                 throws IOException
Specified by:
flush in interface Flushable
Specified by:
flush in class Writer
Throws:
IOException

write

public final void write(char[] cbuf,
                        int off,
                        int len)
                 throws IOException
Specified by:
write in class Writer
Throws:
IOException

write

public final void write(int c)
                 throws IOException
Overrides:
write in class Writer
Throws:
IOException


Copyright © 2010 Jasig. All Rights Reserved.