/** * Convenience method for logging a warning. Do not allow overriding, because * it would not work for warnings emitted by the {@link #getDate} method. */ final void warning(final String method, final int key, final Object value) { if (warningsEnabled) { final LogRecord record = Errors.getResources(metadata.getLocale()). getLogRecord(Level.WARNING, key, value); record.setSourceClassName(MetadataAccessor.class.getName()); record.setSourceMethodName(method); warningOccurred(record); } }
return resources.getLogRecord(level, ErrorKeys.UNEXPECTED_END_OF_STRING); text = text.substring(index); if (level != null) { return resources.getLogRecord(level, ErrorKeys.UNPARSABLE_STRING_$2, text, error);
/** * Logs a warning. * * @param key The resource key. * @param arg1 First value to format in the message. * @param arg1 Second value to format in the message. */ private void logWarning(final int key, final Object arg1, final Object arg2) { final LogRecord warning = Errors.getResources(getWarningLocale()) .getLogRecord(Level.WARNING, key, arg1, arg2); if (className != null) { warning.setSourceClassName(className); } if (methodName != null) { warning.setSourceMethodName(methodName); } logWarning(warning); }
/** * Logs a warning. * * @param key The resource key. * @param arg1 First value to format in the message. * @param arg1 Second value to format in the message. */ private void logWarning(final int key, final Object arg1, final Object arg2) { final LogRecord warning = Errors.getResources(getWarningLocale()) .getLogRecord(Level.WARNING, key, arg1, arg2); if (className != null) { warning.setSourceClassName(className); } if (methodName != null) { warning.setSourceMethodName(methodName); } logWarning(warning); }
/** * Parses the specified string. If the string can't be parsed, then this method returns * {@code null}. If it can be parsed at least partially and is of the kind specified at * construction time, then it is returned. If the string has not been fully parsed, then * a {@linkplain LogRecord log record} is prepared and logged. * * @param text The text to parse, or {@code null}. * @return The parsed object, or {@code null} if {@code text} was null or can't be parsed. */ public T parse(String text) { if (text == null || (text=text.trim()).length() == 0) { return null; } final ParsePosition position = new ParsePosition(0); final Object value = parseObject(text, position); int index = position.getIndex(); final int error = position.getErrorIndex(); if (error >= 0 && error < index) { index = error; } if (index < text.length()) { doLogWarning(formatUnparsable(text, 0, index, getWarningLocale(), level)); } else if (value!=null && !type.isInstance(value)) { doLogWarning(Errors.getResources(getWarningLocale()).getLogRecord(level, ErrorKeys.ILLEGAL_CLASS_$2, value.getClass(), type)); return null; } return type.cast(value); }