Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/aendvari/tethys/tag/logic/LogicTagData.java


1   /*
2    * LogicTagData.java
3    *
4    * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5    *
6    * See the file LICENSE for terms of use.
7    *
8    */
9   
10  package com.aendvari.tethys.tag.logic;
11  
12  import javax.servlet.*;
13  import javax.servlet.http.*;
14  import javax.servlet.jsp.*;
15  
16  import com.aendvari.tethys.*;
17  import com.aendvari.tethys.context.*;
18  import com.aendvari.tethys.tag.data.TagData;
19  
20  /**
21   * <p>Provides access to logic tag data.</p>
22   *
23   * <p>The objects in this class are created on demand to reduce unnecessary
24   * object creation.</p>
25   *
26   * @author Trevor Milne
27   *
28   */
29  
30  public class LogicTagData extends TagData
31  {
32    /* Variables */
33  
34  
35    /** Used to obtain tag data instances. */
36    protected static LogicTagData accessor = new LogicTagData();
37  
38    /** Container for logic responses. */
39    protected ContextMap responseMap;
40  
41  
42    /* Constants */
43  
44  
45    protected final static String TagDataKey = TagData.TagDataBase + "/logic";
46  
47  
48    /* Constructors */
49  
50  
51      /**
52       * Constructs an empty <code>LogicTagData</code>.
53       *
54       */
55  
56    public LogicTagData()
57    {
58      responseMap = null;
59    }
60  
61  
62    /* Access */
63  
64  
65    /**
66     * Returns the servlet attribute key for this tag data.
67     *
68     * @return                  The servlet attribute location for this tag data.
69     *
70     */
71  
72    protected String getDataKey()
73    {
74      return TagDataKey;
75    }
76  
77    /**
78     * Returns a new instance of this tag data.
79     * This method is to be implemented by subclasses.
80     *
81     * @return                  The new tag data object.
82     *
83     */
84  
85    protected TagData createObject()
86    {
87      return new LogicTagData();
88    }
89  
90  
91    /** Wraps {@link TagData#getTagData(HttpServletRequest)}. */
92    public static LogicTagData getData(HttpServletRequest request) { return (LogicTagData)accessor.getTagData(request); }
93  
94    /** Wraps {@link TagData#getTagData(HttpSession)}. */
95    public static LogicTagData getData(HttpSession session) { return (LogicTagData)accessor.getTagData(session); }
96  
97    /** Wraps {@link TagData#getTagData(ServletContext)}. */
98    public static LogicTagData getData(ServletContext context) { return (LogicTagData)accessor.getTagData(context); }
99  
100   /** Wraps {@link TagData#getTagData(PageContext)}. */
101   public static LogicTagData getData(PageContext context) { return (LogicTagData)accessor.getTagData(context); }
102 
103   /** Wraps {@link TagData#getTagData(PageContext, String)}. */
104   public static LogicTagData getData(PageContext context, String scope) { return (LogicTagData)accessor.getTagData(context, scope); }
105 
106 
107   /** Wraps {@link TagData#setTagData(HttpServletRequest, TagData)}. */
108   public static void setData(HttpServletRequest request, LogicTagData data) { accessor.setTagData(request, data); }
109 
110   /** Wraps {@link TagData#setTagData(HttpSession, TagData)}. */
111   public static void setData(HttpSession session, LogicTagData data) { accessor.setTagData(session, data); }
112 
113   /** Wraps {@link TagData#setTagData(ServletContext, TagData)}. */
114   public static void setData(ServletContext context, LogicTagData data) { accessor.setTagData(context, data); }
115 
116   /** Wraps {@link TagData#setTagData(PageContext, String, TagData)}. */
117   public static void setData(PageContext context, String scope, LogicTagData data) { accessor.setTagData(context, scope, data); }
118 
119 
120   /* Response map */
121 
122 
123   /**
124    * Returns the response map of this tag data. A default instance will be created.
125    *
126    * @return                  A {@link ContextMap} instance.
127    *
128    */
129 
130   public ContextMap getResponseMap()
131   {
132     // check if object has not been created
133     if (responseMap == null)
134     {
135       // create a default response
136       Response context = new Response("", "", false);
137 
138       // create a default instance
139       responseMap = new ContextMap(context);
140     }
141 
142     return responseMap;
143   }
144 
145     /**
146      * Sets the response map of this tag data.
147      *
148      * @param    setResponseMap        The new {@link ContextMap}.
149      *
150      */
151 
152   public void setResponseMap(ContextMap setResponseMap)
153   {
154     responseMap = setResponseMap;
155   }
156 }
157