struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dge...@locus.apache.org
Subject cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/template/util Content.java ContentMap.java ContentMapStack.java
Date Sun, 08 Oct 2000 01:17:40 GMT
dgeary      00/10/07 18:17:40

  Added:       src/share/org/apache/struts/taglib/template/util
                        Content.java ContentMap.java ContentMapStack.java
  Log:
  Adding utility classes for template tags.
  
  Revision  Changes    Path
  1.1                  jakarta-struts/src/share/org/apache/struts/taglib/template/util/Content.java
  
  Index: Content.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/util/Content.java,v
1.1 2000/10/08 01:17:40 dgeary Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/08 01:17:40 $
   *
   * ====================================================================
   *
   * 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.struts.taglib.template.util;
  
  /**
   *  A utility file for templates.
   *  <p>
   *  This represents template content, which is included by templates. 
   *  Templates can also treat content as plain text and print it to the
   *  implicit out variable.
   * 
   *  This simple class maintain two properties:
   *  <ul>
   *  <li><i>content</i>: A string representing either a URI or text.</li>
   *  <li><i>direct</i>: If true, content is printed; otherwise content
is 
   *  included (default is false).</li>
   *  </ul>
   *  </p>
   *
   * @author David Geary
   * @revision $Revision: 1.1 $
   */
  public class Content {
  
  // ----------------------------------------------------- Instance Variables
  
  
      /**
       *  Templates regard this as content to be either included or 
       *  printed directly.<br> This is a blank final that is
       *  set at construction.
       * 
       */
      private final String content;
  
  
      /**
       *   Represents a boolean; if true, content is included, otherwise
       *   content is printed.<br>This is a blank final that is set at 
       *  construction.<br>This is a string instead of a boolean as
       *  a convenience for the tags, whose corresponding attribute
       *  is a string.
       *  
       */
      private final String direct;
  
  
  // ------------------------------------------------------------ Construtors
  
      /**
       * The only constructor.
       *
       * @param content The content's URI
       * @param direct Is content printed directly (true) or included (false)?
       */
     public Content(String content, String direct) {
  
        this.content = content;
        this.direct = direct;
  
     }
  
  
      // --------------------------------------------------------- Public Methods
  
      /**
       * Return content 
       */
      public String getContent() {
  
        return (content);
  
      }
  
      /**
       * Is content to be printed directly (isDirect() == true) <br>
       * instead of included (isDirect() == false)?
       */
      public boolean isDirect() {
  
        return (Boolean.valueOf(direct).booleanValue());
  
      }
  
  
     /**
       * Returns a string representation of the content
       */
     public String toString() { 
  
        return content;
  
     }
  
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/taglib/template/util/ContentMap.java
  
  Index: ContentMap.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/util/ContentMap.java,v
1.1 2000/10/08 01:17:40 dgeary Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/08 01:17:40 $
   *
   * ====================================================================
   *
   * 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.struts.taglib.template.util;
  
  import java.util.HashMap;
  
  /**
   * A simple facade for a hash map. This class restricts operations
   * that can be performed on a hash map of contents. 
   *
   * @author David Geary
   * @version $Revision: 1.1 $ $Date: 2000/10/08 01:17:40 $
   */
  public class ContentMap {
  
  
  // ------------------------------------------------------------ Construtors
  
     /**
       * Explicitly declare a do-nothing, no-arg constructor. 
       */
     public ContentMap() { }
  
  // ----------------------------------------------------- Instance Variables
  
  
     /**
       * The map.
       */
     private HashMap map = new HashMap();
  
  // --------------------------------------------------------- Public Methods
  
  
     /**
       * Put named content into map.
       *
       * @param name The content's name
       * @param content The content
       */
     public void put(String name, Content content) {
     
        map.put(name, content);
  
     }
  
  
     /**
       * Returns the content associated with name
       *
       * @name Name of content to retrieve
       */
     public Content get(String name) {
  
        return (Content)map.get(name);
  
     }
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/taglib/template/util/ContentMapStack.java
  
  Index: ContentMapStack.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/template/util/ContentMapStack.java,v
1.1 2000/10/08 01:17:40 dgeary Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/08 01:17:40 $
   *
   * ====================================================================
   *
   * 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.struts.taglib.template.util;
  
  import javax.servlet.jsp.PageContext;
  import java.util.Stack;
  
  /**
   * This class provides access to a stack of ContentMaps in request scope
   * through static methods.
   *
   * @author David Geary
   * @version $Revision: 1.1 $ $Date: 2000/10/08 01:17:40 $
   */
  public class ContentMapStack {
  
  // ------------------------------------------------------------ Construtors
  
     /**
       * No instantiations of this class are allowed.
       */
     private ContentMapStack() { } // no instantiations
  
  // -------------------------------------------------- Public Static Methods
  
  
     /**
       * Return a reference to the stack. If there is no stack, one is
       * created and placed into request scope associated with the
       * page context.
       *
       * @param pc The page context associated with a custom tag.
       */
     public static Stack getStack(PageContext pc) {
  
        Stack s = (Stack)pc.getAttribute("template-stack",
                                         PageContext.REQUEST_SCOPE);
        if(s == null) {
           s = new Stack();
           pc.setAttribute("template-stack", s,
                           PageContext.REQUEST_SCOPE);
        }
        return s;
  
     }
  
  
     /**
       * Peek at the map on top of the stack.
       * 
       * @param pc The page context associated with a custom tag.
       */
     public static ContentMap peek(PageContext pc) {
  
        return (ContentMap)getStack(pc).peek();
  
     }
  
  
     /**
       * Push a content map onto the stack. 
       *
       * @param pc The page context associated with a custom tag.
       * @param map A content map that gets pushed onto the stack.
       */
     public static void push(PageContext pc, ContentMap map) {
  
        getStack(pc).push(map);
  
     }
  
  
     /**
       * 
       * @param pc The page context associated with a custom tag.
       */
     public static ContentMap pop(PageContext pc) {
  
        return (ContentMap)getStack(pc).pop();
  
     }
  
  }
  
  
  

Mime
View raw message