org.apache.taglibs.regexp
Class SplitTag

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

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

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

The body of the tag iterates through each string generated from the split. The normal <jsp:getProperty/> can be used to get the value of each string split out using the id of the split tag script variable.

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

By default, the split is done on whitespace. Set the optional attribute regexp to the id of a regexp tag script variable id to perform the split using a custom regular expression.

You can set the optional tag attribute limit to the number of items you want to limit the split to.

JSP Tag Lib Descriptor

 <name>split</name>
 <tagclass>org.apache.taglibs.regexp.SplitTag</tagclass>
 <bodycontent>JSP</bodycontent>
 <info>Implements a perl style split on the text.</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>false</required>
     <rtexprvalue>false</rtexprvalue>
   </attribute>
   <attribute>
     <name>limit</name>
     <required>false</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
SplitTag()
           
 
Method Summary
 int doAfterBody()
          Method called at end of each iteration of the split tag
 int doEndTag()
          Method called at end of split Tag
 int doStartTag()
          Setup to split the text based on supplied attributes
 java.lang.String getSplit()
          String split out from text can be obtained by the JSP page using <jsp:getProperty name="id" property="split"/>
 void setLimit(int limit)
           
 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

SplitTag

public SplitTag()
Method Detail

doStartTag

public final int doStartTag()
                     throws javax.servlet.jsp.JspException
Setup to split the text based on supplied attributes

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_BODY_TAG if there is a string from the split, BODY_SKIP if no strings resulted from the split
Throws:
javax.servlet.jsp.JspException

doAfterBody

public final int doAfterBody()
                      throws javax.servlet.jsp.JspException
Method called at end of each iteration of the split 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 split, 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 split 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)

setLimit

public final void setLimit(int limit)

getSplit

public final java.lang.String getSplit()
String split out from text can be obtained by the JSP page using <jsp:getProperty name="id" property="split"/>

Returns:
String - string that was split out from text


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