View Javadoc

1   // 
2   //Copyright (c) 2003, Caltha - Gajda, Krzewski, Mach, Potempski Sp.J. 
3   //All rights reserved. 
4   //   
5   //Redistribution and use in source and binary forms, with or without modification,  
6   //are permitted provided that the following conditions are met: 
7   //   
8   //* Redistributions of source code must retain the above copyright notice,  
9   //this list of conditions and the following disclaimer. 
10  //* Redistributions in binary form must reproduce the above copyright notice,  
11  //this list of conditions and the following disclaimer in the documentation  
12  //and/or other materials provided with the distribution. 
13  //* Neither the name of the Caltha - Gajda, Krzewski, Mach, Potempski Sp.J.  
14  //nor the names of its contributors may be used to endorse or promote products  
15  //derived from this software without specific prior written permission. 
16  // 
17  //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  
18  //AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED  
19  //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
20  //IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,  
21  //INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,  
22  //BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
23  //OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
24  //WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)  
25  //ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  
26  //POSSIBILITY OF SUCH DAMAGE. 
27  //
28  
29  package org.objectledge.i18n;
30  
31  import java.util.Collection;
32  import java.util.List;
33  import java.util.Locale;
34  
35  /**
36   * Common interface for i18n various i18n implementations.
37   * 
38   * @author <a href="mailto:pablo@caltha.pl">Pawel Potempski</a>
39   * @author <a href="mailto:dgajda@caltha.pl">Damian Gajda</a>
40   * @version $Id: I18n.java,v 1.14 2006/03/23 09:54:54 pablo Exp $
41   */
42  public interface I18n
43  {
44  	/*** 
45  	 * Returns configured default locale.
46  	 * 
47  	 * @return the default locale object. 
48  	 */
49  	public Locale getDefaultLocale();
50  
51      /*** 
52       * Returns configured prefered locale.
53       * 
54       * @return the prefered locale object. 
55       */
56      public Locale getPreferedLocale();
57  
58  	/*** 
59  	 * Returns configured locales.
60  	 * 
61  	 * @return an array of defined locale. 
62  	 */
63  	public Locale[] getSupportedLocales();
64  	
65  	/***
66  	 * Returns the human readable name of the given locale.
67  	 * 
68  	 * @param locale the locale.
69  	 * @return the human readable name of the given locale.
70  	 */
71  	public String getLocaleName(Locale locale);
72  	
73      /*** 
74       * Checks if a string value is defined for a default locale.
75       * 
76       * @param key the key.
77       * @return <code>true</code> if the string is defined
78       */
79      public boolean defined(String key);
80  
81      /*** 
82       * Checks if a string value is defined for a given locale.
83       * 
84       * @param locale the locale.
85       * @param key the key.
86       * @return <code>true</code> if the string is defined
87       */
88      public boolean defined(Locale locale, String key);
89  
90      /*** 
91  	 * Get the string value.
92  	 * 
93  	 * @param locale the locale.
94  	 * @param key the key.
95  	 * @return the string value.
96  	 */
97  	public String get(Locale locale, String key);
98  	
99      /*** 
100      * Get the string value with given default value if the string is missing in
101      * both given and default locale.
102      * 
103      * @param locale the locale.
104      * @param key the key.
105      * @param defaultValue the default value in case key mapping is missing.
106      * @return the string value.
107      */
108     public String get(Locale locale, String key, String defaultValue);
109 
110     /***
111 	 * Get the string and replace $[1..n] variables with given values.
112 	 *
113 	 * @param locale the locale.
114 	 * @param key the key.
115 	 * @param values the values use for substitution.
116 	 * @return the the output string.
117 	 */
118 	public String get(Locale locale, String key, String ... values);
119 
120     /***
121 	 * Get the string and replace $[1..n] variables with given values.
122 	 *
123 	 * @param locale the locale.
124 	 * @param key the key.
125 	 * @param values the values use for substitution.
126 	 * @return the the output string.
127 	 */
128 	public String get(Locale locale, String key, List<String> values);	
129 
130     /***
131      * Get all keys defined for given locale.
132      * 
133      * @param locale the locale.
134      * @return the list of keys.
135      */
136     public Collection<String> getKeys(Locale locale);
137     
138 	/***
139 	 * Reload the localization.
140 	 * 
141 	 */
142 	public void reload();
143 }