001: /*
002: * Copyright (c) 1998-2001 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 javax.servlet.jsp.tagext;
030:
031: /**
032: * TagVariableInfo objects create runtime variables available to the tags.
033: *
034: * <p/>For example, a NESTED variable could be used like:
035: *
036: * <code><pre>
037: * <mytag:loop name='i' min='0' max='10'>
038: * Iter: <%= i %>
039: * </mytag:loop>
040: * </pre></code>
041: *
042: * @since JSP 1.2
043: */
044: public class TagVariableInfo {
045: private String _nameGiven;
046: private String _nameFromAttribute;
047: private String _className;
048: private boolean _declare;
049: private int _scope;
050:
051: /**
052: * Creates information for a variable.
053: *
054: * @param nameGiven name of the variable
055: * @param nameFromAttribute name of the variable
056: * @param className the java classname of the variable
057: * @param declare true if the variable should be declared
058: * @param scope the scope of the variable
059: */
060: public TagVariableInfo(String nameGiven, String nameFromAttribute,
061: String className, boolean declare, int scope) {
062: _nameGiven = nameGiven;
063: _nameFromAttribute = nameFromAttribute;
064: _className = className;
065: _declare = declare;
066: _scope = scope;
067: }
068:
069: /**
070: * Returns the variable name, if it's static.
071: */
072: public String getNameGiven() {
073: return _nameGiven;
074: }
075:
076: /**
077: * Returns the attribute name that will contain the variable name
078: */
079: public String getNameFromAttribute() {
080: return _nameFromAttribute;
081: }
082:
083: /**
084: * Returns the variable's Java class.
085: */
086: public String getClassName() {
087: return _className;
088: }
089:
090: /**
091: * True if the variable should be declared. If false, the JSP engine
092: * assumes the variable is already declared and just assigns the value.
093: */
094: public boolean getDeclare() {
095: return _declare;
096: }
097:
098: /**
099: * Returns the variable's scope.
100: *
101: * <ul>
102: * <li>AT_BEGIN - available as soon as the tag starts
103: * <li>NESTED - only available in the tag body
104: * <li>AT_END - only available after the tag ends.
105: */
106: public int getScope() {
107: return _scope;
108: }
109: }
|