geirm 01/04/22 11:03:49
Modified: src/java/org/apache/velocity/runtime/parser Parser.jjt
Log:
Change on public interface, from taking an InputStream to a Reader - this
moves encoding responsibility to upper levels. This keeps parser
responsibilities simpler.
Revision Changes Path
1.59 +3 -32
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.jjt
Index: Parser.jjt
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/Parser.jjt,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- Parser.jjt 2001/04/14 02:50:19 1.58
+++ Parser.jjt 2001/04/22 18:03:48 1.59
@@ -120,7 +120,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: Parser.jjt,v 1.58 2001/04/14 02:50:19 geirm Exp $
+ * @version $Id: Parser.jjt,v 1.59 2001/04/22 18:03:48 geirm Exp $
*/
public class Parser
{
@@ -134,11 +134,6 @@
*/
String currentTemplateName = "";
- /**
- * encoding for the input stream.
- */
- private String inputEncoding = "ISO-8859-1";
-
/**
* This constructor was added to allow the re-use of parsers.
* The normal constructor takes a single argument which
@@ -149,11 +144,6 @@
public Parser()
{
this(new ByteArrayInputStream("\n".getBytes()));
-
- /*
- * get the encoding property. Default is ISO latin
- */
- inputEncoding = Runtime.getString( Runtime.INPUT_ENCODING, "ISO-8859-1");
}
/**
@@ -165,7 +155,7 @@
* method and re-initializing the lexer with
* the new stream that we want parsed.
*/
- public SimpleNode parse(InputStream stream, String templateName )
+ public SimpleNode parse( Reader reader, String templateName )
throws ParseException
{
SimpleNode sn = null;
@@ -181,29 +171,10 @@
Runtime.dumpVMNamespace( currentTemplateName );
- /*
- * wrap in a reader so users can control the encoding
- * of the template
- */
-
- BufferedReader br = null;
-
- try
- {
- br = new BufferedReader( new InputStreamReader( stream, inputEncoding
) );
- }
- catch( UnsupportedEncodingException uce )
- {
- String msg = "Parser Exception: Unsupported input encoding : " +
inputEncoding
- + " for template " + templateName;
- Runtime.error( msg );
- throw new ParseException( msg );
- }
-
try
{
token_source.clearStateVars();
- ReInit(br);
+ ReInit(reader);
sn = process();
}
catch (ParseException pe)