You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by de...@apache.org on 2007/01/06 17:49:25 UTC
svn commit: r493507 [1/2] - in /jakarta/commons/sandbox/i18n/trunk:
src/examples/ src/examples/org/apache/i18n/examples/
src/java/org/apache/commons/i18n/ src/java/org/apache/commons/i18n/bundles/
src/resources/ src/test/ src/test/org/apache/commons/i1...
Author: dennisl
Date: Sat Jan 6 08:49:24 2007
New Revision: 493507
URL: http://svn.apache.org/viewvc?view=rev&rev=493507
Log:
Set EOL-style to native.
Modified:
jakarta/commons/sandbox/i18n/trunk/src/examples/i18n-jdbc.properties (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/examples/org/apache/i18n/examples/QualifiedJdbcExample.java (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/I18nUtils.java (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/JdbcMessageProvider.java (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedRuntimeException.java (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/ErrorBundle.java (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/MessageBundle.java (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/TextBundle.java (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages.properties (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages_de.properties (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle.properties (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle2.properties (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle_de.properties (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/I18nUtilsTest.java (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/JdbcMessageProviderTest.java (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/test/testMessages.xml (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/src/test/variantTestMessages.xml (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/xdocs/changes.xml (contents, props changed)
jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml (contents, props changed)
Modified: jakarta/commons/sandbox/i18n/trunk/src/examples/i18n-jdbc.properties
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/examples/i18n-jdbc.properties?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/examples/i18n-jdbc.properties (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/examples/i18n-jdbc.properties Sat Jan 6 08:49:24 2007
@@ -1,7 +1,7 @@
-jdbc.connect.driver=org.hsqldb.jdbcDriver
-jdbc.connect.url=jdbc:hsqldb:.
-jdbc.connect.login=sa
-jdbc.connect.password=
-jdbc.sql.table=messages
-jdbc.sql.locale.column=language
+jdbc.connect.driver=org.hsqldb.jdbcDriver
+jdbc.connect.url=jdbc:hsqldb:.
+jdbc.connect.login=sa
+jdbc.connect.password=
+jdbc.sql.table=messages
+jdbc.sql.locale.column=language
jdbc.sql.key.column=id
Propchange: jakarta/commons/sandbox/i18n/trunk/src/examples/i18n-jdbc.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/examples/org/apache/i18n/examples/QualifiedJdbcExample.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/examples/org/apache/i18n/examples/QualifiedJdbcExample.java?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/examples/org/apache/i18n/examples/QualifiedJdbcExample.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/examples/org/apache/i18n/examples/QualifiedJdbcExample.java Sat Jan 6 08:49:24 2007
@@ -1,152 +1,152 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.i18n.examples;
-
-import org.apache.commons.i18n.MessageManager;
-import org.apache.commons.i18n.JdbcMessageProvider;
-import org.apache.commons.i18n.LocalizedRuntimeException;
-import org.apache.commons.i18n.bundles.TextBundle;
-import org.apache.commons.i18n.bundles.ErrorBundle;
-
-import java.sql.Connection;
-import java.sql.Statement;
-import java.sql.SQLException;
-import java.sql.DriverManager;
-import java.util.Locale;
-import java.util.Properties;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
-/**
- * This example shows
- * a) how to use qualified message providers, instead of searching through all available providers.
- * b) how to use i18n for messages stored in databases. For the sake of the example, we will create
- * an in memory database holding the i18n messages using HSQLDB.
- * @author Mattias Jiderhamn
- * @see <a href="http://hsqldb.org/">HSQLDB</a>
- */
-public class QualifiedJdbcExample {
- public static void main(String[] args) throws Exception {
- /////////////////////////////////////////////////////
- // Prepare example
- /////////////////////////////////////////////////////
-
- // Set up in-memory data for the sake of the example
- prepareTables();
-
- /////////////////////////////////////////////////////
- // Example of initialization
- /////////////////////////////////////////////////////
-
- // We can initialize JDBC message provider using a properties file
- Properties props = new Properties();
- props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("i18n-jdbc.properties"));
- MessageManager.addMessageProvider("messages", new JdbcMessageProvider(props));
-
- // We can also initialize JDBC message provider by providing connection (or DataSource)
- Connection conn = getNewConnection();
- MessageManager.addMessageProvider("errors", new JdbcMessageProvider(conn, "errors", "id", "language"));
- conn.close();
-
- /////////////////////////////////////////////////////
- // Example of usage
- /////////////////////////////////////////////////////
-
- // Simulate the locale of the current user in a multi-user environment
- // such as a web application
- Locale currentUsersLocale = new Locale("sv"); // Assume Swedish
-
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
-
- // Get i18n text qualifying the message source (i.e. the MessageProvider) to use; messages
- TextBundle textBundle = new TextBundle("messages", "enterFirstName");
- System.out.println(textBundle.getText(currentUsersLocale) + ":");
- String firstName = reader.readLine();
-
- textBundle = new TextBundle("messages", "enterLastName");
- System.out.println(textBundle.getText(currentUsersLocale) + ":");
- String lastName = reader.readLine();
-
- validateNames(firstName, lastName);
- }
- catch(LocalizedRuntimeException lrex) {
- // Retrieve the detailed localized error message
- ErrorBundle errorMessage = lrex.getErrorMessage();
-
- // Print summary and details using the current users locale
- System.out.println("-- " + errorMessage.getSummary(currentUsersLocale) + " --");
- System.out.println(errorMessage.getDetails(currentUsersLocale));
- }
- }
-
- private static void validateNames(String firstname, String lastname) {
- if(firstname.equals(lastname))
- throw new LocalizedRuntimeException(new ErrorBundle("errors", "identicalNames"));
- }
-
- ///////////////////////////////////////////////////////////////////////
- // Utility methods for the example
- ///////////////////////////////////////////////////////////////////////
-
- /**
- * Create connection to in-memory HSQLDB database
- * @return
- * @throws ClassNotFoundException
- * @throws SQLException
- */
- private static Connection getNewConnection() throws ClassNotFoundException, SQLException {
- Class.forName("org.hsqldb.jdbcDriver"); // Load HSQLDB database driver
- return DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
- }
-
- /**
- * Create tables and insert messages
- */
- private static void prepareTables() throws ClassNotFoundException, SQLException {
- Connection conn = getNewConnection();
- Statement stmt = conn.createStatement();
- stmt.execute(
- "CREATE TABLE messages ( " +
- " 'id' VARCHAR(30), " +
- " 'language' VARCHAR(2), " +
- " 'text' VARCHAR(100)" +
- ")");
- stmt.execute("INSERT INTO messages VALUES ('enterFirstName', 'en', 'Please enter your first name')");
- stmt.execute("INSERT INTO messages VALUES ('enterLastName', 'en', 'Please enter your last name')");
- stmt.execute("INSERT INTO messages VALUES ('enterFirstName', 'sv', 'Vänligen ange ditt förnamn')");
- stmt.execute("INSERT INTO messages VALUES ('enterLastName', 'sv', 'Vänligen ange ditt efternamn')");
- stmt.execute(
- "CREATE TABLE errors ( " +
- " 'id' VARCHAR(30), " +
- " 'language' VARCHAR(2), " +
- " 'summary' VARCHAR(100), " +
- " 'details' VARCHAR(100) " +
- ")");
- stmt.execute("INSERT INTO errors VALUES (" +
- " 'identicalNames', 'en', " +
- " 'Error! Identical names.', 'You entered the same name as both first name and last name'" +
- ")");
- stmt.execute("INSERT INTO errors VALUES (" +
- " 'identicalNames', 'sv', " +
- " 'Fel! Identiska namn.', 'Du angav samma namn som både förnamn och efternamn'" +
- ")");
- stmt.close();
- conn.close();
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.i18n.examples;
+
+import org.apache.commons.i18n.MessageManager;
+import org.apache.commons.i18n.JdbcMessageProvider;
+import org.apache.commons.i18n.LocalizedRuntimeException;
+import org.apache.commons.i18n.bundles.TextBundle;
+import org.apache.commons.i18n.bundles.ErrorBundle;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.SQLException;
+import java.sql.DriverManager;
+import java.util.Locale;
+import java.util.Properties;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * This example shows
+ * a) how to use qualified message providers, instead of searching through all available providers.
+ * b) how to use i18n for messages stored in databases. For the sake of the example, we will create
+ * an in memory database holding the i18n messages using HSQLDB.
+ * @author Mattias Jiderhamn
+ * @see <a href="http://hsqldb.org/">HSQLDB</a>
+ */
+public class QualifiedJdbcExample {
+ public static void main(String[] args) throws Exception {
+ /////////////////////////////////////////////////////
+ // Prepare example
+ /////////////////////////////////////////////////////
+
+ // Set up in-memory data for the sake of the example
+ prepareTables();
+
+ /////////////////////////////////////////////////////
+ // Example of initialization
+ /////////////////////////////////////////////////////
+
+ // We can initialize JDBC message provider using a properties file
+ Properties props = new Properties();
+ props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("i18n-jdbc.properties"));
+ MessageManager.addMessageProvider("messages", new JdbcMessageProvider(props));
+
+ // We can also initialize JDBC message provider by providing connection (or DataSource)
+ Connection conn = getNewConnection();
+ MessageManager.addMessageProvider("errors", new JdbcMessageProvider(conn, "errors", "id", "language"));
+ conn.close();
+
+ /////////////////////////////////////////////////////
+ // Example of usage
+ /////////////////////////////////////////////////////
+
+ // Simulate the locale of the current user in a multi-user environment
+ // such as a web application
+ Locale currentUsersLocale = new Locale("sv"); // Assume Swedish
+
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
+
+ // Get i18n text qualifying the message source (i.e. the MessageProvider) to use; messages
+ TextBundle textBundle = new TextBundle("messages", "enterFirstName");
+ System.out.println(textBundle.getText(currentUsersLocale) + ":");
+ String firstName = reader.readLine();
+
+ textBundle = new TextBundle("messages", "enterLastName");
+ System.out.println(textBundle.getText(currentUsersLocale) + ":");
+ String lastName = reader.readLine();
+
+ validateNames(firstName, lastName);
+ }
+ catch(LocalizedRuntimeException lrex) {
+ // Retrieve the detailed localized error message
+ ErrorBundle errorMessage = lrex.getErrorMessage();
+
+ // Print summary and details using the current users locale
+ System.out.println("-- " + errorMessage.getSummary(currentUsersLocale) + " --");
+ System.out.println(errorMessage.getDetails(currentUsersLocale));
+ }
+ }
+
+ private static void validateNames(String firstname, String lastname) {
+ if(firstname.equals(lastname))
+ throw new LocalizedRuntimeException(new ErrorBundle("errors", "identicalNames"));
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // Utility methods for the example
+ ///////////////////////////////////////////////////////////////////////
+
+ /**
+ * Create connection to in-memory HSQLDB database
+ * @return
+ * @throws ClassNotFoundException
+ * @throws SQLException
+ */
+ private static Connection getNewConnection() throws ClassNotFoundException, SQLException {
+ Class.forName("org.hsqldb.jdbcDriver"); // Load HSQLDB database driver
+ return DriverManager.getConnection("jdbc:hsqldb:.", "sa", ""); // Connect to in-memory database
+ }
+
+ /**
+ * Create tables and insert messages
+ */
+ private static void prepareTables() throws ClassNotFoundException, SQLException {
+ Connection conn = getNewConnection();
+ Statement stmt = conn.createStatement();
+ stmt.execute(
+ "CREATE TABLE messages ( " +
+ " 'id' VARCHAR(30), " +
+ " 'language' VARCHAR(2), " +
+ " 'text' VARCHAR(100)" +
+ ")");
+ stmt.execute("INSERT INTO messages VALUES ('enterFirstName', 'en', 'Please enter your first name')");
+ stmt.execute("INSERT INTO messages VALUES ('enterLastName', 'en', 'Please enter your last name')");
+ stmt.execute("INSERT INTO messages VALUES ('enterFirstName', 'sv', 'Vänligen ange ditt förnamn')");
+ stmt.execute("INSERT INTO messages VALUES ('enterLastName', 'sv', 'Vänligen ange ditt efternamn')");
+ stmt.execute(
+ "CREATE TABLE errors ( " +
+ " 'id' VARCHAR(30), " +
+ " 'language' VARCHAR(2), " +
+ " 'summary' VARCHAR(100), " +
+ " 'details' VARCHAR(100) " +
+ ")");
+ stmt.execute("INSERT INTO errors VALUES (" +
+ " 'identicalNames', 'en', " +
+ " 'Error! Identical names.', 'You entered the same name as both first name and last name'" +
+ ")");
+ stmt.execute("INSERT INTO errors VALUES (" +
+ " 'identicalNames', 'sv', " +
+ " 'Fel! Identiska namn.', 'Du angav samma namn som både förnamn och efternamn'" +
+ ")");
+ stmt.close();
+ conn.close();
+ }
+}
Propchange: jakarta/commons/sandbox/i18n/trunk/src/examples/org/apache/i18n/examples/QualifiedJdbcExample.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/I18nUtils.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/I18nUtils.java?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/I18nUtils.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/I18nUtils.java Sat Jan 6 08:49:24 2007
@@ -1,48 +1,48 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.i18n;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-/**
- * This class holds utility methods useful when working with i18n.
- * @author Mattias Jiderhamn
- */
-public class I18nUtils {
-
- static final String INTERNAL_MESSAGE_NOT_FOUND = "Internal I18n error: Message not found";
- static final String MESSAGE_NOT_FOUND = "messageNotFound";
- static final String NO_MESSAGE_ENTRIES_FOUND = "noMessageEntriesFound";
- static final String MESSAGE_ENTRY_NOT_FOUND = "messageEntryNotFound";
- static final String RESOURCE_BUNDLE_NOT_FOUND = "resourceBundleNotFound";
- public static final String MESSAGE_PARSING_ERROR = "messageParsingError";
-
- public static final ResourceBundle INTERNAL_MESSAGES = ResourceBundle.getBundle("i18n-messages", Locale.getDefault());
-
- private I18nUtils() {
- }
-
- public static Locale getParentLocale (Locale locale) {
- if(locale.getVariant().length() != 0)
- return new Locale(locale.getLanguage(), locale.getCountry());
- else if(locale.getCountry().length() != 0)
- return new Locale(locale.getLanguage());
- else // Locale with only language have no parent
- return null;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.i18n;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * This class holds utility methods useful when working with i18n.
+ * @author Mattias Jiderhamn
+ */
+public class I18nUtils {
+
+ static final String INTERNAL_MESSAGE_NOT_FOUND = "Internal I18n error: Message not found";
+ static final String MESSAGE_NOT_FOUND = "messageNotFound";
+ static final String NO_MESSAGE_ENTRIES_FOUND = "noMessageEntriesFound";
+ static final String MESSAGE_ENTRY_NOT_FOUND = "messageEntryNotFound";
+ static final String RESOURCE_BUNDLE_NOT_FOUND = "resourceBundleNotFound";
+ public static final String MESSAGE_PARSING_ERROR = "messageParsingError";
+
+ public static final ResourceBundle INTERNAL_MESSAGES = ResourceBundle.getBundle("i18n-messages", Locale.getDefault());
+
+ private I18nUtils() {
+ }
+
+ public static Locale getParentLocale (Locale locale) {
+ if(locale.getVariant().length() != 0)
+ return new Locale(locale.getLanguage(), locale.getCountry());
+ else if(locale.getCountry().length() != 0)
+ return new Locale(locale.getLanguage());
+ else // Locale with only language have no parent
+ return null;
+ }
+}
Propchange: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/I18nUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/JdbcMessageProvider.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/JdbcMessageProvider.java?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/JdbcMessageProvider.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/JdbcMessageProvider.java Sat Jan 6 08:49:24 2007
@@ -1,183 +1,183 @@
-package org.apache.commons.i18n;
-
-import javax.sql.DataSource;
-import java.util.*;
-import java.sql.*;
-
-/**
- * @author Mattias Jiderhamn
- */
-public class JdbcMessageProvider implements MessageProvider {
- /**
- * This Map has locale or language as key, and a Map with the different
- * messages as value.
- */
- private final Map locales = new HashMap();
-
- private String idColumn;
-
- private String languageColumn;
-
- public JdbcMessageProvider(Connection conn, String table, String idColumn, String languageColumn)
- throws SQLException {
- this.idColumn = idColumn;
- this.languageColumn = languageColumn;
- init(conn, table);
- }
-
- public JdbcMessageProvider(DataSource ds, String table, String idColumn, String languageColumn)
- throws SQLException {
- this.idColumn = idColumn;
- this.languageColumn = languageColumn;
- Connection conn = null;
- try {
- conn = ds.getConnection();
- init(conn, table);
- }
- finally {
- if(conn != null)
- conn.close();
- }
- }
-
- /**
- * Create JDBC MessageProvider from properties in a Map, such
- * as a java.util.Properties object. The following are the properties in use, which
- * are the same as for JDBCResources of Jakarta Commons Resources
- * jdbc.connect.driver = org.gjt.mm.mysql.Driver
- * jdbc.connect.url = jdbc:mysql://localhost/resources
- * jdbc.connect.login = resourcesTest
- * jdbc.connect.password = resourcesTest
- *
- * jdbc.sql.table = resources
- * jdbc.sql.locale.column = locale
- * jdbc.sql.key.column = msgKey
- */
- public JdbcMessageProvider(Map properties) throws ClassNotFoundException, SQLException {
- String driver = (String)properties.get("jdbc.connect.driver");
- String url = (String)properties.get("jdbc.connect.url");
- String user = (String)properties.get("jdbc.connect.login");
- String pass = (String)properties.get("jdbc.connect.password");
-
- String table = (String)properties.get("jdbc.sql.table");
- this.idColumn = (String)properties.get("jdbc.sql.key.column");
- this.languageColumn = (String)properties.get("jdbc.sql.locale.column");
-
- Class.forName(driver);
- Connection conn = null;
- try {
- conn = DriverManager.getConnection(url, user, pass);
- init(conn, table);
- }
- finally {
- if(conn != null)
- conn.close();
- }
- }
-
- ///////////////////////////////////////////////////////////////////////
- // Methods for initialization
- ///////////////////////////////////////////////////////////////////////
-
- private void init(Connection conn, String table) throws SQLException {
- Statement stmt = null;
- ResultSet rs = null;
- try {
- stmt = conn.createStatement();
- rs = stmt.executeQuery("SELECT * FROM " + table);
- String[] valueColumns = getValueColumns(rs);
- while(rs.next()) {
- String id = rs.getString(idColumn);
- Locale locale = getLocale(rs);
- Map entries = new HashMap();
- for(int i = 0; i < valueColumns.length; i++) {
- entries.put(valueColumns[i], rs.getString(valueColumns[i]));
- }
- Map localeMap = (Map)locales.get(locale);
- if(localeMap == null) { // If first record for this Locale
- localeMap = new HashMap();
- locales.put(locale, localeMap);
- }
- localeMap.put(id, entries);
- }
- }
- finally {
- if(stmt != null)
- stmt.close();
- if(rs != null)
- rs.close();
- }
- }
-
- /**
- * Get a String of all the column names, except the ID column and the
- * language column.
- * @param rs A <code>ResultSet</code> ready for reading meta data.
- * @return A String array with the text value column names.
- * @throws SQLException If an SQL error occurs.
- */
- protected String[] getValueColumns(ResultSet rs) throws SQLException {
- List output = new LinkedList();
- ResultSetMetaData metadata = rs.getMetaData();
- int count = metadata.getColumnCount();
- for(int i = 0; i < count; i++) {
- String columnName = metadata.getColumnName(i+1); // (Count from 1)
- if(! idColumn.equals(columnName) && ! languageColumn.equals(columnName) )
- output.add(columnName);
- }
- return (String[])output.toArray(new String[0]);
- }
-
- /**
- * Get <code>Locale</code> for the current record in the ResultSet. May be overridden
- * by subclasses to allow for proprietary interpretation of language data.
- * The default implementation assumes the column with the name provided as languageColumn
- * for the constructor contains the ISO-639 code.
- * @return The <code>Locale</code> of the current <code>ResultSet</code> record.
- */
- protected Locale getLocale(ResultSet rs) throws SQLException {
- return new Locale(rs.getString(languageColumn).toLowerCase());
- }
-
- ///////////////////////////////////////////////////////////////////////
- // Methods to implement MessageProvider
- ///////////////////////////////////////////////////////////////////////
-
- public String getText(String id, String entry, Locale locale) {
- // TODO: Add Logging
- Map entries = getEntries(id, locale);
- if(entries != null) {
- // TODO: Consider whether we need to recurse up if entries does not contain requested entry
- return (String)entries.get(entry);
- }
- else
- return null;
- }
-
- public Map getEntries(String id, Locale locale) {
- Map entries = findEntriesRecursively(id,locale);
- if(entries == null) // If not found by using specified locale, try to use default
- entries = findEntriesRecursively(id,Locale.getDefault());
- return entries;
- }
-
- /**
- * Find entries by looking at the parent locale (language, country, variant ->
- * language, country -> language) until entry is found. If entry not found for topmost
- * Locale (language only), null is returned.
- */
- private Map findEntriesRecursively(String id, Locale locale) {
- Map localeIds = (Map)locales.get(locale);
- if(localeIds != null) {
- Map entries = (Map)localeIds.get(id);
- if(entries != null)
- return entries;
- }
- Locale parentLocale = I18nUtils.getParentLocale(locale);
- if(parentLocale == null)
- return null;
- else
- return findEntriesRecursively(id, parentLocale); // Recursive call
- }
-
-}
+package org.apache.commons.i18n;
+
+import javax.sql.DataSource;
+import java.util.*;
+import java.sql.*;
+
+/**
+ * @author Mattias Jiderhamn
+ */
+public class JdbcMessageProvider implements MessageProvider {
+ /**
+ * This Map has locale or language as key, and a Map with the different
+ * messages as value.
+ */
+ private final Map locales = new HashMap();
+
+ private String idColumn;
+
+ private String languageColumn;
+
+ public JdbcMessageProvider(Connection conn, String table, String idColumn, String languageColumn)
+ throws SQLException {
+ this.idColumn = idColumn;
+ this.languageColumn = languageColumn;
+ init(conn, table);
+ }
+
+ public JdbcMessageProvider(DataSource ds, String table, String idColumn, String languageColumn)
+ throws SQLException {
+ this.idColumn = idColumn;
+ this.languageColumn = languageColumn;
+ Connection conn = null;
+ try {
+ conn = ds.getConnection();
+ init(conn, table);
+ }
+ finally {
+ if(conn != null)
+ conn.close();
+ }
+ }
+
+ /**
+ * Create JDBC MessageProvider from properties in a Map, such
+ * as a java.util.Properties object. The following are the properties in use, which
+ * are the same as for JDBCResources of Jakarta Commons Resources
+ * jdbc.connect.driver = org.gjt.mm.mysql.Driver
+ * jdbc.connect.url = jdbc:mysql://localhost/resources
+ * jdbc.connect.login = resourcesTest
+ * jdbc.connect.password = resourcesTest
+ *
+ * jdbc.sql.table = resources
+ * jdbc.sql.locale.column = locale
+ * jdbc.sql.key.column = msgKey
+ */
+ public JdbcMessageProvider(Map properties) throws ClassNotFoundException, SQLException {
+ String driver = (String)properties.get("jdbc.connect.driver");
+ String url = (String)properties.get("jdbc.connect.url");
+ String user = (String)properties.get("jdbc.connect.login");
+ String pass = (String)properties.get("jdbc.connect.password");
+
+ String table = (String)properties.get("jdbc.sql.table");
+ this.idColumn = (String)properties.get("jdbc.sql.key.column");
+ this.languageColumn = (String)properties.get("jdbc.sql.locale.column");
+
+ Class.forName(driver);
+ Connection conn = null;
+ try {
+ conn = DriverManager.getConnection(url, user, pass);
+ init(conn, table);
+ }
+ finally {
+ if(conn != null)
+ conn.close();
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // Methods for initialization
+ ///////////////////////////////////////////////////////////////////////
+
+ private void init(Connection conn, String table) throws SQLException {
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("SELECT * FROM " + table);
+ String[] valueColumns = getValueColumns(rs);
+ while(rs.next()) {
+ String id = rs.getString(idColumn);
+ Locale locale = getLocale(rs);
+ Map entries = new HashMap();
+ for(int i = 0; i < valueColumns.length; i++) {
+ entries.put(valueColumns[i], rs.getString(valueColumns[i]));
+ }
+ Map localeMap = (Map)locales.get(locale);
+ if(localeMap == null) { // If first record for this Locale
+ localeMap = new HashMap();
+ locales.put(locale, localeMap);
+ }
+ localeMap.put(id, entries);
+ }
+ }
+ finally {
+ if(stmt != null)
+ stmt.close();
+ if(rs != null)
+ rs.close();
+ }
+ }
+
+ /**
+ * Get a String of all the column names, except the ID column and the
+ * language column.
+ * @param rs A <code>ResultSet</code> ready for reading meta data.
+ * @return A String array with the text value column names.
+ * @throws SQLException If an SQL error occurs.
+ */
+ protected String[] getValueColumns(ResultSet rs) throws SQLException {
+ List output = new LinkedList();
+ ResultSetMetaData metadata = rs.getMetaData();
+ int count = metadata.getColumnCount();
+ for(int i = 0; i < count; i++) {
+ String columnName = metadata.getColumnName(i+1); // (Count from 1)
+ if(! idColumn.equals(columnName) && ! languageColumn.equals(columnName) )
+ output.add(columnName);
+ }
+ return (String[])output.toArray(new String[0]);
+ }
+
+ /**
+ * Get <code>Locale</code> for the current record in the ResultSet. May be overridden
+ * by subclasses to allow for proprietary interpretation of language data.
+ * The default implementation assumes the column with the name provided as languageColumn
+ * for the constructor contains the ISO-639 code.
+ * @return The <code>Locale</code> of the current <code>ResultSet</code> record.
+ */
+ protected Locale getLocale(ResultSet rs) throws SQLException {
+ return new Locale(rs.getString(languageColumn).toLowerCase());
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // Methods to implement MessageProvider
+ ///////////////////////////////////////////////////////////////////////
+
+ public String getText(String id, String entry, Locale locale) {
+ // TODO: Add Logging
+ Map entries = getEntries(id, locale);
+ if(entries != null) {
+ // TODO: Consider whether we need to recurse up if entries does not contain requested entry
+ return (String)entries.get(entry);
+ }
+ else
+ return null;
+ }
+
+ public Map getEntries(String id, Locale locale) {
+ Map entries = findEntriesRecursively(id,locale);
+ if(entries == null) // If not found by using specified locale, try to use default
+ entries = findEntriesRecursively(id,Locale.getDefault());
+ return entries;
+ }
+
+ /**
+ * Find entries by looking at the parent locale (language, country, variant ->
+ * language, country -> language) until entry is found. If entry not found for topmost
+ * Locale (language only), null is returned.
+ */
+ private Map findEntriesRecursively(String id, Locale locale) {
+ Map localeIds = (Map)locales.get(locale);
+ if(localeIds != null) {
+ Map entries = (Map)localeIds.get(id);
+ if(entries != null)
+ return entries;
+ }
+ Locale parentLocale = I18nUtils.getParentLocale(locale);
+ if(parentLocale == null)
+ return null;
+ else
+ return findEntriesRecursively(id, parentLocale); // Recursive call
+ }
+
+}
Propchange: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/JdbcMessageProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java Sat Jan 6 08:49:24 2007
@@ -1,61 +1,61 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.i18n;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-
-import org.apache.commons.i18n.bundles.ErrorBundle;
-
-/**
- * The <code>LocalizedError</code> class is the base class for all errors
- * that provide locaized error informations. This class should be subclassed
- * in order to provide specific errors capable of localization support.
- *
- */
-public class LocalizedError extends Error {
- private ErrorBundle errorMessage;
-
- /**
- * @param errorMessage The error message contains a detailed localized description of this error
- * @param throwable The <code>Throwable</code> that caused this error
- */
- public LocalizedError(ErrorBundle errorMessage, Throwable throwable) {
- super(errorMessage.getSummary(Locale.getDefault(), throwable.getMessage()), throwable);
- this.errorMessage = errorMessage;
- }
-
- /**
- * @param errorMessage The error message contains a detailed localized description of this error
- */
- public LocalizedError(ErrorBundle errorMessage) {
- super(errorMessage.getSummary(
- Locale.getDefault(),
- MessageFormat.format(
- I18nUtils.INTERNAL_MESSAGES.getString(I18nUtils.MESSAGE_ENTRY_NOT_FOUND),
- new String[] { errorMessage.getId(), ErrorBundle.SUMMARY })));
- this.errorMessage = errorMessage;
- }
-
-
- /**
- * @return the detailed error message that describes this error
- */
- public ErrorBundle getErrorMessage() {
- return errorMessage;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.i18n;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+
+import org.apache.commons.i18n.bundles.ErrorBundle;
+
+/**
+ * The <code>LocalizedError</code> class is the base class for all errors
+ * that provide locaized error informations. This class should be subclassed
+ * in order to provide specific errors capable of localization support.
+ *
+ */
+public class LocalizedError extends Error {
+ private ErrorBundle errorMessage;
+
+ /**
+ * @param errorMessage The error message contains a detailed localized description of this error
+ * @param throwable The <code>Throwable</code> that caused this error
+ */
+ public LocalizedError(ErrorBundle errorMessage, Throwable throwable) {
+ super(errorMessage.getSummary(Locale.getDefault(), throwable.getMessage()), throwable);
+ this.errorMessage = errorMessage;
+ }
+
+ /**
+ * @param errorMessage The error message contains a detailed localized description of this error
+ */
+ public LocalizedError(ErrorBundle errorMessage) {
+ super(errorMessage.getSummary(
+ Locale.getDefault(),
+ MessageFormat.format(
+ I18nUtils.INTERNAL_MESSAGES.getString(I18nUtils.MESSAGE_ENTRY_NOT_FOUND),
+ new String[] { errorMessage.getId(), ErrorBundle.SUMMARY })));
+ this.errorMessage = errorMessage;
+ }
+
+
+ /**
+ * @return the detailed error message that describes this error
+ */
+ public ErrorBundle getErrorMessage() {
+ return errorMessage;
+ }
+}
Propchange: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedError.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedRuntimeException.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedRuntimeException.java?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedRuntimeException.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedRuntimeException.java Sat Jan 6 08:49:24 2007
@@ -1,58 +1,58 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.i18n;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-
-import org.apache.commons.i18n.bundles.ErrorBundle;
-
-/**
- * The <code>LocalizedRuntimeException</code> class is the base class for all runtime exceptions
- * that provide locaized error informations.
- *
- */public class LocalizedRuntimeException extends RuntimeException {
- private ErrorBundle errorMessage;
-
- /**
- * @param errorMessage The error message contains a detailed localized description of the error that caused the exception
- * @param throwable The <code>Throwable</code> that caused this exception
- */
- public LocalizedRuntimeException(ErrorBundle errorMessage, Throwable throwable) {
- super(errorMessage.getSummary(Locale.getDefault(), throwable.getMessage()), throwable);
- this.errorMessage = errorMessage;
- }
-
- /**
- * @param errorMessage The error message contains a detailed localized description of the error that caused the exception
- */
- public LocalizedRuntimeException(ErrorBundle errorMessage) {
- super(errorMessage.getSummary(
- Locale.getDefault(),
- MessageFormat.format(
- I18nUtils.INTERNAL_MESSAGES.getString(I18nUtils.MESSAGE_ENTRY_NOT_FOUND),
- new String[] { errorMessage.getId(), ErrorBundle.SUMMARY })));
- this.errorMessage = errorMessage;
- }
-
- /**
- * @return the detailed error message that describes this exception
- */
- public ErrorBundle getErrorMessage() {
- return errorMessage;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.i18n;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+
+import org.apache.commons.i18n.bundles.ErrorBundle;
+
+/**
+ * The <code>LocalizedRuntimeException</code> class is the base class for all runtime exceptions
+ * that provide locaized error informations.
+ *
+ */public class LocalizedRuntimeException extends RuntimeException {
+ private ErrorBundle errorMessage;
+
+ /**
+ * @param errorMessage The error message contains a detailed localized description of the error that caused the exception
+ * @param throwable The <code>Throwable</code> that caused this exception
+ */
+ public LocalizedRuntimeException(ErrorBundle errorMessage, Throwable throwable) {
+ super(errorMessage.getSummary(Locale.getDefault(), throwable.getMessage()), throwable);
+ this.errorMessage = errorMessage;
+ }
+
+ /**
+ * @param errorMessage The error message contains a detailed localized description of the error that caused the exception
+ */
+ public LocalizedRuntimeException(ErrorBundle errorMessage) {
+ super(errorMessage.getSummary(
+ Locale.getDefault(),
+ MessageFormat.format(
+ I18nUtils.INTERNAL_MESSAGES.getString(I18nUtils.MESSAGE_ENTRY_NOT_FOUND),
+ new String[] { errorMessage.getId(), ErrorBundle.SUMMARY })));
+ this.errorMessage = errorMessage;
+ }
+
+ /**
+ * @return the detailed error message that describes this exception
+ */
+ public ErrorBundle getErrorMessage() {
+ return errorMessage;
+ }
+}
Propchange: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedRuntimeException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/ErrorBundle.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/ErrorBundle.java?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/ErrorBundle.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/ErrorBundle.java Sat Jan 6 08:49:24 2007
@@ -1,104 +1,104 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.i18n.bundles;
-
-import java.util.Locale;
-
-import org.apache.commons.i18n.MessageNotFoundException;
-
-
-/**
- * <p>The <code>ErrorBundle</code> bundles together title, text, details and summary.</p>
- * <p>This bundle can be used to describe an error in detail and is used in the provided localized
- * exceptions.</p>
- *
- */
-public class ErrorBundle extends MessageBundle {
- public final static String SUMMARY = "summary";
- public final static String DETAILS = "details";
-
- /**
- * @param messageId Unique message id that identifies the message
- */
- public ErrorBundle(String messageId) {
- super(messageId);
- }
-
- /**
- * @param providerId The name of the message provider (i.e. source) to use for the message
- * @param messageId Unique message id that identifies the message
- */
- public ErrorBundle(String providerId, String messageId) {
- super(providerId, messageId);
- }
-
- /**
- * @param messageId Unique message id that identifies the message
- * @param arguments An array of objects conaining the values that should be
- * inserted into the localized message.
- */
- public ErrorBundle(String messageId, Object[] arguments) {
- super(messageId, arguments);
- }
-
- /**
- * @param providerId The name of the message provider (i.e. source) to use for the message
- * @param messageId Unique message id that identifies the message
- * @param arguments An array of objects conaining the values that should be
- * inserted into the localized message.
- */
- public ErrorBundle(String providerId, String messageId, Object[] arguments) {
- super(providerId, messageId, arguments);
- }
-
- /**
- * @param locale The locale that is used to find the appropriate localized text
- * @return returns the localized message entry with the key <code>summary</code>
- * @throws MessageNotFoundException is thrown if no entry with key <code>summary</code> could be found in the message bundle identified by the given message identifier
- */
- public String getSummary(Locale locale) throws MessageNotFoundException {
- return getEntry(SUMMARY, locale);
- }
-
- /**
- * @param locale The locale that is used to find the appropriate localized text
- * @param defaultSummary The default text will be returned, if no entry with key <code>summary</code> could be found in the message bundle identified by the given message identifier
- * @return returns the localized message entry with the key <code>summary</code>
- */
- public String getSummary(Locale locale, String defaultSummary) {
- return getEntry(SUMMARY, locale, defaultSummary);
- }
-
-
- /**
- * @param locale The locale that is used to find the appropriate localized text
- * @return returns the localized message entry with the key <code>details</code>
- * @throws MessageNotFoundException is thrown if no entry with key <code>details</code> could be found in the message bundle identified by the given message identifier
- */
- public String getDetails(Locale locale) throws MessageNotFoundException {
- return getEntry(DETAILS, locale);
- }
-
- /**
- * @param locale The locale that is used to find the appropriate localized text
- * @param defaultDetails The default text will be returned, if no entry with key <code>details</code> could be found in the message bundle identified by the given message identifier
- * @return returns the localized message entry with the key <code>details</code>
- */
- public String getDetails(Locale locale, String defaultDetails) {
- return getEntry(DETAILS, locale, defaultDetails);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.i18n.bundles;
+
+import java.util.Locale;
+
+import org.apache.commons.i18n.MessageNotFoundException;
+
+
+/**
+ * <p>The <code>ErrorBundle</code> bundles together title, text, details and summary.</p>
+ * <p>This bundle can be used to describe an error in detail and is used in the provided localized
+ * exceptions.</p>
+ *
+ */
+public class ErrorBundle extends MessageBundle {
+ public final static String SUMMARY = "summary";
+ public final static String DETAILS = "details";
+
+ /**
+ * @param messageId Unique message id that identifies the message
+ */
+ public ErrorBundle(String messageId) {
+ super(messageId);
+ }
+
+ /**
+ * @param providerId The name of the message provider (i.e. source) to use for the message
+ * @param messageId Unique message id that identifies the message
+ */
+ public ErrorBundle(String providerId, String messageId) {
+ super(providerId, messageId);
+ }
+
+ /**
+ * @param messageId Unique message id that identifies the message
+ * @param arguments An array of objects conaining the values that should be
+ * inserted into the localized message.
+ */
+ public ErrorBundle(String messageId, Object[] arguments) {
+ super(messageId, arguments);
+ }
+
+ /**
+ * @param providerId The name of the message provider (i.e. source) to use for the message
+ * @param messageId Unique message id that identifies the message
+ * @param arguments An array of objects conaining the values that should be
+ * inserted into the localized message.
+ */
+ public ErrorBundle(String providerId, String messageId, Object[] arguments) {
+ super(providerId, messageId, arguments);
+ }
+
+ /**
+ * @param locale The locale that is used to find the appropriate localized text
+ * @return returns the localized message entry with the key <code>summary</code>
+ * @throws MessageNotFoundException is thrown if no entry with key <code>summary</code> could be found in the message bundle identified by the given message identifier
+ */
+ public String getSummary(Locale locale) throws MessageNotFoundException {
+ return getEntry(SUMMARY, locale);
+ }
+
+ /**
+ * @param locale The locale that is used to find the appropriate localized text
+ * @param defaultSummary The default text will be returned, if no entry with key <code>summary</code> could be found in the message bundle identified by the given message identifier
+ * @return returns the localized message entry with the key <code>summary</code>
+ */
+ public String getSummary(Locale locale, String defaultSummary) {
+ return getEntry(SUMMARY, locale, defaultSummary);
+ }
+
+
+ /**
+ * @param locale The locale that is used to find the appropriate localized text
+ * @return returns the localized message entry with the key <code>details</code>
+ * @throws MessageNotFoundException is thrown if no entry with key <code>details</code> could be found in the message bundle identified by the given message identifier
+ */
+ public String getDetails(Locale locale) throws MessageNotFoundException {
+ return getEntry(DETAILS, locale);
+ }
+
+ /**
+ * @param locale The locale that is used to find the appropriate localized text
+ * @param defaultDetails The default text will be returned, if no entry with key <code>details</code> could be found in the message bundle identified by the given message identifier
+ * @return returns the localized message entry with the key <code>details</code>
+ */
+ public String getDetails(Locale locale, String defaultDetails) {
+ return getEntry(DETAILS, locale, defaultDetails);
+ }
+}
Propchange: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/ErrorBundle.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/MessageBundle.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/MessageBundle.java?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/MessageBundle.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/MessageBundle.java Sat Jan 6 08:49:24 2007
@@ -1,82 +1,82 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.i18n.bundles;
-
-import java.util.Locale;
-
-import org.apache.commons.i18n.MessageNotFoundException;
-
-
-/**
- * <p>The <code>MessageBundle</code> groups together title and text.</p>
- *
- */
-public class MessageBundle extends TextBundle {
- public final static String TITLE = "title";
-
- /**
- * @param messageId Unique message id that identifies the message
- */
- public MessageBundle(String messageId) {
- super(messageId);
- }
-
- /**
- * @param providerId The name of the message provider (i.e. source) to use for the message
- * @param messageId Unique message id that identifies the message
- */
- public MessageBundle(String providerId, String messageId) {
- super(providerId, messageId);
- }
-
- /**
- * @param messageId Unique message id that identifies the message
- * @param arguments An array of objects conaining the values that should be
- * inserted into the localized message.
- */
- public MessageBundle(String messageId, Object[] arguments) {
- super(messageId, arguments);
- }
-
- /**
- * @param providerId The name of the message provider (i.e. source) to use for the message
- * @param messageId Unique message id that identifies the message
- * @param arguments An array of objects conaining the values that should be
- * inserted into the localized message.
- */
- public MessageBundle(String providerId, String messageId, Object[] arguments) {
- super(providerId, messageId, arguments);
- }
-
- /**
- * @param locale The locale that is used to find the appropriate localized text
- * @return returns the localized message entry with the key <code>title</code>
- * @throws MessageNotFoundException is thrown if no entry with key <code>title</code> could be found in the message bundle identified by the given message identifier
- */
- public String getTitle(Locale locale) throws MessageNotFoundException {
- return getEntry(TITLE, locale);
- }
-
- /**
- * @param locale The locale that is used to find the appropriate localized text
- * @param defaultTitle The default text will be returned, if no entry with key <code>title</code> could be found in the message bundle identified by the given message identifier
- * @return returns the localized message entry with the key <code>title</code>
- */
- public String getTitle(Locale locale, String defaultTitle) {
- return getEntry(TITLE, locale, defaultTitle);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.i18n.bundles;
+
+import java.util.Locale;
+
+import org.apache.commons.i18n.MessageNotFoundException;
+
+
+/**
+ * <p>The <code>MessageBundle</code> groups together title and text.</p>
+ *
+ */
+public class MessageBundle extends TextBundle {
+ public final static String TITLE = "title";
+
+ /**
+ * @param messageId Unique message id that identifies the message
+ */
+ public MessageBundle(String messageId) {
+ super(messageId);
+ }
+
+ /**
+ * @param providerId The name of the message provider (i.e. source) to use for the message
+ * @param messageId Unique message id that identifies the message
+ */
+ public MessageBundle(String providerId, String messageId) {
+ super(providerId, messageId);
+ }
+
+ /**
+ * @param messageId Unique message id that identifies the message
+ * @param arguments An array of objects conaining the values that should be
+ * inserted into the localized message.
+ */
+ public MessageBundle(String messageId, Object[] arguments) {
+ super(messageId, arguments);
+ }
+
+ /**
+ * @param providerId The name of the message provider (i.e. source) to use for the message
+ * @param messageId Unique message id that identifies the message
+ * @param arguments An array of objects conaining the values that should be
+ * inserted into the localized message.
+ */
+ public MessageBundle(String providerId, String messageId, Object[] arguments) {
+ super(providerId, messageId, arguments);
+ }
+
+ /**
+ * @param locale The locale that is used to find the appropriate localized text
+ * @return returns the localized message entry with the key <code>title</code>
+ * @throws MessageNotFoundException is thrown if no entry with key <code>title</code> could be found in the message bundle identified by the given message identifier
+ */
+ public String getTitle(Locale locale) throws MessageNotFoundException {
+ return getEntry(TITLE, locale);
+ }
+
+ /**
+ * @param locale The locale that is used to find the appropriate localized text
+ * @param defaultTitle The default text will be returned, if no entry with key <code>title</code> could be found in the message bundle identified by the given message identifier
+ * @return returns the localized message entry with the key <code>title</code>
+ */
+ public String getTitle(Locale locale, String defaultTitle) {
+ return getEntry(TITLE, locale, defaultTitle);
+ }
+}
Propchange: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/MessageBundle.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/TextBundle.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/TextBundle.java?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/TextBundle.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/TextBundle.java Sat Jan 6 08:49:24 2007
@@ -1,84 +1,84 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.i18n.bundles;
-
-import java.util.Locale;
-
-import org.apache.commons.i18n.LocalizedBundle;
-import org.apache.commons.i18n.MessageNotFoundException;
-
-/**
- * <p>The <code>TextBundle</code> represents the most simple localized bundle with just
- * one single entry. Use this class if you want to deal with simple localized strings that may
- * contain dynamic elements.</p>
- *
- */
-public class TextBundle extends LocalizedBundle {
- public final static String TEXT = "text";
-
- /**
- * @param messageId Unique message id that identifies the message
- */
- public TextBundle(String messageId) {
- super(messageId);
- }
-
- /**
- * @param providerId The name of the message provider (i.e. source) to use for the message
- * @param messageId Unique message id that identifies the message
- */
- public TextBundle(String providerId, String messageId) {
- super(providerId, messageId);
- }
-
- /**
- * @param messageId Unique message id that identifies the message
- * @param arguments An array of objects conaining the values that should be
- * inserted into the localized message.
- */
- public TextBundle(String messageId, Object[] arguments) {
- super(messageId, arguments);
- }
-
- /**
- * @param providerId The name of the message provider (i.e. source) to use for the message
- * @param messageId Unique message id that identifies the message
- * @param arguments An array of objects conaining the values that should be
- * inserted into the localized message.
- */
- public TextBundle(String providerId, String messageId, Object[] arguments) {
- super(providerId, messageId, arguments);
- }
-
- /**
- * @param locale The locale that is used to find the appropriate localized text
- * @return returns the localized message entry with the key <code>text</code>
- * @throws MessageNotFoundException is thrown if no entry with key <code>text</code> could be found in the message bundle identified by the given message identifier
- */
- public String getText(Locale locale) throws MessageNotFoundException {
- return getEntry(TEXT, locale);
- }
-
- /**
- * @param locale The locale that is used to find the appropriate localized text
- * @param defaultText The default text will be returned, if no entry with key <code>text</code> could be found in the message bundle identified by the given message identifier
- * @return returns the localized message entry with the key <code>text</code>
- */
- public String getText(Locale locale, String defaultText) {
- return getEntry(TEXT, locale, defaultText);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.i18n.bundles;
+
+import java.util.Locale;
+
+import org.apache.commons.i18n.LocalizedBundle;
+import org.apache.commons.i18n.MessageNotFoundException;
+
+/**
+ * <p>The <code>TextBundle</code> represents the most simple localized bundle with just
+ * one single entry. Use this class if you want to deal with simple localized strings that may
+ * contain dynamic elements.</p>
+ *
+ */
+public class TextBundle extends LocalizedBundle {
+ public final static String TEXT = "text";
+
+ /**
+ * @param messageId Unique message id that identifies the message
+ */
+ public TextBundle(String messageId) {
+ super(messageId);
+ }
+
+ /**
+ * @param providerId The name of the message provider (i.e. source) to use for the message
+ * @param messageId Unique message id that identifies the message
+ */
+ public TextBundle(String providerId, String messageId) {
+ super(providerId, messageId);
+ }
+
+ /**
+ * @param messageId Unique message id that identifies the message
+ * @param arguments An array of objects conaining the values that should be
+ * inserted into the localized message.
+ */
+ public TextBundle(String messageId, Object[] arguments) {
+ super(messageId, arguments);
+ }
+
+ /**
+ * @param providerId The name of the message provider (i.e. source) to use for the message
+ * @param messageId Unique message id that identifies the message
+ * @param arguments An array of objects conaining the values that should be
+ * inserted into the localized message.
+ */
+ public TextBundle(String providerId, String messageId, Object[] arguments) {
+ super(providerId, messageId, arguments);
+ }
+
+ /**
+ * @param locale The locale that is used to find the appropriate localized text
+ * @return returns the localized message entry with the key <code>text</code>
+ * @throws MessageNotFoundException is thrown if no entry with key <code>text</code> could be found in the message bundle identified by the given message identifier
+ */
+ public String getText(Locale locale) throws MessageNotFoundException {
+ return getEntry(TEXT, locale);
+ }
+
+ /**
+ * @param locale The locale that is used to find the appropriate localized text
+ * @param defaultText The default text will be returned, if no entry with key <code>text</code> could be found in the message bundle identified by the given message identifier
+ * @return returns the localized message entry with the key <code>text</code>
+ */
+ public String getText(Locale locale, String defaultText) {
+ return getEntry(TEXT, locale, defaultText);
+ }
+}
Propchange: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/TextBundle.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages.properties
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages.properties?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages.properties (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages.properties Sat Jan 6 08:49:24 2007
@@ -1,5 +1,5 @@
-messageNotFound=Message with key {0} not found
-noMessageEntriesFound=No message entries found for bundle with key {0}
-messageEntryNotFound=Message bundle with key {0} does not contain an entry with key {1}
-resourceBundleNotFound=Could not find resource bundle with base name {0}, uninstalling it
+messageNotFound=Message with key {0} not found
+noMessageEntriesFound=No message entries found for bundle with key {0}
+messageEntryNotFound=Message bundle with key {0} does not contain an entry with key {1}
+resourceBundleNotFound=Could not find resource bundle with base name {0}, uninstalling it
messageParsingError=Error while parsing message file with id {0}
Propchange: jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages_de.properties
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages_de.properties?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages_de.properties (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages_de.properties Sat Jan 6 08:49:24 2007
@@ -1,5 +1,5 @@
-messageNotFound=Keine Nachricht mit Schlüssel {0} gefunden
-noMessageEntriesFound=Keine Einträge für die Nachricht mit Schlüssel {0} gefunden
-messageEntryNotFound=Die Nachricht mit Schlüssel {0} enthält keinen Eintrag mit Schlüssel {1}
-resourceBundleNotFound=Übersetzungsdatei mit dem Namen {0} wurde nicht gefunden und wird daher deinstalliert
+messageNotFound=Keine Nachricht mit Schlüssel {0} gefunden
+noMessageEntriesFound=Keine Einträge für die Nachricht mit Schlüssel {0} gefunden
+messageEntryNotFound=Die Nachricht mit Schlüssel {0} enthält keinen Eintrag mit Schlüssel {1}
+resourceBundleNotFound=Übersetzungsdatei mit dem Namen {0} wurde nicht gefunden und wird daher deinstalliert
messageParsingError=Fehler beim Einlesen der Übersetzungsdatei mit der ID {0}
Propchange: jakarta/commons/sandbox/i18n/trunk/src/resources/i18n-messages_de.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle.properties
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle.properties?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle.properties (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle.properties Sat Jan 6 08:49:24 2007
@@ -1,4 +1,4 @@
-# Example for using message bundles using a flat properties-file
-helloWorld.title=Hello World
-helloWorld.text=I wish you a merry christmas!
+# Example for using message bundles using a flat properties-file
+helloWorld.title=Hello World
+helloWorld.text=I wish you a merry christmas!
helloWorld.notTranslated=This entry is not translated to any other languages
Propchange: jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle2.properties
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle2.properties?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle2.properties (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle2.properties Sat Jan 6 08:49:24 2007
@@ -1,2 +1,2 @@
-# Example 2 for using message bundles using a flat properties-file
+# Example 2 for using message bundles using a flat properties-file
onlyInSecond.title=This message exists in another resource bundle
Propchange: jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle2.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle_de.properties
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle_de.properties?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle_de.properties (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle_de.properties Sat Jan 6 08:49:24 2007
@@ -1,3 +1,3 @@
-# Example for using message bundles using a flat properties-file
-helloWorld.title=Hallo Welt
+# Example for using message bundles using a flat properties-file
+helloWorld.title=Hallo Welt
helloWorld.text=Ich wünsche Dir alles Gute und ein frohes Fest!
Propchange: jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle_de.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/I18nUtilsTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/I18nUtilsTest.java?view=diff&rev=493507&r1=493506&r2=493507
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/I18nUtilsTest.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/I18nUtilsTest.java Sat Jan 6 08:49:24 2007
@@ -1,42 +1,42 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.i18n;
-
-import junit.framework.TestCase;
-
-import java.util.Locale;
-
-/**
- * @author Mattias Jiderhamn
- */
-public class I18nUtilsTest extends TestCase {
- public void testGetParentLocale() {
- assertEquals("Language, country and variant",
- new Locale("en", "GB"),
- I18nUtils.getParentLocale(new Locale("en", "GB", "scottish")));
-
- assertEquals("Language and country",
- Locale.ENGLISH,
- I18nUtils.getParentLocale(new Locale("en", "GB")));
-
- assertEquals("Language and variant",
- Locale.ENGLISH,
- I18nUtils.getParentLocale(new Locale("en", "", "scottish")));
-
- assertNull("Language only", I18nUtils.getParentLocale(Locale.ENGLISH));
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.i18n;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+
+/**
+ * @author Mattias Jiderhamn
+ */
+public class I18nUtilsTest extends TestCase {
+ public void testGetParentLocale() {
+ assertEquals("Language, country and variant",
+ new Locale("en", "GB"),
+ I18nUtils.getParentLocale(new Locale("en", "GB", "scottish")));
+
+ assertEquals("Language and country",
+ Locale.ENGLISH,
+ I18nUtils.getParentLocale(new Locale("en", "GB")));
+
+ assertEquals("Language and variant",
+ Locale.ENGLISH,
+ I18nUtils.getParentLocale(new Locale("en", "", "scottish")));
+
+ assertNull("Language only", I18nUtils.getParentLocale(Locale.ENGLISH));
+ }
+}
Propchange: jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/I18nUtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org