libjava/classpath/ChangeLog.gcj:
2007-05-31 Matthias Klose <doko@ubuntu.com> * javax/management/NotificationBroadcasterSupport.java (getNotificationInfo): Add cast. * native/jni/qt-peer/Makefile.am (AM_CXXFLAGS): Add libstdc++ include directories. * native/jni/qt-peer/Makefile.in: Regenerate. libjava/ChangeLog: 2007-06-03 Matthias Klose <doko@ubuntu.com> * java/io/natFileWin32.cc (setFilePermissions): New (stub only). _access: Handle EXEC query, stub only. 2007-06-03 Matthias Klose <doko@ubuntu.com> Merged from classpath: * gnu/java/nio/SelectorProviderImpl.java: Whitespace merge. * java/lang/System.java(inheritedChannel): New. * java/lang/Character.java: Remove stray`;'. * java/net/MulticastSocket.java: Merged. * java/text/DateFormatSymbols.java(getInstance): New, comment updates. * java/text/Collator.java(getInstance): Merged. * java/util/Calendar.java: New attributes ALL_STYLES, SHORT, LONG. getDisplayName, getDisplayNames: New. * java/util/logging/Logger.java: Merged. * Regenerate .class and .h files. 2007-06-03 Matthias Klose <doko@ubuntu.com> * java/io/File.java: Merge with classpath-0.95, new method setFilePermissions, new attribute EXEC. * java/io/natFilePosix.cc (setFilePermissions): New. _access: Handle EXEC query. * classpath/lib/java/io/File.class, java/io/File.h: Regenerate. 2007-06-03 Matthias Klose <doko@ubuntu.com> Imported GNU Classpath 0.95. * classpath/Makefile.in, classpath/native/jni/midi-dssi/Makefile.in, classpath/native/jni/classpath/Makefile.in, classpath/native/jni/Makefile.in, classpath/native/jni/gconf-peer/Makefile.in, classpath/native/jni/java-io/Makefile.in, classpath/native/jni/native-lib/Makefile.in, classpath/native/jni/java-util/Makefile.in, classpath/native/jni/midi-alsa/Makefile.in, classpath/native/jni/java-lang/Makefile.in, classpath/native/jni/java-nio/Makefile.in, classpath/native/jni/java-net/Makefile.in, classpath/native/jni/xmlj/Makefile.in, classpath/native/jni/qt-peer/Makefile.in, classpath/native/jni/gtk-peer/Makefile.in, classpath/native/Makefile.in, classpath/native/jawt/Makefile.in, classpath/native/fdlibm/Makefile.in, classpath/native/plugin/Makefile.in, classpath/resource/Makefile.in, classpath/scripts/Makefile.in, classpath/tools/Makefile.in, classpath/doc/Makefile.in, classpath/doc/api/Makefile.in, classpath/lib/Makefile.in, classpath/external/Makefile.in, classpath/external/jsr166/Makefile.in, classpath/external/sax/Makefile.in, classpath/external/w3c_dom/Makefile.in, classpath/external/relaxngDatatype/Makefile.in, classpath/include/Makefile.in, classpath/examples/Makefile.in: Regenerate. * classpath/config.guess, classpath/config.sub, classpath/ltmain.sh : Update. * classpath/configure, classpath/depcomp, classpath/missing, classpath/aclocal.m4, classpath/install-sh: Regenerate. * gnu/classpath/Configuration.java (CLASSPATH_VERSION): Now 0.95. * sources.am: Regenerate. * Makefile.in: Regenerate. * Update the .class files and generated CNI header files, add new .class and generated CNI header files. * Remove generated files for removed java source files: classpath/gnu/java/net/BASE64.java, classpath/gnu/java/security/util/Base64.java, classpath/gnu/java/awt/peer/gtk/GThreadMutex.java, classpath/gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java, classpath/gnu/java/awt/font/autofit/Scaler.java, classpath/gnu/classpath/jdwp/util/Value.java, classpath/gnu/javax/net/ssl/Base64.java. * Remove empty directories. * Makefile.am(nat_source_files): Add natVMOperatingSystemMXBeanImpl.cc. * java/lang/Class.java(setAccessible): Merge from classpath. * java/util/Locale.java: Remove. * gnu/java/lang/management/VMOperatingSystemMXBeanImpl.java, gnu/java/lang/management/natVMOperatingSystemMXBeanImpl.cc: New. * gcj/javaprims.h: Update class declarations. * scripts/classes.pl: Update usage. * HACKING: Mention to build all peers. From-SVN: r125302
This commit is contained in:
parent
af333b9a7f
commit
e1bea0c068
2951 changed files with 80982 additions and 68583 deletions
|
@ -213,9 +213,7 @@ class AttributedStringIterator implements AttributedCharacterIterator
|
|||
Iterator iterator = attributeSet.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
// Qualified name is a workaround for a gcj 4.0 bug.
|
||||
AttributedCharacterIterator.Attribute attributeKey
|
||||
= (AttributedCharacterIterator.Attribute) iterator.next();
|
||||
Attribute attributeKey = (Attribute) iterator.next();
|
||||
Object v1 = runValues.get(attributeKey);
|
||||
Object v2 = getAttribute(attributeKey, limit + 1);
|
||||
boolean changed = false;
|
||||
|
@ -298,9 +296,7 @@ class AttributedStringIterator implements AttributedCharacterIterator
|
|||
Iterator iterator = attributeSet.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
// Qualified name is a workaround for a gcj 4.0 bug.
|
||||
AttributedCharacterIterator.Attribute attributeKey
|
||||
= (AttributedCharacterIterator.Attribute) iterator.next();
|
||||
Attribute attributeKey = (Attribute) iterator.next();
|
||||
Object v1 = runValues.get(attributeKey);
|
||||
Object v2 = getAttribute(attributeKey, prev);
|
||||
boolean changed = false;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* BreakIterator.java -- Breaks text into elements
|
||||
Copyright (C) 1998, 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2001, 2004, 2005, 2007
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -38,9 +39,19 @@ exception statement from your version. */
|
|||
|
||||
package java.text;
|
||||
|
||||
import gnu.java.locale.LocaleHelper;
|
||||
|
||||
import gnu.java.text.CharacterBreakIterator;
|
||||
import gnu.java.text.LineBreakIterator;
|
||||
import gnu.java.text.SentenceBreakIterator;
|
||||
import gnu.java.text.WordBreakIterator;
|
||||
|
||||
import java.text.spi.BreakIteratorProvider;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* This class iterates over text elements such as words, lines, sentences,
|
||||
|
@ -179,19 +190,34 @@ public abstract class BreakIterator implements Cloneable
|
|||
|
||||
/**
|
||||
* This method returns an instance of <code>BreakIterator</code> that will
|
||||
* iterate over characters as defined in the specified locale. If the
|
||||
* desired locale is not available, the default locale is used.
|
||||
* iterate over characters as defined in the specified locale.
|
||||
*
|
||||
* @param locale The desired locale.
|
||||
*
|
||||
* @return A <code>BreakIterator</code> instance for the default locale.
|
||||
* @return A <code>BreakIterator</code> instance for the specified locale.
|
||||
*/
|
||||
public static BreakIterator getCharacterInstance (Locale locale)
|
||||
{
|
||||
BreakIterator r = getInstance ("CharacterIterator", locale);
|
||||
if (r == null)
|
||||
r = new gnu.java.text.CharacterBreakIterator ();
|
||||
return r;
|
||||
BreakIterator r = getInstance("CharacterIterator", locale);
|
||||
if (r != null)
|
||||
return r;
|
||||
for (BreakIteratorProvider p :
|
||||
ServiceLoader.load(BreakIteratorProvider.class))
|
||||
{
|
||||
for (Locale loc : p.getAvailableLocales())
|
||||
{
|
||||
if (loc.equals(locale))
|
||||
{
|
||||
BreakIterator bi = p.getCharacterInstance(locale);
|
||||
if (bi != null)
|
||||
return bi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (locale.equals(Locale.ROOT))
|
||||
return new CharacterBreakIterator();
|
||||
return getCharacterInstance(LocaleHelper.getFallbackLocale(locale));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,8 +233,7 @@ public abstract class BreakIterator implements Cloneable
|
|||
|
||||
/**
|
||||
* This method returns an instance of <code>BreakIterator</code> that will
|
||||
* iterate over line breaks as defined in the specified locale. If the
|
||||
* desired locale is not available, the default locale is used.
|
||||
* iterate over line breaks as defined in the specified locale.
|
||||
*
|
||||
* @param locale The desired locale.
|
||||
*
|
||||
|
@ -217,9 +242,25 @@ public abstract class BreakIterator implements Cloneable
|
|||
public static BreakIterator getLineInstance (Locale locale)
|
||||
{
|
||||
BreakIterator r = getInstance ("LineIterator", locale);
|
||||
if (r == null)
|
||||
r = new gnu.java.text.LineBreakIterator ();
|
||||
return r;
|
||||
if (r != null)
|
||||
return r;
|
||||
for (BreakIteratorProvider p :
|
||||
ServiceLoader.load(BreakIteratorProvider.class))
|
||||
{
|
||||
for (Locale loc : p.getAvailableLocales())
|
||||
{
|
||||
if (loc.equals(locale))
|
||||
{
|
||||
BreakIterator bi = p.getLineInstance(locale);
|
||||
if (bi != null)
|
||||
return bi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (locale.equals(Locale.ROOT))
|
||||
return new LineBreakIterator();
|
||||
return getLineInstance(LocaleHelper.getFallbackLocale(locale));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,8 +276,7 @@ public abstract class BreakIterator implements Cloneable
|
|||
|
||||
/**
|
||||
* This method returns an instance of <code>BreakIterator</code> that will
|
||||
* iterate over sentences as defined in the specified locale. If the
|
||||
* desired locale is not available, the default locale is used.
|
||||
* iterate over sentences as defined in the specified locale.
|
||||
*
|
||||
* @param locale The desired locale.
|
||||
*
|
||||
|
@ -245,9 +285,25 @@ public abstract class BreakIterator implements Cloneable
|
|||
public static BreakIterator getSentenceInstance (Locale locale)
|
||||
{
|
||||
BreakIterator r = getInstance ("SentenceIterator", locale);
|
||||
if (r == null)
|
||||
r = new gnu.java.text.SentenceBreakIterator ();
|
||||
return r;
|
||||
if (r != null)
|
||||
return r;
|
||||
for (BreakIteratorProvider p :
|
||||
ServiceLoader.load(BreakIteratorProvider.class))
|
||||
{
|
||||
for (Locale loc : p.getAvailableLocales())
|
||||
{
|
||||
if (loc.equals(locale))
|
||||
{
|
||||
BreakIterator bi = p.getSentenceInstance(locale);
|
||||
if (bi != null)
|
||||
return bi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (locale.equals(Locale.ROOT))
|
||||
return new SentenceBreakIterator();
|
||||
return getSentenceInstance(LocaleHelper.getFallbackLocale(locale));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -271,8 +327,7 @@ public abstract class BreakIterator implements Cloneable
|
|||
|
||||
/**
|
||||
* This method returns an instance of <code>BreakIterator</code> that will
|
||||
* iterate over words as defined in the specified locale. If the
|
||||
* desired locale is not available, the default locale is used.
|
||||
* iterate over words as defined in the specified locale.
|
||||
*
|
||||
* @param locale The desired locale.
|
||||
*
|
||||
|
@ -281,9 +336,25 @@ public abstract class BreakIterator implements Cloneable
|
|||
public static BreakIterator getWordInstance (Locale locale)
|
||||
{
|
||||
BreakIterator r = getInstance ("WordIterator", locale);
|
||||
if (r == null)
|
||||
r = new gnu.java.text.WordBreakIterator ();
|
||||
return r;
|
||||
if (r != null)
|
||||
return r;
|
||||
for (BreakIteratorProvider p :
|
||||
ServiceLoader.load(BreakIteratorProvider.class))
|
||||
{
|
||||
for (Locale loc : p.getAvailableLocales())
|
||||
{
|
||||
if (loc.equals(locale))
|
||||
{
|
||||
BreakIterator bi = p.getWordInstance(locale);
|
||||
if (bi != null)
|
||||
return bi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (locale.equals(Locale.ROOT))
|
||||
return new WordBreakIterator();
|
||||
return getWordInstance(LocaleHelper.getFallbackLocale(locale));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,10 +40,13 @@ package java.text;
|
|||
|
||||
import gnu.java.locale.LocaleHelper;
|
||||
|
||||
import java.text.spi.CollatorProvider;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* This class is the abstract superclass of classes which perform
|
||||
|
@ -285,7 +288,8 @@ public abstract class Collator implements Comparator<Object>, Cloneable
|
|||
/**
|
||||
* This method returns an instance of <code>Collator</code> for the
|
||||
* specified locale. If no <code>Collator</code> exists for the desired
|
||||
* locale, a <code>Collator</code> for the default locale will be returned.
|
||||
* locale, the fallback procedure described in
|
||||
* {@link java.util.spi.LocaleServiceProvider} is invoked.
|
||||
*
|
||||
* @param loc The desired locale to load a <code>Collator</code> for.
|
||||
*
|
||||
|
@ -293,27 +297,51 @@ public abstract class Collator implements Comparator<Object>, Cloneable
|
|||
*/
|
||||
public static Collator getInstance (Locale loc)
|
||||
{
|
||||
ResourceBundle res;
|
||||
String pattern;
|
||||
try
|
||||
{
|
||||
res = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
|
||||
loc, ClassLoader.getSystemClassLoader());
|
||||
pattern = res.getString("collation_rules");
|
||||
ResourceBundle res =
|
||||
ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
|
||||
loc, ClassLoader.getSystemClassLoader());
|
||||
return new RuleBasedCollator(res.getString("collation_rules"));
|
||||
}
|
||||
catch (MissingResourceException x)
|
||||
{
|
||||
pattern = "<0<1<2<3<4<5<6<7<8<9<A,a<b,B<c,C<d,D<e,E<f,F<g,G<h,H<i,I<j,J<k,K" +
|
||||
"<l,L<m,M<n,N<o,O<p,P<q,Q<r,R<s,S<t,T<u,U<v,V<w,W<x,X<y,Y<z,Z";
|
||||
}
|
||||
try
|
||||
{
|
||||
return new RuleBasedCollator (pattern);
|
||||
/* This means runtime support for the locale
|
||||
* is not available, so we check providers. */
|
||||
}
|
||||
catch (ParseException x)
|
||||
{
|
||||
throw (InternalError)new InternalError().initCause(x);
|
||||
}
|
||||
for (CollatorProvider p : ServiceLoader.load(CollatorProvider.class))
|
||||
{
|
||||
for (Locale l : p.getAvailableLocales())
|
||||
{
|
||||
if (l.equals(loc))
|
||||
{
|
||||
Collator c = p.getInstance(loc);
|
||||
if (c != null)
|
||||
return c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (loc.equals(Locale.ROOT))
|
||||
{
|
||||
try
|
||||
{
|
||||
return new RuleBasedCollator("<0<1<2<3<4<5<6<7<8<9<A,a<b,B<c," +
|
||||
"C<d,D<e,E<f,F<g,G<h,H<i,I<j,J<k,K" +
|
||||
"<l,L<m,M<n,N<o,O<p,P<q,Q<r,R<s,S<t,"+
|
||||
"T<u,U<v,V<w,W<x,X<y,Y<z,Z");
|
||||
}
|
||||
catch (ParseException x)
|
||||
{
|
||||
throw (InternalError)new InternalError().initCause(x);
|
||||
}
|
||||
}
|
||||
return getInstance(LocaleHelper.getFallbackLocale(loc));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,12 +39,17 @@ exception statement from your version. */
|
|||
|
||||
package java.text;
|
||||
|
||||
import gnu.java.locale.LocaleHelper;
|
||||
|
||||
import java.text.spi.DateFormatProvider;
|
||||
|
||||
import java.io.InvalidObjectException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
|
@ -550,17 +555,14 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
private static DateFormat computeInstance (int dateStyle, int timeStyle,
|
||||
Locale loc, boolean use_date,
|
||||
boolean use_time)
|
||||
throws MissingResourceException
|
||||
{
|
||||
ResourceBundle res;
|
||||
try
|
||||
{
|
||||
res = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
|
||||
loc, ClassLoader.getSystemClassLoader());
|
||||
}
|
||||
catch (MissingResourceException x)
|
||||
{
|
||||
res = null;
|
||||
}
|
||||
if (loc.equals(Locale.ROOT))
|
||||
return computeDefault(dateStyle,timeStyle,use_date,use_time);
|
||||
|
||||
ResourceBundle res =
|
||||
ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
|
||||
loc, ClassLoader.getSystemClassLoader());
|
||||
|
||||
String pattern = null;
|
||||
if (use_date)
|
||||
|
@ -642,6 +644,59 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
return new SimpleDateFormat (pattern, loc);
|
||||
}
|
||||
|
||||
private static DateFormat computeDefault (int dateStyle, int timeStyle,
|
||||
boolean use_date, boolean use_time)
|
||||
{
|
||||
String pattern = null;
|
||||
if (use_date)
|
||||
{
|
||||
switch (dateStyle)
|
||||
{
|
||||
case FULL:
|
||||
pattern = "EEEE MMMM d, yyyy G";
|
||||
break;
|
||||
case LONG:
|
||||
pattern = "MMMM d, yyyy";
|
||||
break;
|
||||
case MEDIUM:
|
||||
pattern = "d-MMM-yy";
|
||||
break;
|
||||
case SHORT:
|
||||
pattern = "M/d/yy";
|
||||
default:
|
||||
throw new IllegalArgumentException ();
|
||||
}
|
||||
}
|
||||
|
||||
if (use_time)
|
||||
{
|
||||
if (pattern == null)
|
||||
pattern = "";
|
||||
else
|
||||
pattern += " ";
|
||||
|
||||
switch (timeStyle)
|
||||
{
|
||||
case FULL:
|
||||
pattern += "h:mm:ss;S 'o''clock' a z";
|
||||
break;
|
||||
case LONG:
|
||||
pattern += "h:mm:ss a z";
|
||||
break;
|
||||
case MEDIUM:
|
||||
pattern += "h:mm:ss a";
|
||||
break;
|
||||
case SHORT:
|
||||
pattern += "h:mm a";
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException ();
|
||||
}
|
||||
}
|
||||
|
||||
return new SimpleDateFormat (pattern, Locale.ROOT);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns an instance of <code>DateFormat</code> that will
|
||||
* format using the default formatting style for dates.
|
||||
|
@ -678,7 +733,29 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
*/
|
||||
public static final DateFormat getDateInstance (int style, Locale loc)
|
||||
{
|
||||
return computeInstance (style, loc, true, false);
|
||||
try
|
||||
{
|
||||
return computeInstance (style, loc, true, false);
|
||||
}
|
||||
catch (MissingResourceException e)
|
||||
{
|
||||
for (DateFormatProvider p :
|
||||
ServiceLoader.load(DateFormatProvider.class))
|
||||
{
|
||||
for (Locale l : p.getAvailableLocales())
|
||||
{
|
||||
if (l.equals(loc))
|
||||
{
|
||||
DateFormat df = p.getDateInstance(style, loc);
|
||||
if (df != null)
|
||||
return df;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getDateInstance(style,
|
||||
LocaleHelper.getFallbackLocale(loc));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -717,7 +794,30 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
int timeStyle,
|
||||
Locale loc)
|
||||
{
|
||||
return computeInstance (dateStyle, timeStyle, loc, true, true);
|
||||
try
|
||||
{
|
||||
return computeInstance (dateStyle, timeStyle, loc, true, true);
|
||||
}
|
||||
catch (MissingResourceException e)
|
||||
{
|
||||
for (DateFormatProvider p :
|
||||
ServiceLoader.load(DateFormatProvider.class))
|
||||
{
|
||||
for (Locale l : p.getAvailableLocales())
|
||||
{
|
||||
if (l.equals(loc))
|
||||
{
|
||||
DateFormat df = p.getDateTimeInstance(dateStyle,
|
||||
timeStyle, loc);
|
||||
if (df != null)
|
||||
return df;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getDateTimeInstance(dateStyle, timeStyle,
|
||||
LocaleHelper.getFallbackLocale(loc));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -779,7 +879,29 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
*/
|
||||
public static final DateFormat getTimeInstance (int style, Locale loc)
|
||||
{
|
||||
return computeInstance (style, loc, false, true);
|
||||
try
|
||||
{
|
||||
return computeInstance (style, loc, false, true);
|
||||
}
|
||||
catch (MissingResourceException e)
|
||||
{
|
||||
for (DateFormatProvider p :
|
||||
ServiceLoader.load(DateFormatProvider.class))
|
||||
{
|
||||
for (Locale l : p.getAvailableLocales())
|
||||
{
|
||||
if (l.equals(loc))
|
||||
{
|
||||
DateFormat df = p.getTimeInstance(style, loc);
|
||||
if (df != null)
|
||||
return df;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getTimeInstance(style,
|
||||
LocaleHelper.getFallbackLocale(loc));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* DateFormatSymbols.java -- Format over a range of numbers
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -38,14 +38,26 @@ exception statement from your version. */
|
|||
|
||||
package java.text;
|
||||
|
||||
import gnu.java.locale.LocaleHelper;
|
||||
|
||||
import java.text.spi.DateFormatSymbolsProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import java.util.spi.TimeZoneNameProvider;
|
||||
|
||||
/**
|
||||
* This class acts as container for locale specific date/time formatting
|
||||
* information such as the days of the week and the months of the year.
|
||||
*
|
||||
* @author Per Bothner (bothner@cygnus.com)
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @date October 24, 1998.
|
||||
*/
|
||||
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
|
||||
|
@ -60,6 +72,15 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
String[] shortMonths;
|
||||
String[] shortWeekdays;
|
||||
String[] weekdays;
|
||||
|
||||
/**
|
||||
* The timezone strings supplied by the runtime.
|
||||
*/
|
||||
private String[][] runtimeZoneStrings;
|
||||
|
||||
/**
|
||||
* Custom timezone strings supplied by {@link #setZoneStrings()}.
|
||||
*/
|
||||
private String[][] zoneStrings;
|
||||
|
||||
private static final long serialVersionUID = -5987973545549424702L;
|
||||
|
@ -83,22 +104,52 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
return res.getString(name).split("\u00ae");
|
||||
}
|
||||
|
||||
private String[][] getZoneStrings(ResourceBundle res)
|
||||
private String[][] getZoneStrings(ResourceBundle res, Locale locale)
|
||||
{
|
||||
List<String[]> allZones = new ArrayList<String[]>();
|
||||
try
|
||||
{
|
||||
int index = 0;
|
||||
String data = res.getString("zoneStrings");
|
||||
String[] zones = data.split("\u00a9");
|
||||
String[][] array = new String[zones.length][];
|
||||
for (int a = 0; a < zones.length; ++a)
|
||||
array[a] = zones[a].split("\u00ae");
|
||||
return array;
|
||||
allZones.add(zones[a].split("\u00ae"));
|
||||
}
|
||||
catch (MissingResourceException e)
|
||||
{
|
||||
return new String[0][];
|
||||
/* This means runtime support for the locale
|
||||
* is not available, so we just include providers. */
|
||||
}
|
||||
for (TimeZoneNameProvider p :
|
||||
ServiceLoader.load(TimeZoneNameProvider.class))
|
||||
{
|
||||
for (Locale loc : p.getAvailableLocales())
|
||||
{
|
||||
if (loc.equals(locale))
|
||||
{
|
||||
for (String id : TimeZone.getAvailableIDs())
|
||||
{
|
||||
String[] z = new String[5];
|
||||
z[0] = id;
|
||||
z[1] = p.getDisplayName(id, false,
|
||||
TimeZone.LONG,
|
||||
locale);
|
||||
z[2] = p.getDisplayName(id, false,
|
||||
TimeZone.SHORT,
|
||||
locale);
|
||||
z[3] = p.getDisplayName(id, true,
|
||||
TimeZone.LONG,
|
||||
locale);
|
||||
z[4] = p.getDisplayName(id, true,
|
||||
TimeZone.SHORT,
|
||||
locale);
|
||||
allZones.add(z);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return allZones.toArray(new String[allZones.size()][]);
|
||||
}
|
||||
|
||||
private String[] formatsForKey(ResourceBundle res, String key)
|
||||
|
@ -114,11 +165,18 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
/**
|
||||
* This method initializes a new instance of <code>DateFormatSymbols</code>
|
||||
* by loading the date format information for the specified locale.
|
||||
* This constructor only obtains instances using the runtime's resources;
|
||||
* to also include {@link java.text.spi.DateFormatSymbolsProvider} instances,
|
||||
* call {@link #getInstance(java.util.Locale)} instead.
|
||||
*
|
||||
* @param locale The locale for which date formatting symbols should
|
||||
* be loaded.
|
||||
* @throws MissingResourceException if the resources for the specified
|
||||
* locale could not be found or loaded.
|
||||
* @see #getInstance(java.util.Locale)
|
||||
*/
|
||||
public DateFormatSymbols (Locale locale) throws MissingResourceException
|
||||
public DateFormatSymbols (Locale locale)
|
||||
throws MissingResourceException
|
||||
{
|
||||
ResourceBundle res
|
||||
= ResourceBundle.getBundle("gnu.java.locale.LocaleInformation", locale,
|
||||
|
@ -131,16 +189,23 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
shortMonths = getStringArray(res, "shortMonths");
|
||||
shortWeekdays = getStringArray(res, "shortWeekdays");
|
||||
weekdays = getStringArray(res, "weekdays");
|
||||
zoneStrings = getZoneStrings(res);
|
||||
runtimeZoneStrings = getZoneStrings(res, locale);
|
||||
dateFormats = formatsForKey(res, "DateFormat");
|
||||
timeFormats = formatsForKey(res, "TimeFormat");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method loads the format symbol information for the default
|
||||
* locale.
|
||||
* locale. This constructor only obtains instances using the runtime's resources;
|
||||
* to also include {@link java.text.spi.DateFormatSymbolsProvider} instances,
|
||||
* call {@link #getInstance()} instead.
|
||||
*
|
||||
* @throws MissingResourceException if the resources for the default
|
||||
* locale could not be found or loaded.
|
||||
* @see #getInstance()
|
||||
*/
|
||||
public DateFormatSymbols () throws MissingResourceException
|
||||
public DateFormatSymbols()
|
||||
throws MissingResourceException
|
||||
{
|
||||
this (Locale.getDefault());
|
||||
}
|
||||
|
@ -274,12 +339,21 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
* <li>3 - The long name of the time zone (daylight savings time).</li>
|
||||
* <li>4 - the short name of the time zone (daylight savings time).</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* If {@link #setZoneStrings(String[][])} has been called, then the value
|
||||
* passed to this will be returned. Otherwise the returned array contains
|
||||
* zone names provided by the runtime environment and any
|
||||
* {@link java.util.spi.TimeZoneProvider} instances.
|
||||
* </p>
|
||||
*
|
||||
* @return The list of time zone display strings.
|
||||
* @see #setZoneStrings(String[][])
|
||||
*/
|
||||
public String[] [] getZoneStrings ()
|
||||
public String[][] getZoneStrings()
|
||||
{
|
||||
return zoneStrings;
|
||||
if (zoneStrings != null)
|
||||
return zoneStrings;
|
||||
return runtimeZoneStrings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -537,4 +611,65 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
^ hashCode(weekdays)
|
||||
^ hashCode(zoneStrings));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link DateFormatSymbols} instance for the
|
||||
* default locale obtained from either the runtime itself
|
||||
* or one of the installed
|
||||
* {@link java.text.spi.DateFormatSymbolsProvider} instances.
|
||||
* This is equivalent to calling
|
||||
* <code>getInstance(Locale.getDefault())</code>.
|
||||
*
|
||||
* @return a {@link DateFormatSymbols} instance for the default
|
||||
* locale.
|
||||
* @since 1.6
|
||||
*/
|
||||
public static final DateFormatSymbols getInstance()
|
||||
{
|
||||
return getInstance(Locale.getDefault());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link DateFormatSymbols} instance for the
|
||||
* specified locale obtained from either the runtime itself
|
||||
* or one of the installed
|
||||
* {@link java.text.spi.DateFormatSymbolsProvider} instances.
|
||||
*
|
||||
* @param locale the locale for which an instance should be
|
||||
* returned.
|
||||
* @return a {@link DateFormatSymbols} instance for the specified
|
||||
* locale.
|
||||
* @throws NullPointerException if <code>locale</code> is
|
||||
* <code>null</code>.
|
||||
* @since 1.6
|
||||
*/
|
||||
public static final DateFormatSymbols getInstance(Locale locale)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateFormatSymbols syms = new DateFormatSymbols(locale);
|
||||
return syms;
|
||||
}
|
||||
catch (MissingResourceException e)
|
||||
{
|
||||
/* This means runtime support for the locale
|
||||
* is not available, so we check providers. */
|
||||
}
|
||||
for (DateFormatSymbolsProvider p :
|
||||
ServiceLoader.load(DateFormatSymbolsProvider.class))
|
||||
{
|
||||
for (Locale loc : p.getAvailableLocales())
|
||||
{
|
||||
if (loc.equals(locale))
|
||||
{
|
||||
DateFormatSymbols syms = p.getInstance(locale);
|
||||
if (syms != null)
|
||||
return syms;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getInstance(LocaleHelper.getFallbackLocale(locale));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -439,8 +439,8 @@ public class DecimalFormat extends NumberFormat
|
|||
FieldPosition pos = (FieldPosition) attributes.get(i);
|
||||
Format.Field attribute = pos.getFieldAttribute();
|
||||
|
||||
as.addAttribute(attribute, attribute, pos.getBeginIndex(), pos
|
||||
.getEndIndex());
|
||||
as.addAttribute(attribute, attribute, pos.getBeginIndex(),
|
||||
pos.getEndIndex());
|
||||
}
|
||||
|
||||
// return the CharacterIterator from AttributedString
|
||||
|
@ -659,6 +659,7 @@ public class DecimalFormat extends NumberFormat
|
|||
// correct the size of the end parsing flag
|
||||
int len = str.length();
|
||||
if (len < stop) stop = len;
|
||||
char groupingSeparator = symbols.getGroupingSeparator();
|
||||
|
||||
int i = start;
|
||||
while (i < stop)
|
||||
|
@ -672,6 +673,7 @@ public class DecimalFormat extends NumberFormat
|
|||
}
|
||||
else if (this.parseIntegerOnly)
|
||||
{
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
else if (ch == decimalSeparator)
|
||||
|
@ -688,8 +690,19 @@ public class DecimalFormat extends NumberFormat
|
|||
if (inExponent)
|
||||
number.append(ch);
|
||||
else
|
||||
break;
|
||||
{
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!groupingUsed || ch != groupingSeparator)
|
||||
{
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2nd special case: infinity
|
||||
|
@ -723,25 +736,25 @@ public class DecimalFormat extends NumberFormat
|
|||
|
||||
// now we have to check the suffix, done here after number parsing
|
||||
// or the index will not be updated correctly...
|
||||
boolean isNegativeSuffix = str.endsWith(this.negativeSuffix);
|
||||
boolean isPositiveSuffix = str.endsWith(this.positiveSuffix);
|
||||
boolean hasNegativeSuffix = str.endsWith(this.negativeSuffix);
|
||||
boolean hasPositiveSuffix = str.endsWith(this.positiveSuffix);
|
||||
boolean positiveEqualsNegative = negativeSuffix.equals(positiveSuffix);
|
||||
|
||||
positiveLen = positiveSuffix.length();
|
||||
negativeLen = negativeSuffix.length();
|
||||
|
||||
if (isNegative && !isNegativeSuffix)
|
||||
if (isNegative && !hasNegativeSuffix)
|
||||
{
|
||||
pos.setErrorIndex(i);
|
||||
return null;
|
||||
}
|
||||
else if (isNegativeSuffix &&
|
||||
else if (hasNegativeSuffix &&
|
||||
!positiveEqualsNegative &&
|
||||
(negativeLen > positiveLen))
|
||||
{
|
||||
isNegative = true;
|
||||
}
|
||||
else if (!isPositiveSuffix)
|
||||
else if (!hasPositiveSuffix)
|
||||
{
|
||||
pos.setErrorIndex(i);
|
||||
return null;
|
||||
|
@ -749,7 +762,7 @@ public class DecimalFormat extends NumberFormat
|
|||
|
||||
if (isNegative) number.insert(0, '-');
|
||||
|
||||
pos.setIndex(i - 1);
|
||||
pos.setIndex(i);
|
||||
|
||||
// now we handle the return type
|
||||
BigDecimal bigDecimal = new BigDecimal(number.toString());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* DecimalFormatSymbols.java -- Format symbols used by DecimalFormat
|
||||
Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2000, 2001, 2004, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -38,13 +38,19 @@ exception statement from your version. */
|
|||
|
||||
package java.text;
|
||||
|
||||
import gnu.java.locale.LocaleHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.text.spi.DecimalFormatSymbolsProvider;
|
||||
|
||||
import java.util.Currency;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* This class is a container for the symbols used by
|
||||
|
@ -80,6 +86,11 @@ public class DecimalFormatSymbols implements Cloneable, Serializable
|
|||
/**
|
||||
* This method initializes a new instance of
|
||||
* <code>DecimalFormatSymbols</code> for the default locale.
|
||||
* This constructor only obtains instances using the runtime's resources;
|
||||
* to also include {@link java.text.spi.DateFormatSymbolsProvider} instances,
|
||||
* call {@link #getInstance()} instead.
|
||||
*
|
||||
* @see #getInstance()
|
||||
*/
|
||||
public DecimalFormatSymbols ()
|
||||
{
|
||||
|
@ -137,18 +148,19 @@ public class DecimalFormatSymbols implements Cloneable, Serializable
|
|||
* international currency symbol will be set to the strings "?"
|
||||
* and "XXX" respectively. This generally happens with language
|
||||
* locales (those with no specified country), such as
|
||||
* <code>Locale.ENGLISH</code>.
|
||||
* <code>Locale.ENGLISH</code>. This constructor only obtains
|
||||
* instances using the runtime's resources; to also include
|
||||
* {@link java.text.spi.DecimalFormatSymbolsProvider} instances,
|
||||
* call {@link #getInstance(java.util.Locale)} instead.
|
||||
*
|
||||
* @param loc The local to load symbols for.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @see #getInstance(java.util.Locale)
|
||||
*/
|
||||
public DecimalFormatSymbols (Locale loc)
|
||||
{
|
||||
ResourceBundle res;
|
||||
|
||||
currency = Currency.getInstance("XXX");
|
||||
currencySymbol = "?";
|
||||
intlCurrencySymbol = "XXX";
|
||||
try
|
||||
{
|
||||
res = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
|
||||
|
@ -158,6 +170,9 @@ public class DecimalFormatSymbols implements Cloneable, Serializable
|
|||
{
|
||||
res = null;
|
||||
}
|
||||
currency = Currency.getInstance("XXX");
|
||||
currencySymbol = "?";
|
||||
intlCurrencySymbol = "XXX";
|
||||
try
|
||||
{
|
||||
Currency localeCurrency = Currency.getInstance(loc);
|
||||
|
@ -684,4 +699,68 @@ public class DecimalFormatSymbols implements Cloneable, Serializable
|
|||
|
||||
serialVersionOnStream = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link DecimalFormatSymbols} instance for the
|
||||
* default locale obtained from either the runtime itself
|
||||
* or one of the installed
|
||||
* {@link java.text.spi.DecimalFormatSymbolsProvider} instances.
|
||||
* This is equivalent to calling
|
||||
* <code>getInstance(Locale.getDefault())</code>.
|
||||
*
|
||||
* @return a {@link DecimalFormatSymbols} instance for the default
|
||||
* locale.
|
||||
* @since 1.6
|
||||
*/
|
||||
public static final DecimalFormatSymbols getInstance()
|
||||
{
|
||||
return getInstance(Locale.getDefault());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link DecimalFormatSymbols} instance for the
|
||||
* specified locale obtained from either the runtime itself
|
||||
* or one of the installed
|
||||
* {@link java.text.spi.DecimalFormatSymbolsProvider} instances.
|
||||
*
|
||||
* @param locale the locale for which an instance should be
|
||||
* returned.
|
||||
* @return a {@link DecimalFormatSymbols} instance for the specified
|
||||
* locale.
|
||||
* @throws NullPointerException if <code>locale</code> is
|
||||
* <code>null</code>.
|
||||
* @since 1.6
|
||||
*/
|
||||
public static final DecimalFormatSymbols getInstance(Locale locale)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!locale.equals(Locale.ROOT))
|
||||
ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
|
||||
locale,
|
||||
ClassLoader.getSystemClassLoader());
|
||||
return new DecimalFormatSymbols(locale);
|
||||
}
|
||||
catch (MissingResourceException x)
|
||||
{
|
||||
/* This means runtime support for the locale
|
||||
* is not available, so we check providers. */
|
||||
}
|
||||
for (DecimalFormatSymbolsProvider p :
|
||||
ServiceLoader.load(DecimalFormatSymbolsProvider.class))
|
||||
{
|
||||
for (Locale loc : p.getAvailableLocales())
|
||||
{
|
||||
if (loc.equals(locale))
|
||||
{
|
||||
DecimalFormatSymbols syms = p.getInstance(locale);
|
||||
if (syms != null)
|
||||
return syms;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getInstance(LocaleHelper.getFallbackLocale(locale));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,70 +82,72 @@ public class MessageFormat extends Format
|
|||
// Recompute the locale-based formatter.
|
||||
void setLocale (Locale loc)
|
||||
{
|
||||
if (type == null)
|
||||
;
|
||||
else if (type.equals("number"))
|
||||
if (type != null)
|
||||
{
|
||||
formatClass = java.lang.Number.class;
|
||||
if (type.equals("number"))
|
||||
{
|
||||
formatClass = java.lang.Number.class;
|
||||
|
||||
if (style == null)
|
||||
format = NumberFormat.getInstance(loc);
|
||||
else if (style.equals("currency"))
|
||||
format = NumberFormat.getCurrencyInstance(loc);
|
||||
else if (style.equals("percent"))
|
||||
format = NumberFormat.getPercentInstance(loc);
|
||||
else if (style.equals("integer"))
|
||||
{
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(loc);
|
||||
nf.setMaximumFractionDigits(0);
|
||||
nf.setGroupingUsed(false);
|
||||
format = nf;
|
||||
}
|
||||
else
|
||||
{
|
||||
format = NumberFormat.getNumberInstance(loc);
|
||||
DecimalFormat df = (DecimalFormat) format;
|
||||
df.applyPattern(style);
|
||||
}
|
||||
}
|
||||
else if (type.equals("time") || type.equals("date"))
|
||||
{
|
||||
formatClass = java.util.Date.class;
|
||||
if (style == null)
|
||||
format = NumberFormat.getInstance(loc);
|
||||
else if (style.equals("currency"))
|
||||
format = NumberFormat.getCurrencyInstance(loc);
|
||||
else if (style.equals("percent"))
|
||||
format = NumberFormat.getPercentInstance(loc);
|
||||
else if (style.equals("integer"))
|
||||
{
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(loc);
|
||||
nf.setMaximumFractionDigits(0);
|
||||
nf.setGroupingUsed(false);
|
||||
format = nf;
|
||||
}
|
||||
else
|
||||
{
|
||||
format = NumberFormat.getNumberInstance(loc);
|
||||
DecimalFormat df = (DecimalFormat) format;
|
||||
df.applyPattern(style);
|
||||
}
|
||||
}
|
||||
else if (type.equals("time") || type.equals("date"))
|
||||
{
|
||||
formatClass = java.util.Date.class;
|
||||
|
||||
int val = DateFormat.DEFAULT;
|
||||
boolean styleIsPattern = false;
|
||||
if (style == null)
|
||||
;
|
||||
else if (style.equals("short"))
|
||||
val = DateFormat.SHORT;
|
||||
else if (style.equals("medium"))
|
||||
val = DateFormat.MEDIUM;
|
||||
else if (style.equals("long"))
|
||||
val = DateFormat.LONG;
|
||||
else if (style.equals("full"))
|
||||
val = DateFormat.FULL;
|
||||
else
|
||||
styleIsPattern = true;
|
||||
int val = DateFormat.DEFAULT;
|
||||
boolean styleIsPattern = false;
|
||||
if (style != null)
|
||||
{
|
||||
if (style.equals("short"))
|
||||
val = DateFormat.SHORT;
|
||||
else if (style.equals("medium"))
|
||||
val = DateFormat.MEDIUM;
|
||||
else if (style.equals("long"))
|
||||
val = DateFormat.LONG;
|
||||
else if (style.equals("full"))
|
||||
val = DateFormat.FULL;
|
||||
else
|
||||
styleIsPattern = true;
|
||||
}
|
||||
|
||||
if (type.equals("time"))
|
||||
format = DateFormat.getTimeInstance(val, loc);
|
||||
else
|
||||
format = DateFormat.getDateInstance(val, loc);
|
||||
|
||||
if (type.equals("time"))
|
||||
format = DateFormat.getTimeInstance(val, loc);
|
||||
else
|
||||
format = DateFormat.getDateInstance(val, loc);
|
||||
if (styleIsPattern)
|
||||
{
|
||||
SimpleDateFormat sdf = (SimpleDateFormat) format;
|
||||
sdf.applyPattern(style);
|
||||
}
|
||||
}
|
||||
else if (type.equals("choice"))
|
||||
{
|
||||
formatClass = java.lang.Number.class;
|
||||
|
||||
if (styleIsPattern)
|
||||
{
|
||||
SimpleDateFormat sdf = (SimpleDateFormat) format;
|
||||
sdf.applyPattern(style);
|
||||
}
|
||||
}
|
||||
else if (type.equals("choice"))
|
||||
{
|
||||
formatClass = java.lang.Number.class;
|
||||
|
||||
if (style == null)
|
||||
throw new
|
||||
IllegalArgumentException ("style required for choice format");
|
||||
format = new ChoiceFormat (style);
|
||||
if (style == null)
|
||||
throw new
|
||||
IllegalArgumentException ("style required for choice format");
|
||||
format = new ChoiceFormat (style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* NumberFormat.java -- Formats and parses numbers
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2007
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -38,14 +39,20 @@ exception statement from your version. */
|
|||
|
||||
package java.text;
|
||||
|
||||
import gnu.java.locale.LocaleHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import java.text.spi.NumberFormatProvider;
|
||||
|
||||
import java.util.Currency;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* This is the abstract superclass of all classes which format and
|
||||
|
@ -309,17 +316,13 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
|
||||
private static NumberFormat computeInstance(Locale loc, String resource,
|
||||
String def)
|
||||
throws MissingResourceException
|
||||
{
|
||||
ResourceBundle res;
|
||||
try
|
||||
{
|
||||
res = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
|
||||
loc, ClassLoader.getSystemClassLoader());
|
||||
}
|
||||
catch (MissingResourceException x)
|
||||
{
|
||||
res = null;
|
||||
}
|
||||
if (loc.equals(Locale.ROOT))
|
||||
return new DecimalFormat(def, DecimalFormatSymbols.getInstance(loc));
|
||||
ResourceBundle res =
|
||||
ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
|
||||
loc, ClassLoader.getSystemClassLoader());
|
||||
String fmt;
|
||||
try
|
||||
{
|
||||
|
@ -329,7 +332,7 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
{
|
||||
fmt = def;
|
||||
}
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols (loc);
|
||||
DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(loc);
|
||||
return new DecimalFormat (fmt, dfs);
|
||||
}
|
||||
|
||||
|
@ -352,11 +355,33 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
*/
|
||||
public static NumberFormat getCurrencyInstance (Locale loc)
|
||||
{
|
||||
NumberFormat format;
|
||||
|
||||
format = computeInstance (loc, "currencyFormat", "\u00A4#,##0.00;(\u00A4#,##0.00)");
|
||||
format.setMaximumFractionDigits(format.getCurrency().getDefaultFractionDigits());
|
||||
return format;
|
||||
try
|
||||
{
|
||||
NumberFormat format;
|
||||
|
||||
format = computeInstance (loc, "currencyFormat",
|
||||
"\u00A4#,##0.00;(\u00A4#,##0.00)");
|
||||
format.setMaximumFractionDigits(format.getCurrency().getDefaultFractionDigits());
|
||||
return format;
|
||||
}
|
||||
catch (MissingResourceException e)
|
||||
{
|
||||
for (NumberFormatProvider p :
|
||||
ServiceLoader.load(NumberFormatProvider.class))
|
||||
{
|
||||
for (Locale l : p.getAvailableLocales())
|
||||
{
|
||||
if (l.equals(loc))
|
||||
{
|
||||
NumberFormat nf = p.getCurrencyInstance(loc);
|
||||
if (nf != null)
|
||||
return nf;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getCurrencyInstance(LocaleHelper.getFallbackLocale(loc));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -456,7 +481,28 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
*/
|
||||
public static NumberFormat getNumberInstance (Locale loc)
|
||||
{
|
||||
return computeInstance (loc, "numberFormat", "#,##0.###");
|
||||
try
|
||||
{
|
||||
return computeInstance (loc, "numberFormat", "#,##0.###");
|
||||
}
|
||||
catch (MissingResourceException e)
|
||||
{
|
||||
for (NumberFormatProvider p :
|
||||
ServiceLoader.load(NumberFormatProvider.class))
|
||||
{
|
||||
for (Locale l : p.getAvailableLocales())
|
||||
{
|
||||
if (l.equals(loc))
|
||||
{
|
||||
NumberFormat nf = p.getNumberInstance(loc);
|
||||
if (nf != null)
|
||||
return nf;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getNumberInstance(LocaleHelper.getFallbackLocale(loc));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -484,10 +530,32 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
*/
|
||||
public static NumberFormat getIntegerInstance(Locale locale)
|
||||
{
|
||||
NumberFormat format = computeInstance (locale, "integerFormat", "#,##0");
|
||||
format.setMaximumFractionDigits(0);
|
||||
format.setParseIntegerOnly (true);
|
||||
return format;
|
||||
try
|
||||
{
|
||||
NumberFormat format = computeInstance (locale,
|
||||
"integerFormat", "#,##0");
|
||||
format.setMaximumFractionDigits(0);
|
||||
format.setParseIntegerOnly (true);
|
||||
return format;
|
||||
}
|
||||
catch (MissingResourceException e)
|
||||
{
|
||||
for (NumberFormatProvider p :
|
||||
ServiceLoader.load(NumberFormatProvider.class))
|
||||
{
|
||||
for (Locale l : p.getAvailableLocales())
|
||||
{
|
||||
if (l.equals(locale))
|
||||
{
|
||||
NumberFormat nf = p.getIntegerInstance(locale);
|
||||
if (nf != null)
|
||||
return nf;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getIntegerInstance(LocaleHelper.getFallbackLocale(locale));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -511,7 +579,28 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
*/
|
||||
public static NumberFormat getPercentInstance (Locale loc)
|
||||
{
|
||||
return computeInstance (loc, "percentFormat", "#,##0%");
|
||||
try
|
||||
{
|
||||
return computeInstance (loc, "percentFormat", "#,##0%");
|
||||
}
|
||||
catch (MissingResourceException e)
|
||||
{
|
||||
for (NumberFormatProvider p :
|
||||
ServiceLoader.load(NumberFormatProvider.class))
|
||||
{
|
||||
for (Locale l : p.getAvailableLocales())
|
||||
{
|
||||
if (l.equals(loc))
|
||||
{
|
||||
NumberFormat nf = p.getPercentInstance(loc);
|
||||
if (nf != null)
|
||||
return nf;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getPercentInstance(LocaleHelper.getFallbackLocale(loc));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1101,11 +1101,21 @@ public class SimpleDateFormat extends DateFormat
|
|||
if (is_numeric)
|
||||
{
|
||||
numberFormat.setMinimumIntegerDigits(fmt_count);
|
||||
if (limit_digits)
|
||||
numberFormat.setMaximumIntegerDigits(fmt_count);
|
||||
if (maybe2DigitYear)
|
||||
index = pos.getIndex();
|
||||
Number n = numberFormat.parse(dateStr, pos);
|
||||
Number n = null;
|
||||
if (limit_digits)
|
||||
{
|
||||
// numberFormat.setMaximumIntegerDigits(fmt_count) may
|
||||
// not work as expected. So we explicitly use substring
|
||||
// of dateStr.
|
||||
int origPos = pos.getIndex();
|
||||
pos.setIndex(0);
|
||||
n = numberFormat.parse(dateStr.substring(origPos, origPos + fmt_count), pos);
|
||||
pos.setIndex(origPos + pos.getIndex());
|
||||
}
|
||||
else
|
||||
n = numberFormat.parse(dateStr, pos);
|
||||
if (pos == null || ! (n instanceof Long))
|
||||
return null;
|
||||
value = n.intValue() + offset;
|
||||
|
|
|
@ -1,220 +0,0 @@
|
|||
# This property file contains dependencies of classes, methods, and
|
||||
# field on other methods or classes.
|
||||
#
|
||||
# Syntax:
|
||||
#
|
||||
# <used>: <needed 1> [... <needed N>]
|
||||
#
|
||||
# means that when <used> is included, <needed 1> (... <needed N>) must
|
||||
# be included as well.
|
||||
#
|
||||
# <needed X> and <used> are of the form
|
||||
#
|
||||
# <class.methodOrField(signature)>
|
||||
#
|
||||
# or just
|
||||
#
|
||||
# <class>
|
||||
#
|
||||
# Within dependencies, variables can be used. A variable is defined as
|
||||
# follows:
|
||||
#
|
||||
# {variable}: value1 value2 ... value<n>
|
||||
#
|
||||
# variables can be used on the right side of dependencies as follows:
|
||||
#
|
||||
# <used>: com.bla.blu.{variable}.Class.m()V
|
||||
#
|
||||
# The use of the variable will expand to <n> dependencies of the form
|
||||
#
|
||||
# <used>: com.bla.blu.value1.Class.m()V
|
||||
# <used>: com.bla.blu.value2.Class.m()V
|
||||
# ...
|
||||
# <used>: com.bla.blu.value<n>.Class.m()V
|
||||
#
|
||||
# Variables can be redefined when building a system to select the
|
||||
# required support for features like encodings, protocols, etc.
|
||||
#
|
||||
# Hints:
|
||||
#
|
||||
# - For methods and fields, the signature is mandatory. For
|
||||
# specification, please see the Java Virtual Machine Specification by
|
||||
# SUN. Unlike in the spec, field signatures (types) are in brackets.
|
||||
#
|
||||
# - Package names must be separated by '/' (and not '.'). E.g.,
|
||||
# java/lang/Class (this is necessary, because the '.' is used to
|
||||
# separate method or field names from classes)
|
||||
#
|
||||
# - In case <needed> refers to a class, only the class itself will be
|
||||
# included in the resulting binary, NOT necessarily all its methods
|
||||
# and fields. If you want to refer to all methods and fields, you can
|
||||
# write class.* as an abbreviation.
|
||||
#
|
||||
# - Abbreviations for packages are also possible: my/package/* means all
|
||||
# methods and fields of all classes in my/package.
|
||||
#
|
||||
# - A line with a trailing '\' continues in the next line.
|
||||
|
||||
# end of file
|
||||
|
||||
# All locales supported are loaded via classes from java.text (see below)
|
||||
# from class gnu/java/locale/LocaleInformation_<locale_id>
|
||||
#
|
||||
# This introduces a dependency for all locales. To allow an easy selection
|
||||
# and addition of locales, the library variable {text_locales} can be set to
|
||||
# the set of supported locales.
|
||||
#
|
||||
|
||||
{text_locales}: \
|
||||
af_ZA \
|
||||
ar_AE \
|
||||
ar_BH \
|
||||
ar_DZ \
|
||||
ar_EG \
|
||||
ar_IN \
|
||||
ar_IQ \
|
||||
ar_JO \
|
||||
ar_KW \
|
||||
ar_LB \
|
||||
ar_LY \
|
||||
ar_MA \
|
||||
ar_OM \
|
||||
ar_QA \
|
||||
ar_SD \
|
||||
ar_SY \
|
||||
ar_TN \
|
||||
ar_YE \
|
||||
be_BY \
|
||||
bn_IN \
|
||||
br_FR \
|
||||
bs_BA \
|
||||
ca_ES \
|
||||
cs_CZ \
|
||||
cy_GB \
|
||||
da_DK \
|
||||
de \
|
||||
de_AT \
|
||||
de_BE \
|
||||
de_CH \
|
||||
de_DE \
|
||||
de_LU \
|
||||
el_GR \
|
||||
en \
|
||||
en_AU \
|
||||
en_BW \
|
||||
en_CA \
|
||||
en_DK \
|
||||
en_GB \
|
||||
en_HK \
|
||||
en_IE \
|
||||
en_IN \
|
||||
en_NZ \
|
||||
en_PH \
|
||||
en_SG \
|
||||
en_US \
|
||||
en_ZA \
|
||||
en_ZW \
|
||||
es_AR \
|
||||
es_BO \
|
||||
es_CL \
|
||||
es_CO \
|
||||
es_CR \
|
||||
es_DO \
|
||||
es_EC \
|
||||
es_ES \
|
||||
es_GT \
|
||||
es_HN \
|
||||
es_MX \
|
||||
es_NI \
|
||||
es_PA \
|
||||
es_PE \
|
||||
es_PR \
|
||||
es_PY \
|
||||
es_SV \
|
||||
es_US \
|
||||
es_UY \
|
||||
es_VE \
|
||||
et_EE \
|
||||
eu_ES \
|
||||
fa_IR \
|
||||
fi_FI \
|
||||
fo_FO \
|
||||
fr_BE \
|
||||
fr_CA \
|
||||
fr_CH \
|
||||
fr_FR \
|
||||
fr_LU \
|
||||
ga_IE \
|
||||
gd_GB \
|
||||
gl_ES \
|
||||
gv_GB \
|
||||
he_IL \
|
||||
hi_IN \
|
||||
hr_HR \
|
||||
hu_HU \
|
||||
id_ID \
|
||||
it_CH \
|
||||
it_IT \
|
||||
iw_IL \
|
||||
ja_JP \
|
||||
ka_GE \
|
||||
kl_GL \
|
||||
ko_KR \
|
||||
kw_GB \
|
||||
lt_LT \
|
||||
lv_LV \
|
||||
mi_NZ \
|
||||
mk_MK \
|
||||
mr_IN \
|
||||
mt_MT \
|
||||
nl \
|
||||
nl_BE \
|
||||
nl_NL \
|
||||
nn_NO \
|
||||
no_NO \
|
||||
oc_FR \
|
||||
pl_PL \
|
||||
pt_BR \
|
||||
pt_PT \
|
||||
ro_RO \
|
||||
ru_RU \
|
||||
ru_UA \
|
||||
se_NO \
|
||||
sk_SK \
|
||||
sl_SI \
|
||||
sq_AL \
|
||||
sr_YU \
|
||||
sv_FI \
|
||||
sv_SE \
|
||||
ta_IN \
|
||||
te_IN \
|
||||
tg_TJ \
|
||||
tl_PH \
|
||||
tr_TR \
|
||||
uk_UA \
|
||||
ur_PK \
|
||||
uz_UZ \
|
||||
vi_VN \
|
||||
yi_US \
|
||||
zh_CN \
|
||||
zh_HK \
|
||||
zh_SG \
|
||||
zh_TW
|
||||
|
||||
java/text/Collator.getInstance(Ljava/util/Locale;)Ljava/text/Collator;: \
|
||||
gnu/java/locale/LocaleInformation_{text_locales}.*
|
||||
|
||||
java/text/DateFormatSymbols.<init>(Ljava/util/Locale;)V: \
|
||||
gnu/java/locale/LocaleInformation_{text_locales}.*
|
||||
|
||||
java/text/DecimalFormatSymbols.<init>(Ljava/util/Locale;)V: \
|
||||
gnu/java/locale/LocaleInformation_{text_locales}.*
|
||||
|
||||
java/text/BreakIterator.getInstance(Ljava/lang/String;Ljava/util/Locale;)Ljava/text/BreakIterator;: \
|
||||
gnu/java/locale/LocaleInformation_{text_locales}.*
|
||||
|
||||
java/text/NumberFormat.computeInstance(Ljava/util/Locale;Ljava/lang/String;Ljava/lang/String;)Ljava/text/NumberFormat;: \
|
||||
gnu/java/locale/LocaleInformation_{text_locales}.*
|
||||
|
||||
java/text/DateFormat.computeInstance(IILjava/util/Locale;ZZ)Ljava/text/DateFormat;: \
|
||||
gnu/java/locale/LocaleInformation_{text_locales}.*
|
124
libjava/classpath/java/text/spi/BreakIteratorProvider.java
Normal file
124
libjava/classpath/java/text/spi/BreakIteratorProvider.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
/* BreakIteratorProvider.java -- Providers of localized instances
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package java.text.spi;
|
||||
|
||||
import java.text.BreakIterator;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import java.util.spi.LocaleServiceProvider;
|
||||
|
||||
/**
|
||||
* A {@link BreakIteratorProvider} provides localized
|
||||
* instances of {@link java.text.BreakIterator}.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class BreakIteratorProvider
|
||||
extends LocaleServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a new {@link BreakIteratorProvider}.
|
||||
* Provided for implicit invocation by subclasses.
|
||||
*/
|
||||
protected BreakIteratorProvider()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.BreakIterator} instance
|
||||
* for character breaks in the specified
|
||||
* {@link java.util.Locale}.
|
||||
*
|
||||
* @param locale the desired locale.
|
||||
* @return the localized instance for character breaks.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.BreakIterator#getCharacterInstance(java.util.Locale)
|
||||
*/
|
||||
public abstract BreakIterator getCharacterInstance(Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.BreakIterator} instance
|
||||
* for line breaks in the specified {@link java.util.Locale}.
|
||||
*
|
||||
* @param locale the desired locale.
|
||||
* @return the localized instance for line breaks.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.BreakIterator#getLineInstance(java.util.Locale)
|
||||
*/
|
||||
public abstract BreakIterator getLineInstance(Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.BreakIterator} instance
|
||||
* for sentence breaks in the specified
|
||||
* {@link java.util.Locale}.
|
||||
*
|
||||
* @param locale the desired locale.
|
||||
* @return the localized instance for sentence breaks.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.BreakIterator#getSentenceInstance(java.util.Locale)
|
||||
*/
|
||||
public abstract BreakIterator getSentenceInstance(Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.BreakIterator} instance
|
||||
* for word breaks in the specified
|
||||
* {@link java.util.Locale}.
|
||||
*
|
||||
* @param locale the desired locale.
|
||||
* @return the localized instance for word breaks.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.BreakIterator#getWordInstance(java.util.Locale)
|
||||
*/
|
||||
public abstract BreakIterator getWordInstance(Locale locale);
|
||||
|
||||
}
|
79
libjava/classpath/java/text/spi/CollatorProvider.java
Normal file
79
libjava/classpath/java/text/spi/CollatorProvider.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
/* CollatorProvider.java -- Providers of localized instances
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package java.text.spi;
|
||||
|
||||
import java.text.Collator;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import java.util.spi.LocaleServiceProvider;
|
||||
|
||||
/**
|
||||
* A {@link CollatorProvider} provides localized
|
||||
* instances of {@link java.text.Collator}.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class CollatorProvider
|
||||
extends LocaleServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a new {@link CollatorProvider}.
|
||||
* Provided for implicit invocation by subclasses.
|
||||
*/
|
||||
protected CollatorProvider()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.Collator} instance
|
||||
* for the specified {@link java.util.Locale}.
|
||||
*
|
||||
* @param locale the desired locale.
|
||||
* @return the localized instance.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.Collator#getInstance(java.util.Locale)
|
||||
*/
|
||||
public abstract Collator getInstance(Locale locale);
|
||||
|
||||
}
|
129
libjava/classpath/java/text/spi/DateFormatProvider.java
Normal file
129
libjava/classpath/java/text/spi/DateFormatProvider.java
Normal file
|
@ -0,0 +1,129 @@
|
|||
/* DateFormatProvider.java -- Providers of localized instances
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package java.text.spi;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import java.util.spi.LocaleServiceProvider;
|
||||
|
||||
/**
|
||||
* A {@link DateFormatProvider} provides localized
|
||||
* instances of {@link java.text.DateFormat}.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class DateFormatProvider
|
||||
extends LocaleServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a new {@link DateFormatProvider}.
|
||||
* Provided for implicit invocation by subclasses.
|
||||
*/
|
||||
protected DateFormatProvider()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.DateFormat} instance
|
||||
* for formatting dates with the given style in the specified
|
||||
* {@link java.util.Locale}.
|
||||
*
|
||||
* @param style the formatting style; one of {@link DateFormat#SHORT},
|
||||
* {@link DateFormat#MEDIUM}, {@link DateFormat#LONG}
|
||||
* or {@link DateFormat#FULL}.
|
||||
* @param locale the desired locale.
|
||||
* @return the localized instance for formatting dates.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the style is invalid or
|
||||
* the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.DateFormat#getDateInstance(int,java.util.Locale)
|
||||
*/
|
||||
public abstract DateFormat getDateInstance(int style,
|
||||
Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.DateFormat} instance
|
||||
* for formatting dates and times with the given style in the
|
||||
* specified {@link java.util.Locale}.
|
||||
*
|
||||
* @param dateStyle the date formatting style; one of
|
||||
* {@link DateFormat#SHORT}, {@link DateFormat#MEDIUM},
|
||||
* {@link DateFormat#LONG} or {@link DateFormat#FULL}.
|
||||
* @param timeStyle the time formatting style; one of
|
||||
* {@link DateFormat#SHORT}, {@link DateFormat#MEDIUM},
|
||||
* {@link DateFormat#LONG} or {@link DateFormat#FULL}.
|
||||
* @param locale the desired locale.
|
||||
* @return the localized instance for formatting dates.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if either style is invalid or
|
||||
* the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.DateFormat#getDateInstance(java.util.Locale)
|
||||
*/
|
||||
public abstract DateFormat getDateTimeInstance(int dateStyle,
|
||||
int timeStyle,
|
||||
Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.DateFormat} instance
|
||||
* for formatting times with the given style in the specified
|
||||
* {@link java.util.Locale}.
|
||||
*
|
||||
* @param style the formatting style; one of {@link DateFormat#SHORT},
|
||||
* {@link DateFormat#MEDIUM}, {@link DateFormat#LONG}
|
||||
* or {@link DateFormat#FULL}.
|
||||
* @param locale the desired locale.
|
||||
* @return the localized instance for formatting times.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the style is invalid or
|
||||
* the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.DateFormat#getTimeInstance(int,java.util.Locale)
|
||||
*/
|
||||
public abstract DateFormat getTimeInstance(int style,
|
||||
Locale locale);
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/* DateFormatSymbolsProvider.java -- Providers of localized instances
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package java.text.spi;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import java.util.spi.LocaleServiceProvider;
|
||||
|
||||
/**
|
||||
* A {@link DateFormatSymbolsProvider} provides localized
|
||||
* instances of {@link java.text.DateFormatSymbols}.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class DateFormatSymbolsProvider
|
||||
extends LocaleServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a new {@link DateFormatSymbolsProvider}.
|
||||
* Provided for implicit invocation by subclasses.
|
||||
*/
|
||||
protected DateFormatSymbolsProvider()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.DateFormatSymbols} instance
|
||||
* for the specified {@link java.util.Locale}.
|
||||
*
|
||||
* @param locale the locale to express the symbols in.
|
||||
* @return the localized instance.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.DateFormatSymbols#getInstance(java.util.Locale)
|
||||
*/
|
||||
public abstract DateFormatSymbols getInstance(Locale locale);
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/* DecimalFormatSymbolsProvider.java -- Providers of localized instances
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package java.text.spi;
|
||||
|
||||
import java.text.DecimalFormatSymbols;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import java.util.spi.LocaleServiceProvider;
|
||||
|
||||
/**
|
||||
* A {@link DecimalFormatSymbolsProvider} provides localized
|
||||
* instances of {@link java.text.DecimalFormatSymbols}.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class DecimalFormatSymbolsProvider
|
||||
extends LocaleServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a new {@link DecimalFormatSymbolsProvider}.
|
||||
* Provided for implicit invocation by subclasses.
|
||||
*/
|
||||
protected DecimalFormatSymbolsProvider()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.DecimalFormatSymbols} instance
|
||||
* for the specified {@link java.util.Locale}.
|
||||
*
|
||||
* @param locale the locale to express the symbols in.
|
||||
* @return the localized instance.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.DecimalFormatSymbols#getInstance(java.util.Locale)
|
||||
*/
|
||||
public abstract DecimalFormatSymbols getInstance(Locale locale);
|
||||
|
||||
}
|
129
libjava/classpath/java/text/spi/NumberFormatProvider.java
Normal file
129
libjava/classpath/java/text/spi/NumberFormatProvider.java
Normal file
|
@ -0,0 +1,129 @@
|
|||
/* NumberFormatProvider.java -- Providers of localized instances
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package java.text.spi;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import java.util.spi.LocaleServiceProvider;
|
||||
|
||||
/**
|
||||
* A {@link NumberFormatProvider} provides localized
|
||||
* instances of {@link java.text.NumberFormat}.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class NumberFormatProvider
|
||||
extends LocaleServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a new {@link NumberFormatProvider}.
|
||||
* Provided for implicit invocation by subclasses.
|
||||
*/
|
||||
protected NumberFormatProvider()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.NumberFormat} instance
|
||||
* for monetary values in the specified
|
||||
* {@link java.util.Locale}.
|
||||
*
|
||||
* @param locale the desired locale.
|
||||
* @return the localized instance for monetary values.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.NumberFormat#getCurrencyInstance(java.util.Locale)
|
||||
*/
|
||||
public abstract NumberFormat getCurrencyInstance(Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.NumberFormat} instance
|
||||
* for integers in the specified {@link java.util.Locale}.
|
||||
* The returned instance should be configured to round
|
||||
* floating point numbers to the nearest integer using
|
||||
* {@link java.math.RoundingMode#HALF_EVEN} rounding,
|
||||
* and to parse only the integer part of a number.
|
||||
*
|
||||
* @param locale the desired locale.
|
||||
* @return the localized instance for integers.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.NumberFormat#getIntegerInstance(java.util.Locale)
|
||||
* @see java.math.RoundingMode#HALF_EVEN
|
||||
* @see java.text.NumberFormat#isParseIntegerOnly()
|
||||
*/
|
||||
public abstract NumberFormat getIntegerInstance(Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a general-purpose {@link java.text.NumberFormat}
|
||||
* instance in the specified {@link java.util.Locale}.
|
||||
*
|
||||
* @param locale the desired locale.
|
||||
* @return a general-purpose localized instance.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.NumberFormat#getNumberInstance(java.util.Locale)
|
||||
*/
|
||||
public abstract NumberFormat getNumberInstance(Locale locale);
|
||||
|
||||
/**
|
||||
* Returns a {@link java.text.NumberFormat} instance
|
||||
* for percentage values in the specified
|
||||
* {@link java.util.Locale}.
|
||||
*
|
||||
* @param locale the desired locale.
|
||||
* @return the localized instance for percentage values.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
* @throws IllegalArgumentException if the locale is not one
|
||||
* returned by
|
||||
* {@link getAvailableLocales()}
|
||||
* @see java.text.NumberFormat#getPercentInstance(java.util.Locale)
|
||||
*/
|
||||
public abstract NumberFormat getPercentInstance(Locale locale);
|
||||
|
||||
}
|
50
libjava/classpath/java/text/spi/package.html
Normal file
50
libjava/classpath/java/text/spi/package.html
Normal file
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<!-- package.html - describes classes in java.text.spi package.
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. -->
|
||||
|
||||
<html>
|
||||
<head><title>GNU Classpath - java.text.spi</title></head>
|
||||
|
||||
<body>
|
||||
|
||||
<p>
|
||||
A series of service provider interfaces for use by the
|
||||
classes in <code>java.text</code>.
|
||||
</p>
|
||||
<p><span style="font-weight: bold;">Since</span>: 1.6</p>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue