Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagLibraryInfo.java URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagLibraryInfo.java?rev=379499&view=auto ============================================================================== --- tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagLibraryInfo.java (added) +++ tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagLibraryInfo.java Tue Feb 21 07:46:36 2006 @@ -0,0 +1,286 @@ +/* +* Copyright 2004 The Apache Software Foundation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package javax.servlet.jsp.tagext; + +import javax.servlet.jsp.tagext.TagInfo; +import javax.servlet.jsp.tagext.TagFileInfo; + +/** + * Translation-time information associated with a taglib directive, and its + * underlying TLD file. + * + * Most of the information is directly from the TLD, except for + * the prefix and the uri values used in the taglib directive + * + * + */ + +abstract public class TagLibraryInfo { + + /** + * Constructor. + * + * This will invoke the constructors for TagInfo, and TagAttributeInfo + * after parsing the TLD file. + * + * @param prefix the prefix actually used by the taglib directive + * @param uri the URI actually used by the taglib directive + */ + protected TagLibraryInfo(String prefix, String uri) { + this.prefix = prefix; + this.uri = uri; + } + + // ==== methods accessing taglib information ======= + + /** + * The value of the uri attribute from the taglib directive for + * this library. + * + * @return the value of the uri attribute + */ + + public String getURI() { + return uri; + } + + /** + * The prefix assigned to this taglib from the taglib directive + * + * @return the prefix assigned to this taglib from the taglib directive + */ + + public String getPrefixString() { + return prefix; + } + + // ==== methods using the TLD data ======= + + /** + * The preferred short name (prefix) as indicated in the TLD. + * This may be used by authoring tools as the preferred prefix + * to use when creating an taglib directive for this library. + * + * @return the preferred short name for the library + */ + public String getShortName() { + return shortname; + } + + /** + * The "reliable" URN indicated in the TLD (the uri element). + * This may be used by authoring tools as a global identifier + * to use when creating a taglib directive for this library. + * + * @return a reliable URN to a TLD like this + */ + public String getReliableURN() { + return urn; + } + + + /** + * Information (documentation) for this TLD. + * + * @return the info string for this tag lib + */ + + public String getInfoString() { + return info; + } + + + /** + * A string describing the required version of the JSP container. + * + * @return the (minimal) required version of the JSP container. + * @see javax.servlet.jsp.JspEngineInfo + */ + + public String getRequiredVersion() { + return jspversion; + } + + + /** + * An array describing the tags that are defined in this tag library. + * + * @return the TagInfo objects corresponding to the tags defined by this + * tag library, or a zero length array if this tag library + * defines no tags + */ + public TagInfo[] getTags() { + return tags; + } + + /** + * An array describing the tag files that are defined in this tag library. + * + * @return the TagFileInfo objects corresponding to the tag files defined + * by this tag library, or a zero length array if this + * tag library defines no tags files + * @since 2.0 + */ + public TagFileInfo[] getTagFiles() { + return tagFiles; + } + + + /** + * Get the TagInfo for a given tag name, looking through all the + * tags in this tag library. + * + * @param shortname The short name (no prefix) of the tag + * @return the TagInfo for the tag with the specified short name, or + * null if no such tag is found + */ + + public TagInfo getTag(String shortname) { + TagInfo tags[] = getTags(); + + if (tags == null || tags.length == 0) { + return null; + } + + for (int i=0; i < tags.length; i++) { + if (tags[i].getTagName().equals(shortname)) { + return tags[i]; + } + } + return null; + } + + /** + * Get the TagFileInfo for a given tag name, looking through all the + * tag files in this tag library. + * + * @param shortname The short name (no prefix) of the tag + * @return the TagFileInfo for the specified Tag file, or null + * if no Tag file is found + * @since 2.0 + */ + public TagFileInfo getTagFile(String shortname) { + TagFileInfo tagFiles[] = getTagFiles(); + + if (tagFiles == null || tagFiles.length == 0) { + return null; + } + + for (int i=0; i < tagFiles.length; i++) { + if (tagFiles[i].getName().equals(shortname)) { + return tagFiles[i]; + } + } + return null; + } + + /** + * An array describing the functions that are defined in this tag library. + * + * @return the functions defined in this tag library, or a zero + * length array if the tag library defines no functions. + * @since 2.0 + */ + public FunctionInfo[] getFunctions() { + return functions; + } + + + /** + * Get the FunctionInfo for a given function name, looking through all the + * functions in this tag library. + * + * @param name The name (no prefix) of the function + * @return the FunctionInfo for the function with the given name, or null + * if no such function exists + * @since 2.0 + */ + public FunctionInfo getFunction(String name) { + + if (functions == null || functions.length == 0) { + System.err.println("No functions"); + return null; + } + + for (int i=0; i < functions.length; i++) { + if (functions[i].getName().equals(name)) { + return functions[i]; + } + } + return null; + } + + + // Protected fields + + /** + * The prefix assigned to this taglib from the taglib directive. + */ + protected String prefix; + + /** + * The value of the uri attribute from the taglib directive for + * this library. + */ + protected String uri; + + /** + * An array describing the tags that are defined in this tag library. + */ + protected TagInfo[] tags; + + /** + * An array describing the tag files that are defined in this tag library. + * + * @since 2.0 + */ + protected TagFileInfo[] tagFiles; + + /** + * An array describing the functions that are defined in this tag library. + * + * @since 2.0 + */ + protected FunctionInfo[] functions; + + // Tag Library Data + + /** + * The version of the tag library. + */ + protected String tlibversion; // required + + /** + * The version of the JSP specification this tag library is written to. + */ + protected String jspversion; // required + + /** + * The preferred short name (prefix) as indicated in the TLD. + */ + protected String shortname; // required + + /** + * The "reliable" URN indicated in the TLD. + */ + protected String urn; // required + + /** + * Information (documentation) for this TLD. + */ + protected String info; // optional +}
Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagLibraryValidator.java URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagLibraryValidator.java?rev=379499&view=auto ============================================================================== --- tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagLibraryValidator.java (added) +++ tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagLibraryValidator.java Tue Feb 21 07:46:36 2006 @@ -0,0 +1,143 @@ +/* +* Copyright 2004 The Apache Software Foundation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package javax.servlet.jsp.tagext; + +import java.util.Map; + +/** + * Translation-time validator class for a JSP page. + * A validator operates on the XML view associated with the JSP page. + * + * <p> + * The TLD file associates a TagLibraryValidator class and some init + * arguments with a tag library. + * + * <p> + * The JSP container is reponsible for locating an appropriate + * instance of the appropriate subclass by + * + * <ul> + * <li> new a fresh instance, or reuse an available one + * <li> invoke the setInitParams(Map) method on the instance + * </ul> + * + * once initialized, the validate(String, String, PageData) method will + * be invoked, where the first two arguments are the prefix + * and uri for this tag library in the XML View. The prefix is intended + * to make it easier to produce an error message. However, it is not + * always accurate. In the case where a single URI is mapped to more + * than one prefix in the XML view, the prefix of the first URI is provided. + * Therefore, to provide high quality error messages in cases where the + * tag elements themselves are checked, the prefix parameter should be + * ignored and the actual prefix of the element should be used instead. + * TagLibraryValidators should always use the uri to identify elements + * as beloning to the tag library, not the prefix. + * + * <p> + * A TagLibraryValidator instance + * may create auxiliary objects internally to perform + * the validation (e.g. an XSchema validator) and may reuse it for all + * the pages in a given translation run. + * + * <p> + * The JSP container is not guaranteed to serialize invocations of + * validate() method, and TagLibraryValidators should perform any + * synchronization they may require. + * + * <p> + * As of JSP 2.0, a JSP container must provide a jsp:id attribute to + * provide higher quality validation errors. + * The container will track the JSP pages + * as passed to the container, and will assign to each element + * a unique "id", which is passed as the value of the jsp:id + * attribute. Each XML element in the XML view available will + * be extended with this attribute. The TagLibraryValidator + * can then use the attribute in one or more ValidationMessage + * objects. The container then, in turn, can use these + * values to provide more precise information on the location + * of an error. + * + * <p> + * The actual prefix of the <code>id</code> attribute may or may not be + * <code>jsp</code> but it will always map to the namespace + * <code>http://java.sun.com/JSP/Page</code>. A TagLibraryValidator + * implementation must rely on the uri, not the prefix, of the <code>id</code> + * attribute. + */ + +abstract public class TagLibraryValidator { + + /** + * Sole constructor. (For invocation by subclass constructors, + * typically implicit.) + */ + public TagLibraryValidator() { + } + + /** + * Set the init data in the TLD for this validator. + * Parameter names are keys, and parameter values are the values. + * + * @param map A Map describing the init parameters + */ + public void setInitParameters(Map map) { + initParameters = map; + } + + + /** + * Get the init parameters data as an immutable Map. + * Parameter names are keys, and parameter values are the values. + * + * @return The init parameters as an immutable map. + */ + public Map getInitParameters() { + return initParameters; + } + + /** + * Validate a JSP page. + * This will get invoked once per unique tag library URI in the + * XML view. This method will return null if the page is valid; otherwise + * the method should return an array of ValidationMessage objects. + * An array of length zero is also interpreted as no errors. + * + * @param prefix the first prefix with which the tag library is + * associated, in the XML view. Note that some tags may use + * a different prefix if the namespace is redefined. + * @param uri the tag library's unique identifier + * @param page the JspData page object + * @return A null object, or zero length array if no errors, an array + * of ValidationMessages otherwise. + */ + public ValidationMessage[] validate(String prefix, String uri, + PageData page) + { + return null; + } + + /** + * Release any data kept by this instance for validation purposes. + */ + public void release() { + initParameters = null; + } + + // Private data + private Map initParameters; + +} Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagSupport.java URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagSupport.java?rev=379499&view=auto ============================================================================== --- tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagSupport.java (added) +++ tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagSupport.java Tue Feb 21 07:46:36 2006 @@ -0,0 +1,293 @@ +/* +* Copyright 2004 The Apache Software Foundation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package javax.servlet.jsp.tagext; + +import java.io.Serializable; +import java.util.Enumeration; +import java.util.Hashtable; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.PageContext; + +/** + * A base class for defining new tag handlers implementing Tag. + * + * <p> The TagSupport class is a utility class intended to be used as + * the base class for new tag handlers. The TagSupport class + * implements the Tag and IterationTag interfaces and adds additional + * convenience methods including getter methods for the properties in + * Tag. TagSupport has one static method that is included to + * facilitate coordination among cooperating tags. + * + * <p> Many tag handlers will extend TagSupport and only redefine a + * few methods. + */ + +public class TagSupport implements IterationTag, Serializable { + + /** + * Find the instance of a given class type that is closest to a given + * instance. + * This method uses the getParent method from the Tag + * interface. + * This method is used for coordination among cooperating tags. + * + * <p> + * The current version of the specification only provides one formal + * way of indicating the observable type of a tag handler: its + * tag handler implementation class, described in the tag-class + * subelement of the tag element. This is extended in an + * informal manner by allowing the tag library author to + * indicate in the description subelement an observable type. + * The type should be a subtype of the tag handler implementation + * class or void. + * This addititional constraint can be exploited by a + * specialized container that knows about that specific tag library, + * as in the case of the JSP standard tag library. + * + * <p> + * When a tag library author provides information on the + * observable type of a tag handler, client programmatic code + * should adhere to that constraint. Specifically, the Class + * passed to findAncestorWithClass should be a subtype of the + * observable type. + * + * + * @param from The instance from where to start looking. + * @param klass The subclass of Tag or interface to be matched + * @return the nearest ancestor that implements the interface + * or is an instance of the class specified + */ + + public static final Tag findAncestorWithClass(Tag from, Class klass) { + boolean isInterface = false; + + if (from == null || + klass == null || + (!Tag.class.isAssignableFrom(klass) && + !(isInterface = klass.isInterface()))) { + return null; + } + + for (;;) { + Tag tag = from.getParent(); + + if (tag == null) { + return null; + } + + if ((isInterface && klass.isInstance(tag)) || + klass.isAssignableFrom(tag.getClass())) + return tag; + else + from = tag; + } + } + + /** + * Default constructor, all subclasses are required to define only + * a public constructor with the same signature, and to call the + * superclass constructor. + * + * This constructor is called by the code generated by the JSP + * translator. + */ + + public TagSupport() { } + + /** + * Default processing of the start tag, returning SKIP_BODY. + * + * @return SKIP_BODY + * @throws JspException if an error occurs while processing this tag + * + * @see Tag#doStartTag() + */ + + public int doStartTag() throws JspException { + return SKIP_BODY; + } + + /** + * Default processing of the end tag returning EVAL_PAGE. + * + * @return EVAL_PAGE + * @throws JspException if an error occurs while processing this tag + * + * @see Tag#doEndTag() + */ + + public int doEndTag() throws JspException { + return EVAL_PAGE; + } + + + /** + * Default processing for a body. + * + * @return SKIP_BODY + * @throws JspException if an error occurs while processing this tag + * + * @see IterationTag#doAfterBody() + */ + + public int doAfterBody() throws JspException { + return SKIP_BODY; + } + + // Actions related to body evaluation + + + /** + * Release state. + * + * @see Tag#release() + */ + + public void release() { + parent = null; + id = null; + if( values != null ) { + values.clear(); + } + values = null; + } + + /** + * Set the nesting tag of this tag. + * + * @param t The parent Tag. + * @see Tag#setParent(Tag) + */ + + public void setParent(Tag t) { + parent = t; + } + + /** + * The Tag instance most closely enclosing this tag instance. + * @see Tag#getParent() + * + * @return the parent tag instance or null + */ + + public Tag getParent() { + return parent; + } + + /** + * Set the id attribute for this tag. + * + * @param id The String for the id. + */ + + public void setId(String id) { + this.id = id; + } + + /** + * The value of the id attribute of this tag; or null. + * + * @return the value of the id attribute, or null + */ + + public String getId() { + return id; + } + + /** + * Set the page context. + * + * @param pageContext The PageContext. + * @see Tag#setPageContext + */ + + public void setPageContext(PageContext pageContext) { + this.pageContext = pageContext; + } + + /** + * Associate a value with a String key. + * + * @param k The key String. + * @param o The value to associate. + */ + + public void setValue(String k, Object o) { + if (values == null) { + values = new Hashtable(); + } + values.put(k, o); + } + + /** + * Get a the value associated with a key. + * + * @param k The string key. + * @return The value associated with the key, or null. + */ + + public Object getValue(String k) { + if (values == null) { + return null; + } else { + return values.get(k); + } + } + + /** + * Remove a value associated with a key. + * + * @param k The string key. + */ + + public void removeValue(String k) { + if (values != null) { + values.remove(k); + } + } + + /** + * Enumerate the keys for the values kept by this tag handler. + * + * @return An enumeration of all the keys for the values set, + * or null or an empty Enumeration if no values have been set. + */ + + public Enumeration getValues() { + if (values == null) { + return null; + } + return values.keys(); + } + + // private fields + + private Tag parent; + private Hashtable values; + /** + * The value of the id attribute of this tag; or null. + */ + protected String id; + + // protected fields + + /** + * The PageContext. + */ + protected PageContext pageContext; +} + Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagVariableInfo.java URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagVariableInfo.java?rev=379499&view=auto ============================================================================== --- tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagVariableInfo.java (added) +++ tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TagVariableInfo.java Tue Feb 21 07:46:36 2006 @@ -0,0 +1,120 @@ +/* +* Copyright 2004 The Apache Software Foundation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +package javax.servlet.jsp.tagext; + +/** + * Variable information for a tag in a Tag Library; + * This class is instantiated from the Tag Library Descriptor file (TLD) + * and is available only at translation time. + * + * This object should be immutable. + * + * This information is only available in JSP 1.2 format TLDs or above. + */ + +public class TagVariableInfo { + + /** + * Constructor for TagVariableInfo. + * + * @param nameGiven value of <name-given> + * @param nameFromAttribute value of <name-from-attribute> + * @param className value of <variable-class> + * @param declare value of <declare> + * @param scope value of <scope> + */ + public TagVariableInfo( + String nameGiven, + String nameFromAttribute, + String className, + boolean declare, + int scope) { + this.nameGiven = nameGiven; + this.nameFromAttribute = nameFromAttribute; + this.className = className; + this.declare = declare; + this.scope = scope; + } + + /** + * The body of the <name-given> element. + * + * @return The variable name as a constant + */ + + public String getNameGiven() { + return nameGiven; + } + + /** + * The body of the <name-from-attribute> element. + * This is the name of an attribute whose (translation-time) + * value will give the name of the variable. One of + * <name-given> or <name-from-attribute> is required. + * + * @return The attribute whose value defines the variable name + */ + + public String getNameFromAttribute() { + return nameFromAttribute; + } + + /** + * The body of the <variable-class> element. + * + * @return The name of the class of the variable or + * 'java.lang.String' if not defined in the TLD. + */ + + public String getClassName() { + return className; + } + + /** + * The body of the <declare> element. + * + * @return Whether the variable is to be declared or not. + * If not defined in the TLD, 'true' will be returned. + */ + + public boolean getDeclare() { + return declare; + } + + /** + * The body of the <scope> element. + * + * @return The scope to give the variable. NESTED + * scope will be returned if not defined in + * the TLD. + */ + + public int getScope() { + return scope; + } + + + /* + * private fields + */ + private String nameGiven; // <name-given> + private String nameFromAttribute; // <name-from-attribute> + private String className; // <class> + private boolean declare; // <declare> + private int scope; // <scope> +} Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TryCatchFinally.java URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TryCatchFinally.java?rev=379499&view=auto ============================================================================== --- tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TryCatchFinally.java (added) +++ tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/TryCatchFinally.java Tue Feb 21 07:46:36 2006 @@ -0,0 +1,98 @@ +/* +* Copyright 2004 The Apache Software Foundation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +package javax.servlet.jsp.tagext; + + + +/** + * The auxiliary interface of a Tag, IterationTag or BodyTag tag + * handler that wants additional hooks for managing resources. + * + * <p>This interface provides two new methods: doCatch(Throwable) + * and doFinally(). The prototypical invocation is as follows: + * + * <pre> + * h = get a Tag(); // get a tag handler, perhaps from pool + * + * h.setPageContext(pc); // initialize as desired + * h.setParent(null); + * h.setFoo("foo"); + * + * // tag invocation protocol; see Tag.java + * try { + * doStartTag()... + * .... + * doEndTag()... + * } catch (Throwable t) { + * // react to exceptional condition + * h.doCatch(t); + * } finally { + * // restore data invariants and release per-invocation resources + * h.doFinally(); + * } + * + * ... other invocations perhaps with some new setters + * ... + * h.release(); // release long-term resources + * </pre> + */ + +public interface TryCatchFinally { + + /** + * Invoked if a Throwable occurs while evaluating the BODY + * inside a tag or in any of the following methods: + * Tag.doStartTag(), Tag.doEndTag(), + * IterationTag.doAfterBody() and BodyTag.doInitBody(). + * + * <p>This method is not invoked if the Throwable occurs during + * one of the setter methods. + * + * <p>This method may throw an exception (the same or a new one) + * that will be propagated further up the nest chain. If an exception + * is thrown, doFinally() will be invoked. + * + * <p>This method is intended to be used to respond to an exceptional + * condition. + * + * @param t The throwable exception navigating through this tag. + * @throws Throwable if the exception is to be rethrown further up + * the nest chain. + */ + + void doCatch(Throwable t) throws Throwable; + + /** + * Invoked in all cases after doEndTag() for any class implementing + * Tag, IterationTag or BodyTag. This method is invoked even if + * an exception has occurred in the BODY of the tag, + * or in any of the following methods: + * Tag.doStartTag(), Tag.doEndTag(), + * IterationTag.doAfterBody() and BodyTag.doInitBody(). + * + * <p>This method is not invoked if the Throwable occurs during + * one of the setter methods. + * + * <p>This method should not throw an Exception. + * + * <p>This method is intended to maintain per-invocation data + * integrity and resource management actions. + */ + + void doFinally(); +} Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/ValidationMessage.java URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/ValidationMessage.java?rev=379499&view=auto ============================================================================== --- tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/ValidationMessage.java (added) +++ tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/ValidationMessage.java Tue Feb 21 07:46:36 2006 @@ -0,0 +1,85 @@ +/* +* Copyright 2004 The Apache Software Foundation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +package javax.servlet.jsp.tagext; + + +/** + * A validation message from either TagLibraryValidator or TagExtraInfo. + * <p> + * As of JSP 2.0, a JSP container must support a jsp:id attribute + * to provide higher quality validation errors. + * The container will track the JSP pages + * as passed to the container, and will assign to each element + * a unique "id", which is passed as the value of the jsp:id + * attribute. Each XML element in the XML view available will + * be extended with this attribute. The TagLibraryValidator + * can then use the attribute in one or more ValidationMessage + * objects. The container then, in turn, can use these + * values to provide more precise information on the location + * of an error. + * + * <p> + * The actual prefix of the <code>id</code> attribute may or may not be + * <code>jsp</code> but it will always map to the namespace + * <code>http://java.sun.com/JSP/Page</code>. A TagLibraryValidator + * implementation must rely on the uri, not the prefix, of the <code>id</code> + * attribute. + */ + +public class ValidationMessage { + + /** + * Create a ValidationMessage. The message String should be + * non-null. The value of id may be null, if the message + * is not specific to any XML element, or if no jsp:id + * attributes were passed on. If non-null, the value of + * id must be the value of a jsp:id attribute for the PageData + * passed into the validate() method. + * + * @param id Either null, or the value of a jsp:id attribute. + * @param message A localized validation message. + */ + public ValidationMessage(String id, String message) { + this.id = id; + this.message = message; + } + + + /** + * Get the jsp:id. + * Null means that there is no information available. + * + * @return The jsp:id information. + */ + public String getId() { + return id; + } + + /** + * Get the localized validation message. + * + * @return A validation message + */ + public String getMessage(){ + return message; + } + + // Private data + private String id; + private String message; +} Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/VariableInfo.java URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/VariableInfo.java?rev=379499&view=auto ============================================================================== --- tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/VariableInfo.java (added) +++ tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/VariableInfo.java Tue Feb 21 07:46:36 2006 @@ -0,0 +1,283 @@ +/* +* Copyright 2004 The Apache Software Foundation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +package javax.servlet.jsp.tagext; + +/** + * Information on the scripting variables that are created/modified by + * a tag (at run-time). This information is provided by TagExtraInfo + * classes and it is used by the translation phase of JSP. + * + * <p> + * Scripting variables generated by a custom action have an associated + * scope of either AT_BEGIN, NESTED, or AT_END. + * + * <p> + * The class name (VariableInfo.getClassName) in the returned objects + * is used to determine the types of the scripting variables. + * Note that because scripting variables are assigned their values + * from scoped attributes which cannot be of primitive types, + * "boxed" types such as <code>java.lang.Integer</code> must + * be used instead of primitives. + * + * <p> + * The class name may be a Fully Qualified Class Name, or a short + * class name. + * + * <p> + * If a Fully Qualified Class Name is provided, it should refer to a + * class that should be in the CLASSPATH for the Web Application (see + * Servlet 2.4 specification - essentially it is WEB-INF/lib and + * WEB-INF/classes). Failure to be so will lead to a translation-time + * error. + * + * <p> + * If a short class name is given in the VariableInfo objects, then + * the class name must be that of a public class in the context of the + * import directives of the page where the custom action appears. + * The class must also be in the CLASSPATH for the Web Application + * (see Servlet 2.4 specification - essentially it is WEB-INF/lib and + * WEB-INF/classes). Failure to be so will lead to a translation-time + * error. + * + * <p><B>Usage Comments</B> + * <p> + * Frequently a fully qualified class name will refer to a class that + * is known to the tag library and thus, delivered in the same JAR + * file as the tag handlers. In most other remaining cases it will + * refer to a class that is in the platform on which the JSP processor + * is built (like J2EE). Using fully qualified class names in this + * manner makes the usage relatively resistant to configuration + * errors. + * + * <p> + * A short name is usually generated by the tag library based on some + * attributes passed through from the custom action user (the author), + * and it is thus less robust: for instance a missing import directive + * in the referring JSP page will lead to an invalid short name class + * and a translation error. + * + * <p><B>Synchronization Protocol</B> + * + * <p> + * The result of the invocation on getVariableInfo is an array of + * VariableInfo objects. Each such object describes a scripting + * variable by providing its name, its type, whether the variable is + * new or not, and what its scope is. Scope is best described through + * a picture: + * + * <p> + * <IMG src="doc-files/VariableInfo-1.gif" + * alt="NESTED, AT_BEGIN and AT_END Variable Scopes"/> + * + *<p> + * The JSP 2.0 specification defines the interpretation of 3 values: + * + * <ul> + * <li> NESTED, if the scripting variable is available between + * the start tag and the end tag of the action that defines it. + * <li> + * AT_BEGIN, if the scripting variable is available from the start tag + * of the action that defines it until the end of the scope. + * <li> AT_END, if the scripting variable is available after the end tag + * of the action that defines it until the end of the scope. + * </ul> + * + * The scope value for a variable implies what methods may affect its + * value and thus where synchronization is needed as illustrated by + * the table below. <b>Note:</b> the synchronization of the variable(s) + * will occur <em>after</em> the respective method has been called. + * + * <blockquote> + * <table cellpadding="2" cellspacing="2" border="0" width="55%" + * bgcolor="#999999" summary="Variable Synchronization Points"> + * <tbody> + * <tr align="center"> + * <td valign="top" colspan="6" bgcolor="#999999"><u><b>Variable Synchronization + * Points</b></u><br> + * </td> + * </tr> + * <tr> + * <th valign="top" bgcolor="#c0c0c0"> </th> + * <th valign="top" bgcolor="#c0c0c0" align="center">doStartTag()</th> + * <th valign="top" bgcolor="#c0c0c0" align="center">doInitBody()</th> + * <th valign="top" bgcolor="#c0c0c0" align="center">doAfterBody()</th> + * <th valign="top" bgcolor="#c0c0c0" align="center">doEndTag()</th> + * <th valign="top" bgcolor="#c0c0c0" align="center">doTag()</th> + * </tr> + * <tr> + * <td valign="top" bgcolor="#c0c0c0"><b>Tag<br> + * </b></td> + * <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff"><br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff"><br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, AT_END<br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff"><br> + * </td> + * </tr> + * <tr> + * <td valign="top" bgcolor="#c0c0c0"><b>IterationTag<br> + * </b></td> + * <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff"><br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, AT_END<br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff"><br> + * </td> + * </tr> + * <tr> + * <td valign="top" bgcolor="#c0c0c0"><b>BodyTag<br> + * </b></td> + * <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<sup>1</sup><br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<sup>1</sup><br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, AT_END<br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff"><br> + * </td> + * </tr> + * <tr> + * <td valign="top" bgcolor="#c0c0c0"><b>SimpleTag<br> + * </b></td> + * <td valign="top" align="center" bgcolor="#ffffff"><br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff"><br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff"><br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff"><br> + * </td> + * <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, AT_END<br> + * </td> + * </tr> + * </tbody> + * </table> + * <sup>1</sup> Called after <code>doStartTag()</code> if + * <code>EVAL_BODY_INCLUDE</code> is returned, or after + * <code>doInitBody()</code> otherwise. + * </blockquote> + * + * <p><B>Variable Information in the TLD</B> + * <p> + * Scripting variable information can also be encoded directly for most cases + * into the Tag Library Descriptor using the <variable> subelement of the + * <tag> element. See the JSP specification. + */ + +public class VariableInfo { + + /** + * Scope information that scripting variable is visible only within the + * start/end tags. + */ + public static final int NESTED = 0; + + /** + * Scope information that scripting variable is visible after start tag. + */ + public static final int AT_BEGIN = 1; + + /** + * Scope information that scripting variable is visible after end tag. + */ + public static final int AT_END = 2; + + + /** + * Constructor + * These objects can be created (at translation time) by the TagExtraInfo + * instances. + * + * @param varName The name of the scripting variable + * @param className The type of this variable + * @param declare If true, it is a new variable (in some languages this will + * require a declaration) + * @param scope Indication on the lexical scope of the variable + */ + + public VariableInfo(String varName, + String className, + boolean declare, + int scope) { + this.varName = varName; + this.className = className; + this.declare = declare; + this.scope = scope; + } + + // Accessor methods + + /** + * Returns the name of the scripting variable. + * + * @return the name of the scripting variable + */ + public String getVarName() { + return varName; + } + + /** + * Returns the type of this variable. + * + * @return the type of this variable + */ + public String getClassName() { + return className; + } + + /** + * Returns whether this is a new variable. + * If so, in some languages this will require a declaration. + * + * @return whether this is a new variable. + */ + public boolean getDeclare() { + return declare; + } + + /** + * Returns the lexical scope of the variable. + * + * @return the lexical scope of the variable, either AT_BEGIN, AT_END, + * or NESTED. + * @see #AT_BEGIN + * @see #AT_END + * @see #NESTED + */ + public int getScope() { + return scope; + } + + + // == private data + private String varName; + private String className; + private boolean declare; + private int scope; +} + Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/BodyTagProtocol.gif URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/BodyTagProtocol.gif?rev=379499&view=auto ============================================================================== Binary file - no diff available. Propchange: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/BodyTagProtocol.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/IterationTagProtocol.gif URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/IterationTagProtocol.gif?rev=379499&view=auto ============================================================================== Binary file - no diff available. Propchange: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/IterationTagProtocol.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/TagProtocol.gif URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/TagProtocol.gif?rev=379499&view=auto ============================================================================== Binary file - no diff available. Propchange: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/TagProtocol.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/VariableInfo-1.gif URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/VariableInfo-1.gif?rev=379499&view=auto ============================================================================== Binary file - no diff available. Propchange: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/doc-files/VariableInfo-1.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/package.html URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/package.html?rev=379499&view=auto ============================================================================== --- tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/package.html (added) +++ tomcat/jasper/tc6.0.x/src/share/javax/servlet/jsp/tagext/package.html Tue Feb 21 07:46:36 2006 @@ -0,0 +1,85 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<!-- + - The Apache Software License, Version 1.1 + - + - Copyright (c) 1999 The Apache Software Foundation. All rights + - reserved. + - + - Redistribution and use in source and binary forms, with or without + - modification, are permitted provided that the following conditions + - are met: + - + - 1. Redistributions of source code must retain the above copyright + - notice, this list of conditions and the following disclaimer. + - + - 2. Redistributions in binary form must reproduce the above copyright + - notice, this list of conditions and the following disclaimer in + - the documentation and/or other materials provided with the + - distribution. + - + - 3. The end-user documentation included with the redistribution, if + - any, must include the following acknowlegement: + - "This product includes software developed by the + - Apache Software Foundation (http://www.apache.org/)." + - Alternately, this acknowlegement may appear in the software itself, + - if and wherever such third-party acknowlegements normally appear. + - + - 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + - Foundation" must not be used to endorse or promote products derived + - from this software without prior written permission. For written + - permission, please contact [EMAIL PROTECTED] + - + - 5. Products derived from this software may not be called "Apache" + - nor may "Apache" appear in their names without prior written + - permission of the Apache Group. + - + - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + - DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + - ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + - USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + - SUCH DAMAGE. + - ==================================================================== + - + - This software consists of voluntary contributions made by many + - individuals on behalf of the Apache Software Foundation. For more + - information on the Apache Software Foundation, please see + - <http://www.apache.org/>. + - + --> +</head> +<body bgcolor="white"> + +Classes and interfaces for the definition of JavaServer Pages Tag Libraries. + +<p> +The JavaServer Pages(tm) (JSP) 2.0 specification provides a portable +mechanism for the description of tag libraries. +<p> +A JSP tag library contains +<ul> +<li>A Tag Library Descriptor</li> +<li>A number of Tag Files or Tag handler classes defining + request-time behavior</li> +<li>Additional classes and resources used at runtime</li> +<li>Possibly some additional classes to provide extra translation + information</li> +</ul> +<p> +The JSP 2.0 specification and the reference implementation both contain +simple and moderately complex examples of actions defined using this +mechanism. These are available at JSP's web site, at +<a href="http://java.sun.com/products/jsp">http://java.sun.com/products/jsp</a>. +Some readers may want to consult those to get a quick feel for how +the mechanisms work together. + +</body> +</html> Modified: tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspApplicationContextImpl.java URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspApplicationContextImpl.java?rev=379499&r1=379498&r2=379499&view=diff ============================================================================== --- tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspApplicationContextImpl.java (original) +++ tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspApplicationContextImpl.java Tue Feb 21 07:46:36 2006 @@ -22,7 +22,6 @@ import javax.el.ArrayELResolver; import javax.el.BeanELResolver; import javax.el.CompositeELResolver; -import javax.el.ELContext; import javax.el.ELContextEvent; import javax.el.ELContextListener; import javax.el.ELResolver; @@ -35,11 +34,9 @@ import javax.servlet.jsp.JspContext; import javax.servlet.jsp.el.ImplicitObjectELResolver; import javax.servlet.jsp.el.ScopedAttributeELResolver; -import javax.servlet.jsp.el.VariableResolver; import org.apache.el.ExpressionFactoryImpl; import org.apache.jasper.el.ELContextImpl; -import org.apache.jasper.el.ELResolverImpl; /** * Implementation of JspApplicationContext --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]