/** Returns a string representation of this entry. */ @Override public String toString() { return Classes.getShortClassName(this) + "[key=" + key + ", value=" + value + ']'; } }
/** * Returns the interpolation name for the specified interpolation object. This method tries to * infer the name from the object's class name. * * @param Interpolation The interpolation object, or {@code null} for "nearest" (which is an * other way to say "no interpolation"). */ public static String getInterpolationName(Interpolation interp) { if (interp == null) { interp = Interpolation.getInstance(Interpolation.INTERP_NEAREST); } final String prefix = "Interpolation"; for (Class<?> classe = interp.getClass(); classe != null; classe = classe.getSuperclass()) { String name = Classes.getShortName(classe); int index = name.lastIndexOf(prefix); if (index >= 0) { return name.substring(index + prefix.length()); } } return Classes.getShortClassName(interp); }
/** * Returns a short class name for the specified object. This method will omit the package name. * For example, it will return "String" instead of "java.lang.String" for a {@link String} * object. * * @param object The object (may be {@code null}). * @return A short class name for the specified object. */ public static String getShortClassName(final Object object) { return getShortName(getClass(object)); } }
/** * Returns a string representation of this category. The returned string is implementation * dependent. It is usually provided for debugging purposes. */ @Override public String toString() { final StringBuilder buffer = new StringBuilder(Classes.getShortClassName(this)); buffer.append("(\"").append(name).append("\":["); if (Classes.isInteger(getRange().getElementClass())) { buffer.append(Math.round(minimum)) .append("...") .append(Math.round(maximum)); // Inclusive } else { buffer.append(minimum).append(" ... ").append(maximum); // Inclusive } return buffer.append("])").toString(); }
protected String typeName() { if (name == null) { return Classes.getShortName(binding); } return name; }
/** * Inverses the specified math transform. This method is invoked by constructors only. It wraps * {@link NoninvertibleTransformException} into {@link IllegalArgumentException}, since failures * to inverse a transform are caused by an illegal user-supplied transform. * * @throws IllegalArgumentException if the transform is non-invertible. */ private static MathTransform2D inverse(final MathTransform2D gridToCRS2D) throws IllegalArgumentException { if (gridToCRS2D == null) { return null; } else try { return gridToCRS2D.inverse(); } catch (NoninvertibleTransformException exception) { throw new IllegalArgumentException( Errors.format(ErrorKeys.BAD_TRANSFORM_$1, Classes.getClass(gridToCRS2D)), exception); } }
if (Classes.primitiveToWrapper(paramType).isInstance(argument)) { continue; // Argument is of the expected type: nothing to do. elementType = ((CheckedCollection) addTo).getElementType(); } else { Class<?> c = Classes.boundOfParameterizedAttribute(setter); if (c == null) { c = Classes.boundOfParameterizedAttribute(getter); if (c == null) { c = Object.class; parsed = Classes.valueOf(elementType, text); } catch (RuntimeException e) {
/** Formats the specified number. */ private String format(final Number value) { if (numberFormat == null) { numberFormat = NumberFormat.getNumberInstance(locale); numberFormat.setMinimumFractionDigits(0); } int precision = 0; if (!Classes.isInteger(value.getClass())) { precision = PRECISION; final double v = Math.abs(value.doubleValue()); if (v > 0) { final int digits = (int) Math.log10(v); if (Math.abs(digits) >= PRECISION) { // TODO: Switch to exponential notation when a convenient API will be available // in J2SE. return value.toString(); } if (digits >= 0) { precision -= digits; } precision = Math.max(0, PRECISION - precision); } } numberFormat.setMaximumFractionDigits(precision); return numberFormat.format(value); }
name = field.getName(); final Class<?> type = Classes.primitiveToWrapper(field.getType()); if (Number.class.isAssignableFrom(type)) { name = name + "=N";
/** * Compares two factories for order. This is used for sorting out the factories before to * display them. */ public int compare(final Class<?> factory1, final Class<?> factory2) { // Or sort by name return Classes.getShortName(factory1).compareToIgnoreCase(Classes.getShortName(factory2)); }
Errors.format(ErrorKeys.NOT_AN_ANGLE_OBJECT_$1, Classes.getClass(obj)));
if (lower != min || upper != max || !Classes.isInteger(category.getRange().getElementClass())) { throw new IllegalStateException( Errors.format(ErrorKeys.NON_INTEGER_CATEGORY));
return validValues != null && validValues.contains(value); final Class<?> type = Classes.primitiveToWrapper(value.getClass()); final Class<?> expected = Classes.primitiveToWrapper(descriptor.getValueClass()); if (expected.isAssignableFrom(type)) { return false; // value not of the correct type
/** * Returns a string representation of this grid geometry. The returned string is implementation * dependent. It is usually provided for debugging purposes. */ @Override public String toString() { return Classes.getShortClassName(this) + '[' + gridRange + ", " + gridToCRS + ']'; }
/** Returns a string representation of the specified object, for debugging purpose only. */ final String toString(final Class owner) { final AuthorityFactory factory = getAuthorityFactory(); return Classes.getShortName(owner) + '[' + Classes.getShortName(getType()) + " in " + Classes.getShortClassName(factory) + "(\"" + factory.getAuthority().getTitle() + "\")]"; }
/** * Format an error message saying that the specified factory is not yet supported. The error * message will be given to a {@link FactoryNotFoundException}. * * @param type The factory type requested by the users. */ private static String unsupportedFactory(final Class type) { return Errors.format(ErrorKeys.FACTORY_NOT_FOUND_$1, Classes.getShortName(type)); }
Errors.format( ErrorKeys.ILLEGAL_OPERATION_FOR_VALUE_CLASS_$1, Classes.getClass(value)); } else { @SuppressWarnings("unchecked") // Type checked in the above test case.
/** * Returns the name for the {@linkplain #getTransformation transformation} to be created by this * builder. */ public String getName() { return Classes.getShortClassName(this) + " fit"; }
/** Invoked when a factory can't be loaded. Log a warning, but do not stop the process. */ private static void loadingFailure( final Class<?> category, final Throwable error, final boolean showStackTrace) { final String name = Classes.getShortName(category); final StringBuilder cause = new StringBuilder(Classes.getShortClassName(error)); final String message = error.getLocalizedMessage(); if (message != null) { cause.append(": "); cause.append(message); } final LogRecord record = Loggings.format( Level.WARNING, LoggingKeys.CANT_LOAD_SERVICE_$2, name, cause.toString()); if (showStackTrace) { record.setThrown(error); } record.setSourceClassName(FactoryRegistry.class.getName()); record.setSourceMethodName("scanForPlugins"); record.setLoggerName(LOGGER.getName()); LOGGER.log(record); }
/** * Checks if the type is compatible with the expected one. This method is used as a safety by * {@code getFooAuthorityFactory(String)} methods in {@link URN_AuthorityFactory}. If a mismatch * is found, a warning is logged but no exception is thrown since it doesn't prevent the class * to work in a predictable way. It is just an indication for the user that his URN may be * wrong. */ final void logWarningIfTypeMismatch( AuthorityFactory authorityFactory, final Class<? extends AuthorityFactory> expected) { if (!expected.isAssignableFrom(type.type)) { // Build a simplified URN, omitting "urn:ogc:def" and version number. final LogRecord record = Loggings.format(Level.WARNING, LoggingKeys.MISMATCHED_URI_TYPE_$1, uri); // Set the source to the public or protected method. record.setSourceClassName(authorityFactory.getClass().getName()); record.setSourceMethodName("get" + Classes.getShortName(expected)); final Logger logger = AbstractAuthorityFactory.LOGGER; record.setLoggerName(logger.getName()); logger.log(record); } }