001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *  http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    
020    //
021    // This source code implements specifications defined by the Java
022    // Community Process. In order to remain compliant with the specification
023    // DO NOT add / change / or delete method signatures!
024    //
025    
026    package javax.servlet.jsp.tagext;
027    
028    /**
029     * Variable information for a tag in a Tag Library;
030     * This class is instantiated from the Tag Library Descriptor file (TLD)
031     * and is available only at translation time.
032     *
033     * This object should be immutable.
034     *
035     * This information is only available in JSP 1.2 format TLDs or above.
036     */
037    
038    public class TagVariableInfo {
039    
040        /**
041         * Constructor for TagVariableInfo.
042         *
043         * @param nameGiven value of <name-given>
044         * @param nameFromAttribute value of <name-from-attribute>
045         * @param className value of <variable-class>
046         * @param declare value of <declare>
047         * @param scope value of <scope>
048         */
049        public TagVariableInfo(
050                String nameGiven,
051                String nameFromAttribute,
052                String className,
053                boolean declare,
054                int scope) {
055            this.nameGiven         = nameGiven;
056            this.nameFromAttribute = nameFromAttribute;
057            this.className         = className;
058            this.declare           = declare;
059            this.scope             = scope;
060        }
061    
062        /**
063         * The body of the <name-given> element.
064         *
065         * @return The variable name as a constant
066         */
067    
068        public String getNameGiven() {
069            return nameGiven;
070        }
071    
072        /**
073         * The body of the <name-from-attribute> element.
074         * This is the name of an attribute whose (translation-time)
075         * value will give the name of the variable.  One of
076         * <name-given> or <name-from-attribute> is required.
077         *
078         * @return The attribute whose value defines the variable name
079         */
080    
081        public String getNameFromAttribute() {
082            return nameFromAttribute;
083        }
084    
085        /**
086         * The body of the <variable-class> element.  
087         *
088         * @return The name of the class of the variable or
089         *         'java.lang.String' if not defined in the TLD.
090         */
091    
092        public String getClassName() {
093            return className;
094        }
095    
096        /**
097         * The body of the <declare> element.
098         *
099         * @return Whether the variable is to be declared or not.
100         *         If not defined in the TLD, 'true' will be returned.
101         */
102    
103        public boolean getDeclare() {
104            return declare;
105        }
106    
107        /**
108         * The body of the <scope> element.
109         *
110         * @return The scope to give the variable.  NESTED
111         *         scope will be returned if not defined in 
112         *         the TLD.
113         */
114    
115        public int getScope() {
116            return scope;
117        }
118    
119    
120        /*
121         * private fields
122         */
123        private String   nameGiven;         // <name-given>
124        private String   nameFromAttribute; // <name-from-attribute>
125        private String   className;         // <class>
126        private boolean  declare;           // <declare>
127        private int      scope;             // <scope>
128    }