org.apache.taglibs.regexp
Class MatchTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by org.apache.taglibs.regexp.MatchTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.Tag

public class MatchTag
extends javax.servlet.jsp.tagext.BodyTagSupport

JSP Tag match, used to implement a perl style match on the text.

The body of the tag iterates through each match found. The normal <jsp:getProperty/> can be used to get the match results using the id of the match tag script variable.

The attribute text must be set to the id of a text tag, and the regexp attribute must be set to the id of a regexp tag.

JSP Tag Lib Descriptor

 <name>match</name>
 <tagclass>org.apache.taglibs.regexp.MatchTag</tagclass>
 <bodycontent>JSP</bodycontent>
 <info>Uses the regexp to find matches in text, loops for each match found.</info>
   <attribute>
     <name>id</name>
     <required>true</required>
     <rtexprvalue>false</rtexprvalue>
   </attribute>
   <attribute>
     <name>text</name>
     <required>true</required>
     <rtexprvalue>false</rtexprvalue>
   </attribute>
   <attribute>
     <name>regexp</name>
     <required>true</required>
     <rtexprvalue>false</rtexprvalue>
   </attribute>
 

Author:
Glenn Nielsen
See Also:
RegexpTag, TextTag, RegexpData, TextData, Serialized Form

Field Summary
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
MatchTag()
           
 
Method Summary
 int doAfterBody()
          Method called at end of each iteration of the match tag
 int doEndTag()
          Method called at end of match Tag
 int doStartTag()
          Setup to loop through matches found in the text using regexp
 java.lang.String getGroup(int i)
          Returns the string for the group parenthesized number
 java.lang.String getMatch()
          Returns the entire string that was matched on using <jsp:getProperty name="id" property="match"/>
 java.lang.String getPostMatch()
          Returns the string after the current match using <jsp:getProperty name="id" property="postMatch"/>
 java.lang.String getPreMatch()
          Returns the string preceding the current match using <jsp:getProperty name="id" property="preMatch"/>
 void setRegexp(java.lang.String str)
           
 void setText(java.lang.String str)
           
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Constructor Detail

MatchTag

public MatchTag()
Method Detail

doStartTag

public final int doStartTag()
                     throws javax.servlet.jsp.JspException
Setup to loop through matches found in the text using regexp

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_BODY_TAG if a match is found, BODY_SKIP if no matches are found
Throws:
javax.servlet.jsp.JspException

doAfterBody

public final int doAfterBody()
                      throws javax.servlet.jsp.JspException
Method called at end of each iteration of the match tag

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_BODY_TAG if there is another string match, or BODY_SKIP if there are no more strings
Throws:
javax.servlet.jsp.JspException

doEndTag

public final int doEndTag()
                   throws javax.servlet.jsp.JspException
Method called at end of match Tag

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_PAGE
Throws:
javax.servlet.jsp.JspException

setRegexp

public final void setRegexp(java.lang.String str)

setText

public final void setText(java.lang.String str)

getMatch

public final java.lang.String getMatch()
Returns the entire string that was matched on using <jsp:getProperty name="id" property="match"/>

Returns:
String - entire text of match

getPreMatch

public final java.lang.String getPreMatch()
Returns the string preceding the current match using <jsp:getProperty name="id" property="preMatch"/>

Returns:
String - text preceding match

getPostMatch

public final java.lang.String getPostMatch()
Returns the string after the current match using <jsp:getProperty name="id" property="postMatch"/>

Returns:
String - text after the match

getGroup

public final java.lang.String getGroup(int i)
Returns the string for the group parenthesized number

Returns:
String - for group parenthesized number


Copyright ? 2000-2004 The Apache Software Foundation. All Rights Reserved.