You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ki...@apache.org on 2002/06/07 22:04:28 UTC
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Compiler.java JspReader.java Parser.java ParserController.java CompileException.java ParseException.java
kinman 2002/06/07 13:04:28
Modified: jasper2/src/share/org/apache/jasper/compiler Compiler.java
JspReader.java Parser.java ParserController.java
Removed: jasper2/src/share/org/apache/jasper/compiler
CompileException.java ParseException.java
Log:
- Removed unused classes and methods.
Revision Changes Path
1.13 +3 -41 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java
Index: Compiler.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Compiler.java 5 Jun 2002 22:01:33 -0000 1.12
+++ Compiler.java 7 Jun 2002 20:04:27 -0000 1.13
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v 1.12 2002/06/05 22:01:33 kinman Exp $
- * $Revision: 1.12 $
- * $Date: 2002/06/05 22:01:33 $
+ * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v 1.13 2002/06/07 20:04:27 kinman Exp $
+ * $Revision: 1.13 $
+ * $Date: 2002/06/07 20:04:27 $
*
* ====================================================================
*
@@ -340,44 +340,6 @@
public JspCompilationContext getCompilationContext() {
return ctxt;
- }
-
-
- /**
- * Change the encoding for the reader if specified.
- */
- public String changeEncodingIfNecessary(JspReader tmpReader)
- throws JasperException {
-
- // A lot of code replicated from Parser.java
- // Main aim is to "get-it-to-work".
- while (tmpReader.skipUntil("<%@") != null) {
-
- tmpReader.skipSpaces();
-
- // check if it is a page directive.
- if (tmpReader.matches("page")) {
-
- tmpReader.advance(4);
- tmpReader.skipSpaces();
-
- try {
- Attributes attrs = tmpReader.parseTagAttributes();
- String ct = attrs.getValue("contentType");
- if (ct != null) {
- int loc = ct.indexOf("charset=");
- if (loc > 0) {
- String encoding = ct.substring(loc + 8);
- return encoding;
- }
- }
- } catch (ParseException ex) {
- // Ignore the exception here, it will be caught later.
- return null;
- }
- }
- }
- return null;
}
1.5 +0 -217 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
Index: JspReader.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JspReader.java 17 Apr 2002 01:42:54 -0000 1.4
+++ JspReader.java 7 Jun 2002 20:04:27 -0000 1.5
@@ -457,223 +457,6 @@
}
/**
- * Parse an attribute/value pair, and store it in provided hash table.
- * The attribute/value pair is defined by:
- * <pre>
- * av := spaces token spaces '=' spaces token spaces
- * </pre>
- * Where <em>token</em> is defined by <code>parseToken</code> and
- * <em>spaces</em> is defined by <code>skipSpaces</code>.
- * The name is always considered case insensitive, hence stored in its
- * lower case version.
- * @param into The Hashtable instance to save the result to.
- */
- private void parseAttributeValue(AttributesImpl into)
- throws JasperException {
- // Get the attribute name:
- skipSpaces();
- String name = parseToken(false);
- // Check for an equal sign:
- skipSpaces();
- if (peekChar() != '=') {
- err.jspError(mark(), "jsp.error.attr.novalue", name);
- }
- char ch = (char) nextChar();
- // Get the attribute value:
- skipSpaces();
- String value = parseToken(true);
- skipSpaces();
- // Add the binding to the provided hashtable:
- //TODO review if the empty namespace works, or if we should get another one
- //TODO do we want to use typw to indicate rt expression/scripting vlaue?
- into.addAttribute("", name, name, "CDATA", value);
- return;
- }
-
- /**
- * Parse some tag attributes for Beans.
- * The stream is assumed to be positioned right after the tag name. The
- * syntax recognized is:
- * <pre>
- * tag-attrs := empty | attr-list (">" | "-->" | %>)
- * attr-list := empty | av spaces attr-list
- * empty := spaces
- * </pre>
- * Where <em>av</em> is defined by <code>parseAttributeValue</code>.
- * @return A Hashtable mapping String instances (variable names) into
- * String instances (variable values).
- */
- public Attributes parseTagAttributesBean() throws JasperException {
- AttributesImpl values = new AttributesImpl();
-
- while (true) {
- skipSpaces();
- int ch = peekChar();
- if (ch == '>') {
- // End of the useBean tag.
- return values;
-
- } else if (ch == '/') {
- Mark mark = mark();
- nextChar();
- // XMLesque Close tags
- try {
- if (nextChar() == '>')
- return values;
- } finally {
- reset(mark);
- }
- }
- if (ch == -1)
- break;
- // Parse as an attribute=value:
- parseAttributeValue(values);
- }
-
- // Reached EOF:
- err.jspError(mark(), "jsp.error.tag.attr.unterminated");
- return null;
- }
-
- /**
- * Parse some tag attributes.
- * The stream is assumed to be positioned right after the tag name. The
- * syntax recognized is:
- * <pre>
- * tag-attrs := empty | attr-list (">" | "-->" | %>)
- * attr-list := empty | av spaces attr-list
- * empty := spaces
- * </pre>
- * Where <em>av</em> is defined by <code>parseAttributeValue</code>.
- * @return A Hashtable mapping String instances (variable names) into
- * String instances (variable values).
- */
- public Attributes parseTagAttributes() throws JasperException {
- AttributesImpl values = new AttributesImpl();
-
- while (true) {
- skipSpaces();
- int ch = peekChar();
- if (ch == '>') {
- return values;
- }
- if (ch == '-') {
- Mark mark = mark();
- nextChar();
- // Close NCSA like attributes "->"
- try {
- if (nextChar() == '-' && nextChar() == '>')
- return values;
- } finally {
- reset(mark);
- }
- } else if (ch == '%') {
- Mark mark = mark();
- nextChar();
- // Close variable like attributes "%>"
- try {
- if (nextChar() == '>')
- return values;
- } finally {
- reset(mark);
- }
- } else if (ch == '/') {
- Mark mark = mark();
- nextChar();
- // XMLesque Close tags
- try {
- if (nextChar() == '>')
- return values;
- } finally {
- reset(mark);
- }
- }
- if (ch == -1)
- break;
- // Parse as an attribute=value:
- parseAttributeValue(values);
- }
-
- // Reached EOF:
- err.jspError(mark(), "jsp.error.tag.attr.unterminated");
- return null;
- }
-
- /**
- * Parse PARAM tag attributes into the given hashtable.
- * Parses the PARAM tag as defined by:
- * <pre>
- * <PARAM tag-attributes %gt;
- * </pre>
- * Two special tag attributes are recognized here:
- * <ol>
- * <li>The <strong>name</strong> attribute,
- * <li>The <strong>value</strong> attribute.
- * </ol>
- * The resulting name, value pair is stored in the provided hash table.
- * @param into Storage for parameter values.
- */
- public void parseParamTag(Hashtable into) throws JasperException {
- // Really check for a param tag:
- if (matches("param")) {
- advance(6);
- parseParams (into);
- } else {
- // False alarm, just skip it
- }
- }
-
- /**
- * Parse jsp:param tag attributes into the given hashtable.
- * Parses the jsp:param tag as defined by:
- * <pre>
- * <jsp:param tag-attributes %gt;
- * </pre>
- * Two special tag attributes are recognized here:
- * <ol>
- * <li>The <strong>name</strong> attribute,
- * <li>The <strong>value</strong> attribute.
- * </ol>
- * The resulting name, value pair is stored in the provided hash table.
- * @param into Storage for parameter values.
- */
- public void parsePluginParamTag(Hashtable into) throws JasperException {
- // Really check for a param tag:
- if (matches("<jsp:param")) {
- advance(11);
- parseParams (into);
- } else {
- // False alarm, just skip it
- }
- }
-
- public void parseParams (Hashtable into) throws JasperException {
-
- Attributes attrs = parseTagAttributes();
- // Check attributes (name and value):
- String name = (String) attrs.getValue("name");
- String value = (String) attrs.getValue("value");
- if (name == null) {
- err.jspError(mark(), "jsp.error.param.noname");
- }
- if (value == null) {
- err.jspError(mark(), "jsp.error.param.novalue");
- }
- // Put that new binding into the params hashatble:
- String oldval[] = (String[]) into.get(name);
- if (oldval == null) {
- String newval[] = new String[1];
- newval[0] = value;
- into.put(name, newval);
- } else {
- String newval[] = new String[oldval.length+1];
- System.arraycopy(oldval, 0, newval, 0, oldval.length);
- newval[oldval.length] = value;
- into.put(name, newval);
- }
- }
-
- /**
* Parse utils - Is current character a token delimiter ?
* Delimiters are currently defined to be =, >, <, ", and ' or any
* any space character as defined by <code>isSpace</code>.
1.4 +13 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java
Index: Parser.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Parser.java 17 Apr 2002 01:42:54 -0000 1.3
+++ Parser.java 7 Jun 2002 20:04:27 -0000 1.4
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v 1.3 2002/04/17 01:42:54 kinman Exp $
- * $Revision: 1.3 $
- * $Date: 2002/04/17 01:42:54 $
+ * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v 1.4 2002/06/07 20:04:27 kinman Exp $
+ * $Revision: 1.4 $
+ * $Date: 2002/06/07 20:04:27 $
*
* ====================================================================
*
@@ -137,6 +137,16 @@
reader.skipSpaces();
return attrs;
+ }
+
+ /**
+ * Parse Attributes for a reader, provided for external use
+ */
+ public static Attributes parseAttributes(ParserController pc,
+ JspReader reader)
+ throws JasperException {
+ Parser tmpParser = new Parser(pc, reader);
+ return tmpParser.parseAttributes();
}
/**
1.4 +1 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java
Index: ParserController.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ParserController.java 6 May 2002 04:33:15 -0000 1.3
+++ ParserController.java 7 Jun 2002 20:04:27 -0000 1.4
@@ -252,7 +252,7 @@
if (jspReader.matches("page")) {
jspReader.advance(4);
jspReader.skipSpaces();
- Attributes attrs = jspReader.parseTagAttributes();
+ Attributes attrs = Parser.parseAttributes(this, jspReader);
String attribute = "pageEncoding";
newEncoding = attrs.getValue("pageEncoding");
if (newEncoding == null) {
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>