net.sf.jga.fn.string
Class Match

java.lang.Object
  extended by net.sf.jga.fn.Functor<R>
      extended by net.sf.jga.fn.UnaryFunctor<java.lang.String,java.lang.Boolean>
          extended by net.sf.jga.fn.string.Match
All Implemented Interfaces:
java.io.Serializable, Visitable

public class Match
extends UnaryFunctor<java.lang.String,java.lang.Boolean>

Unary Functor that tests a string argument against a given regular expression. The expression is not presumed to be anchored: if any part of the input string matches the regular expression, then the result will be true.

Copyright © 2003-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface Match.Visitor
          Interface for classes that may interpret a Match predicate.
 
Constructor Summary
Match()
          Builds a Match with an empty string pattern
Match(java.util.regex.Pattern pattern)
          Builds a Match with a given Pattern
Match(java.lang.String regex)
          Builds a Match with a given regular expression
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(Match) method, if it implements the nested Visitor interface.
 java.lang.Boolean fn(java.lang.String arg)
          Tests a string against the regular expression given at construction
 java.lang.String getRegex()
          Returns the format object used to present values in formatted form.
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.UnaryFunctor
bind, bind0th, bindNth, compose, compose, compose, composeNth, composeNth, eval, generate, generateNth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Match

public Match()
Builds a Match with an empty string pattern


Match

public Match(java.lang.String regex)
Builds a Match with a given regular expression


Match

public Match(java.util.regex.Pattern pattern)
Builds a Match with a given Pattern

Method Detail

getRegex

public java.lang.String getRegex()
Returns the format object used to present values in formatted form.

Returns:
the format used to present values

fn

public java.lang.Boolean fn(java.lang.String arg)
Tests a string against the regular expression given at construction

Specified by:
fn in class UnaryFunctor<java.lang.String,java.lang.Boolean>
Parameters:
arg - the value to tested
Returns:
true if the string matches the regular expression given at construction

accept

public void accept(Visitor v)
Calls the Visitor's visit(Match) method, if it implements the nested Visitor interface.

Specified by:
accept in interface Visitable
Overrides:
accept in class Functor<java.lang.Boolean>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2006 David A. Hall. All Rights Reserved.