001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.jsp.cfg;
030:
031: import com.caucho.config.types.Signature;
032:
033: import javax.servlet.jsp.tagext.JspFragment;
034:
035: /**
036: * Configuration for the taglib attribute in the .tld
037: */
038: public class TldAttribute {
039: private String _name;
040: private boolean _required;
041: private boolean _rtexprvalue;
042: private Class _type;
043: private String _description;
044: private boolean _isFragment;
045:
046: private DeferredMethod _deferredMethod;
047: private DeferredValue _deferredValue;
048:
049: /**
050: * Sets the attribute name.
051: */
052: public void setName(String name) {
053: _name = name;
054: }
055:
056: /**
057: * Gets the attribute name.
058: */
059: public String getName() {
060: return _name;
061: }
062:
063: /**
064: * Sets the description.
065: */
066: public void setDescription(String description) {
067: _description = description;
068: }
069:
070: public String getDescription() {
071: return _description;
072: }
073:
074: /**
075: * Sets true if the attribute is required.
076: */
077: public void setRequired(boolean required) {
078: _required = required;
079: }
080:
081: /**
082: * Returns true if the attribute is required.
083: */
084: public boolean getRequired() {
085: return _required;
086: }
087:
088: /**
089: * Sets true if the attribute allows runtime expressions
090: */
091: public void setRtexprvalue(boolean rtexprvalue) {
092: _rtexprvalue = rtexprvalue;
093: }
094:
095: /**
096: * Returns true if runtime expressions are required.
097: */
098: public boolean getRtexprvalue() {
099: return _rtexprvalue;
100: }
101:
102: /**
103: * Sets true if the attribute allows runtime expressions
104: */
105: public void setFragment(boolean isFragment) {
106: _isFragment = isFragment;
107: }
108:
109: /**
110: * Sets true if the attribute allows runtime expressions
111: */
112: public boolean isFragment() {
113: return _isFragment;
114: }
115:
116: /**
117: * Sets the type of the attribute.
118: */
119: public void setType(Class type) {
120: _type = type;
121: }
122:
123: /**
124: * Returns the type of the attribute.
125: */
126: public Class getType() {
127: if (_type != null)
128: return _type;
129: else if (isFragment())
130: return JspFragment.class;
131: else
132: return String.class;
133: }
134:
135: /**
136: * Sets the deferred value.
137: */
138: public void setDeferredValue(DeferredValue v) {
139: _deferredValue = v;
140: }
141:
142: /**
143: * Sets the deferred value.
144: */
145: public DeferredValue getDeferredValue() {
146: return _deferredValue;
147: }
148:
149: /**
150: * Sets the deferred method.
151: */
152: public void setDeferredMethod(DeferredMethod defer) {
153: _deferredMethod = defer;
154: }
155:
156: public String getExpectedType() {
157: if (_deferredValue != null)
158: return _deferredValue.getType();
159: else
160: return null;
161: }
162:
163: public DeferredMethod getDeferredMethod() {
164: return _deferredMethod;
165: }
166:
167: public String getDeferredMethodSignature() {
168: if (_deferredMethod != null) {
169: Signature sig = _deferredMethod.getMethodSignature();
170:
171: if (sig != null)
172: return sig.getSignature();
173: }
174:
175: return null;
176: }
177:
178: public static class DeferredMethod {
179: private Signature _signature;
180:
181: public void setMethodSignature(Signature sig) {
182: _signature = sig;
183: }
184:
185: public Signature getMethodSignature() {
186: return _signature;
187: }
188: }
189:
190: public static class DeferredValue {
191: private String _type;
192:
193: public void setId(String id) {
194: }
195:
196: public void setType(String type) {
197: _type = type;
198: }
199:
200: public String getType() {
201: return _type;
202: }
203: }
204: }
|