tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From harishksw...@apache.org
Subject cvs commit: jakarta-tapestry/framework/src/org/apache/tapestry/util RegexpMatcher.java
Date Sat, 27 Sep 2003 16:11:01 GMT
harishkswamy    2003/09/27 09:11:01

  Modified:    framework/src/org/apache/tapestry/util RegexpMatcher.java
  Log:
  Modified to find part input matches against the pattern. Also added a method to return the
escaped pattern.
  
  -HK
  
  Revision  Changes    Path
  1.3       +33 -4     jakarta-tapestry/framework/src/org/apache/tapestry/util/RegexpMatcher.java
  
  Index: RegexpMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/util/RegexpMatcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RegexpMatcher.java	17 Apr 2003 21:33:50 -0000	1.2
  +++ RegexpMatcher.java	27 Sep 2003 16:11:01 -0000	1.3
  @@ -85,6 +85,8 @@
   
       private Map _compiledPatterns = new HashMap();
   
  +    private Map _escapedPatternStrings = new HashMap();
  +
       protected Pattern compilePattern(String pattern)
       {
           if (_patternCompiler == null)
  @@ -123,13 +125,40 @@
           _compiledPatterns.clear();
       }
   
  +    protected PatternMatcher getPatternMatcher()
  +    {
  +        if (_matcher == null)
  +            _matcher = new Perl5Matcher();
  +
  +        return _matcher;
  +    }
  +
       public boolean matches(String pattern, String input)
       {
           Pattern compiledPattern = getCompiledPattern(pattern);
   
  -        if (_matcher == null)
  -            _matcher = new Perl5Matcher();
  +        return getPatternMatcher().matches(input, compiledPattern);
  +    }
  +
  +    public boolean contains(String pattern, String input)
  +    {
  +        Pattern compiledPattern = getCompiledPattern(pattern);
  +
  +        return getPatternMatcher().contains(input, compiledPattern);
  +    }
  +
  +    public String getEscapedPatternString(String pattern)
  +    {
  +        String result = (String) _escapedPatternStrings.get(pattern);
  +
  +        if (result == null)
  +        {
  +            result = Perl5Compiler.quotemeta(pattern);
  +
  +            _escapedPatternStrings.put(pattern, result);
  +        }
   
  -        return _matcher.matches(input, compiledPattern);
  +        return result;
       }
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Mime
View raw message