com.unitesk.atp.text.filters
Class PatternFilter

java.lang.Object
  extended by com.unitesk.atp.text.filters.Filter
      extended by com.unitesk.atp.text.filters.PatternFilter
All Implemented Interfaces:
TextReceiver

public class PatternFilter
extends Filter

This filter interprets strings as patterns. A pattern can have parameters limited by <parameter_start> and <parameter_end> (${ and } by default). Parameters are passed to parameter processor and the rest of line - to the client of filter. The special case - empty parameter always stands as escaping of <parameter_start> and don't passed to parameter processor. <parameter_start> is passed to the client instead. Parameters can't be nested. The way of parameters processing depends on processor. For example it can treat them as alias names, replace by values and pass to the same client.

Version:
$Id: PatternFilter.java,v 1.1 2004/10/09 06:36:40 all-x Exp $
Author:
Alexey Demakov

Nested Class Summary
static interface PatternFilter.ParameterProcessor
          Processor of pattern parameters.
 
Field Summary
 
Fields inherited from class com.unitesk.atp.text.filters.Filter
client
 
Constructor Summary
PatternFilter(TextReceiver client, PatternFilter.ParameterProcessor parameter_processor)
          Constructs pattern filter with default parameter delimeters $( and ).
PatternFilter(TextReceiver client, PatternFilter.ParameterProcessor parameter_processor, String parameter_start, String parameter_end)
          Constructs pattern filter with the specified parameter delimeters.
 
Method Summary
 void txt(String s)
          Receives the string and interprets it as pattern.
 
Methods inherited from class com.unitesk.atp.text.filters.Filter
getClient, nl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PatternFilter

public PatternFilter(TextReceiver client,
                     PatternFilter.ParameterProcessor parameter_processor)
Constructs pattern filter with default parameter delimeters $( and ).

Parameters:
client - The client of filter.
parameter_processor - The processor of pattern parameters.
Throws:
NullPointerException - If any of the parameters is null

PatternFilter

public PatternFilter(TextReceiver client,
                     PatternFilter.ParameterProcessor parameter_processor,
                     String parameter_start,
                     String parameter_end)
Constructs pattern filter with the specified parameter delimeters.

Parameters:
client - The client of filter.
parameter_processor - The processor of pattern parameters.
parameter_start - The parameter start delimeter.
parameter_end - The parameter end delimeter.
Throws:
NullPointerException - If any of the parameters is null or any of the delimeters is an empty string.
Method Detail

txt

public void txt(String s)
Receives the string and interprets it as pattern. A pattern can have parameters limited by <parameter_start> and <parameter_end> ($( and ) by default). Parameters are passed to parameter processor and the rest of line - to the filter client. The special case - empty parameter always stands as escaping of <parameter_start> and don't passed to parameter processor. <parameter_start> is passed to the client instead. Parameters can't be nested.

Specified by:
txt in interface TextReceiver
Overrides:
txt in class Filter
Parameters:
s - the pattern
Throws:
FilterException - inheritors can use it for their own purposes


Copyright © 2001-2006 ISP RAS, RedVerst Group. All Rights Reserved.