KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > regexp > RegexpData


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.regexp;
18
19 import java.util.*;
20 import org.apache.oro.text.*;
21 import org.apache.oro.text.perl.*;
22 import org.apache.oro.text.regex.*;
23 import javax.servlet.*;
24 import javax.servlet.http.*;
25 import javax.servlet.jsp.*;
26 import javax.servlet.jsp.tagext.*;
27
28 /**
29  * Script variable data for JSP Tag <b>regexp</b>, used to define a perl
30  * regular expression for later use.
31  * <p>
32  * Uses a static PatternCacheLRU to cache up to 100 regular expressions.
33  *
34  * @see RegexpTag
35  *
36  * @author Glenn Nielsen
37  */

38
39 public class RegexpData
40 {
41
42     // Static compiled regexp patterns
43
// So that each time a regexp tag is used we don't have to recompile the regexp
44
// if the regular expression is being reused.
45
// Set to a capacity of 100 unique patterns, this should be enough
46
// for most users.
47
private static PatternCacheLRU regexp = new PatternCacheLRU(100);
48
49     // The regular expression to use
50
private String JavaDoc regexptext = null;
51
52     RegexpData(String JavaDoc text)
53     {
54     regexptext = text;
55     }
56
57     /*
58      * Get the plain text regular expression
59      *
60      * @return String - regular expression text
61      */

62     public final String JavaDoc getRegexp()
63     {
64     return regexptext;
65     }
66
67     /*
68      * Get the static PatternCacheLRU
69      *
70      * @return PatternCacheLRU - the static PatternCacheLRU
71      */

72     public final static PatternCacheLRU getPatternCache()
73     {
74     return regexp;
75     }
76 }
77
Popular Tags