geirm 01/03/15 21:04:38
Modified: src/java/org/apache/velocity/app Velocity.java
Log:
Added 'templateExists()' method that tells if a template can be found via
the currently configured resource loaders.
Revision Changes Path
1.7 +27 -1 jakarta-velocity/src/java/org/apache/velocity/app/Velocity.java
Index: Velocity.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/app/Velocity.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Velocity.java 2001/03/15 04:46:32 1.6
+++ Velocity.java 2001/03/16 05:04:37 1.7
@@ -96,7 +96,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
* @author <a href="[EMAIL PROTECTED]">Christoph Reck</a>
* @author <a href="[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Velocity.java,v 1.6 2001/03/15 04:46:32 geirm Exp $
+ * @version $Id: Velocity.java,v 1.7 2001/03/16 05:04:37 geirm Exp $
*/
public class Velocity implements RuntimeConstants
@@ -392,5 +392,31 @@
}
return false;
+ }
+
+
+ /**
+ * Determines if a template is accessable via the currently
+ * configured resource loaders.
+ * <br><br>
+ * The assumption is that the caller will use it at some
+ * point so that the current implementation, while
+ * displaying lazyness and sloth, isn't entirely
+ * unreasonable.
+ *
+ * @param templateName name of the temlpate to search for
+ * @return true if found, false otherwise
+ */
+ public static boolean templateExists( String templateName )
+ {
+ try
+ {
+ Template t = Runtime.getTemplate( templateName );
+ return true;
+ }
+ catch( Exception e )
+ {
+ return false;
+ }
}
}