Back to index

wims  3.65+svn20090927
CachingResourcesManager.java
Go to the documentation of this file.
00001 /*
00002 $Id: CachingResourcesManager.java,v 1.2 2003/02/18 11:48:48 sander Exp $
00003 */
00004 
00005 
00006 package fr.ove.utils;
00007 
00008 import fr.ove.utils.ResourcesManager;
00009 
00016 public class CachingResourcesManager extends ResourcesManager {
00020     private String cachedResource = "";
00021     
00025     private String[] cachedProperties = null;
00026     
00031     public CachingResourcesManager(String resourcesName) {
00032         super(resourcesName);
00033     }
00034     
00040     public String accessResource(String resource, int index) {
00041         String property = null;
00042         
00043         if (!cachedResource.equals(resource)) {
00044             String[] properties = getResourceStrings(resource);
00045             if ((index >= 0) && (index < properties.length)) {
00046                 property = properties[index];
00047                 cachedResource = resource;
00048                 cachedProperties = properties;
00049             }
00050         }
00051         else if ((index >= 0) && (index < cachedProperties.length))
00052             property = cachedProperties[index];
00053         
00054         return property;
00055         
00056     }
00057 }