Home | History | Annotate | Download | only in resourceloader
      1 /*
      2  * Copyright (C) 2010 Google Inc.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.google.clearsilver.jsilver.resourceloader;
     18 
     19 import java.io.IOException;
     20 import java.io.Reader;
     21 
     22 /**
     23  * Implementations of ResourceLoader should extend this class rather than directly implement the
     24  * ResourceLoader interface - this allows changes to be made to the ResourceLoader interface whilst
     25  * retaining backwards compatibility with existing implementations.
     26  *
     27  * @see ResourceLoader
     28  */
     29 public abstract class BaseResourceLoader implements ResourceLoader {
     30 
     31   @Override
     32   public void close(Reader reader) throws IOException {
     33     reader.close();
     34   }
     35 
     36   /**
     37    * Default implementation returns the filename as the ResourceLoaders that subclass this class
     38    * tend to assume they are the only ResourceLoader in use. Or at least that the filename is the
     39    * only necessary form of uniqueness between two instances of this same ResourceLoader.
     40    */
     41   @Override
     42   public Object getKey(String filename) {
     43     return filename;
     44   }
     45 
     46   /**
     47    * Default implementation does not check whether the resource has changed.
     48    */
     49   @Override
     50   public Object getResourceVersionId(String filename) {
     51     return filename;
     52   }
     53 }
     54