public static getString ( String key, String defaultValue ) : String | ||
key | String | property key /// |
defaultValue | String | default value to return if key not /// found in resource manager. /// |
return | String |
/// <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 static bool Evaluate(IContext context, TextWriter writer, System.String logTag, Stream instream) { /* * first, parse - convert ParseException if thrown */ TextReader reader = null; System.String encoding = null; try { encoding = RuntimeSingleton.getString(NVelocity.Runtime.RuntimeConstants_Fields.INPUT_ENCODING, NVelocity.Runtime.RuntimeConstants_Fields.ENCODING_DEFAULT); reader = 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, reader)); }
/// <summary> /// merges a template and puts the rendered stream into the writer /// </summary> /// <param name="templateName">name of template to be used in merge /// </param> /// <param name="context"> filled context to be used in merge /// </param> /// <param name="writer"> writer to write template into /// </param> /// <returns>true if successful, false otherwise. Errors /// logged to velocity log. /// </returns> /// <deprecated>Use /// {@link #mergeTemplate( String templateName, String encoding, /// Context context, Writer writer )} /// </deprecated> public static bool MergeTemplate(System.String templateName, IContext context, TextWriter writer) { return(MergeTemplate(templateName, RuntimeSingleton.getString(NVelocity.Runtime.RuntimeConstants_Fields.INPUT_ENCODING, NVelocity.Runtime.RuntimeConstants_Fields.ENCODING_DEFAULT), context, writer)); }