Source Code Cross Referenced for ResourceInternationalString.java in  » GIS » GeoTools-2.4.1 » org » geotools » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
005:         *    (C) 2004, 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.util;
018:
019:        // J2SE dependencies
020:        import java.io.Serializable;
021:        import java.util.Locale;
022:        import java.util.MissingResourceException;
023:        import java.util.ResourceBundle;
024:
025:        // Geotools dependencies
026:        import org.geotools.resources.Utilities;
027:
028:        /**
029:         * An international string backed by a {@linkplain ResourceBundle resource bundle}. A resource
030:         * bundle can be a Java class or a {@linkplain java.util.Properties properties} file, one for
031:         * each language. The constructor expects the fully qualified class name of the base resource
032:         * bundle (the one used when no resource was found in the client's language). The right resource
033:         * bundle is loaded at runtime for the client's language by looking for a class or a
034:         * {@linkplain java.util.Properties properties} file with the right suffix ("{@code _en}" for
035:         * English or "{@code _fr}" for French). This mechanism is explained in J2SE's javadoc for the
036:         * {@link ResourceBundle#getBundle(String,Locale,ClassLoader) getBundle} static method.
037:         * <p>
038:         * <b>Example:</b> If a file named "{@code MyResources.properties}" exists in the package
039:         * "{@code org.geotools.mypackage}" and contains a line like "{@code MyKey = some value}",
040:         * then an international string for "{@code some value}" can be created using the following
041:         * code:
042:         *
043:         * <blockquote><code>
044:         * InternationalString value = new ResourceInternationalString(
045:         * "org.geotools.mypackage.MyResources", "MyKey");
046:         * </code></blockquote>
047:         *
048:         * The "{@code some value}" string will be localized if the required properties files exist, for
049:         * example "{@code MyResources_fr.properties}" for French, "{@code MyResources_it.properties}"
050:         * for Italian, <cite>etc.</cite>
051:         *
052:         * @since 2.1
053:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/util/ResourceInternationalString.java $
054:         * @version $Id: ResourceInternationalString.java 23493 2006-12-17 04:47:25Z desruisseaux $
055:         * @author Martin Desruisseaux
056:         */
057:        public class ResourceInternationalString extends
058:                AbstractInternationalString implements  Serializable {
059:            /**
060:             * Serial number for interoperability with different versions.
061:             */
062:            private static final long serialVersionUID = 6339944890723487336L;
063:
064:            /**
065:             * The name of the resource bundle from which to fetch the string.
066:             */
067:            private final String resources;
068:
069:            /**
070:             * The key for the resource to fetch.
071:             */
072:            private final String key;
073:
074:            /**
075:             * Creates a new international string from the specified resource bundle and key.
076:             *
077:             * @param resources The name of the resource bundle, as a fully qualified class name.
078:             * @param key The key for the resource to fetch.
079:             */
080:            public ResourceInternationalString(final String resources,
081:                    final String key) {
082:                this .resources = resources;
083:                this .key = key;
084:                ensureNonNull("resources", resources);
085:                ensureNonNull("key", key);
086:            }
087:
088:            /**
089:             * Returns a string in the specified locale. If there is no string for the specified
090:             * {@code locale}, then this method search for a string in an other locale as
091:             * specified in the {@link ResourceBundle} class description.
092:             *
093:             * @param  locale The locale to look for, or {@code null} for an unlocalized version.
094:             * @return The string in the specified locale, or in a default locale.
095:             * @throws MissingResourceException is the key given to the constructor is invalid.
096:             */
097:            public String toString(Locale locale)
098:                    throws MissingResourceException {
099:                if (locale == null) {
100:                    // The English locale (NOT the system default) is often used
101:                    // as the real identifier in OGC IdentifiedObject naming. If
102:                    // a user wants a string in the system default locale, he
103:                    // should invokes the 'toString()' method instead.
104:                    locale = Locale.ENGLISH;
105:                }
106:                return ResourceBundle.getBundle(resources, locale).getString(
107:                        key);
108:            }
109:
110:            /**
111:             * Compares this international string with the specified object for equality.
112:             */
113:            public boolean equals(final Object object) {
114:                if (object != null && object.getClass().equals(getClass())) {
115:                    final ResourceInternationalString that = (ResourceInternationalString) object;
116:                    return Utilities.equals(this .key, that.key)
117:                            && Utilities.equals(this .resources, that.resources);
118:                }
119:                return false;
120:            }
121:
122:            /**
123:             * Returns a hash code value for this international text.
124:             */
125:            public int hashCode() {
126:                return (int) serialVersionUID ^ key.hashCode()
127:                        ^ resources.hashCode();
128:            }
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.