This defines static methods for loading resources. @author Douglas Brown @version 1.0
| 85 | * @version 1.0 |
| 86 | */ |
| 87 | public class ResourceLoader { |
| 88 | |
| 89 | static { |
| 90 | if (OSPRuntime.isJS) { |
| 91 | // ensures that OSPRuntime has initialized Assets |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | public static File tempDirFile = new File(OSPRuntime.tempDir); |
| 96 | |
| 97 | private final static String encoding = "UTF-8"; //$NON-NLS-1$ |
| 98 | final static Charset defaultCharset = Charset.forName(encoding); |
| 99 | |
| 100 | @SuppressWarnings("javadoc") |
| 101 | protected static final String WIN_XP_DEFAULT_CACHE = "/Local Settings/Application Data/OSP/Cache"; //$NON-NLS-1$ |
| 102 | protected static final String WINDOWS_DEFAULT_CACHE = "/AppData/Local/OSP/Cache"; //$NON-NLS-1$ |
| 103 | protected static final String OSX_DEFAULT_CACHE = "/Library/Caches/OSP"; //$NON-NLS-1$ |
| 104 | protected static final String LINUX_DEFAULT_CACHE = "/.config/OSP/Cache"; //$NON-NLS-1$ |
| 105 | protected static final String SEARCH_CACHE_SUBDIRECTORY = "Search"; //$NON-NLS-1$ |
| 106 | protected static final int WEB_CONNECTION_RETRY = 1; |
| 107 | |
| 108 | protected static ArrayList<String> searchPaths = new ArrayList<String>(); // search paths |
| 109 | protected static ArrayList<String> appletSearchPaths = new ArrayList<String>(); // search paths for apples |
| 110 | protected static int maxPaths = 20; // max number of paths in history |
| 111 | protected static Hashtable<String, Resource> resources = new Hashtable<String, Resource>(); // cached resources |
| 112 | protected static boolean cacheEnabled = OSPRuntime.resCacheEnabled; |
| 113 | protected static boolean canceled = false; |
| 114 | protected static Map<String, URLClassLoader> zipLoaders = (OSPRuntime.checkZipLoaders |
| 115 | ? new TreeMap<String, URLClassLoader>() |
| 116 | : null); // maps path to zipLoader |
| 117 | protected static URLClassLoader xsetZipLoader; // zipLoader of current xset |
| 118 | protected static Set<String> extractExtensions = new TreeSet<String>(); |
| 119 | protected static ArrayList<String> pathsNotFound = new ArrayList<String>(); |
| 120 | protected static File ospCache; |
| 121 | public static boolean warningShown = false; |
| 122 | |
| 123 | public static final FileFilter OSP_CACHE_FILTER; |
| 124 | |
| 125 | static { |
| 126 | OSP_CACHE_FILTER = new FileFilter() { |
| 127 | @Override |
| 128 | public boolean accept(File file) { |
| 129 | return file.isDirectory() && file.getName().startsWith("osp-"); //$NON-NLS-1$ |
| 130 | } |
| 131 | }; |
| 132 | } |
| 133 | |
| 134 | |
| 135 | // protected static boolean zipURLsOK; BH 2020.11.12 |
| 136 | protected static boolean webConnected; |
| 137 | |
| 138 | public static boolean ignoreMissingWebConnection = false; // see LibraryBrowser |
| 139 | |
| 140 | |
| 141 | protected static String downloadURL = ""; //$NON-NLS-1$ |
| 142 | /** |
| 143 | * A three-way toggele: |
| 144 | * |
nothing calls this directly
no test coverage detected