KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibm > icu > text > UFormat


1 /*
2  *******************************************************************************
3  * Copyright (C) 2003-2006, International Business Machines Corporation and *
4  * others. All Rights Reserved. *
5  *******************************************************************************
6  */

7 package com.ibm.icu.text;
8
9 import java.text.Format JavaDoc;
10 import com.ibm.icu.util.ULocale;
11
12 /**
13  * An abstract class that extends {@link java.text.Format} to provide
14  * additional ICU protocol, specifically, the <tt>getLocale()</tt>
15  * API. All ICU format classes are subclasses of this class.
16  *
17  * @see com.ibm.icu.util.ULocale
18  * @author weiv
19  * @author Alan Liu
20  * @draft ICU 2.8 (retain)
21  * @provisional This API might change or be removed in a future release.
22  */

23 public abstract class UFormat extends Format JavaDoc {
24     // jdk1.4.2 serialver
25
private static final long serialVersionUID = -4964390515840164416L;
26
27     /**
28      * @draft ICU 2.8 (retain)
29      * @provisional This API might change or be removed in a future release.
30      */

31     public UFormat() {}
32
33     // -------- BEGIN ULocale boilerplate --------
34

35     /**
36      * Return the locale that was used to create this object, or null.
37      * This may may differ from the locale requested at the time of
38      * this object's creation. For example, if an object is created
39      * for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
40      * drawn from <tt>en</tt> (the <i>actual</i> locale), and
41      * <tt>en_US</tt> may be the most specific locale that exists (the
42      * <i>valid</i> locale).
43      *
44      * <p>Note: This method will be implemented in ICU 3.0; ICU 2.8
45      * contains a partial preview implementation. The <i>actual</i>
46      * locale is returned correctly, but the <i>valid</i> locale is
47      * not, in most cases.
48      * @param type type of information requested, either {@link
49      * com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
50      * com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
51      * @return the information specified by <i>type</i>, or null if
52      * this object was not constructed from locale data.
53      * @see com.ibm.icu.util.ULocale
54      * @see com.ibm.icu.util.ULocale#VALID_LOCALE
55      * @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
56      * @draft ICU 2.8 (retain)
57      * @provisional This API might change or be removed in a future release.
58      */

59     public final ULocale getLocale(ULocale.Type type) {
60         return type == ULocale.ACTUAL_LOCALE ?
61             this.actualLocale : this.validLocale;
62     }
63
64     /**
65      * Set information about the locales that were used to create this
66      * object. If the object was not constructed from locale data,
67      * both arguments should be set to null. Otherwise, neither
68      * should be null. The actual locale must be at the same level or
69      * less specific than the valid locale. This method is intended
70      * for use by factories or other entities that create objects of
71      * this class.
72      * @param valid the most specific locale containing any resource
73      * data, or null
74      * @param actual the locale containing data used to construct this
75      * object, or null
76      * @see com.ibm.icu.util.ULocale
77      * @see com.ibm.icu.util.ULocale#VALID_LOCALE
78      * @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
79      * @internal
80      */

81     final void setLocale(ULocale valid, ULocale actual) {
82         // Change the following to an assertion later
83
if ((valid == null) != (actual == null)) {
84             ///CLOVER:OFF
85
throw new IllegalArgumentException JavaDoc();
86             ///CLOVER:ON
87
}
88         // Another check we could do is that the actual locale is at
89
// the same level or less specific than the valid locale.
90
this.validLocale = valid;
91         this.actualLocale = actual;
92     }
93
94     /**
95      * The most specific locale containing any resource data, or null.
96      * @see com.ibm.icu.util.ULocale
97      * @internal
98      */

99     private ULocale validLocale;
100
101     /**
102      * The locale containing data used to construct this object, or
103      * null.
104      * @see com.ibm.icu.util.ULocale
105      * @internal
106      */

107     private ULocale actualLocale;
108
109     // -------- END ULocale boilerplate --------
110
}
111
Popular Tags