Ejemplo n.º 1
0
        /// <summary>
        /// Renders the input stream using the context into the output writer.
        /// To be used when a template is dynamically constructed, or want to
        /// use Velocity as a token replacer.
        /// </summary>
        /// <param name="context">context to use in rendering input string
        /// </param>
        /// <param name="out"> Writer in which to render the output
        /// </param>
        /// <param name="logTag"> string to be used as the template name for log messages
        /// in case of error
        /// </param>
        /// <param name="instream">input stream containing the VTL to be rendered
        /// </param>
        /// <returns>true if successful, false otherwise.  If false, see
        /// Velocity runtime log
        /// </returns>
        /// <deprecated>Use
        /// {@link #evaluate( Context context, Writer writer,
        /// String logTag, Reader reader ) }
        /// </deprecated>
        public virtual bool Evaluate(IContext context, TextWriter writer, System.String logTag, Stream instream)
        {
            /*
             *  first, parse - convert ParseException if thrown
             */
            TextReader br = null;

            System.String encoding = null;

            try {
                encoding = ri.getString(RuntimeConstants_Fields.INPUT_ENCODING, RuntimeConstants_Fields.ENCODING_DEFAULT);
                br       = new StreamReader(new StreamReader(instream, System.Text.Encoding.GetEncoding(encoding)).BaseStream);
            } catch (IOException uce) {
                System.String msg = "Unsupported input encoding : " + encoding + " for template " + logTag;
                throw new ParseErrorException(msg);
            }

            return(Evaluate(context, writer, logTag, br));
        }