Update to Worldwind release 0.4.1
[worldwind-tracker.git] / gov / nasa / worldwind / cache / BasicDataFileCache.java
blob7bd303a7a6814635aba980a0644a7b3743cc59a7
1 /*
2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
5 All Rights Reserved.
6 */
7 package gov.nasa.worldwind.cache;
9 import gov.nasa.worldwind.Configuration;
10 import gov.nasa.worldwind.avlist.AVKey;
11 import gov.nasa.worldwind.util.Logging;
13 import java.io.*;
15 /**
16 * @author Tom Gaskins
17 * @version $Id: BasicDataFileCache.java 3335 2007-10-19 04:05:22Z tgaskins $
19 public class BasicDataFileCache extends AbstractFileCache
21 public BasicDataFileCache()
23 String cachePathName = Configuration.getStringValue(AVKey.DATA_FILE_CACHE_CONFIGURATION_FILE_NAME);
24 if (cachePathName == null)
26 String message = Logging.getMessage("FileCache.NoConfiguration");
27 Logging.logger().severe(message);
28 throw new IllegalStateException(message);
31 java.io.InputStream is = null;
32 File file = new File(cachePathName);
33 if (file.exists())
35 try
37 is = new FileInputStream(file);
39 catch (FileNotFoundException e)
41 String message = Logging.getMessage("FileCache.LocalConfigFileNotFound", cachePathName);
42 Logging.logger().finest(message);
46 if (is == null)
48 is = this.getClass().getClassLoader().getResourceAsStream(cachePathName);
51 if (is == null)
53 String message = Logging.getMessage("FileCache.ConfigurationNotFound", cachePathName);
54 Logging.logger().severe(message);
55 throw new IllegalStateException(message);
58 this.initialize(is);