You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by gl...@locus.apache.org on 2000/11/06 14:54:22 UTC
cvs commit: jakarta-taglibs/regexp/src/org/apache/taglibs/regexp RegexpTag.java
glenn 00/11/06 05:54:22
Modified: regexp/src/org/apache/taglibs/regexp RegexpTag.java
Log:
Cleanup for release
Revision Changes Path
1.2 +9 -23 jakarta-taglibs/regexp/src/org/apache/taglibs/regexp/RegexpTag.java
Index: RegexpTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/regexp/src/org/apache/taglibs/regexp/RegexpTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RegexpTag.java 2000/10/22 01:32:04 1.1
+++ RegexpTag.java 2000/11/06 13:54:21 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-taglibs/regexp/src/org/apache/taglibs/regexp/RegexpTag.java,v 1.1 2000/10/22 01:32:04 glenn Exp $
- * $Revision: 1.1 $
- * $Date: 2000/10/22 01:32:04 $
+ * $Header: /home/cvs/jakarta-taglibs/regexp/src/org/apache/taglibs/regexp/RegexpTag.java,v 1.2 2000/11/06 13:54:21 glenn Exp $
+ * $Revision: 1.2 $
+ * $Date: 2000/11/06 13:54:21 $
*
* ====================================================================
*
@@ -72,7 +72,7 @@
/**
* JSP Tag <b>regexp</b>, used to define a perl regular expression
- * for later use.
+ * for later use as a script variable.
* <p>
* The body of the tag is used as the regular expression.
* <p>
@@ -81,7 +81,7 @@
* <name>regexp</name>
* <tagclass>org.apache.taglibs.regexp.RegexpTag</tagclass>
* <bodycontent>JSP</bodycontent>
- * <info>Used to create a script variable for a regular expression.</info>
+ * <info>Create a script variable for a regular expression.</info>
* <attribute>
* <name>id</name>
* <required>true</required>
@@ -89,19 +89,13 @@
* </attribute>
* </pre>
*
+ * @see RegexpData
+ *
* @author Glenn Nielsen
*/
public class RegexpTag extends BodyTagSupport
{
-
- // Static compiled regexp patterns
- // So that each time a regexp tag is used we don't have to recompile the regexp
- // if the regular expression is being reused.
- // Set to a capacity of 100 unique patterns, this should be enough
- // for most users.
- private static PatternCacheLRU regexp = new PatternCacheLRU(100);
-
// The regular expression to use for this tag
private String regexptext = null;
@@ -110,7 +104,7 @@
*
* @return EVAL_BODY_TAG
*/
- public int doStartTag() throws JspException
+ public final int doStartTag() throws JspException
{
return EVAL_BODY_TAG;
}
@@ -120,7 +114,7 @@
*
* @return SKIP_BODY
*/
- public int doAfterBody() throws JspException
+ public final int doAfterBody() throws JspException
{
// Use the body of the tag as regular expression
BodyContent body = getBodyContent();
@@ -135,6 +129,8 @@
"regexp tag regexp could not find a regular expresion in body of tag.");
// Add the regular expression
+ RegexpData rd = new RegexpData(regexptext);
+ PatternCacheLRU regexp = RegexpData.getPatternCache();
try {
regexp.addPattern(regexptext,
Perl5Compiler.MULTILINE_MASK|Perl5Compiler.READ_ONLY_MASK);
@@ -143,17 +139,7 @@
regexptext + "\" " + e.getMessage());
}
- pageContext.setAttribute(id,this,PageContext.PAGE_SCOPE);
+ pageContext.setAttribute(id,rd,PageContext.PAGE_SCOPE);
return SKIP_BODY;
- }
-
- public String getRegexp()
- {
- return regexptext;
- }
-
- public static PatternCacheLRU getPatternCache()
- {
- return regexp;
}
}