/// <summary> /// Assures that the results directory exists. If the results directory /// cannot be created, fails the test. /// </summary> protected internal static void assureResultsDirectoryExists(System.String resultsDirectory) { System.IO.FileInfo dir = new System.IO.FileInfo(resultsDirectory); bool tmpBool; if (System.IO.File.Exists(dir.FullName)) { tmpBool = true; } else { tmpBool = System.IO.Directory.Exists(dir.FullName); } if (!tmpBool) { RuntimeSingleton.info("Template results directory does not exist"); Boolean ok = true; try { System.IO.Directory.CreateDirectory(dir.FullName); } catch (System.Exception ex) { ok = false; } if (ok) { RuntimeSingleton.info("Created template results directory"); } else { System.String errMsg = "Unable to create template results directory"; RuntimeSingleton.warn(errMsg); Assertion.Fail(errMsg); } } }
public static bool MergeTemplate(String templateName, IContext context, TextWriter writer) { return (MergeTemplate(templateName, RuntimeSingleton.getString(RuntimeConstants.INPUT_ENCODING, RuntimeConstants.ENCODING_DEFAULT), context, writer)); }
/// <summary> /// Invokes a currently registered Velocimacro with the parms provided /// and places the rendered stream into the writer. /// <br> /// Note : currently only accepts args to the VM if they are in the context. /// </summary> /// <param name="vmName">name of Velocimacro to call /// </param> /// <param name="logTag">string to be used for template name in case of error /// </param> /// <param name="params[]">args used to invoke Velocimacro. In context key format : /// eg "foo","bar" (rather than "$foo","$bar") /// </param> /// <param name="context">Context object containing data/objects used for rendering. /// </param> /// <param name="writer"> Writer for output stream /// </param> /// <returns>true if Velocimacro exists and successfully invoked, false otherwise. /// </returns> public static bool InvokeVelocimacro(String vmName, String logTag, String[] params_Renamed, IContext context, TextWriter writer) { /* * check parms */ if (vmName == null || params_Renamed == null || context == null || writer == null || logTag == null) { RuntimeSingleton.error("Velocity.invokeVelocimacro() : invalid parameter"); return(false); } /* * does the VM exist? */ if (!RuntimeSingleton.isVelocimacro(vmName, logTag)) { RuntimeSingleton.error("Velocity.invokeVelocimacro() : VM '" + vmName + "' not registered."); return(false); } /* * now just create the VM call, and use evaluate */ StringBuilder construct = new StringBuilder("#"); construct.Append(vmName); construct.Append("("); for (int i = 0; i < params_Renamed.Length; i++) { construct.Append(" $"); construct.Append(params_Renamed[i]); } construct.Append(" )"); try { bool retval = Evaluate(context, writer, logTag, construct.ToString()); return(retval); } catch (Exception e) { RuntimeSingleton.error("Velocity.invokeVelocimacro() : error " + e); } return(false); }
/// <summary> /// Renders the input reader 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="reader">Reader containing the VTL to be rendered</param> /// <returns>true if successful, false otherwise. If false, see Velocity runtime log</returns> public static bool Evaluate(IContext context, TextWriter writer, String logTag, TextReader reader) { SimpleNode nodeTree = null; try { nodeTree = RuntimeSingleton.parse(reader, logTag); } catch (ParseException pex) { throw new ParseErrorException(pex.Message); } /* * now we want to init and render */ if (nodeTree != null) { InternalContextAdapterImpl ica = new InternalContextAdapterImpl(context); ica.PushCurrentTemplateName(logTag); try { try { nodeTree.init(ica, RuntimeSingleton.RuntimeServices); } catch (Exception e) { RuntimeSingleton.error("Velocity.evaluate() : init exception for tag = " + logTag + " : " + e); } /* * now render, and let any exceptions fly */ nodeTree.render(ica, writer); } finally { ica.PopCurrentTemplateName(); } return(true); } return(false); }
/// <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="encoding">encoding used in template</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> public static bool MergeTemplate(String templateName, String encoding, IContext context, TextWriter writer) { Template template = RuntimeSingleton.GetTemplate(templateName, encoding); if (template == null) { RuntimeSingleton.Error(string.Format("Velocity.parseTemplate() failed loading template '{0}'", templateName)); return(false); } else { template.Merge(context, writer); return(true); } }
public static bool Evaluate(IContext context, TextWriter writer, string logTag, TextReader reader) { SimpleNode simpleNode = null; try { simpleNode = RuntimeSingleton.Parse(reader, logTag); } catch (ParseException ex) { throw new ParseErrorException(ex.Message, ex); } bool result; if (simpleNode != null) { InternalContextAdapterImpl internalContextAdapterImpl = new InternalContextAdapterImpl(context); internalContextAdapterImpl.PushCurrentTemplateName(logTag); try { try { simpleNode.Init(internalContextAdapterImpl, RuntimeSingleton.RuntimeServices); } catch (System.Exception ex2) { RuntimeSingleton.Error(string.Concat(new object[] { "Velocity.evaluate() : init exception for tag = ", logTag, " : ", ex2 })); } simpleNode.Render(internalContextAdapterImpl, writer); } finally { internalContextAdapterImpl.PopCurrentTemplateName(); } result = true; } else { result = false; } return(result); }
/// <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="encoding">encoding used in template /// </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> /// <throws> ParseErrorException The template could not be parsed. </throws> /// <throws> MethodInvocationException A method on a context object could not be invoked. </throws> /// <throws> ResourceNotFoundException A referenced resource could not be loaded. </throws> /// <throws> Exception Any other exception. </throws> /// <summary> /// </summary> /// <since> Velocity v1.1 /// </since> public static bool MergeTemplate(string templateName, string encoding, IContext context, TextWriter writer) { Template template = RuntimeSingleton.GetTemplate(templateName, encoding); if (template == null) { string msg = "Velocity.mergeTemplate() was unable to load template '" + templateName + "'"; Log.Error(msg); throw new ResourceNotFoundException(msg); } else { template.Merge(context, writer); return(true); } }
public static bool Evaluate(IContext context, TextWriter writer, string logTag, Stream instream) { TextReader reader = null; string text = null; try { text = RuntimeSingleton.getString("input.encoding", "ISO-8859-1"); reader = new StreamReader(new StreamReader(instream, Encoding.GetEncoding(text)).BaseStream); } catch (IOException innerException) { string exceptionMessage = "Unsupported input encoding : " + text + " for template " + logTag; throw new ParseErrorException(exceptionMessage, innerException); } return(Velocity.Evaluate(context, writer, logTag, reader)); }
public static bool MergeTemplate(string templateName, string encoding, IContext context, TextWriter writer) { Template template = RuntimeSingleton.GetTemplate(templateName, encoding); bool result; if (template == null) { RuntimeSingleton.Error("Velocity.parseTemplate() failed loading template '" + templateName + "'"); result = false; } else { template.Merge(context, writer); result = true; } return(result); }
/// <summary> /// Renders the input reader 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="writer"> 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="reader">Reader containing the VTL to be rendered</param> /// <returns>true if successful, false otherwise. If false, see Velocity runtime log</returns> public static bool Evaluate(IContext context, TextWriter writer, String logTag, TextReader reader) { SimpleNode nodeTree = null; try { nodeTree = RuntimeSingleton.Parse(reader, logTag); } catch (ParseException parseException) { throw new ParseErrorException(parseException.Message, parseException); } // now we want to init and render if (nodeTree != null) { InternalContextAdapterImpl internalContextAdapterImpl = new InternalContextAdapterImpl(context); internalContextAdapterImpl.PushCurrentTemplateName(logTag); try { try { nodeTree.Init(internalContextAdapterImpl, RuntimeSingleton.RuntimeServices); } catch (Exception exception) { RuntimeSingleton.Error( string.Format("Velocity.evaluate() : init exception for tag = {0} : {1}", logTag, exception)); } // now render, and let any exceptions fly nodeTree.Render(internalContextAdapterImpl, writer); } finally { internalContextAdapterImpl.PopCurrentTemplateName(); } return(true); } return(false); }
/// <summary> Runs the test. /// </summary> public virtual void runTest() { try { assureResultsDirectoryExists(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR); /* * Get the template and the output. Do them backwards. * vm_test2 uses a local VM and vm_test1 doesn't */ Template template2 = RuntimeSingleton.getTemplate(getFileName(null, "vm_test2", org.apache.velocity.test.TemplateTestBase_Fields.TMPL_FILE_EXT)); Template template1 = RuntimeSingleton.getTemplate(getFileName(null, "vm_test1", org.apache.velocity.test.TemplateTestBase_Fields.TMPL_FILE_EXT)); System.IO.FileStream fos1 = new System.IO.FileStream(getFileName(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, "vm_test1", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT), System.IO.FileMode.Create); System.IO.FileStream fos2 = new System.IO.FileStream(getFileName(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, "vm_test2", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT), System.IO.FileMode.Create); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer1 = new BufferedWriter(new System.IO.StreamWriter(fos1)); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer2 = new BufferedWriter(new System.IO.StreamWriter(fos2)); /* * put the Vector into the context, and merge both */ VelocityContext context = new VelocityContext(); template1.merge(context, writer1); writer1.Flush(); writer1.Close(); template2.merge(context, writer2); writer2.Flush(); writer2.Close(); if (!isMatch(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, org.apache.velocity.test.TemplateTestBase_Fields.COMPARE_DIR, "vm_test1", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT, org.apache.velocity.test.TemplateTestBase_Fields.CMP_FILE_EXT) || !isMatch(org.apache.velocity.test.TemplateTestBase_Fields.RESULT_DIR, org.apache.velocity.test.TemplateTestBase_Fields.COMPARE_DIR, "vm_test2", org.apache.velocity.test.TemplateTestBase_Fields.RESULT_FILE_EXT, org.apache.velocity.test.TemplateTestBase_Fields.CMP_FILE_EXT)) { fail("Output incorrect."); } } catch (System.Exception e) { fail(e.Message); } }
/// <summary> /// Invokes a currently registered Velocimacro with the parameters provided /// and places the rendered stream into the writer. /// /// Note : currently only accepts args to the VM if they are in the context. /// </summary> /// <param name="vmName">name of Velocimacro to call</param> /// <param name="logTag">string to be used for template name in case of error</param> /// <param name="parameters">args used to invoke Velocimacro. In context key format : /// eg "foo","bar" (rather than "$foo","$bar") /// </param> /// <param name="context">Context object containing data/objects used for rendering.</param> /// <param name="writer"> Writer for output stream</param> /// <returns>true if Velocimacro exists and successfully invoked, false otherwise.</returns> public static bool InvokeVelocimacro(String vmName, String logTag, String[] parameters, IContext context, TextWriter writer) { // check parameters if (vmName == null || parameters == null || context == null || writer == null || logTag == null) { RuntimeSingleton.Error("Velocity.invokeVelocimacro() : invalid parameter"); return(false); } // does the VM exist? if (!RuntimeSingleton.IsVelocimacro(vmName, logTag)) { RuntimeSingleton.Error(string.Format("Velocity.invokeVelocimacro() : VM '{0}' not registered.", vmName)); return(false); } // now just create the VM call, and use evaluate StringBuilder construct = new StringBuilder("#"); construct.Append(vmName); construct.Append("("); for (int i = 0; i < parameters.Length; i++) { construct.Append(" $"); construct.Append(parameters[i]); } construct.Append(" )"); try { bool retval = Evaluate(context, writer, logTag, construct.ToString()); return(retval); } catch (Exception e) { RuntimeSingleton.Error(string.Format("Velocity.invokeVelocimacro() : error {0}", e)); } return(false); }
public static bool Evaluate(IContext context, TextWriter writer, String logTag, Stream instream) { // first, parse - convert ParseException if thrown TextReader reader = null; String encoding = null; try { encoding = RuntimeSingleton.getString(RuntimeConstants.INPUT_ENCODING, RuntimeConstants.ENCODING_DEFAULT); reader = new StreamReader(new StreamReader(instream, Encoding.GetEncoding(encoding)).BaseStream); } catch (IOException ioException) { String msg = string.Format("Unsupported input encoding : {0} for template {1}", encoding, logTag); throw new ParseErrorException(msg, ioException); } return(Evaluate(context, writer, logTag, reader)); }
/// <summary> Runs the test. /// </summary> public virtual void runTest() { try { /* * lets ensure the results directory exists */ assureResultsDirectoryExists(RESULTS_DIR); Template template1 = RuntimeSingleton.getTemplate(getFileName(null, "template/test1", TMPL_FILE_EXT)); Template template2 = RuntimeSingleton.getTemplate(getFileName(null, "template/test2", TMPL_FILE_EXT)); System.IO.FileStream fos1 = new System.IO.FileStream(getFileName(RESULTS_DIR, "test1", RESULT_FILE_EXT), System.IO.FileMode.Create); System.IO.FileStream fos2 = new System.IO.FileStream(getFileName(RESULTS_DIR, "test2", RESULT_FILE_EXT), System.IO.FileMode.Create); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer1 = new BufferedWriter(new System.IO.StreamWriter(fos1)); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' System.IO.StreamWriter writer2 = new BufferedWriter(new System.IO.StreamWriter(fos2)); /* * put the Vector into the context, and merge both */ VelocityContext context = new VelocityContext(); template1.merge(context, writer1); writer1.Flush(); writer1.Close(); template2.merge(context, writer2); writer2.Flush(); writer2.Close(); if (!isMatch(RESULTS_DIR, COMPARE_DIR, "test1", RESULT_FILE_EXT, CMP_FILE_EXT) || !isMatch(RESULTS_DIR, COMPARE_DIR, "test2", RESULT_FILE_EXT, CMP_FILE_EXT)) { fail("Output is incorrect!"); } } catch (System.Exception e) { fail(e.Message); } }
public static bool InvokeVelocimacro(string vmName, string logTag, string[] parameters, IContext context, TextWriter writer) { bool result; if (vmName == null || parameters == null || context == null || writer == null || logTag == null) { RuntimeSingleton.Error("Velocity.invokeVelocimacro() : invalid parameter"); result = false; } else if (!RuntimeSingleton.IsVelocimacro(vmName, logTag)) { RuntimeSingleton.Error("Velocity.invokeVelocimacro() : VM '" + vmName + "' not registered."); result = false; } else { StringBuilder stringBuilder = new StringBuilder("#"); stringBuilder.Append(vmName); stringBuilder.Append("("); for (int i = 0; i < parameters.Length; i++) { stringBuilder.Append(" $"); stringBuilder.Append(parameters[i]); } stringBuilder.Append(" )"); try { bool flag = Velocity.Evaluate(context, writer, logTag, stringBuilder.ToString()); result = flag; return(result); } catch (System.Exception arg) { RuntimeSingleton.Error("Velocity.invokeVelocimacro() : error " + arg); } result = false; } return(result); }
/// <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, String logTag, Stream instream) { /* * first, parse - convert ParseException if thrown */ TextReader reader = null; String encoding = null; try { encoding = RuntimeSingleton.getString(RuntimeConstants_Fields.INPUT_ENCODING, RuntimeConstants_Fields.ENCODING_DEFAULT); reader = new StreamReader(new StreamReader(instream, Encoding.GetEncoding(encoding)).BaseStream); } catch (IOException uce) { String msg = "Unsupported input encoding : " + encoding + " for template " + logTag; throw new ParseErrorException(msg); } return(Evaluate(context, writer, logTag, reader)); }
/// <summary> /// Assures that the results directory exists. If the results directory /// cannot be created, fails the test. /// </summary> protected internal static void AssureResultsDirectoryExists(String resultsDirectory) { FileInfo dir = new FileInfo(resultsDirectory); bool tmpBool; if (File.Exists(dir.FullName)) { tmpBool = true; } else { tmpBool = Directory.Exists(dir.FullName); } if (!tmpBool) { RuntimeSingleton.Info("Template results directory does not exist"); Boolean ok = true; try { Directory.CreateDirectory(dir.FullName); } catch (Exception) { ok = false; } if (ok) { RuntimeSingleton.Info("Created template results directory"); } else { String errMsg = "Unable to create template results directory"; RuntimeSingleton.Warn(errMsg); Assert.True(false, errMsg); } } }
/// <summary> /// Implementation of IHttpHandler method, called by container upon /// loading (is Isreusable returns true, instances may be pooled) /// </summary> /// <param name="context"></param> /// <param name="requestType"></param> /// <param name="url"></param> /// <param name="pathTranslated"></param> public virtual void Init(HttpContext context, String requestType, String url, String pathTranslated) { this.context = context; this.requestType = requestType; this.url = url; this.pathTranslated = pathTranslated; lock (this) { if (!initialized) { // do whatever we have to do to init Velocity InitVelocity(); // we can get these now that velocity is initialized defaultContentType = RuntimeSingleton.getString(CONTENT_TYPE, DEFAULT_CONTENT_TYPE); encoding = RuntimeSingleton.getString(RuntimeConstants_Fields.OUTPUT_ENCODING, DEFAULT_OUTPUT_ENCODING); initialized = true; } } return; }
/// <summary> /// Runs the test. /// </summary> private Boolean RunTest(String baseFileName) { // run setup before each test so that the context is clean SetUp(); try { Template template = RuntimeSingleton.getTemplate(getFileName(null, baseFileName, NVelocity.Test.TemplateTestBase_Fields.TMPL_FILE_EXT)) ; assureResultsDirectoryExists(NVelocity.Test.TemplateTestBase_Fields.RESULT_DIR); /* get the file to write to */ FileStream fos = new FileStream(getFileName(NVelocity.Test.TemplateTestBase_Fields.RESULT_DIR, baseFileName, NVelocity.Test.TemplateTestBase_Fields.RESULT_FILE_EXT), FileMode.Create); //UPGRADE_ISSUE: Constructor 'java.io.BufferedWriter.BufferedWriter' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javaioBufferedWriterBufferedWriter_javaioWriter"' StreamWriter writer = new StreamWriter(fos); /* process the template */ template.Merge(context, writer); /* close the file */ writer.Flush(); writer.Close(); if (!isMatch(TemplateTestBase_Fields.RESULT_DIR, TemplateTestBase_Fields.COMPARE_DIR, baseFileName, TemplateTestBase_Fields.RESULT_FILE_EXT, TemplateTestBase_Fields.CMP_FILE_EXT)) { //Fail("Processed template did not match expected output"); return(false); } } catch (System.Exception e) { System.Console.Out.WriteLine("EXCEPTION : " + e); Assertion.Fail(e.Message); } return(true); }
/// <summary> Default constructor: sets up the Velocity /// Runtime, creates the visitor for traversing /// the node structure and then produces the /// visual representation by the visitation. /// </summary> public TemplateNodeView(System.String template) { try { RuntimeSingleton.init("velocity.properties"); System.IO.StreamReader isr = new InputStreamReader(new System.IO.FileStream(template, System.IO.FileMode.Open, System.IO.FileAccess.Read), RuntimeSingleton.getString(RuntimeSingleton.INPUT_ENCODING)) ; //UPGRADE_ISSUE: The equivalent of constructor 'java.io.BufferedReader.BufferedReader' is incompatible with the expected type in C#. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1109"' System.IO.StreamReader br = new System.IO.StreamReader(isr.BaseStream); document = RuntimeSingleton.parse(br, template) ; visitor = new NodeViewMode(); visitor.Context = null; //UPGRADE_ISSUE: The equivalent of parameter java.lang.System.out is incompatible with the expected type in C#. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1109"' visitor.Writer = new System.IO.StreamWriter(System.Console.Out); document.jjtAccept(visitor, null); } catch (System.Exception e) { System.Console.Out.WriteLine(e); SupportClass.WriteStackTrace(e, Console.Error); } }
/// <summary> /// Clear a NVelocity Runtime property. /// </summary> /// <param name="key">of property to clear</param> public static void ClearProperty(String key) { RuntimeSingleton.clearProperty(key); }
/// <summary> /// Add a Velocity Runtime property. /// </summary> /// <param name="key">key</param> /// <param name="value">value</param> public static void AddProperty(String key, Object value) { RuntimeSingleton.addProperty(key, value); }
/// <summary> /// initialize the Velocity runtime engine, using default properties /// plus the properties in the passed in java.util.Properties object /// </summary> /// <param name="p"> /// Proprties object containing initialization properties /// </param> public static void Init(ExtendedProperties p) { RuntimeSingleton.init(p); }
/// <summary> /// initialize the Velocity runtime engine, using default properties /// plus the properties in the properties file passed in as the arg /// </summary> /// <param name="propsFilename"> /// file containing properties to use to initialize /// the Velocity runtime /// </param> public static void Init(String propsFilename) { RuntimeSingleton.init(propsFilename); }
/// <summary> /// Log a debug message. /// </summary> /// <param name="Object">message to log</param> public static void Debug(Object message) { RuntimeSingleton.debug(message); }
/// <summary> /// Log an error message. /// </summary> /// <param name="Object">message to log</param> public static void Error(Object message) { RuntimeSingleton.error(message); }
/// <summary> /// Log an info message. /// </summary> /// <param name="Object">message to log</param> public static void Info(Object message) { RuntimeSingleton.info(message); }
/// <summary> /// Log a warning message. /// </summary> /// <param name="Object">message to log /// </param> public static void Warn(Object message) { RuntimeSingleton.warn(message); }
/// <summary> /// <p>Determines whether a resource is accessable via the /// currently configured resource loaders. {@link /// org.apache.velocity.runtime.resource.Resource} is the generic /// description of templates, static content, etc.</p> /// /// <p>Note that the current implementation will <b>not</b> change /// the state of the system in any real way - so this cannot be /// used to pre-load the resource cache, as the previous /// implementation did as a side-effect.</p> /// </summary> /// <param name="resourceName"> name of the resource to search for</param> /// <returns>Whether the resource was located.</returns> public static bool ResourceExists(String templateName) { return(RuntimeSingleton.getLoaderNameForResource(templateName) != null); }
/// <summary> /// Returns a <code>Template</code> from the Velocity /// resource management system. /// </summary> /// <param name="name">The file name of the desired template. /// </param> /// <param name="encoding">The character encoding to use for the template. /// </param> /// <returns> The template. /// @throws ResourceNotFoundException if template not found /// from any available source. /// @throws ParseErrorException if template cannot be parsed due /// to syntax (or other) error. /// @throws Exception if an error occurs in template initialization /// @since Velocity v1.1 /// </returns> public static Template GetTemplate(String name, String encoding) { return(RuntimeSingleton.getTemplate(name, encoding)); }