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