KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jsp > cfg > TldAttribute


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.jsp.cfg;
30
31 import com.caucho.config.types.Signature;
32
33 import javax.servlet.jsp.tagext.JspFragment JavaDoc;
34
35 /**
36  * Configuration for the taglib attribute in the .tld
37  */

38 public class TldAttribute {
39   private String JavaDoc _name;
40   private boolean _required;
41   private boolean _rtexprvalue;
42   private Class JavaDoc _type;
43   private String JavaDoc _description;
44   private boolean _isFragment;
45
46   private DeferredMethod _deferredMethod;
47   private DeferredValue _deferredValue;
48
49   /**
50    * Sets the attribute name.
51    */

52   public void setName(String JavaDoc name)
53   {
54     _name = name;
55   }
56
57   /**
58    * Gets the attribute name.
59    */

60   public String JavaDoc getName()
61   {
62     return _name;
63   }
64
65   /**
66    * Sets the description.
67    */

68   public void setDescription(String JavaDoc description)
69   {
70     _description = description;
71   }
72
73   public String JavaDoc getDescription()
74   {
75     return _description;
76   }
77
78   /**
79    * Sets true if the attribute is required.
80    */

81   public void setRequired(boolean required)
82   {
83     _required = required;
84   }
85
86   /**
87    * Returns true if the attribute is required.
88    */

89   public boolean getRequired()
90   {
91     return _required;
92   }
93
94   /**
95    * Sets true if the attribute allows runtime expressions
96    */

97   public void setRtexprvalue(boolean rtexprvalue)
98   {
99     _rtexprvalue = rtexprvalue;
100   }
101
102   /**
103    * Returns true if runtime expressions are required.
104    */

105   public boolean getRtexprvalue()
106   {
107     return _rtexprvalue;
108   }
109
110   /**
111    * Sets true if the attribute allows runtime expressions
112    */

113   public void setFragment(boolean isFragment)
114   {
115     _isFragment = isFragment;
116   }
117
118   /**
119    * Sets true if the attribute allows runtime expressions
120    */

121   public boolean isFragment()
122   {
123     return _isFragment;
124   }
125
126   /**
127    * Sets the type of the attribute.
128    */

129   public void setType(Class JavaDoc type)
130   {
131     _type = type;
132   }
133
134   /**
135    * Returns the type of the attribute.
136    */

137   public Class JavaDoc getType()
138   {
139     if (_type != null)
140       return _type;
141     else if (isFragment())
142       return JspFragment JavaDoc.class;
143     else
144       return String JavaDoc.class;
145   }
146
147   /**
148    * Sets the deferred value.
149    */

150   public void setDeferredValue(DeferredValue v)
151   {
152     _deferredValue = v;
153   }
154
155   /**
156    * Sets the deferred value.
157    */

158   public DeferredValue getDeferredValue()
159   {
160     return _deferredValue;
161   }
162
163   /**
164    * Sets the deferred method.
165    */

166   public void setDeferredMethod(DeferredMethod defer)
167   {
168     _deferredMethod = defer;
169   }
170
171   public String JavaDoc getExpectedType()
172   {
173     if (_deferredValue != null)
174       return _deferredValue.getType();
175     else
176       return null;
177   }
178
179   public DeferredMethod getDeferredMethod()
180   {
181     return _deferredMethod;
182   }
183   
184   public String JavaDoc getDeferredMethodSignature()
185   {
186     if (_deferredMethod != null) {
187       Signature sig = _deferredMethod.getMethodSignature();
188
189       if (sig != null)
190     return sig.getSignature();
191     }
192     
193     return null;
194   }
195
196   public static class DeferredMethod {
197     private Signature _signature;
198
199     public void setMethodSignature(Signature sig)
200     {
201       _signature = sig;
202     }
203
204     public Signature getMethodSignature()
205     {
206       return _signature;
207     }
208   }
209
210   public static class DeferredValue {
211     private String JavaDoc _type;
212
213     public void setId(String JavaDoc id)
214     {
215     }
216
217     public void setType(String JavaDoc type)
218     {
219       _type = type;
220     }
221
222     public String JavaDoc getType()
223     {
224       return _type;
225     }
226   }
227 }
228
Popular Tags