/** * Returns the URL to the property file that contains CRS definitions. The default implementation * performs the following search path: * * <ul> * <li>If a value is set for the {@value #CRS_DIRECTORY_KEY} system property key, then the * {@value #FILENAME} file will be searched in this directory. * <li>If no value is set for the above-cited system property, or if no {@value #FILENAME} file * was found in that directory, then the first {@value #FILENAME} file found in any {@code * org/geotools/referencing/factory/epsg} directory on the classpath will be used. * <li>If no file was found on the classpath neither, then this factory will be disabled. * </ul> * * @return The URL, or {@code null} if none. */ protected URL getDefinitionsURL() { try { if (directory != null) { final File file = new File(directory, FILENAME); if (file.isFile()) { return file.toURI().toURL(); } } } catch (SecurityException exception) { Logging.unexpectedException(LOGGER, exception); } catch (MalformedURLException exception) { Logging.unexpectedException(LOGGER, exception); } return FactoryUsingWKT.class.getResource(FILENAME); }
/** * Implementation of {@code fixName} method. If the context is {@code null}, then the {@linkplain * #getInitialContext GeoTools initial context} will be fetch only when first needed. */ private static String fixName(Context context, final String name, final Hints hints) { String fixed = null; if (name != null) { final StringTokenizer tokens = new StringTokenizer(name, ":/"); while (tokens.hasMoreTokens()) { final String part = tokens.nextToken(); if (fixed == null) { fixed = part; } else try { if (context == null) { context = getInitialContext(hints); } fixed = context.composeName(fixed, part); } catch (NamingException e) { Logging.unexpectedException(GeoTools.class, "fixName", e); return name; } } } return fixed; }
/** * Logs an exception as if it originated from {@link Hints#scanSystemProperties}, since it is the * public API that may invokes this method. */ private static void unexpectedException(final Exception exception) { Logging.unexpectedException(Hints.class, "scanSystemProperties", exception); }