/** * Returns the error message to be given to {@link IllegalStateException} when there is no data. */ private static String noData() { return Resources.format(Resources.Keys.MissingValuesInLocalizationGrid); }
/** * Returns the warning to log, or {@code null} if none. The caller is responsible for setting the logger name, * source class name and source method name. * * @param fine {@code true} for including warnings at fine level, or {@code false} for only the warning level. * @return the warning to log, or {@code null} if none. */ public LogRecord warning(final boolean fine) { if (arguments != null) { if (resourceKey != 0) { return Resources.forLocale(null).getLogRecord(Level.WARNING, resourceKey, arguments); } else if (fine) { return new LogRecord(Level.FINE, (String) arguments[0]); } } return null; } }
/** * Creates a remarks for parameters that are not formally EPSG parameter. * * @param origin the name of the projection for where the parameter is formally used. * @return a remarks saying that the parameter is actually defined in {@code origin}. */ static InternationalString notFormalParameter(final String origin) { return Resources.formatInternational(Resources.Keys.NotFormalProjectionParameter_1, origin); } }
/** * Returns resources in the locale specified in the given property map. This convenience method looks * for the {@link #LOCALE_KEY} entry. If the given map is null, or contains no entry for the locale key, * or the value is not an instance of {@link Locale}, then this method fallback on the default locale. * * @param properties the map of properties, or {@code null} if none. * @return resources in the given locale. * @throws MissingResourceException if resources can't be found. */ public static Resources forProperties(final Map<?,?> properties) throws MissingResourceException { return forLocale(getLocale(properties)); }
throw new IllegalArgumentException(Resources.forProperties(properties) .getString(Resources.Keys.DuplicatedSpatialComponents_1, type)); throw new IllegalArgumentException(Resources.forProperties(properties) .getString(Resources.Keys.EllipsoidalHeightNotAllowed_1, isProjected));
@Override protected IndexedResourceBundle getBundle(final Locale locale) { return forLocale(locale); } }
/** * Creates an exception for an unknown authority code. * This convenience method is provided for implementation of {@code createFoo(String)} methods. * * @param type the GeoAPI interface that was to be created (e.g. {@code CoordinateReferenceSystem.class}). * @param code the unknown authority code. * @return an exception initialized with an error message built from the specified informations. */ private NoSuchAuthorityCodeException noSuchAuthorityCode(final Class<?> type, final String code) { return new NoSuchAuthorityCodeException(resources().getString(Resources.Keys.NoSuchAuthorityCode_3, Constants.EPSG, type, code), Constants.EPSG, code, code); }
/** * Returns resources in the given locale. * * @param locale the locale, or {@code null} for the default locale. * @return resources in the given locale. * @throws MissingResourceException if resources can't be found. */ public static Resources forLocale(final Locale locale) throws MissingResourceException { return getBundle(Resources.class, locale); }
/** * Returns an error message for the error detected by * {@link #ensureValidValue(Class, Set, Range, Object)}. * * @param name the parameter name. * @param value the user-supplied value (not necessarily equals to the converted value). */ String message(final Map<?,?> properties, String name, Object value) { final Object index = arguments[0]; if (index != null) { name = name + '[' + index + ']'; value = Array.get(value, (Integer) index); } arguments[0] = name; if (needsValue) { arguments[arguments.length - 1] = value; } return (internal ? Resources.forProperties(properties) : Errors.getResources(properties)).getString(errorKey, arguments); }
final LogRecord record = resources().getLogRecord(Level.WARNING, Resources.Keys.AmbiguousEllipsoid_1, Constants.EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + code); record.setLoggerName(Loggers.CRS_FACTORY);
throw new IllegalArgumentException(Resources.forProperties(properties) .getString(Resources.Keys.DuplicatedSpatialComponents_1, type)); throw new IllegalArgumentException(Resources.forProperties(properties) .getString(Resources.Keys.EllipsoidalHeightNotAllowed_1, isProjected));
/** * Returns a human-readable text for this constant. * * @param locale the desired locale, or {@code null}. * @return a human-readable text in the given locale if possible. */ @Override public String toString(final Locale locale) { return Resources.forLocale(locale).getString(opposite ? Resources.Keys.InverseOperationUsesOppositeSign : Resources.Keys.InverseOperationUsesSameSign); }
/** * Returns resources in the locale specified in the given property map. This convenience method looks * for the {@link #LOCALE_KEY} entry. If the given map is null, or contains no entry for the locale key, * or the value is not an instance of {@link Locale}, then this method fallback on the default locale. * * @param properties the map of properties, or {@code null} if none. * @return resources in the given locale. * @throws MissingResourceException if resources can't be found. */ public static Resources forProperties(final Map<?,?> properties) throws MissingResourceException { return forLocale(getLocale(properties)); }
@Override protected IndexedResourceBundle getBundle(final Locale locale) { return forLocale(locale); } }
/** * Creates an exception for an unknown authority code. * This convenience method is provided for implementation of {@code createFoo(String)} methods. * * @param type the GeoAPI interface that was to be created (e.g. {@code CoordinateReferenceSystem.class}). * @param code the unknown authority code. * @return an exception initialized with an error message built from the specified information. */ private NoSuchAuthorityCodeException noSuchAuthorityCode(final Class<?> type, final String code) { return new NoSuchAuthorityCodeException(resources().getString(Resources.Keys.NoSuchAuthorityCode_3, Constants.EPSG, type, code), Constants.EPSG, code, code); }
/** * Returns resources in the given locale. * * @param locale the locale, or {@code null} for the default locale. * @return resources in the given locale. * @throws MissingResourceException if resources can't be found. */ public static Resources forLocale(final Locale locale) throws MissingResourceException { return getBundle(Resources.class, locale); }
/** * Returns an error message for the error detected by * {@link #ensureValidValue(Class, Set, Range, Object)}. * * @param name the parameter name. * @param value the user-supplied value (not necessarily equals to the converted value). */ String message(final Map<?,?> properties, String name, Object value) { final Object index = arguments[0]; if (index != null) { name = name + '[' + index + ']'; value = Array.get(value, (Integer) index); } arguments[0] = name; if (needsValue) { arguments[arguments.length - 1] = value; } return (internal ? Resources.forProperties(properties) : Errors.getResources(properties)).getString(errorKey, arguments); }
final LogRecord record = resources().getLogRecord(Level.WARNING, Resources.Keys.AmbiguousEllipsoid_1, Constants.EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + code); record.setLoggerName(Loggers.CRS_FACTORY);
/** * Throws an exception for mismatched descriptor if a condition is false. * This is used for verifying that a descriptors has the expected properties. */ private static void verifyEquivalence(final String name, final boolean condition) { if (!condition) { throw new IllegalArgumentException(Resources.format(Resources.Keys.MismatchedParameterDescriptor_1, name)); } } }