jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/core OutTag.java
Date Wed, 17 Apr 2002 21:02:56 GMT
shawn       02/04/17 14:02:55

  Modified:    standard/conf c-rt.tld c.tld
               standard/src/org/apache/taglibs/standard/tag/common/xml
                        ExprSupport.java
               standard/src/org/apache/taglibs/standard/tag/el/core
                        SetTag.java
  Added:       standard/src/org/apache/taglibs/standard/tag/common/core
                        OutSupport.java
               standard/src/org/apache/taglibs/standard/tag/el/core
                        OutTag.java
               standard/src/org/apache/taglibs/standard/tag/rt/core
                        OutTag.java
  Removed:     standard/src/org/apache/taglibs/standard/tag/el/core
                        ExprTag.java
  Log:
  <c:out> now in both libraries.  And no longer called ExprTag.  :-)
  
  Revision  Changes    Path
  1.16      +25 -0     jakarta-taglibs/standard/conf/c-rt.tld
  
  Index: c-rt.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/conf/c-rt.tld,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- c-rt.tld	17 Apr 2002 14:53:26 -0000	1.15
  +++ c-rt.tld	17 Apr 2002 21:02:55 -0000	1.16
  @@ -209,6 +209,31 @@
     </tag>
   
     <tag>
  +    <name>out</name>
  +    <tag-class>org.apache.taglibs.standard.tag.rt.core.OutTag</tag-class>
  +    <body-content>JSP</body-content>
  +    <description>
  +        Like &lt;%= ... &gt;, but for expressions.
  +    </description> 
  +    <attribute>
  +        <name>value</name>
  +        <required>true</required>
  +        <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +        <name>default</name>
  +        <required>false</required>
  +        <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +    <attribute>
  +        <name>escapeXml</name>
  +        <required>false</required>
  +        <rtexprvalue>true</rtexprvalue>
  +    </attribute>
  +  </tag>
  +
  +
  +  <tag>
       <name>otherwise</name>
       <tag-class>org.apache.taglibs.standard.tag.common.core.OtherwiseTag</tag-class>
       <body-content>JSP</body-content>
  
  
  
  1.18      +2 -1      jakarta-taglibs/standard/conf/c.tld
  
  Index: c.tld
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/conf/c.tld,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- c.tld	17 Apr 2002 14:53:26 -0000	1.17
  +++ c.tld	17 Apr 2002 21:02:55 -0000	1.18
  @@ -19,6 +19,7 @@
   	<param-value>
   	    out:value
   	    out:default
  +	    out:escapeXml
   	    if:test
   	    import:url
   	    import:context
  @@ -83,7 +84,7 @@
   
     <tag>
       <name>out</name>
  -    <tag-class>org.apache.taglibs.standard.tag.el.core.ExprTag</tag-class>
  +    <tag-class>org.apache.taglibs.standard.tag.el.core.OutTag</tag-class>
       <body-content>JSP</body-content>
       <description>
   	Like &lt;%= ... &gt;, but for expressions.
  
  
  
  1.1                  jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/core/OutSupport.java
  
  Index: OutSupport.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.standard.tag.common.core;
  
  import java.io.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.jstl.core.ExpressionException;
  import javax.servlet.jsp.tagext.*;
  import org.apache.taglibs.standard.tag.common.core.*;
  import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
  import org.apache.taglibs.standard.resources.Resources;
  
  /**
   * <p>Support for handlers of the &lt;out&gt; tag, which simply evalutes and
   * prints the result of the expression it's passed.  If the expression
   * fails to complete evaluation successfully because of a
   * javax.servlet.jsp.jstl.core.ExpressionException, or if the result is
   * null, we print the value of the 'default' attribute's expression or
   * our body (which two are mutually exclusive, although this constraint
   * is enforced outside this handler, in our TagLibraryValidator).</p>
   *
   * @author Shawn Bayern
   */
  public class OutSupport extends BodyTagSupport {
  
      /*
       * (One almost wishes XML and JSP could support "anonymous tags,"
       * given the amount of trouble we had naming this one!)  :-)  - sb
       */
  
      //*********************************************************************
      // Internal state
  
      protected String value ;                    // tag attribute
      protected String def;			// tag attribute
      protected boolean escapeXml;		// tag attribute
      private boolean needBody;			// non-space body needed?
  
      //*********************************************************************
      // Construction and initialization
  
      /**
       * Constructs a new handler.  As with TagSupport, subclasses should
       * not provide other constructors and are expected to call the
       * superclass constructor.
       */
      public OutSupport() {
          super();
          init();
      }
  
      // resets local state
      private void init() {
          value = def = null;
          escapeXml = false;
  	needBody = false;
      }
  
      // Releases any resources we may have (or inherit)
      public void release() {
          super.release();
          init();
      }
  
  
      //*********************************************************************
      // Tag logic
  
      // evaluates 'value' and determines if the body should be evaluted
      public int doStartTag() throws JspException {
        try {
  	Object result;
  
  	result = value;
  
  	// print value if available; otherwise, try 'default'
  	if (result != null) {
              out(pageContext, escapeXml, result.toString());
  	    return SKIP_BODY;
  	} else {
  	    // if we don't have a 'default' attribute, just go to the body
  	    if (def == null) {
  		needBody = true;
  		return EVAL_BODY_BUFFERED;
  	    }
  
  	    // if we do have 'default', try it
  	    if (result != null) {
  		// good 'default'
                  out(pageContext, escapeXml, result.toString());
  		return SKIP_BODY;
  	    } else {
  		// bad 'default'
  		throw new NullAttributeException("out", "default");
  	    }
  	}
        } catch (IOException ex) {
  	throw new JspException(ex.getMessage(), ex);
        }
      }
  
      // prints the body if necessary; reports errors
      public int doEndTag() throws JspException {
        try {
  	if (!needBody)
  	    return EVAL_PAGE;		// nothing more to do
  
  	// trim and print out the body
  	if (bodyContent != null && bodyContent.getString() != null)
              out(pageContext, escapeXml, bodyContent.getString().trim());
  	return EVAL_PAGE;
        } catch (IOException ex) {
  	throw new JspException(ex.getMessage(), ex);
        }
      }
  
  
      //*********************************************************************
      // Public utility methods
  
      /**
       * Outputs <tt>text</tt> to <tt>pageContext</tt>'s current JspWriter.
       * If <tt>escapeXml</tt> is true, performs the following substring
       * replacements (to facilitate output to XML/HTML pages):
       *
       *    & -> &amp;
       *    < -> &lt;
       *    > -> &gt;
       *    " -> &#034;
       *    ' -> &#039;
       */
      public static void out(PageContext pageContext,
                             boolean escapeXml,
                             String text) throws IOException {
          JspWriter w = pageContext.getOut();
  	if (!escapeXml)
              w.print(text);
          else {
              // avoid needless double-buffering (is this really more efficient?)
              for (int i = 0; i < text.length(); i++) {
                  char c = text.charAt(i);
                  if (c == '&')
                      w.print("&amp;");
                  else if (c == '<')
                      w.print("&lt;");
                  else if (c == '>')
                      w.print("&gt;");
                  else if (c == '"')
                      w.print("&#034;");
                  else if (c == '\'')
                      w.print("&#039;");
                  else
                      w.print(c);
              }
          }
      }
  }
  
  
  
  1.2       +1 -1      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/xml/ExprSupport.java
  
  Index: ExprSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/xml/ExprSupport.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExprSupport.java	7 Mar 2002 00:41:57 -0000	1.1
  +++ ExprSupport.java	17 Apr 2002 21:02:55 -0000	1.2
  @@ -100,7 +100,7 @@
           try {
   	    XPathUtil xu = new XPathUtil(pageContext);
   	    String result = xu.valueOf(XPathUtil.getContext(this), select);
  -	    org.apache.taglibs.standard.tag.el.core.ExprTag.out(
  +	    org.apache.taglibs.standard.tag.common.core.OutSupport.out(
                 pageContext, escapeXml, result);
   	    return SKIP_BODY;
           } catch (java.io.IOException ex) {
  
  
  
  1.5       +1 -1      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/core/SetTag.java
  
  Index: SetTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/core/SetTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SetTag.java	17 Apr 2002 14:53:26 -0000	1.4
  +++ SetTag.java	17 Apr 2002 21:02:55 -0000	1.5
  @@ -60,7 +60,7 @@
   import org.apache.taglibs.standard.tag.common.core.*;
   
   /**
  - * <p>A handler for &lt;sett&gt;, which redirects the browser to a
  + * <p>A handler for &lt;set&gt;, which redirects the browser to a
    * new URL.
    *
    * @author Shawn Bayern
  
  
  
  1.1                  jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/core/OutTag.java
  
  Index: OutTag.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.standard.tag.el.core;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import org.apache.taglibs.standard.tag.common.core.*;
  
  /**
   * <p>A handler for &lt;out&gt;, which redirects the browser to a
   * new URL.
   *
   * @author Shawn Bayern
   */
  
  public class OutTag extends OutSupport {
  
      //*********************************************************************
      // 'Private' state (implementation details)
  
      private String value_;			// stores EL-based property
      private String default_;			// stores EL-based property
      private String escapeXml_;			// stores EL-based property
  
  
      //*********************************************************************
      // Constructor
  
      public OutTag() {
          super();
          init();
      }
  
  
      //*********************************************************************
      // Tag logic
  
      // evaluates expression and chains to parent
      public int doStartTag() throws JspException {
  
          // evaluate any expressions we were passed, once per invocation
          evaluateExpressions();
  
  	// chain to the parent implementation
  	return super.doStartTag();
      }
  
  
      // Releases any resources we may have (or inherit)
      public void release() {
          super.release();
          init();
      }
  
  
      //*********************************************************************
      // Accessor methods
  
      public void setValue(String value_) {
          this.value_ = value_;
      }
  
      public void setDefault(String default_) {
          this.default_ = default_;
      }
  
      public void setProperty(String escapeXml_) {
          this.escapeXml_ = escapeXml_;
      }
  
  
      //*********************************************************************
      // Private (utility) methods
  
      // (re)initializes state (during release() or construction)
      private void init() {
          // null implies "no expression"
  	value_ = default_ = escapeXml_ = null;
      }
  
      /* Evaluates expressions as necessary */
      private void evaluateExpressions() throws JspException {
          /* 
           * Note: we don't check for type mismatches here; we assume
           * the expression evaluator will return the expected type
           * (by virtue of knowledge we give it about what that type is).
           * A ClassCastException here is truly unexpected, so we let it
           * propagate up.
           */
  
  	value = (String) ExpressionUtil.evalNotNull(
  	    "out", "value", value_, String.class, this, pageContext);
  	def = (String) ExpressionUtil.evalNotNull(
  	    "out", "default", default_, String.class, this, pageContext);
  	escapeXml = true;
  	Boolean escape = ((Boolean) ExpressionUtil.evalNotNull(
  	    "out", "escapeXml", escapeXml_, Boolean.class, this, pageContext));
  	if (escape != null)
  	    escapeXml = escape.booleanValue();
      }
  }
  
  
  
  1.1                  jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/core/OutTag.java
  
  Index: OutTag.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.taglibs.standard.tag.rt.core;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import org.apache.taglibs.standard.tag.common.core.*;
  
  /**
   * <p>Tag handler for &lt;out&gt; in JSTL's rtexprvalue library.</p>
   *
   * @author Shawn Bayern
   */
  
  public class OutTag extends OutSupport {
  
      //*********************************************************************
      // Accessors
         
      // for tag attribute
      public void setValue(String value) {
          this.value = value;
      }
        
      // for tag attribute
      public void setDefault(String def) {
          this.def = def;
      }
          
      // for tag attribute
      public void setEscapeXml(boolean escapeXml) {
          this.escapeXml = escapeXml;
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message