luehe 2002/07/22 16:02:55 Modified: jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java JspUtil.java PageDataImpl.java TagConstants.java TagLibraryInfoImpl.java Log: Added support for Tag File directives in Tag File Documents Revision Changes Path 1.7 +34 -25 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JspDocumentParser.java 17 Jul 2002 20:06:58 -0000 1.6 +++ JspDocumentParser.java 22 Jul 2002 23:02:55 -0000 1.7 @@ -183,21 +183,21 @@ Attributes attrsCopy = new AttributesImpl(attrs); Node node = null; - if (qName.equals(JSP_ROOT_TAG)) { + if (qName.equals(JSP_ROOT)) { node = new Node.JspRoot(attrsCopy, start, current); try { addCustomTagLibraries(attrsCopy); } catch (JasperException je) { throw new SAXException(je); } - } else if (qName.equals(JSP_PAGE_DIRECTIVE_TAG)) { + } else if (qName.equals(JSP_PAGE_DIRECTIVE)) { node = new Node.PageDirective(attrsCopy, start, current); String imports = attrs.getValue("import"); // There can only be one 'import' attribute per page directive if (imports != null) { ((Node.PageDirective) node).addImport(imports); } - } else if (qName.equals(JSP_INCLUDE_DIRECTIVE_TAG)) { + } else if (qName.equals(JSP_INCLUDE_DIRECTIVE)) { node = new Node.IncludeDirective(attrsCopy, start, current); String file = attrsCopy.getValue("file"); try { @@ -209,34 +209,42 @@ } catch (Exception e) { throw new SAXException(e); } - } else if (qName.equals(JSP_DECLARATION_TAG)) { + } else if (qName.equals(JSP_DECLARATION)) { node = new Node.Declaration(start, current); - } else if (qName.equals(JSP_SCRIPTLET_TAG)) { + } else if (qName.equals(JSP_SCRIPTLET)) { node = new Node.Scriptlet(start, current); - } else if (qName.equals(JSP_EXPRESSION_TAG)) { + } else if (qName.equals(JSP_EXPRESSION)) { node = new Node.Expression(start, current); - } else if (qName.equals(JSP_USE_BEAN_TAG)) { + } else if (qName.equals(JSP_USE_BEAN)) { node = new Node.UseBean(attrsCopy, start, current); - } else if (qName.equals(JSP_SET_PROPERTY_TAG)) { + } else if (qName.equals(JSP_SET_PROPERTY)) { node = new Node.SetProperty(attrsCopy, start, current); - } else if (qName.equals(JSP_GET_PROPERTY_TAG)) { + } else if (qName.equals(JSP_GET_PROPERTY)) { node = new Node.GetProperty(attrsCopy, start, current); - } else if (qName.equals(JSP_INCLUDE_TAG)) { + } else if (qName.equals(JSP_INCLUDE)) { node = new Node.IncludeAction(attrsCopy, start, current); - } else if (qName.equals(JSP_FORWARD_TAG)) { + } else if (qName.equals(JSP_FORWARD)) { node = new Node.ForwardAction(attrsCopy, start, current); - } else if (qName.equals(JSP_PARAM_TAG)) { + } else if (qName.equals(JSP_PARAM)) { node = new Node.ParamAction(attrsCopy, start, current); - } else if (qName.equals(JSP_PARAMS_TAG)) { + } else if (qName.equals(JSP_PARAMS)) { node = new Node.ParamsAction(start, current); - } else if (qName.equals(JSP_PLUGIN_TAG)) { + } else if (qName.equals(JSP_PLUGIN)) { node = new Node.PlugIn(attrsCopy, start, current); - } else if (qName.equals(JSP_TEXT_TAG)) { + } else if (qName.equals(JSP_TEXT)) { node = new Node.JspText(start, current); - } else if (qName.equals(JSP_BODY_TAG)) { + } else if (qName.equals(JSP_BODY)) { node = new Node.JspBody(attrsCopy, start, current); - } else if (qName.equals(JSP_ATTRIBUTE_TAG)) { + } else if (qName.equals(JSP_ATTRIBUTE)) { node = new Node.NamedAttribute(attrsCopy, start, current); + } else if (qName.equals(JSP_TAG_DIRECTIVE)) { + node = new Node.TagDirective(attrsCopy, start, current); + } else if (qName.equals(JSP_ATTRIBUTE_DIRECTIVE)) { + node = new Node.AttributeDirective(attrsCopy, start, current); + } else if (qName.equals(JSP_VARIABLE_DIRECTIVE)) { + node = new Node.VariableDirective(attrsCopy, start, current); + } else if (qName.equals(JSP_FRAGMENT_INPUT_DIRECTIVE)) { + node = new Node.FragmentInputDirective(attrsCopy, start, current); } else { node = getCustomTag(qName, attrsCopy, start, current); if (node == null) { @@ -468,14 +476,15 @@ uri = uri.substring(URN_JSPTLD.length()); } - TldLocationsCache cache=ctxt.getOptions().getTldLocationsCache(); - TagLibraryInfo tl=cache.getTagLibraryInfo( uri ); - if( tl==null ) { + TldLocationsCache cache + = ctxt.getOptions().getTldLocationsCache(); + TagLibraryInfo tl = cache.getTagLibraryInfo(uri); + if (tl == null) { // get the location String[] location = ctxt.getTldLocation(uri); - tl = new TagLibraryInfoImpl(ctxt, prefix, uri, - location, err); + tl = new TagLibraryInfoImpl(ctxt, prefix, uri, location, + err); } taglibs.put(prefix, tl); } 1.6 +31 -5 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspUtil.java Index: JspUtil.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspUtil.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- JspUtil.java 16 Jul 2002 19:30:51 -0000 1.5 +++ JspUtil.java 22 Jul 2002 23:02:55 -0000 1.6 @@ -434,10 +434,36 @@ } /** - * Replaces any occurrence of <tt>replace</tt> with <tt>with</tt> in the - * given string. + * Replaces any occurrences of the character <tt>replace</tt> with the + * string <tt>with</tt>. */ public static String replace(String name, char replace, String with) { + StringBuffer buf = new StringBuffer(); + int begin = 0; + int end; + int last = name.length(); + + while (true) { + end = name.indexOf(replace, begin); + if (end < 0) { + end = last; + } + buf.append(name.substring(begin, end)); + if (end == last) { + break; + } + buf.append(with); + begin = end + 1; + } + + return buf.toString(); + } + + /** + * Replaces any occurrences of the character <tt>replace</tt> with the + * character <tt>with</tt>. + */ + public static String replace(String name, char replace, char with) { StringBuffer buf = new StringBuffer(); int begin = 0; int end; 1.5 +23 -23 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java Index: PageDataImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- PageDataImpl.java 16 Jul 2002 19:30:51 -0000 1.4 +++ PageDataImpl.java 22 Jul 2002 23:02:55 -0000 1.5 @@ -243,7 +243,7 @@ * Visits root node of JSP page in JSP syntax. */ public void visit(Node.Root n) throws JasperException { - appendTag(JSP_ROOT_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_ROOT, n.getAttributes(), n.getBody()); } /* @@ -255,7 +255,7 @@ public void visit(Node.JspRoot n) throws JasperException { if (n == this.root) { // top-level jsp:root element - appendTag(JSP_ROOT_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_ROOT, n.getAttributes(), n.getBody()); } else { visitBody(n); } @@ -276,61 +276,61 @@ public void visit(Node.Declaration n) throws JasperException { // jsp:declaration has no attributes, except for jsp:id - appendTag(JSP_DECLARATION_TAG, n.getAttributes(), n.getText()); + appendTag(JSP_DECLARATION, n.getAttributes(), n.getText()); } public void visit(Node.Expression n) throws JasperException { // jsp:scriptlet has no attributes, except for jsp:id - appendTag(JSP_EXPRESSION_TAG, n.getAttributes(), n.getText()); + appendTag(JSP_EXPRESSION, n.getAttributes(), n.getText()); } public void visit(Node.Scriptlet n) throws JasperException { // jsp:scriptlet has no attributes, except for jsp:id - appendTag(JSP_SCRIPTLET_TAG, n.getAttributes(), n.getText()); + appendTag(JSP_SCRIPTLET, n.getAttributes(), n.getText()); } public void visit(Node.IncludeAction n) throws JasperException { - appendTag(JSP_INCLUDE_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_INCLUDE, n.getAttributes(), n.getBody()); } public void visit(Node.ForwardAction n) throws JasperException { - appendTag(JSP_FORWARD_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_FORWARD, n.getAttributes(), n.getBody()); } public void visit(Node.GetProperty n) throws JasperException { - appendTag(JSP_GET_PROPERTY_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_GET_PROPERTY, n.getAttributes(), n.getBody()); } public void visit(Node.SetProperty n) throws JasperException { - appendTag(JSP_SET_PROPERTY_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_SET_PROPERTY, n.getAttributes(), n.getBody()); } public void visit(Node.ParamAction n) throws JasperException { - appendTag(JSP_PARAM_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_PARAM, n.getAttributes(), n.getBody()); } public void visit(Node.ParamsAction n) throws JasperException { - appendTag(JSP_PARAMS_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_PARAMS, n.getAttributes(), n.getBody()); } public void visit(Node.FallBackAction n) throws JasperException { - appendTag(JSP_FALLBACK_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_FALLBACK, n.getAttributes(), n.getBody()); } public void visit(Node.UseBean n) throws JasperException { - appendTag(JSP_USE_BEAN_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_USE_BEAN, n.getAttributes(), n.getBody()); } public void visit(Node.PlugIn n) throws JasperException { - appendTag(JSP_PLUGIN_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_PLUGIN, n.getAttributes(), n.getBody()); } public void visit(Node.NamedAttribute n) throws JasperException { - appendTag(JSP_ATTRIBUTE_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_ATTRIBUTE, n.getAttributes(), n.getBody()); } public void visit(Node.JspBody n) throws JasperException { - appendTag(JSP_BODY_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_BODY, n.getAttributes(), n.getBody()); } public void visit(Node.CustomTag n) throws JasperException { @@ -343,7 +343,7 @@ public void visit(Node.JspText n) throws JasperException { // jsp:text has no attributes, except for jsp:id - appendTag(JSP_TEXT_TAG, n.getAttributes(), n.getBody()); + appendTag(JSP_TEXT, n.getAttributes(), n.getBody()); } public void visit(Node.TemplateText n) throws JasperException { @@ -409,7 +409,7 @@ */ private void appendPageDirective(Node.PageDirective pageDir) { Attributes attrs = pageDir.getAttributes(); - buf.append("<").append(JSP_PAGE_DIRECTIVE_TAG); + buf.append("<").append(JSP_PAGE_DIRECTIVE); buf.append("\n"); // append jsp:id @@ -448,9 +448,9 @@ private void appendText(char[] text, boolean createJspTextElement) { if (createJspTextElement) { - buf.append(JSP_TEXT_TAG_START); + buf.append(JSP_TEXT_START); appendCDATA(text); - buf.append(JSP_TEXT_TAG_END); + buf.append(JSP_TEXT_END); } else { appendCDATA(text); } 1.3 +46 -29 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagConstants.java Index: TagConstants.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagConstants.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TagConstants.java 16 Jul 2002 19:30:51 -0000 1.2 +++ TagConstants.java 22 Jul 2002 23:02:55 -0000 1.3 @@ -61,32 +61,49 @@ package org.apache.jasper.compiler; public interface TagConstants { - public static final String JSP_ROOT_TAG = "jsp:root"; - public static final String JSP_ROOT_TAG_END = "</jsp:root>"; - public static final String JSP_PAGE_DIRECTIVE_TAG = "jsp:directive.page"; - public static final String JSP_INCLUDE_DIRECTIVE_TAG + public static final String JSP_ROOT = "jsp:root"; + public static final String JSP_ROOT_END = "</jsp:root>"; + public static final String JSP_PAGE_DIRECTIVE = "jsp:directive.page"; + public static final String JSP_INCLUDE_DIRECTIVE = "jsp:directive.include"; - public static final String JSP_DECLARATION_TAG = "jsp:declaration"; - public static final String JSP_DECLARATION_TAG_START = "<jsp:declaration>"; - public static final String JSP_DECLARATION_TAG_END = "</jsp:declaration>"; - public static final String JSP_SCRIPTLET_TAG = "jsp:scriptlet"; - public static final String JSP_SCRIPTLET_TAG_START = "<jsp:scriptlet>"; - public static final String JSP_SCRIPTLET_TAG_END = "</jsp:scriptlet>"; - public static final String JSP_EXPRESSION_TAG = "jsp:expression"; - public static final String JSP_EXPRESSION_TAG_START = "<jsp:expression>"; - public static final String JSP_EXPRESSION_TAG_END = "</jsp:expression>"; - public static final String JSP_USE_BEAN_TAG = "jsp:useBean"; - public static final String JSP_SET_PROPERTY_TAG = "jsp:setProperty"; - public static final String JSP_GET_PROPERTY_TAG = "jsp:getProperty"; - public static final String JSP_INCLUDE_TAG = "jsp:include"; - public static final String JSP_FORWARD_TAG = "jsp:forward"; - public static final String JSP_PARAM_TAG = "jsp:param"; - public static final String JSP_PARAMS_TAG = "jsp:params"; - public static final String JSP_PLUGIN_TAG = "jsp:plugin"; - public static final String JSP_FALLBACK_TAG = "jsp:fallback"; - public static final String JSP_TEXT_TAG = "jsp:text"; - public static final String JSP_TEXT_TAG_START = "<jsp:text>"; - public static final String JSP_TEXT_TAG_END = "</jsp:text>"; - public static final String JSP_ATTRIBUTE_TAG = "jsp:attribute"; - public static final String JSP_BODY_TAG = "jsp:body"; + public static final String JSP_DECLARATION = "jsp:declaration"; + public static final String JSP_DECLARATION_START = "<jsp:declaration>"; + public static final String JSP_DECLARATION_END = "</jsp:declaration>"; + public static final String JSP_SCRIPTLET = "jsp:scriptlet"; + public static final String JSP_SCRIPTLET_START = "<jsp:scriptlet>"; + public static final String JSP_SCRIPTLET_END = "</jsp:scriptlet>"; + public static final String JSP_EXPRESSION = "jsp:expression"; + public static final String JSP_EXPRESSION_START = "<jsp:expression>"; + public static final String JSP_EXPRESSION_END = "</jsp:expression>"; + public static final String JSP_USE_BEAN = "jsp:useBean"; + public static final String JSP_SET_PROPERTY = "jsp:setProperty"; + public static final String JSP_GET_PROPERTY = "jsp:getProperty"; + public static final String JSP_INCLUDE = "jsp:include"; + public static final String JSP_FORWARD = "jsp:forward"; + public static final String JSP_PARAM = "jsp:param"; + public static final String JSP_PARAMS = "jsp:params"; + public static final String JSP_PLUGIN = "jsp:plugin"; + public static final String JSP_FALLBACK = "jsp:fallback"; + public static final String JSP_TEXT = "jsp:text"; + public static final String JSP_TEXT_START = "<jsp:text>"; + public static final String JSP_TEXT_END = "</jsp:text>"; + public static final String JSP_ATTRIBUTE = "jsp:attribute"; + public static final String JSP_BODY = "jsp:body"; + + /* + * Tag Files + */ + public static final String JSP_INVOKE = "jsp:invoke"; + public static final String JSP_DO_BODY = "jsp:doBody"; + + /* + * Tag File Directives + */ + public static final String JSP_TAG_DIRECTIVE = "jsp:directive.tag"; + public static final String JSP_ATTRIBUTE_DIRECTIVE + = "jsp:directive.attribute"; + public static final String JSP_VARIABLE_DIRECTIVE + = "jsp:directive.variable"; + public static final String JSP_FRAGMENT_INPUT_DIRECTIVE + = "jsp:directive.fragment-input"; } 1.4 +4 -5 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java Index: TagLibraryInfoImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TagLibraryInfoImpl.java 16 Jul 2002 19:30:51 -0000 1.3 +++ TagLibraryInfoImpl.java 22 Jul 2002 23:02:55 -0000 1.4 @@ -162,8 +162,7 @@ if (uriType == TldLocationsCache.ABS_URI) { err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved", uri); - } else if (uriType == - TldLocationsCache.NOROOT_REL_URI) { + } else if (uriType == TldLocationsCache.NOROOT_REL_URI) { uri = ctxt.resolveRelativeUri(uri); } location = new String[2]; @@ -690,7 +689,7 @@ } /** - * Translation-time validation of the XML docu-ment + * Translation-time validation of the XML document * associated with the JSP page. * This is a convenience method on the associated * TagLibraryValidator class.
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>