* @param jspBeginLineNum The start line number of the JSP element
* responsible for the compilation error
* @param errMsg The compilation error message
+ * @param ctxt The compilation context
*/
public JavacErrorDetail(String javaFileName,
- int javaLineNum,
- String jspFileName,
- int jspBeginLineNum,
- StringBuffer errMsg) {
-
- this(javaFileName, javaLineNum, jspFileName, jspBeginLineNum, errMsg,
- null);
- }
-
- public JavacErrorDetail(String javaFileName,
int javaLineNum,
String jspFileName,
int jspBeginLineNum,
import java.util.List;
import java.util.Vector;
import java.util.jar.JarFile;
-import java.net.URL;
-import java.net.MalformedURLException;
import org.apache.jasper.JasperException;
import org.apache.jasper.JspCompilationContext;
current = new Mark(mark);
}
- boolean matchesIgnoreCase(String string) throws JasperException {
- Mark mark = mark();
- int ch = 0;
- int i = 0;
- do {
- ch = nextChar();
- if (Character.toLowerCase((char) ch) != string.charAt(i++)) {
- reset(mark);
- return false;
- }
- } while (i < string.length());
- reset(mark);
- return true;
- }
-
/**
* search the stream for a match to a string
* @param string The string to match
/**
- * Gets the URL for the given path name.
- *
- * @param path Path name
- *
- * @return URL for the given path name.
- *
- * @exception MalformedURLException if the path name is not given in
- * the correct form
- */
- URL getResource(String path) throws MalformedURLException {
- return context.getResource(path);
- }
-
-
- /**
* 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>.
package org.apache.jasper.compiler;
-import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
// Delimiters for request-time expressions (JSP and XML syntax)
private static final String OPEN_EXPR = "<%=";
private static final String CLOSE_EXPR = "%>";
- private static final String OPEN_EXPR_XML = "%=";
- private static final String CLOSE_EXPR_XML = "%";
// private static ExpressionEvaluatorImpl expressionEvaluator
// = new ExpressionEvaluatorImpl();
public static final int CHUNKSIZE = 1024;
- public static char[] removeQuotes(char[] chars) {
- CharArrayWriter caw = new CharArrayWriter();
- for (int i = 0; i < chars.length; i++) {
- if (chars[i] == '%' && chars[i + 1] == '\\' &&
- chars[i + 2] == '>') {
- caw.write('%');
- caw.write('>');
- i = i + 2;
- } else {
- caw.write(chars[i]);
- }
- }
- return caw.toCharArray();
- }
-
- public static char[] escapeQuotes(char[] chars) {
- // Prescan to convert %\> to %>
- String s = new String(chars);
- while (true) {
- int n = s.indexOf("%\\>");
- if (n < 0)
- break;
- StringBuffer sb = new StringBuffer(s.substring(0, n));
- sb.append("%>");
- sb.append(s.substring(n + 3));
- s = sb.toString();
- }
- chars = s.toCharArray();
- return (chars);
-
- // Escape all backslashes not inside a Java string literal
- /*
- CharArrayWriter caw = new CharArrayWriter();
- boolean inJavaString = false;
- for (int i = 0; i < chars.length; i++) {
- if (chars[i] == '"') inJavaString = !inJavaString;
- // escape out the escape character
- if (!inJavaString && (chars[i] == '\\')) caw.write('\\');
- caw.write(chars[i]);
- }
- return caw.toCharArray();
- */
- }
-
- /**
- * Checks if the token is a runtime expression. In standard JSP syntax, a
- * runtime expression starts with '<%' and ends with '%>'. When the JSP
- * document is in XML syntax, a runtime expression starts with '%=' and ends
- * with '%'.
- *
- * @param token The token to be checked
- * @return whether the token is a runtime expression or not.
- */
- public static boolean isExpression(String token, boolean isXml) {
- String openExpr;
- String closeExpr;
- if (isXml) {
- openExpr = OPEN_EXPR_XML;
- closeExpr = CLOSE_EXPR_XML;
- } else {
- openExpr = OPEN_EXPR;
- closeExpr = CLOSE_EXPR;
- }
- if (token.startsWith(openExpr) && token.endsWith(closeExpr)) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * @return the "expression" part of a runtime expression, taking the
- * delimiters out.
- */
- public static String getExpr(String expression, boolean isXml) {
- String returnString;
- String openExpr;
- String closeExpr;
- if (isXml) {
- openExpr = OPEN_EXPR_XML;
- closeExpr = CLOSE_EXPR_XML;
- } else {
- openExpr = OPEN_EXPR;
- closeExpr = CLOSE_EXPR;
- }
- int length = expression.length();
- if (expression.startsWith(openExpr) && expression.endsWith(closeExpr)) {
- returnString = expression.substring(openExpr.length(), length
- - closeExpr.length());
- } else {
- returnString = "";
- }
- return returnString;
- }
-
/**
* Takes a potential expression and converts it into XML form
*/
// XXX *could* move EL-syntax validation here... (sb)
}
- public static String escapeQueryString(String unescString) {
- if (unescString == null)
- return null;
-
- String escString = "";
- String shellSpChars = "\\\"";
-
- for (int index = 0; index < unescString.length(); index++) {
- char nextChar = unescString.charAt(index);
-
- if (shellSpChars.indexOf(nextChar) != -1)
- escString += "\\";
-
- escString += nextChar;
- }
- return escString;
- }
-
/**
* Escape the 5 entities defined by XML.
*/
return false;
}
- /**
- * Converts the given Xml name to a legal Java identifier. This is slightly
- * more efficient than makeJavaIdentifier in that we only need to worry
- * about '.', '-', and ':' in the string. We also assume that the resultant
- * string is further concatenated with some prefix string so that we don't
- * have to worry about it being a Java key word.
- *
- * @param name
- * Identifier to convert
- *
- * @return Legal Java identifier corresponding to the given identifier
- */
- public static final String makeXmlJavaIdentifier(String name) {
- if (name.indexOf('-') >= 0)
- name = replace(name, '-', "$1");
- if (name.indexOf('.') >= 0)
- name = replace(name, '.', "$2");
- if (name.indexOf(':') >= 0)
- name = replace(name, ':', "$3");
- return name;
- }
-
static InputStreamReader getReader(String fname, String encoding,
JarFile jarFile, JspCompilationContext ctxt, ErrorDispatcher err)
throws JasperException, IOException {
return ctxt.getResource(getFile());
}
- public String toShortString() {
- return "("+line+","+col+")";
- }
-
public boolean equals(Object other) {
if (other instanceof Mark) {
Mark m = (Mark) other;
}
/**
- * @return true if this Mark is greather than the <code>other</code>
- * Mark, false otherwise.
- */
- public boolean isGreater(Mark other) {
-
- boolean greater = false;
-
- if (this.line > other.line) {
- greater = true;
- } else if (this.line == other.line && this.col > other.col) {
- greater = true;
- }
-
- return greater;
- }
-
- /**
* Keep track of parser before parsing an included file.
* This class keeps track of the parser before we switch to parsing an
* included file. In other words, it's the parser's continuation to be
int fileId;
String fileName;
String baseDir;
- String encoding;
char[] stream = null;
IncludeState(int inCursor, int inLine, int inCol, int inFileId,
}
/**
- * Constructor.
- *
- * @param qName
- * The action's qualified name
- * @param localName
- * The action's local name
- * @param start
- * The location of the jsp page
- * @param parent
- * The enclosing node
- */
- public Node(String qName, String localName, Mark start, Node parent) {
- this.qName = qName;
- this.localName = localName;
- this.startMark = start;
- this.isDummy = (start == null);
- addToParent(parent);
- }
-
- /**
* Constructor for Nodes parsed from standard syntax.
*
* @param qName
this.jspAttrs = jspAttrs;
}
- public TagAttributeInfo getTagAttributeInfo(String name) {
- TagInfo info = this.getTagInfo();
- if (info == null)
- return null;
- TagAttributeInfo[] tai = info.getAttributes();
- for (int i = 0; i < tai.length; i++) {
- if (tai[i].getName().equals(name)) {
- return tai[i];
- }
- }
- return null;
- }
-
public JspAttribute[] getJspAttributes() {
return jspAttrs;
}
}
/**
- * Print a standard comment for echo outputed chunk.
- * @param start The starting position of the JSP chunk being processed.
- * @param stop The ending position of the JSP chunk being processed.
- */
- public void printComment(Mark start, Mark stop, char[] chars) {
- if (start != null && stop != null) {
- println("// from="+start);
- println("// to="+stop);
- }
-
- if (chars != null)
- for(int i = 0; i < chars.length;) {
- printin();
- print("// ");
- while (chars[i] != '\n' && i < chars.length)
- writer.print(chars[i++]);
- }
- }
-
- /**
* Prints the given string followed by '\n'
*/
public void println(String s) {
return escString;
}
- /**
- * Decode an URL formatted string.
- * @param encoded The string to decode.
- * @return The decoded string.
- */
-
- public static String decode(String encoded) {
- // speedily leave if we're not needed
- if (encoded == null) return null;
- if (encoded.indexOf('%') == -1 && encoded.indexOf('+') == -1)
- return encoded;
-
- //allocate the buffer - use byte[] to avoid calls to new.
- byte holdbuffer[] = new byte[encoded.length()];
-
- int bufcount = 0;
-
- for (int count = 0; count < encoded.length(); count++) {
- char cur = encoded.charAt(count);
- if (cur == '%') {
- holdbuffer[bufcount++] =
- (byte)Integer.parseInt(encoded.substring(count+1,count+3),16);
- if (count + 2 >= encoded.length())
- count = encoded.length();
- else
- count += 2;
- } else if (cur == '+') {
- holdbuffer[bufcount++] = (byte) ' ';
- } else {
- holdbuffer[bufcount++] = (byte) cur;
- }
- }
- // REVISIT -- remedy for Deprecated warning.
- //return new String(holdbuffer,0,0,bufcount);
- return new String(holdbuffer,0,bufcount);
- }
-
// __begin lookupReadMethodMethod
public static Object handleGetProperty(Object o, String prop)
throws JasperException {