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

Quick Search    Search Deep

Source code: com/aendvari/tethys/tag/data/DataBodyTag.java


1   /*
2    * DataBodyTag.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.data;
11  
12  import javax.servlet.jsp.JspTagException;
13  import javax.servlet.jsp.tagext.*;
14  
15  import com.aendvari.tethys.tag.*;
16  
17  
18  /**
19   * <p>A base class for all body tags requiring ancillary data.</p>
20   *
21   * @author  Trevor Milne
22   *
23   */
24  
25  public abstract class DataBodyTag extends BodyTagSupport implements DataAncestorTag
26  {
27    /* Parameters. */
28  
29    /** The name of the tag. */
30    protected String name;
31  
32    /** The scope of any data associated with this tag. */
33    protected String dataScope;
34  
35  
36    /* Constructors. */
37  
38    /**
39     * Default constructor, all subclasses are required to only define a public
40     * constructor with the same signature, and to call the superclass constructor.
41     *
42     */
43  
44    public DataBodyTag()
45    {
46      super();
47  
48      name = null;
49      dataScope = null;
50    }
51  
52  
53    /* Accessors. */
54  
55    public String getName()
56    {
57      return name;
58    }
59  
60    public void setName(String name)
61    {
62      this.name = name;
63    }
64  
65    public String getDataScope()
66    {
67      // check for undefined scope
68      if (dataScope == null)
69      {
70        // use scope of parent
71        TagSupport parent = TagUtil.getParentTag(this, DataAncestorTag.class);
72  
73        if (parent != null)
74        {
75          // cast to appropriate type of parent
76          if (parent instanceof DataTag)
77          {
78            // don't use getDataScope() to avoid recursion
79            dataScope = ((DataTag)parent).dataScope;
80          }
81          else
82          if (parent instanceof DataBodyTag)
83          {
84            // don't use getDataScope() to avoid recursion
85            dataScope = ((DataBodyTag)parent).dataScope;
86          }
87        }
88      }
89  
90      return dataScope;
91    }
92  
93    public void setDataScope(String scope)
94    {
95      this.dataScope = scope;
96    }
97  
98      /**
99       * Release all allocated resources.
100    *
101      */
102 
103     public void release()
104     {
105         super.release();
106 
107         name = null;
108     dataScope = null;
109     }
110 }
111