<html> <head> <title>class OLocale</title> <link rel="stylesheet" type="text/css" href="../../cpp.css"> </head> <body> <div id="adc-cppref"> <a name="_top_"> </a><table class="navimain" border="0" cellpadding="1" cellspacing="0"> <tr align="center" valign="top"> <td class="navimain"> <a href="../../index.html">Overview</a> </td> <td class="navimain"> <a href="index.html">Namespace</a> </td> <td class="navimainself"> Class </td> <td class="navimain"> <a href="../../index-files/index-1.html">Index</a> </td> <td class="navimain"> <a href="../../help.html">Help</a> </td> </tr> </table> <table class="navisub" cellpadding="0" cellspacing="3"> <tr> <td width="20%"><font size="-2">PUBLIC MEMBERS:</font></td> <td> <font size="-2">CLASSES</font> | <font size="-2">STRUCTS</font> | <font size="-2">UNIONS</font> | <font size="-2">ENUMS</font> | <font size="-2">TYPEDEFS</font> | <a href="#publ_ops"><font size="-2"><b>METHODS</b></font></a> | <a href="#publ_static_ops"><font size="-2"><b>STATIC METHODS</b></font></a> | <font size="-2">DATA</font> | <font size="-2">STATIC DATA</font></td> </tr> <tr> <td width="20%"><font size="-2">PRIVATE MEMBERS:</font></td> <td> <font size="-2">CLASSES</font> | <font size="-2">STRUCTS</font> | <font size="-2">UNIONS</font> | <font size="-2">ENUMS</font> | <font size="-2">TYPEDEFS</font> | <a href="#priv_ops"><font size="-2"><b>METHODS</b></font></a> | <font size="-2">STATIC METHODS</font> | <a href="#priv_vars"><font size="-2"><b>DATA</b></font></a> | <font size="-2">STATIC DATA</font></td> </tr> </table> <hr> <a href="../../names/index.html" alt="Global Namespace in C++"><font size="+1"><b>::</b></font></a> <a href="index.html" alt="namespace"><font size="+1"><b>rtl</b></font></a><font size="+1"> :: </font><div class="title"><h2>class OLocale</h2> </div><hr> <dl> <dt>Base Classes</dt> <dd>None.</dd> </dl> <dl> <dt>Known Derived Classes</dt> <dd>None.</dd> </dl> <br> <table class="flag-table" border="1" cellspacing="0"> <tr> <td width="25%" class="flagname">virtual</td> <td width="25%" class="flagname">abstract</td> <td width="25%" class="flagname">interface</td> <td width="25%" class="flagname">template</td> </tr> <tr> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> <td class="flagno">NO</td> </tr> </table> <dl> <dt>Description</dt> <dd>A <code>OLocale</code> object represents a specific geographical, political, or cultural region. An operation that requires a <code>OLocale</code> to perform its task is called <em>locale-sensitive</em> and uses the <code>OLocale</code> to tailor information for the user. For example, displaying a number is a locale-sensitive operation--the number should be formatted according to the customs/conventions of the user's native country, region, or culture. <P> You create a <code>OLocale</code> object using one of the two constructors in this class: <blockquote> <pre> OLocale(String language, String country) OLocale(String language, String country, String variant) </pre> </blockquote> The first argument to both constructors is a valid <STRONG>ISO Language Code.</STRONG> These codes are the lower-case two-letter codes as defined by ISO-639. You can find a full list of these codes at a number of sites, such as: <BR><a href ="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt"> <code>http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</code></a> <P> The second argument to both constructors is a valid <STRONG>ISO Country Code.</STRONG> These codes are the upper-case two-letter codes as defined by ISO-3166. You can find a full list of these codes at a number of sites, such as: <BR><a href="http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html"> <code>http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</code></a> <P> The second constructor requires a third argument--the <STRONG>Variant.</STRONG> The Variant codes are vendor and browser-specific. For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. Where there are two variants, separate them with an underscore, and put the most important one first. For example, a Traditional Spanish collation might be referenced, with "ES", "ES", "Traditional_WIN". <P> Because a <code>OLocale</code> object is just an identifier for a region, no validity check is performed when you construct a <code>OLocale</code>. If you want to see whether particular resources are available for the <code>OLocale</code> you construct, you must query those resources. For example, ask the <code>NumberFormat</code> for the locales it supports using its <code>getAvailableLocales</code> method. <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular locale, you get back the best available match, not necessarily precisely what you asked for. For more information, look at <a href="java.util.ResourceBundle.html"><code>ResourceBundle</code></a>. <P> The <code>OLocale</code> class provides a number of convenient constants that you can use to create <code>OLocale</code> objects for commonly used locales. For example, the following creates a <code>OLocale</code> object for the United States: <blockquote> <pre> OLocale.US </pre> </blockquote> <P> Once you've created a <code>OLocale</code> you can query it for information about itself. Use <code>getCountry</code> to get the ISO Country Code and <code>getLanguage</code> to get the ISO Language Code. You can use <code>getDisplayCountry</code> to get the name of the country suitable for displaying to the user. Similarly, you can use <code>getDisplayLanguage</code> to get the name of the language suitable for displaying to the user. Interestingly, the <code>getDisplayXXX</code> methods are themselves locale-sensitive and have two versions: one that uses the default locale and one that uses the locale specified as an argument. <P> The JDK provides a number of classes that perform locale-sensitive operations. For example, the <code>NumberFormat</code> class formats numbers, currency, or percentages in a locale-sensitive manner. Classes such as <code>NumberFormat</code> have a number of convenience methods for creating a default object of that type. For example, the <code>NumberFormat</code> class provides these three convenience methods for creating a default <code>NumberFormat</code> object: <blockquote> <pre> NumberFormat.getInstance() NumberFormat.getCurrencyInstance() NumberFormat.getPercentInstance() </pre> </blockquote> These methods have two variants; one with an explicit locale and one without; the latter using the default locale. <blockquote> <pre> NumberFormat.getInstance(myLocale) NumberFormat.getCurrencyInstance(myLocale) NumberFormat.getPercentInstance(myLocale) </pre> </blockquote> A <code>OLocale</code> is the mechanism for identifying the kind of object (<code>NumberFormat</code>) that you would like to get. The locale is <STRONG>just</STRONG> a mechanism for identifying objects, <STRONG>not</STRONG> a container for the objects themselves. <P> Each class that performs locale-sensitive operations allows you to get all the available objects of that type. You can sift through these objects by language, country, or variant, and use the display names to present a menu to the user. For example, you can create a menu of all the collation objects suitable for a given language. Such classes must implement these three class methods: <blockquote> <pre> public static OLocale[] getAvailableLocales() public static String getDisplayName(OLocale objectLocale, OLocale displayLocale) public static final String getDisplayName(OLocale objectLocale) // getDisplayName will throw MissingResourceException if the locale // is not one of the available locales. </pre> </blockquote> </dd> </dl> <dl> <dt>File</dt> <dd>locale.hxx</dd> </dl> <hr> <dl> <dt class="subtitle"><a name="publ_"><h3>Public Members</h3> </a></dt> <dd><a name="publ_ops"> </a><table class="childlist" border="1" cellpadding="5" cellspacing="0" width="100%"> <tr class="subtitle"> <td colspan="2"><h4>Methods</h4> </td> </tr> <tr> <td> <br> <a href="OLocale/o.html#OLocale-1271">OLocale</a>( rtl_Locale * locale );</td> <td width="50%"> </td> </tr> <tr> <td> <br> <a href="OLocale/o.html#OLocale-1272">OLocale</a>( const OLocale & obj );</td> <td width="50%"> </td> </tr> <tr> <td>OLocale & <br> <a href="OLocale/o.html#operator=-1273">operator=</a>( const OLocale & obj );</td> <td width="50%"> </td> </tr> <tr> <td>OUString <br> <a href="OLocale/o.html#getLanguage-1278">getLanguage</a>( ) const;</td> <td width="50%"> Getter for programmatic name of field, an lowercased two-letter ISO-639 code. </td> </tr> <tr> <td>OUString <br> <a href="OLocale/o.html#getCountry-1279">getCountry</a>( ) const;</td> <td width="50%"> Getter for programmatic name of field, an uppercased two-letter ISO-3166 code. </td> </tr> <tr> <td>OUString <br> <a href="OLocale/o.html#getVariant-1280">getVariant</a>( ) const;</td> <td width="50%"> Getter for programmatic name of field. </td> </tr> <tr> <td>sal_Int32 <br> <a href="OLocale/o.html#hashCode-1281">hashCode</a>( ) const;</td> <td width="50%"> Returns the hash code of the locale This. </td> </tr> <tr> <td>sal_Bool <br> <a href="OLocale/o.html#operator==-1282">operator==</a>( const OLocale & obj ) const;</td> <td width="50%"> </td> </tr> <tr> <td>rtl_Locale * <br> <a href="OLocale/o.html#getData-1283">getData</a>( ) const;</td> <td width="50%"> </td> </tr> </table> <hr> <a name="publ_static_ops"> </a><table class="childlist" border="1" cellpadding="5" cellspacing="0" width="100%"> <tr class="subtitle"> <td colspan="2"><h4>Static Methods</h4> </td> </tr> <tr> <td>static OLocale <br> <a href="OLocale/o.html#registerLocale-1274">registerLocale</a>( const OUString & language, const OUString & country, const OUString & variant );</td> <td width="50%"> Construct a locale from language, country, variant. </td> </tr> <tr> <td>static OLocale <br> <a href="OLocale/o.html#registerLocale-1275">registerLocale</a>( const OUString & language, const OUString & country );</td> <td width="50%"> Construct a locale from language, country. </td> </tr> <tr> <td>static OLocale <br> <a href="OLocale/o.html#getDefault-1276">getDefault</a>( );</td> <td width="50%"> </td> </tr> <tr> <td>static void <br> <a href="OLocale/o.html#setDefault-1277">setDefault</a>( const OUString & language, const OUString & country, const OUString & variant );</td> <td width="50%"> </td> </tr> </table> <hr> </dd> </dl> <dl> <dt class="subtitle"><a name="priv_"><h3>Private Members</h3> </a></dt> <dd><a name="priv_ops"> </a><table class="childlist" border="1" cellpadding="5" cellspacing="0" width="100%"> <tr class="subtitle"> <td colspan="2"><h4>Methods</h4> </td> </tr> <tr> <td> <br> <a href="OLocale/o.html#OLocale-1285">OLocale</a>( );</td> <td width="50%"> </td> </tr> </table> <hr> <a name="priv_vars"> </a><table class="childlist" border="1" cellpadding="5" cellspacing="0" width="100%"> <tr class="subtitle"> <td colspan="2"><h4>Data</h4> </td> </tr> <tr bgcolor="white"> <td><a href="../t-rtl_Locale.html">rtl_Locale</a> * <a href="OLocale/d.html#pData"><strong>pData;</strong></a></td> <td>Must be the first member in this class. OUString access this member with *(rtl_Locale **)&locale. </td> </tr> </table> <hr> </dd> </dl> <a href="#_top_" class="objchapter">Top of Page</a><hr size="3"><p class="copyright" align="center">Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.</p> </div> <!-- id="adc-cppref" --> </body> </html>