001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2003-2006, Geotools Project Managment Committee (PMC)
005: * (C) 2001, Institut de Recherche pour le Développement
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.resources.i18n;
018:
019: // J2SE dependencies
020: import java.util.Locale;
021: import java.util.MissingResourceException;
022: import java.util.logging.LogRecord;
023: import java.util.logging.Level;
024:
025: // Geotools dependencies
026: import org.geotools.resources.ResourceBundle;
027:
028: /**
029: * Base class for locale-dependent resources. Instances of this class should
030: * never been created directly. Use the factory method {@link #getResources}
031: * or use static convenience methods instead.
032: *
033: * @since 2.2
034: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/resources/i18n/Logging.java $
035: * @version $Id: Logging.java 22443 2006-10-27 20:47:22Z desruisseaux $
036: * @author Martin Desruisseaux
037: */
038: public class Logging extends ResourceBundle {
039: /**
040: * Returns resources in the given locale.
041: *
042: * @param locale The locale, or {@code null} for the default locale.
043: * @return Resources in the given locale.
044: * @throws MissingResourceException if resources can't be found.
045: */
046: public static Logging getResources(Locale locale)
047: throws MissingResourceException {
048: if (locale == null) {
049: locale = Locale.getDefault();
050: }
051: return (Logging) getBundle(Logging.class.getName(), locale);
052: /*
053: * We rely on cache capability of ResourceBundle.
054: */
055: }
056:
057: /**
058: * Gets a log record for the given key from this resource bundle or one of its parents.
059: *
060: * @param level The log record level.
061: * @param key The key for the desired string.
062: * @return The string for the given key.
063: * @throws MissingResourceException If no object for the given key can be found.
064: */
065: public static LogRecord format(final Level level, final int key)
066: throws MissingResourceException {
067: return getResources(null).getLogRecord(level, key);
068: }
069:
070: /**
071: * Gets a log record for the given key. Replaces all occurence of "{0}"
072: * with values of {@code arg0}.
073: *
074: * @param level The log record level.
075: * @param key The key for the desired string.
076: * @param arg0 Value to substitute to "{0}".
077: * @return The formatted string for the given key.
078: * @throws MissingResourceException If no object for the given key can be found.
079: */
080: public static LogRecord format(final Level level, final int key,
081: final Object arg0) throws MissingResourceException {
082: return getResources(null).getLogRecord(level, key, arg0);
083: }
084:
085: /**
086: * Gets a log record for the given key. Replaces all occurence of "{0}",
087: * "{1}", with values of {@code arg0}, {@code arg1}.
088: *
089: * @param level The log record level.
090: * @param key The key for the desired string.
091: * @param arg0 Value to substitute to "{0}".
092: * @param arg1 Value to substitute to "{1}".
093: * @return The formatted string for the given key.
094: * @throws MissingResourceException If no object for the given key can be found.
095: */
096: public static LogRecord format(final Level level, final int key,
097: final Object arg0, final Object arg1)
098: throws MissingResourceException {
099: return getResources(null).getLogRecord(level, key, arg0, arg1);
100: }
101:
102: /**
103: * Gets a log record for the given key. Replaces all occurence of "{0}",
104: * "{1}", with values of {@code arg0}, {@code arg1}, etc.
105: *
106: * @param level The log record level.
107: * @param key The key for the desired string.
108: * @param arg0 Value to substitute to "{0}".
109: * @param arg1 Value to substitute to "{1}".
110: * @param arg2 Value to substitute to "{2}".
111: * @return The formatted string for the given key.
112: * @throws MissingResourceException If no object for the given key can be found.
113: */
114: public static LogRecord format(final Level level, final int key,
115: final Object arg0, final Object arg1, final Object arg2)
116: throws MissingResourceException {
117: return getResources(null).getLogRecord(level, key, arg0, arg1,
118: arg2);
119: }
120:
121: /**
122: * Gets a log record for the given key. Replaces all occurence of "{0}",
123: * "{1}", with values of {@code arg0}, {@code arg1}, etc.
124: *
125: * @param level The log record level.
126: * @param key The key for the desired string.
127: * @param arg0 Value to substitute to "{0}".
128: * @param arg1 Value to substitute to "{1}".
129: * @param arg2 Value to substitute to "{2}".
130: * @param arg3 Value to substitute to "{3}".
131: * @return The formatted string for the given key.
132: * @throws MissingResourceException If no object for the given key can be found.
133: */
134: public static LogRecord format(final Level level, final int key,
135: final Object arg0, final Object arg1, final Object arg2,
136: final Object arg3) throws MissingResourceException {
137: return getResources(null).getLogRecord(level, key, arg0, arg1,
138: arg2, arg3);
139: }
140: }
|