You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2001/06/12 17:21:10 UTC
cvs commit: jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser DelegatingListener.java JspReader.java ParseEventListener.java ParseUtil.java Parser.java
costin 01/06/12 08:21:10
Modified: jasper34/generator/org/apache/jasper34/javagen
JavaSourceGenerator.java
jasper34/generator/org/apache/jasper34/parser
DelegatingListener.java JspReader.java
ParseEventListener.java ParseUtil.java Parser.java
Log:
Other changes to ContainerLiaison.
Revision Changes Path
1.3 +4 -0 jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/javagen/JavaSourceGenerator.java
Index: JavaSourceGenerator.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/javagen/JavaSourceGenerator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JavaSourceGenerator.java 2001/06/09 21:23:31 1.2
+++ JavaSourceGenerator.java 2001/06/12 15:20:47 1.3
@@ -186,6 +186,10 @@
popIndent();
println( "}" );
}
+
+ // -------------------- Line mapping --------------------
+
+
// -------------------- Low level generator --------------------
1.2 +10 -3 jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/DelegatingListener.java
Index: DelegatingListener.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/DelegatingListener.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DelegatingListener.java 2001/06/06 05:40:14 1.1
+++ DelegatingListener.java 2001/06/12 15:20:54 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/DelegatingListener.java,v 1.1 2001/06/06 05:40:14 costin Exp $
- * $Revision: 1.1 $
- * $Date: 2001/06/06 05:40:14 $
+ * $Header: /home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/DelegatingListener.java,v 1.2 2001/06/12 15:20:54 costin Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/06/12 15:20:54 $
*
* ====================================================================
*
@@ -82,10 +82,17 @@
ParseEventListener delegate;
Parser.Action action;
Mark tmplStart, tmplStop;
+ ContainerLiaison containerL;
- DelegatingListener(ParseEventListener delegate, Parser.Action action) {
+ DelegatingListener(ContainerLiaison containerL,
+ ParseEventListener delegate, Parser.Action action) {
this.delegate = delegate;
this.action = action;
+ this.containerL=containerL;
+ }
+
+ public ContainerLiaison getContainerLiaison() {
+ return containerL;
}
void doAction(Mark start, Mark stop) throws JasperException {
1.3 +32 -31 jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/JspReader.java
Index: JspReader.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/JspReader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JspReader.java 2001/06/08 04:57:01 1.2
+++ JspReader.java 2001/06/12 15:20:56 1.3
@@ -68,7 +68,7 @@
import java.util.Stack;
// use: getRealPath, getResourceAsStream
-import org.apache.jasper34.core.JspCompilationContext;
+import org.apache.jasper34.core.ContainerLiaison;
// getString
import org.apache.jasper34.core.Constants;
import org.apache.tomcat.util.log.*;
@@ -92,8 +92,8 @@
int currFileId = 0;
int size = 0;
- private JspCompilationContext context;
-
+ ContainerLiaison containerL;
+
Log loghelper = Log.getLog("JASPER_LOG", "JspReader");
// LogHelper loghelper = new LogHelper("JASPER_LOG", "JspReader");
@@ -172,9 +172,9 @@
public String getCurrentFile() {
File file=new File( master );
- String longName = (context == null)
- ? file.getAbsolutePath()
- : context.getRealPath(file.toString());
+ String longName = //(context == null)
+ // ? file.getAbsolutePath() :
+ containerL.getRealPath(file.toString());
return longName;
}
@@ -195,9 +195,9 @@
}
// Register the file, and read its content:
- String longName = (context == null)
- ? file.getAbsolutePath()
- : context.getRealPath(file.toString());
+ String longName = //(context == null)
+ //? file.getAbsolutePath() :
+ containerL.getRealPath(file.toString());
if (longName == null)
throw new FileNotFoundException(file.toString());
@@ -205,7 +205,7 @@
int fileid = registerSourceFile(longName);
if (fileid == -1)
- throw new ParseException(Constants.getString("jsp.error.file.already.registered",
+ throw new ParseException(containerL.getString("jsp.error.file.already.registered",
new Object[] {
file
}));
@@ -213,12 +213,12 @@
InputStreamReader reader = null;
try {
- if (context == null)
- reader = new InputStreamReader(new FileInputStream(file),
- encoding);
- else {
- String fileName = context.getRealPath(file.toString());
- InputStream in = context.getResourceAsStream(file.toString());
+// if (context == null)
+// reader = new InputStreamReader(new FileInputStream(file),
+// encoding);
+// else {
+ String fileName = containerL.getRealPath(file.toString());
+ InputStream in = containerL.getResourceAsStream(file.toString());
if (in == null)
throw new FileNotFoundException(fileName);
@@ -227,7 +227,7 @@
} catch (Throwable ex) {
throw new FileNotFoundException(fileName + ": "+ ex.getMessage());
}
- }
+ // }
CharArrayWriter caw = new CharArrayWriter();
char buf[] = new char[1024];
@@ -249,7 +249,7 @@
loghelper.log("Exception parsing file " + file, ex);
// Pop state being constructed:
popFile();
- throw new ParseException(Constants.getString("jsp.error.file.cannot.read",
+ throw new ParseException(containerL.getString("jsp.error.file.cannot.read",
new Object[] { file }));
} finally {
if ( reader != null ) {
@@ -268,14 +268,14 @@
//size--;
if (currFileId < 0) {
throw new ParseException(
- Constants.getString("jsp.error.no.more.content"));
+ containerL.getString("jsp.error.no.more.content"));
}
String fName = getFile(currFileId);
currFileId = unregisterSourceFile(fName);
if (currFileId < -1)
throw new ParseException
- (Constants.getString("jsp.error.file.not.registered",
+ (containerL.getString("jsp.error.file.not.registered",
new Object[] {fName}));
boolean r = current.popStream();
@@ -284,21 +284,22 @@
return r;
}
- protected JspReader(String file, JspCompilationContext ctx, String encoding)
+ protected JspReader(String file, ContainerLiaison containerL,
+ String encoding)
throws ParseException, FileNotFoundException
{
- this.context = ctx;
+ this.containerL=containerL;
this.encoding = encoding;
if (this.encoding == null) this.encoding = "8859_1";
pushFile(file, encoding);
}
public static JspReader createJspReader(String file,
- JspCompilationContext ctx,
+ ContainerLiaison containerL,
String encoding)
throws ParseException, FileNotFoundException
{
- return new JspReader(file, ctx, encoding);
+ return new JspReader(file, containerL, encoding);
}
public boolean hasMoreInput() throws ParseException {
@@ -486,10 +487,10 @@
// Check end of quote, skip closing quote:
if ( ch == -1 )
throw new ParseException(mark(),
- Constants.getString("jsp.error.quotes.unterminated"));
+ containerL.getString("jsp.error.quotes.unterminated"));
}
else throw new ParseException(mark(),
- Constants.getString("jsp.error.attr.quoted"));
+ containerL.getString("jsp.error.attr.quoted"));
} else {
if (!isDelimiter())
// Read value until delimiter is found:
@@ -529,7 +530,7 @@
// Check for an equal sign:
skipSpaces();
if ( peekChar() != '=' )
- throw new ParseException(mark(), Constants.getString("jsp.error.attr.novalue",
+ throw new ParseException(mark(), containerL.getString("jsp.error.attr.novalue",
new Object[] { name }));
char ch = (char) nextChar();
// Get the attribute value:
@@ -584,7 +585,7 @@
}
// Reached EOF:
throw new ParseException(mark(),
- Constants.getString("jsp.error.tag.attr.unterminated"));
+ containerL.getString("jsp.error.tag.attr.unterminated"));
}
/**
@@ -649,7 +650,7 @@
}
// Reached EOF:
throw new ParseException(mark(),
- Constants.getString("jsp.error.tag.attr.unterminated"));
+ containerL.getString("jsp.error.tag.attr.unterminated"));
}
/**
@@ -712,9 +713,9 @@
String name = (String) attrs.get("name");
String value = (String) attrs.get("value");
if ( name == null )
- throw new ParseException(mark(), Constants.getString("jsp.error.param.noname"));
+ throw new ParseException(mark(), containerL.getString("jsp.error.param.noname"));
if ( value == null )
- throw new ParseException(mark(), Constants.getString("jsp.error.param.novalue"));
+ throw new ParseException(mark(), containerL.getString("jsp.error.param.novalue"));
// Put that new binding into the params hashatble:
String oldval[] = (String[]) into.get(name);
if ( oldval == null ) {
1.2 +4 -1 jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/ParseEventListener.java
Index: ParseEventListener.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/ParseEventListener.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ParseEventListener.java 2001/06/06 05:40:14 1.1
+++ ParseEventListener.java 2001/06/12 15:20:57 1.2
@@ -64,8 +64,9 @@
// XXX
import org.apache.jasper34.jsptree.TagLibraries;
-//import org.apache.jasper34.core.*;
+import org.apache.jasper34.core.ContainerLiaison;
import org.apache.jasper34.runtime.JasperException;
+
/**
* Interface for the JSP code generation backend. At some point should
* probably try and make this a SAX (XML) listener.
@@ -73,6 +74,8 @@
* @author Anil K. Vijendran
*/
public interface ParseEventListener {
+ public ContainerLiaison getContainerLiaison();
+
void setTemplateInfo(Mark start, Mark stop);
void beginPageProcessing() throws JasperException;
1.2 +6 -4 jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/ParseUtil.java
Index: ParseUtil.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/ParseUtil.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ParseUtil.java 2001/06/06 05:40:14 1.1
+++ ParseUtil.java 2001/06/12 15:20:59 1.2
@@ -68,6 +68,7 @@
import org.apache.jasper34.runtime.JasperException;
import org.apache.jasper34.core.Constants;
+import org.apache.jasper34.core.ContainerLiaison;
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilder;
@@ -112,8 +113,9 @@
}
public static void checkAttributes (String typeOfTag, Hashtable attrs,
- ValidAttribute[] validAttributes, Mark start)
- throws JasperException
+ ValidAttribute[] validAttributes,
+ Mark start)
+ throws JasperException
{
boolean valid = true;
Hashtable temp = (Hashtable)attrs.clone ();
@@ -143,7 +145,7 @@
* If mandatory attribute is missing then the exception is thrown.
*/
if (!valid)
- throw new ParseException(start, Constants.getString(
+ throw new ParseException(start, ContainerLiaison.getString(
"jsp.error.mandatory.attribute",
new Object[] { typeOfTag, missingAttribute}));
@@ -170,7 +172,7 @@
}
}
if (!valid)
- throw new ParseException(start, Constants.getString(
+ throw new ParseException(start, ContainerLiaison.getString(
"jsp.error.invalid.attribute",
new Object[] { typeOfTag, attribute }));
}
1.2 +36 -31 jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/Parser.java
Index: Parser.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/parser/Parser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Parser.java 2001/06/06 05:40:14 1.1
+++ Parser.java 2001/06/12 15:21:01 1.2
@@ -60,6 +60,7 @@
import java.io.CharArrayWriter;
import org.apache.jasper34.core.Constants;
+import org.apache.jasper34.core.ContainerLiaison;
import org.apache.jasper34.runtime.JasperException;
import org.apache.jasper34.jsptree.TagLibraries;
@@ -103,14 +104,18 @@
* case of an include.
*/
String currentFile;
+ ContainerLiaison containerL;
public interface Action {
void execute(Mark start, Mark stop) throws JasperException;
}
- public Parser(JspReader reader, final ParseEventListener lnr) {
+ public Parser(ContainerLiaison containerL,
+ JspReader reader, final ParseEventListener lnr) {
+ this.containerL=containerL;
this.reader = reader;
- this.listener = new DelegatingListener(lnr,
+ this.listener = new DelegatingListener(containerL,
+ lnr,
new Action() {
public void execute(Mark start, Mark stop)
throws JasperException
@@ -185,7 +190,7 @@
}
if (match == null)
throw new ParseException(reader.mark(),
- Constants.getString("jsp.error.invalid.directive"));
+ listener.getContainerLiaison().getString("jsp.error.invalid.directive"));
reader.advance(match.length());
@@ -205,7 +210,7 @@
reader.skipSpaces();
if (!reader.matches(close))
throw new ParseException(reader.mark(),
- Constants.getString("jsp.error.unterminated",
+ listener.getContainerLiaison().getString("jsp.error.unterminated",
new Object[] { open }));
else
reader.advance(close.length());
@@ -255,7 +260,7 @@
if (!reader.matches(CLOSE_INCLUDE_BODY))
throw new ParseException(reader.mark(),
- Constants.getString
+ listener.getContainerLiaison().getString
("jsp.error.unterminated",
new Object[] { OPEN_INCLUDE }));
reader.advance(CLOSE_INCLUDE_BODY.length());
@@ -267,7 +272,7 @@
reader.skipSpaces();
if (!reader.matches (OPEN_INDIVIDUAL_PARAM))
throw new ParseException (reader.mark(),
- Constants.getString
+ listener.getContainerLiaison().getString
("jsp.error.paramexpected"));
//Parse zero or more param tags.
@@ -278,7 +283,7 @@
if (!reader.matches (CLOSE_INDIVIDUAL_PARAM))
throw new ParseException (reader.mark(),
- Constants.getString
+ listener.getContainerLiaison().getString
("jsp.error.unterminated",
new Object[] {OPEN_INDIVIDUAL_PARAM}));
reader.advance (CLOSE_INDIVIDUAL_PARAM.length ());
@@ -288,7 +293,7 @@
if (!reader.matches(CLOSE_INCLUDE))
throw new ParseException(reader.mark(),
- Constants.getString
+ listener.getContainerLiaison().getString
("jsp.error.unterminated",
new Object[] { OPEN_INCLUDE }));
reader.advance(CLOSE_INCLUDE.length());
@@ -336,7 +341,7 @@
if (!reader.matches(CLOSE_FORWARD_NO_BODY)) {
if (!reader.matches(CLOSE_FORWARD_BODY))
throw new ParseException(reader.mark(),
- Constants.getString
+ listener.getContainerLiaison().getString
("jsp.error.unterminated",
new Object[] { OPEN_FORWARD }));
reader.advance(CLOSE_FORWARD_BODY.length());
@@ -348,7 +353,7 @@
reader.skipSpaces();
if (!reader.matches (OPEN_INDIVIDUAL_PARAM))
throw new ParseException (reader.mark(),
- Constants.getString
+ listener.getContainerLiaison().getString
("jsp.error.paramexpected"));
// Parse zero or more param tags.
while (reader.matches(OPEN_INDIVIDUAL_PARAM)) {
@@ -359,7 +364,7 @@
if (!reader.matches (CLOSE_INDIVIDUAL_PARAM))
throw new ParseException (reader.mark(),
- Constants.getString
+ listener.getContainerLiaison().getString
("jsp.error.unterminated",
new Object[] {OPEN_INDIVIDUAL_PARAM}));
reader.advance (CLOSE_INDIVIDUAL_PARAM.length ());
@@ -369,7 +374,7 @@
if (!reader.matches(CLOSE_FORWARD))
throw new ParseException(reader.mark(),
- Constants.getString
+ listener.getContainerLiaison().getString
("jsp.error.unterminated",
new Object[] { OPEN_FORWARD }));
reader.advance(CLOSE_FORWARD.length());
@@ -410,7 +415,7 @@
Mark start = reader.mark();
Mark stop = reader.skipUntil(CLOSE_COMMENT);
if (stop == null)
- throw new ParseException(Constants.getString("jsp.error.unterminated",
+ throw new ParseException(listener.getContainerLiaison().getString("jsp.error.unterminated",
new Object[] { OPEN_COMMENT }));
parser.flushCharData(parser.tmplStart, parser.tmplStop);
@@ -459,7 +464,7 @@
reader.skipSpaces();
if (!reader.matches(end_open))
throw new ParseException(reader.mark(),
- Constants.getString("jsp.error.unterminated"));
+ listener.getContainerLiaison().getString("jsp.error.unterminated"));
reader.advance(end_open.length());
reader.skipSpaces();
@@ -468,7 +473,7 @@
Mark stop = reader.skipUntil(close);
if (stop == null)
- throw new ParseException(Constants.getString("jsp.error.unterminated",
+ throw new ParseException(listener.getContainerLiaison().getString("jsp.error.unterminated",
new Object[] { open }));
listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);
@@ -513,7 +518,7 @@
reader.skipSpaces();
if (!reader.matches(end_open))
throw new ParseException(reader.mark(),
- Constants.getString("jsp.error.unterminated"));
+ listener.getContainerLiaison().getString("jsp.error.unterminated"));
reader.advance(end_open.length());
reader.skipSpaces();
@@ -523,7 +528,7 @@
Mark stop = reader.skipUntil(close);
if (stop == null)
throw new ParseException(reader.mark(),
- Constants.getString("jsp.error.unterminated",
+ listener.getContainerLiaison().getString("jsp.error.unterminated",
new Object[] { open }));
listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);
listener.handleExpression(start, stop, attrs);
@@ -566,7 +571,7 @@
reader.skipSpaces();
if (!reader.matches(end_open))
throw new ParseException(reader.mark(),
- Constants.getString("jsp.error.unterminated"));
+ listener.getContainerLiaison().getString("jsp.error.unterminated"));
reader.advance(end_open.length());
reader.skipSpaces();
@@ -576,7 +581,7 @@
Mark stop = reader.skipUntil(close);
if (stop == null)
throw new ParseException(reader.mark(),
- Constants.getString("jsp.error.unterminated",
+ listener.getContainerLiaison().getString("jsp.error.unterminated",
new Object[] { open }));
listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);
listener.handleScriptlet(start, stop, attrs);
@@ -618,7 +623,7 @@
if (!reader.matches(CLOSE_BEAN)) {
if (!reader.matches(CLOSE_BEAN_3))
throw new ParseException(reader.mark(),
- Constants.getString("jsp.error.unterminated",
+ listener.getContainerLiaison().getString("jsp.error.unterminated",
new Object[] { "useBean" }));
reader.advance(CLOSE_BEAN_3.length());
Mark stop = reader.mark();
@@ -628,11 +633,11 @@
parser.parse(CLOSE_BEAN_2);
if (oldSize != reader.size) {
throw new ParseException (reader.mark(),
- Constants.getString("jsp.error.usebean.notinsamefile"));
+ listener.getContainerLiaison().getString("jsp.error.usebean.notinsamefile"));
}
if (!reader.matches(CLOSE_BEAN_2))
throw new ParseException(reader.mark(),
- Constants.getString("jsp.error.unterminated"
+ listener.getContainerLiaison().getString("jsp.error.unterminated"
,
new Object[] { OPEN_BEAN })
);
@@ -682,7 +687,7 @@
reader.skipSpaces();
if (!reader.matches(CLOSE_GETPROPERTY))
throw new ParseException(reader.mark(),
- Constants.getString("jsp.error.unterminated",
+ listener.getContainerLiaison().getString("jsp.error.unterminated",
new Object[] { OPEN_GETPROPERTY }));
else
reader.advance(CLOSE_GETPROPERTY.length());
@@ -725,7 +730,7 @@
reader.skipSpaces();
if (!reader.matches(CLOSE_SETPROPERTY))
throw new ParseException(reader.mark(),
- Constants.getString("jsp.error.unterminated",
+ listener.getContainerLiaison().getString("jsp.error.unterminated",
new Object[] { OPEN_SETPROPERTY }));
else
reader.advance(CLOSE_SETPROPERTY.length());
@@ -837,7 +842,7 @@
} catch (ParseException ex) {
throw new ParseException(
start,
- Constants.getString("jsp.error.unterminated.user.tag",
+ listener.getContainerLiaison().getString("jsp.error.unterminated.user.tag",
new Object[]{ParseUtil.escapeXml(tagEnd)}));
}
listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);
@@ -901,7 +906,7 @@
if (!reader.matches(END_OPEN_PLUGIN))
throw new ParseException (reader.mark(),
- Constants.getString("jsp.error.plugin.notclosed"));
+ listener.getContainerLiaison().getString("jsp.error.plugin.notclosed"));
reader.advance (END_OPEN_PLUGIN.length ());
reader.skipSpaces ();
@@ -929,20 +934,20 @@
}
if (!reader.matches (OPEN_INDIVIDUAL_PARAM))
throw new ParseException (reader.mark(),
- Constants.getString("jsp.error.paramexpected"));
+ listener.getContainerLiaison().getString("jsp.error.paramexpected"));
reader.parsePluginParamTag(param);
reader.skipSpaces ();
if (!reader.matches (CLOSE_INDIVIDUAL_PARAM))
throw new ParseException (reader.mark(),
- Constants.getString(
+ listener.getContainerLiaison().getString(
"jsp.error.closeindividualparam"));
reader.advance (CLOSE_INDIVIDUAL_PARAM.length ());
}
if (!paramsClosed)
throw new ParseException (reader.mark(),
- Constants.getString("jsp.error.closeparams"));
+ listener.getContainerLiaison().getString("jsp.error.closeparams"));
reader.skipSpaces ();
}
@@ -958,7 +963,7 @@
if (!reader.matches(CLOSE_PLUGIN))
throw new ParseException(reader.mark(),
- Constants.getString(
+ listener.getContainerLiaison().getString(
"jsp.error.unterminated",
new Object[] { OPEN_PLUGIN }));
@@ -1076,7 +1081,7 @@
CoreElement c = (CoreElement) e.nextElement();
Mark m = reader.mark();
if (c.accept(listener, reader, this)) {
- Constants.message("jsp.message.accepted",
+ listener.getContainerLiaison().message("jsp.message.accepted",
new Object[] { c.getClass().getName(), m },
Log.DEBUG);
accepted = true;