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:42 UTC

cvs commit: jakarta-taglibs/regexp/src/org/apache/taglibs/regexp SplitTag.java

glenn       00/11/06 05:54:42

  Modified:    regexp/src/org/apache/taglibs/regexp SplitTag.java
  Log:
  Cleanup for release
  
  Revision  Changes    Path
  1.2       +37 -19    jakarta-taglibs/regexp/src/org/apache/taglibs/regexp/SplitTag.java
  
  Index: SplitTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/regexp/src/org/apache/taglibs/regexp/SplitTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SplitTag.java	2000/10/22 01:32:04	1.1
  +++ SplitTag.java	2000/11/06 13:54:41	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/regexp/src/org/apache/taglibs/regexp/SplitTag.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/SplitTag.java,v 1.2 2000/11/06 13:54:41 glenn Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/11/06 13:54:41 $
    *
    * ====================================================================
    *
  @@ -120,6 +120,8 @@
    *
    * @see RegexpTag
    * @see TextTag
  + * @see RegexpData
  + * @see TextData
    *
    * @author Glenn Nielsen
    */
  @@ -138,7 +140,7 @@
        *
        * @return EVAL_BODY_TAG if there is a string from the split, BODY_SKIP if no strings resulted from the split
        */
  -    public int doStartTag() throws JspException
  +    public final int doStartTag() throws JspException
       {
   	if( limittext != null ) {
   	    try {
  @@ -150,27 +152,27 @@
   	    }
   	}
   
  -	TextTag tt = (TextTag)pageContext.getAttribute(textid,PageContext.PAGE_SCOPE);
  -	if( tt == null )
  +	TextData td = (TextData)pageContext.getAttribute(textid,PageContext.PAGE_SCOPE);
  +	if( td == null )
   	    throw new JspException(
   		"regexp tag split could not find text tag with id: " +
   		textid);
   
  -	Perl5Util perl = new Perl5Util(RegexpTag.getPatternCache());
  +	Perl5Util perl = new Perl5Util(RegexpData.getPatternCache());
   	String spliton = "/\\s+/m";
   	if( regexpid != null ) {
  -            RegexpTag rt = (RegexpTag)pageContext.getAttribute(regexpid,PageContext.PAGE_SCOPE);
  -            if( rt == null )
  +            RegexpData rd = (RegexpData)pageContext.getAttribute(regexpid,PageContext.PAGE_SCOPE);
  +            if( rd == null )
                   throw new JspException(
                       "regexp tag split could not find regexp tag with id: " +
                       regexpid);
  -	    spliton = rt.getRegexp();
  +	    spliton = rd.getRegexp();
   	}
   	Vector vector = null;
   	if( limit > -1 ) {
  -	    vector = perl.split(spliton,tt.getText(),limit);
  +	    vector = perl.split(spliton,td.getText(),limit);
   	} else {
  -	    vector = perl.split(spliton,tt.getText());
  +	    vector = perl.split(spliton,td.getText());
   	}
   	split = vector.elements();
   	if( !split.hasMoreElements() ) {
  @@ -188,7 +190,7 @@
        *
        * @return EVAL_BODY_TAG if there is another string split, or BODY_SKIP if there are no more strings
        */
  -    public int doAfterBody() throws JspException
  +    public final int doAfterBody() throws JspException
       {
   	if( !split.hasMoreElements() ) {
   	    return SKIP_BODY;
  @@ -202,7 +204,7 @@
        *
        * @return EVAL_PAGE
        */
  -    public int doEndTag() throws JspException
  +    public final int doEndTag() throws JspException
       {
   	try {
   	    if(bodyContent != null)
  @@ -211,19 +213,35 @@
   	    throw new JspException("IO Error: " + e.getMessage());
   	}
   	return EVAL_PAGE;
  -  }
  +    }
   
  -    public void setRegexp(String str)
  +    /*
  +     * Set the optional attribute <b>regexp</b>
  +     *
  +     * @param String name of regexp script variable
  +     */
  +    public final void setRegexp(String str)
       {   
   	regexpid = str;
       }
   
  -    public void setText(String str)
  +    /*
  +     * Set the required attribute <b>text</b>
  +     *
  +     * @param String name of text script variable
  +     */
  +    public final void setText(String str)
       {               
           textid = str;
       }
   
  -    public void setLimit(String str)
  +    /*
  +     * Set the optional attribute <b>limit</b> to the
  +     * number of strings to split out of text.
  +     *
  +     * @param String number of strings to limit split to
  +     */
  +    public final void setLimit(String str)
       {
   	limittext = str;
       }
  @@ -232,9 +250,9 @@
        * String split out from text can be obtained by the JSP page
        * using &lt;jsp:getProperty name=<i>"id"</i> property="split"/&gt;
        *
  -     * @return String split out from text
  +     * @return String - string that was split out from text
        */
  -    public String getSplit()
  +    public final String getSplit()
       {
   	return value;
       }
  @@ -242,9 +260,9 @@
       /**
        * Remove the script variable after split tag closed out
        */
  -    public void release()
  +    public final void release()
       {
  -    if( id.length() > 0 ) 
  +    if( id != null && id.length() > 0 ) 
   	pageContext.removeAttribute(id,PageContext.PAGE_SCOPE);
       }
   }