You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by jo...@locus.apache.org on 2000/11/03 23:50:18 UTC

cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/loader FileTemplateLoader.java

jon         00/11/03 14:50:15

  Modified:    src/java/org/apache/velocity/runtime/loader
                        FileTemplateLoader.java
  Log:
  added more error checking
  
  Revision  Changes    Path
  1.6       +11 -4     jakarta-velocity/src/java/org/apache/velocity/runtime/loader/FileTemplateLoader.java
  
  Index: FileTemplateLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/loader/FileTemplateLoader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FileTemplateLoader.java	2000/10/10 03:33:05	1.5
  +++ FileTemplateLoader.java	2000/11/03 22:50:12	1.6
  @@ -70,7 +70,7 @@
    * That'll change once we decide how we want to do configuration
    * 
    * @author Dave Bryson
  - * $Revision: 1.5 $
  + * $Revision: 1.6 $
    */
   public class FileTemplateLoader extends TemplateLoader
   {
  @@ -87,8 +87,12 @@
           templatepath = Runtime.getString(
               Runtime.TEMPLATE_PATH);
           
  +        Runtime.info("Template loader path: " + templatepath );
  +        
           useCache = Runtime.getBoolean(
               Runtime.TEMPLATE_CACHE );
  +
  +        Runtime.info("Template caching: " + useCache );
           
           checkInterval = new Long(Runtime.getString(
               Runtime.TEMPLATE_MOD_CHECK_INTERVAL)).longValue();
  @@ -108,6 +112,10 @@
       public synchronized Template getTemplate( String name )
        throws Exception
       {
  +        if (name == null || name.length() == 0)
  +        {
  +            throw new Exception ("Need to specify a file name or file path!");
  +        }
           if ( useCache )
           {
               if ( cache.containsKey( name ) )
  @@ -128,9 +136,8 @@
                       
               }
           }
  -        
  -        File file = new File( templatepath, name );
  -           
  +
  +        File file = new File( templatepath, name );           
           if ( file.canRead() )
           {
               Template template = new Template(new BufferedInputStream(