summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.externalToolBuilders/CreateLocaleData.launch13
-rw-r--r--ChangeLog15
-rw-r--r--gnu/java/locale/.cvsignore1
-rw-r--r--gnu/java/locale/LocaleHelper.java53
-rw-r--r--java/text/Collator.java13
-rw-r--r--java/util/Locale.java15
-rw-r--r--lib/Makefile.am12
-rwxr-xr-xscripts/generate-locale-list.sh16
8 files changed, 111 insertions, 27 deletions
diff --git a/.externalToolBuilders/CreateLocaleData.launch b/.externalToolBuilders/CreateLocaleData.launch
index ff11b3c79..fc91d8dcc 100644
--- a/.externalToolBuilders/CreateLocaleData.launch
+++ b/.externalToolBuilders/CreateLocaleData.launch
@@ -1,2 +1,11 @@
-<?xml version='1.0'?>
-<launchConfiguration type='org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'><stringAttribute key='org.eclipse.debug.core.ATTR_REFRESH_SCOPE' value='${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;working set&quot; editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/classpath/java/util&quot; type=&quot;2&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS' value='full,incremental,'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_LOCATION' value='${system_path:make}'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY' value='${build_project}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS' value='-C ${build_project}/lib ../java/util/LocaleData.java'/><booleanAttribute key='org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND' value='false'/><booleanAttribute key='org.eclipse.debug.core.appendEnvironmentVariables' value='true'/></launchConfiguration> \ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-C ${build_project}/lib ../gnu/java/locale/LocaleData.java"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;working set&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/classpath/gnu/java/locale&quot; type=&quot;2&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${build_project}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${system_path:make}"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+</launchConfiguration>
diff --git a/ChangeLog b/ChangeLog
index 8590009d4..edef9d0e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2006-03-24 Tom Tromey <tromey@redhat.com>
+
+ * .externalToolBuilders/CreateLocaleData.launch: Updated.
+ * gnu/java/locale/.cvsignore: New file.
+ * lib/Makefile.am (LocaleData.java): Put in gnu/java/locale.
+ * java/util/Locale.java (getAvailableLocales): Clone result.
+ (getISOCountries): Likewise.
+ (getISOLanguages): Likewise.
+ * scripts/generate-locale-list.sh: Make class public. Added new
+ array.
+ * gnu/java/locale/LocaleHelper.java (getCollatorLocales): New method.
+ (getLocaleCount): Likewise.
+ * java/text/Collator.java (getInstance): Javadoc typo fix.
+ (getAvailableLocales): Wrote.
+
2006-03-24 Roman Kennke <kennke@aicas.com>
* javax/swing/JTabbedPane.java
diff --git a/gnu/java/locale/.cvsignore b/gnu/java/locale/.cvsignore
new file mode 100644
index 000000000..d41ae8d81
--- /dev/null
+++ b/gnu/java/locale/.cvsignore
@@ -0,0 +1 @@
+LocaleData.java
diff --git a/gnu/java/locale/LocaleHelper.java b/gnu/java/locale/LocaleHelper.java
index ff0029390..cec014717 100644
--- a/gnu/java/locale/LocaleHelper.java
+++ b/gnu/java/locale/LocaleHelper.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.locale;
+import java.text.Collator;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
@@ -154,5 +155,57 @@ public class LocaleHelper
}
return localizedString;
}
+
+ /**
+ * Return an array of all the locales for which there is a
+ * {@link Collator} instance. A new array is returned each time.
+ */
+ public static Locale[] getCollatorLocales()
+ {
+ // For now we don't bother caching. This is probably
+ // not called very frequently. And, we would have to
+ // clone the array anyway.
+ if (LocaleData.collatorLocaleNames.length == 0)
+ return new Locale[] { Locale.US };
+ Locale[] result = new Locale[LocaleData.collatorLocaleNames.length];
+ for (int i = 0; i < result.length; ++i)
+ {
+ String language;
+ String region = "";
+ String variant = "";
+ String name = LocaleData.collatorLocaleNames[i];
+
+ language = name.substring(0, 2);
+
+ if (name.length() > 2)
+ region = name.substring(3);
+
+ int index = region.indexOf("_");
+ if (index > 0)
+ {
+ variant = region.substring(index + 1);
+ region = region.substring(0, index - 1);
+ }
+
+ result[i] = new Locale(language, region, variant);
+ }
+ return result;
+ }
+
+ /**
+ * Return the number of locales we know of.
+ */
+ public static int getLocaleCount()
+ {
+ return LocaleData.localeNames.length;
+ }
+
+ /**
+ * Return the Nth locale name.
+ */
+ public static String getLocaleName(int n)
+ {
+ return LocaleData.localeNames[n];
+ }
}
diff --git a/java/text/Collator.java b/java/text/Collator.java
index fe9200775..08739163a 100644
--- a/java/text/Collator.java
+++ b/java/text/Collator.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package java.text;
-import gnu.classpath.NotImplementedException;
+import gnu.java.locale.LocaleHelper;
import java.util.Comparator;
import java.util.Locale;
@@ -70,10 +70,6 @@ import java.util.ResourceBundle;
* @author Aaron M. Renn (arenn@urbanophile.com)
* @date March 18, 1999
*/
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 from http://www.javasoft.com.
- * Status: Mostly complete, but parts stubbed out. Look for FIXME.
- */
public abstract class Collator implements Comparator, Cloneable
{
/**
@@ -245,11 +241,8 @@ public abstract class Collator implements Comparator, Cloneable
* @return The list of locales for which <code>Collator</code>'s exist.
*/
public static synchronized Locale[] getAvailableLocales ()
- throws NotImplementedException
{
- Locale[] l = new Locale[1];
- l[0] = Locale.US;
- return l;
+ return LocaleHelper.getCollatorLocales();
}
/**
@@ -294,7 +287,7 @@ public abstract class Collator implements Comparator, Cloneable
* specified locale. If no <code>Collator</code> exists for the desired
* locale, a <code>Collator</code> for the default locale will be returned.
*
- * @param loc The desired localed to load a <code>Collator</code> for.
+ * @param loc The desired locale to load a <code>Collator</code> for.
*
* @return A <code>Collator</code> for the requested locale
*/
diff --git a/java/util/Locale.java b/java/util/Locale.java
index 9e7bbfea2..e1b1bdfbb 100644
--- a/java/util/Locale.java
+++ b/java/util/Locale.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.util;
import gnu.classpath.SystemProperties;
+import gnu.java.locale.LocaleHelper;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -384,15 +385,15 @@ public final class Locale implements Serializable, Cloneable
{
if (availableLocales == null)
{
- String[] localeNames = LocaleData.localeNames;
- availableLocales = new Locale[localeNames.length];
+ int len = LocaleHelper.getLocaleCount();
+ availableLocales = new Locale[len];
- for (int i = 0; i < localeNames.length; i++)
+ for (int i = 0; i < len; i++)
{
String language;
String region = "";
String variant = "";
- String name = localeNames[i];
+ String name = LocaleHelper.getLocaleName(i);
language = name.substring(0, 2);
@@ -410,7 +411,7 @@ public final class Locale implements Serializable, Cloneable
}
}
- return availableLocales;
+ return (Locale[]) availableLocales.clone();
}
/**
@@ -426,7 +427,7 @@ public final class Locale implements Serializable, Cloneable
countryCache = getISOStrings("territories");
}
- return countryCache;
+ return (String[]) countryCache.clone();
}
/**
@@ -441,7 +442,7 @@ public final class Locale implements Serializable, Cloneable
{
languageCache = getISOStrings("languages");
}
- return languageCache;
+ return (String[]) languageCache.clone();
}
/**
diff --git a/lib/Makefile.am b/lib/Makefile.am
index e2c495714..8e5de9723 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -113,11 +113,11 @@ resources: copy-vmresources.sh
classes: genclasses
-$(top_builddir)/java/util/LocaleData.java: $(top_srcdir)/scripts/generate-locale-list.sh
- mkdir -p $(top_builddir)/java/util
- $(top_srcdir)/scripts/generate-locale-list.sh > $(top_builddir)/java/util/LocaleData.java
+$(top_builddir)/gnu/java/locale/LocaleData.java: $(top_srcdir)/scripts/generate-locale-list.sh
+ mkdir -p $(top_builddir)/gnu/java/locale
+ $(top_srcdir)/scripts/generate-locale-list.sh > $(top_builddir)/gnu/java/locale/LocaleData.java
-genclasses: gen-classlist.sh standard.omit $(top_builddir)/java/util/LocaleData.java gen-xpath-parser
+genclasses: gen-classlist.sh standard.omit $(top_builddir)/gnu/java/locale/LocaleData.java gen-xpath-parser
top_builddir=$(top_builddir) top_srcdir=$(top_srcdir) $(SHELL) ./gen-classlist.sh standard
# Only rebuild parsers when explicitly asked to.
@@ -156,7 +156,7 @@ endif
EXTRA_DIST = standard.omit mkcollections.pl.in Makefile.gcj split-for-gcj.sh
CLEANFILES = compile-classes resources classes \
glibj.zip classes.1 \
- $(top_builddir)/java/util/LocaleData.java \
+ $(top_builddir)/gnu/java/locale/LocaleData.java \
$(JAVA_DEPEND)
clean-local:
@@ -177,4 +177,4 @@ dist-hook:
$(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../vm $(distdir)/../resource -name .cvsignore -print | xargs rm -f
$(FIND) $(distdir)/../gnu $(distdir)/../java $(distdir)/../javax $(distdir)/../org $(distdir)/../vm -name class-dependencies.conf -print | xargs rm -f
rm -f $(distdir)/../gnu/classpath/Configuration.java
- rm -f $(distdir)/../java/util/LocaleData.java
+ rm -f $(distdir)/../gnu/java/locale/LocaleData.java
diff --git a/scripts/generate-locale-list.sh b/scripts/generate-locale-list.sh
index fb55c1c28..3c6809de1 100755
--- a/scripts/generate-locale-list.sh
+++ b/scripts/generate-locale-list.sh
@@ -40,18 +40,30 @@ echo "obligated to do so. If you do not wish to do so, delete this"
echo "exception statement from your version. */"
echo
echo
-echo "package java.util;"
+echo "package gnu.java.locale;"
echo
echo "// This file was automatically generated by scripts/generate-locale-list.sh"
echo
echo
echo "class LocaleData"
echo "{"
-echo " public static String[] localeNames ="
+echo " public static final String[] localeNames ="
echo " {"
( cd $CLASSPATH_SRCDIR/resource/gnu/java/locale ; ls LocaleInformation_*.properties ) | xargs -n 1 echo | sed -e 's/LocaleInformation_\(.*\)\.properties/\1/' |
while read locale ; do echo " \"$locale\"," ; done
echo " };"
+
+echo
+echo " public static final String[] collatorLocaleNames ="
+echo " {"
+
+( cd $CLASSPATH_SRCDIR/resource/gnu/java/locale; grep -l collation_rules LocaleInformation_*.properties) |
+ xargs -n 1 echo | sed -e 's/LocaleInformation_\(.*\)\.properties/\1/' |
+ sed -e '/^$/ d' |
+ while read locale ; do echo " \"$locale\"," ; done
+
+echo " };"
+
echo "}"