jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-taglibs/string/src/org/apache/taglibs/string LeftTag.java MidTag.java RightTag.java
Date Wed, 31 Jul 2002 05:16:10 GMT
bayard      2002/07/30 22:16:10

  Modified:    string/xml string.xml
  Added:       string/src/org/apache/taglibs/string LeftTag.java
                        MidTag.java RightTag.java
  Log:
  Added left mid and right tags. In truth these are not a lot more than
  substring like tags, but as StringUtils in Commons Lang has these as methods
  it makes sense for String taglib to offer up access to them.
  
  Revision  Changes    Path
  1.18      +141 -0    jakarta-taglibs/string/xml/string.xml
  
  Index: string.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/string/xml/string.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- string.xml	31 Jul 2002 04:01:40 -0000	1.17
  +++ string.xml	31 Jul 2002 05:16:10 -0000	1.18
  @@ -1740,6 +1740,147 @@
   
   <!-- end of imported string.tld file -->
   
  +      <tag>
  +        <name>left</name>
  +        <tag-class>org.apache.taglibs.string.LeftTag</tag-class>
  +        <body-content>JSP</body-content>
  +        <display-name>left</display-name>
  +        <description>
  +            Get the leftmost 'n' characters from a string.
  +        </description>
  +        <availability>1.0</availability>
  +        <restrictions>None</restrictions>
  +        <attribute>
  +          <name>var</name>
  +          <required>false</required>
  +          <rtexprvalue>true</rtexprvalue>
  +          <type>java.lang.String</type>
  +          <description>
  +              Variable to store result in.
  +          </description>
  +          <availability>1.0</availability>
  +        </attribute>
  +        <attribute>
  +          <name>count</name>
  +          <required>true</required>
  +          <rtexprvalue>true</rtexprvalue>
  +          <type>java.lang.String</type>
  +          <description>
  +              Number of characters to get.
  +          </description>
  +          <availability>1.0</availability>
  +        </attribute>
  +        <example>
  +          <usage>
  +            <comment>
  +              Will output:  &apos;&lt;A long piece of&gt;&apos;
  +            </comment>
  +            <code>
  +<![CDATA[ 
  +&lt;<str:left count="15">A long piece of text which will get cut.</str:rightPad>
  +]]>       
  +            </code>
  +          </usage>
  +        </example>
  +      </tag>
  +      <tag>
  +        <name>right</name>
  +        <tag-class>org.apache.taglibs.string.RightTag</tag-class>
  +        <body-content>JSP</body-content>
  +        <display-name>right</display-name>
  +        <description>
  +            Get the rightmost 'n' characters from a string.
  +        </description>
  +        <availability>1.0</availability>
  +        <restrictions>None</restrictions>
  +        <attribute>
  +          <name>var</name>
  +          <required>false</required>
  +          <rtexprvalue>true</rtexprvalue>
  +          <type>java.lang.String</type>
  +          <description>
  +              Variable to store result in.
  +          </description>
  +          <availability>1.0</availability>
  +        </attribute>
  +        <attribute>
  +          <name>count</name>
  +          <required>true</required>
  +          <rtexprvalue>true</rtexprvalue>
  +          <type>java.lang.String</type>
  +          <description>
  +              Number of characters to get.
  +          </description>
  +          <availability>1.0</availability>
  +        </attribute>
  +        <example>
  +          <usage>
  +            <comment>
  +              Will output:  &apos;&lt;will get cut.&gt;&apos;
  +            </comment>
  +            <code>
  +<![CDATA[ 
  +&lt;<str:right count="13">A long piece of text which will get cut.</str:rightPad>
  +]]>       
  +            </code>
  +          </usage>
  +        </example>
  +      </tag>
  +      <tag>
  +        <name>mid</name>
  +        <tag-class>org.apache.taglibs.string.MidTag</tag-class>
  +        <body-content>JSP</body-content>
  +        <display-name>mid</display-name>
  +        <description>
  +            Get 'n' characters from the inside of a string.
  +            The start position may be set, or the default may be 
  +            used. The default is to get the central characters.
  +        </description>
  +        <availability>1.0</availability>
  +        <restrictions>None</restrictions>
  +        <attribute>
  +          <name>var</name>
  +          <required>false</required>
  +          <rtexprvalue>true</rtexprvalue>
  +          <type>java.lang.String</type>
  +          <description>
  +              Variable to store result in.
  +          </description>
  +          <availability>1.0</availability>
  +        </attribute>
  +        <attribute>
  +          <name>start</name>
  +          <required>false</required>
  +          <rtexprvalue>true</rtexprvalue>
  +          <type>java.lang.String</type>
  +          <description>
  +              Position to start at.
  +          </description>
  +          <availability>1.0</availability>
  +        </attribute>
  +        <attribute>
  +          <name>count</name>
  +          <required>true</required>
  +          <rtexprvalue>true</rtexprvalue>
  +          <type>java.lang.String</type>
  +          <description>
  +              Number of characters to get.
  +          </description>
  +          <availability>1.0</availability>
  +        </attribute>
  +        <example>
  +          <usage>
  +            <comment>
  +              Will output:  &apos;&lt;text which&gt;&apos;
  +            </comment>
  +            <code>
  +<![CDATA[ 
  +&lt;<str:mid count="10">A long piece of text which will get cut.</str:rightPad>
  +]]>       
  +            </code>
  +          </usage>
  +        </example>
  +      </tag>
     </tagtoc>
   
   </taglib>
  
  
  
  1.1                  jakarta-taglibs/string/src/org/apache/taglibs/string/LeftTag.java
  
  Index: LeftTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-taglibs/string/src/org/apache/taglibs/string/LeftTag.java,v
1.1 2002/07/31 05:16:10 bayard Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/31 05:16:10 $
   *
   * ====================================================================
   *
   * 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.string;
  
  import org.apache.commons.lang.StringUtils;
  import org.apache.commons.lang.NumberUtils;
  
  /**
   * Gets the leftmost 'n' characters from a string.
   *
   * <dl>
   * <dt>count</dt><dd>
   *             Size of characters to get.
   *             Required.
   * </dd>
   * </dl>
   * 
   * @author bayard@generationjava.com
   */
  public class LeftTag extends StringTagSupport {
  
      private int count;
  
      public LeftTag() {
          super();
      }
  
      /**
       * Get the count property
       *
       * @return String property
       */
      public String getCount() {
          return ""+this.count;
      }
  
      /**
       * Set the count property
       *
       * @param count String property
       */
      public void setCount(String count) {
          this.count = NumberUtils.stringToInt(count);
      }
  
  
  
      public String changeString(String text) {
          return StringUtils.left(text, count);
      }
  
      public void initAttributes() {
  
          this.count = 0;
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-taglibs/string/src/org/apache/taglibs/string/MidTag.java
  
  Index: MidTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-taglibs/string/src/org/apache/taglibs/string/MidTag.java,v
1.1 2002/07/31 05:16:10 bayard Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/31 05:16:10 $
   *
   * ====================================================================
   *
   * 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.string;
  
  import org.apache.commons.lang.StringUtils;
  import org.apache.commons.lang.NumberUtils;
  
  /**
   * Gets 'n' characters from the inside of a string.
   *
   * <dl>
   * <dt>count</dt><dd>
   *             Size of characters to get.
   *             Required.
   * </dd>
   * <dt>start</dt><dd>
   *             Index to start from.
   *             Default is to use the central point - count/2.
   * </dd>
   * </dl>
   * 
   * @author bayard@generationjava.com
   */
  public class MidTag extends StringTagSupport {
  
      private int count;
      private int start;
  
      public MidTag() {
          super();
      }
  
      /**
       * Get the count property
       *
       * @return String property
       */
      public String getCount() {
          return ""+this.count;
      }
  
      /**
       * Set the count property
       *
       * @param count String property
       */
      public void setCount(String count) {
          this.count = NumberUtils.stringToInt(count);
      }
  
      /**
       * Get the start property
       *
       * @return String property
       */
      public String getStart() {
          return ""+this.start;
      }
  
      /**
       * Set the start property
       *
       * @param start String property
       */
      public void setStart(String start) {
          this.start = NumberUtils.stringToInt(start);
      }
  
  
      public String changeString(String text) {
          if(start == -1) {
              start = (text.length() - count)/2;
          }
          return StringUtils.mid(text, start, count);
      }
  
      public void initAttributes() {
          this.count = 0;
          this.start = -1;
      }
  
  
  }
  
  
  
  1.1                  jakarta-taglibs/string/src/org/apache/taglibs/string/RightTag.java
  
  Index: RightTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-taglibs/string/src/org/apache/taglibs/string/RightTag.java,v
1.1 2002/07/31 05:16:10 bayard Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/31 05:16:10 $
   *
   * ====================================================================
   *
   * 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.string;
  
  import org.apache.commons.lang.StringUtils;
  import org.apache.commons.lang.NumberUtils;
  
  /**
   * Gets the rightmost 'n' characters from a string.
   *
   * <dl>
   * <dt>count</dt><dd>
   *             Size of characters to get.
   *             Required.
   * </dd>
   * </dl>
   * 
   * @author bayard@generationjava.com
   */
  public class RightTag extends StringTagSupport {
  
      private int count;
  
      public RightTag() {
          super();
      }
  
      /**
       * Get the count property
       *
       * @return String property
       */
      public String getCount() {
          return ""+this.count;
      }
  
      /**
       * Set the count property
       *
       * @param count String property
       */
      public void setCount(String count) {
          this.count = NumberUtils.stringToInt(count);
      }
  
  
  
      public String changeString(String text) {
          return StringUtils.right(text, count);
      }
  
      public void initAttributes() {
  
          this.count = 0;
  
      }
  
  
  }
  
  
  

--
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