ICU-21370 Delete folder for eclipse plug-in build

This commit is contained in:
Yoshito Umaoka 2021-02-26 02:01:18 -05:00
parent 1a666c1029
commit 3688b9b824
97 changed files with 0 additions and 37487 deletions

View file

@ -183,13 +183,6 @@
<delete dir="${out.dir}"/>
<delete dir="${module.dir}"/>
<delete dir="${cldr.release.dir}"/>
<available file="eclipse-build" type="dir" property="eclipse-build.dir.present"/>
<antcall target="_clean.eclipse-build"/>
</target>
<target name="_clean.eclipse-build" if="eclipse-build.dir.present">
<ant dir="eclipse-build" target="clean" inheritAll="false"/>
</target>
<target name="ivy-clean">

View file

@ -1,39 +0,0 @@
# © 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
################################################################################
# Copyright (C) 2014-2015, International Business Machines Corporation and
# others. All Rights Reserved.
################################################################################
# Eclipse installation location
# Specify the folder that contains eclipse.exe, for example: eclipse.home=C:/eclipse
#
# Note:
# By default, this value is set by an environment variable 'ECLIPSE_HOME'.
# You could uncomment below and specify the path in this file alternatively (recommended).
#
#eclipse.home=
#
# Java 7 runtime jar location
# Specify jar file path(es) including Java runtime classes.
#
# Note:
# Java runtime classes are stored in multiple jar files in modern JREs.
# To get the full list of jar files included in JRE, you can write a simple
# code printing system property "sun.boot.class.path".
#
# For example:
#
# java.rt=C:/java7/jre/lib/resources.jar;C:/java7/jre/lib/rt.jar;\
# C:/java7/jre/lib/sunrsasign.jar;C:/java7/jre/lib/jsse.jar;\
# C:/java7/jre/lib/jce.jar;C:/java7/jre/lib/charsets.jar;
# C:/java7/jre/lib/jfr.jar;C:/java7/jre/classes
#
# NOTE: slashes must be forward slashes. Backslashes will NOT work as path separator.
#
# IF java.rt variable has embedded space(s)...
# ...each element containing an embedded space java.rt must individually quoted and the elements separated by a semi-colon.
# ex. "C:/Program Files/IBM/JDK7/jre/lib/vm.jar";"C:/Program Files/IBM/JDK7/jre/lib/core.jar"
# ^^^
#java.rt=

View file

@ -1,409 +0,0 @@
<!--
/*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*******************************************************************************
* Copyright (C) 2010,2016, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
-->
<project name="icu4j-eclipse" default="build" basedir=".">
<property file="build-local.properties"/>
<property file="build.properties"/>
<property name="out.dir" value="out"/>
<property name="eclipse.projects.dir" value="${out.dir}/projects"/>
<property name="main.dir" value="../main"/>
<property name="shared.dir" value="${main.dir}/shared"/>
<import file="${shared.dir}/build/common-targets.xml"/>
<property file="${shared.dir}/build/common.properties"/>
<property file="${shared.dir}/build/locations.properties"/>
<property environment="env"/>
<target name="clean" description="Delete all build outputs">
<delete dir="${out.dir}"/>
</target>
<target name="build"
depends="checkProps,initEnv,icuProjectFiles,icuTestsProjectFiles,icuBaseProjectFiles,icuBaseTestsProjectFiles"
description="Build icu4j plug-ins">
<!-- copy OSGi jar file to baseLocation -->
<mkdir dir="${eclipse.projects.dir}/baseLocation/features"/>
<mkdir dir="${eclipse.projects.dir}/baseLocation/plugins"/>
<copy toDir="${eclipse.projects.dir}/baseLocation/plugins" file="${eclipse.osgi.jar}"/>
<!-- copy PDE build script files and run the build -->
<pathconvert property="eclipse.projects.dir.full" dirsep="/">
<path location="${basedir}/${eclipse.projects.dir}"/>
</pathconvert>
<antcall target="runEclipsePDEBuild">
<param name="icu.plugin.id" value="com.ibm.icu"/>
</antcall>
<antcall target="runEclipsePDEBuild">
<param name="icu.plugin.id" value="com.ibm.icu.base"/>
</antcall>
</target>
<target name="initEclipseHome"
if="env.ECLIPSE_HOME"
unless="eclipse.home"
description="Initialize the property eclipse.home from the environment variable ECLIPSE_HOME">
<property name="eclipse.home" value="${env.ECLIPSE_HOME}"/>
</target>
<target name="checkProps" depends="initEclipseHome">
<fail message="Eclipse home (eclipse.home or env.ECLIPSE_HOME) is not set">
<condition>
<or>
<equals arg1="${eclipse.home}" arg2=""/>
<not>
<isset property="eclipse.home"/>
</not>
</or>
</condition>
</fail>
<fail message="Java runtime jar path (java.rt) is not set">
<condition>
<or>
<equals arg1="${java.rt}" arg2=""/>
<not>
<isset property="java.rt"/>
</not>
</or>
</condition>
</fail>
</target>
<target name="initPluginVersion">
<tstamp>
<format property="build.date" pattern="yyyyMMdd"/>
</tstamp>
<property name="icu4j.eclipse.build.version.string" value="${icu4j.plugin.impl.version.string}.v${build.date}"/>
</target>
<target name="initEnv"
depends="checkProps,initEclipseLauncher,initEclipseOSGiJar,initEclipsePDE"
description="Initialize eclipse PDE build environment">
<echo message="[PDE build configuration properties]"/>
<echo message=" Ant version: ${ant.version}"/>
<echo message=" Eclipse home: ${eclipse.home}"/>
<echo message=" Launcher jar: ${eclipse.launcher}"/>
<echo message=" OSGi bundle jar: ${eclipse.osgi.jar}"/>
<echo message=" Base OS: ${eclipse.baseos}"/>
<echo message=" Base WS: ${eclipse.basews}"/>
<echo message=" Base ARCH: ${eclipse.basearch}"/>
<echo message=" java.rt: ${java.rt}"/>
<!-- try and detect use of backslashes -->
<condition property="java-rt-has-noSlashes">
<matches pattern="/" string="${java.rt}"/>
</condition>
<fail message="java.rt variable has no slashes!" unless="java-rt-has-noSlashes"/>
</target>
<target name="initEclipseLauncher"
if="eclipse.home"
description="Locate org.eclipse.equinox.launcher jar file for eclipse 3.3 and beyond">
<first id="equinox.launcher">
<fileset dir="${eclipse.home}/plugins">
<include name="org.eclipse.equinox.launcher_*.jar"/>
</fileset>
</first>
<pathconvert property="eclipse.launcher" dirsep="/" refid="equinox.launcher"/>
</target>
<target name="initEclipseOSGiJar"
if="eclipse.home"
description="Locate org.eclipse.osgi plugin jar file">
<first id="osgi.bundle">
<fileset dir="${eclipse.home}/plugins">
<include name="org.eclipse.osgi_*.jar"/>
</fileset>
</first>
<pathconvert property="eclipse.osgi.jar" dirsep="/" refid="osgi.bundle"/>
</target>
<target name="initEclipsePDE"
depends="locateEclipsePDE"
if="eclipse.pde.dir"
description="Set up PDE runtime arguments">
<property file="${eclipse.pde.dir}/templates/headless-build/build.properties" prefix="pde.template"/>
<property name="eclipse.baseos" value="${pde.template.baseos}"/>
<property name="eclipse.basews" value="${pde.template.basews}"/>
<property name="eclipse.basearch" value="${pde.template.basearch}"/>
</target>
<target name="locateEclipsePDE"
if="eclipse.home"
description="Locate org.eclipse.pde.build plug-in and set the property 'eclipse.pde.dir'">
<first id="eclipse.pde.plugin.dir">
<dirset dir="${eclipse.home}/plugins">
<include name="org.eclipse.pde.build_*"/>
</dirset>
</first>
<pathconvert property="eclipse.pde.dir" dirsep="/" refid="eclipse.pde.plugin.dir"/>
</target>
<target name="runEclipsePDEBuild">
<mkdir dir="${eclipse.projects.dir}/buildScripts/${icu.plugin.id}"/>
<copy toDir="${eclipse.projects.dir}/buildScripts/${icu.plugin.id}">
<fileset dir="pdebuild" includes="**/*"/>
<filterset>
<filter token="PLUGIN_ID" value="${icu.plugin.id}"/>
<filter token="BUILD_DIR" value="${eclipse.projects.dir.full}"/>
<filter token="BUILD_TYPE" value="ICU4J"/>
<filter token="BUILD_ID" value="${icu.plugin.id}"/>
<filter token="BASE_LOCATION" value="${eclipse.projects.dir.full}/baseLocation"/>
<filter token="BASE_OS" value="${eclipse.baseos}"/>
<filter token="BASE_WS" value="${eclipse.basews}"/>
<filter token="BASE_ARCH" value="${eclipse.basearch}"/>
<filter token="JAVA_RT" value="${java.rt}"/>
</filterset>
</copy>
<java jar="${eclipse.launcher}" fork="true" failonerror="true">
<arg value="-application"/>
<arg value="org.eclipse.ant.core.antRunner"/>
<arg value="-buildfile"/>
<arg value="${eclipse.pde.dir}/scripts/build.xml"/>
<arg value="-Dbuilder=${eclipse.projects.dir.full}/buildScripts/${icu.plugin.id}"/>
</java>
</target>
<target name="icuProjectFiles"
depends="initPluginVersion"
description="Copy com.ibm.icu plug-in project files">
<delete failonerror="no">
<fileset dir="${eclipse.projects.dir}/plugins/com.ibm.icu" />
<fileset dir="${eclipse.projects.dir}/features/com.ibm.icu" />
</delete>
<!-- icu source -->
<copy toDir="${eclipse.projects.dir}/plugins/com.ibm.icu/src">
<fileset dir="${icu4j.collate.dir}/src"/>
<fileset dir="${icu4j.core.dir}/src"/>
<fileset dir="${icu4j.currdata.dir}/src"/>
<fileset dir="${icu4j.langdata.dir}/src"/>
<fileset dir="${icu4j.regiondata.dir}/src"/>
<fileset dir="${icu4j.translit.dir}/src"/>
</copy>
<!-- overwriting the ICU runtime configuration file for forcing ICU4J plugin to use JDK time zone rules -->
<copy file="misc/ICUConfig.properties"
toDir="${eclipse.projects.dir}/plugins/com.ibm.icu/src/com/ibm/icu"
overwrite="true"/>
<!-- icu data -->
<unjar src="${icu4j.data.jar}" dest="${eclipse.projects.dir}/plugins/com.ibm.icu/src">
<patternset>
<exclude name="META-INF"/>
<exclude name="META-INF/**/*"/>
<exclude name="**/*.cnv"/>
<exclude name="**/cnvalias.icu"/>
</patternset>
</unjar>
<!-- icu tz data -->
<unjar src="${icu4j.tzdata.jar}" dest="${eclipse.projects.dir}/plugins/com.ibm.icu/src">
<patternset>
<exclude name="META-INF"/>
<exclude name="META-INF/**/*"/>
</patternset>
</unjar>
<!-- full locale names lists -->
<antcall target="@full-locale-names">
<param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}"/>
</antcall>
<antcall target="@full-locale-names">
<param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/brkitr"/>
</antcall>
<antcall target="@full-locale-names">
<param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/coll"/>
</antcall>
<antcall target="@full-locale-names">
<param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/curr"/>
</antcall>
<antcall target="@full-locale-names">
<param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/lang"/>
</antcall>
<antcall target="@full-locale-names">
<param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/rbnf"/>
</antcall>
<antcall target="@full-locale-names">
<param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/region"/>
</antcall>
<antcall target="@full-locale-names">
<param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/translit"/>
</antcall>
<antcall target="@full-locale-names">
<param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/zone"/>
</antcall>
<!-- plugin project -->
<copy todir="${eclipse.projects.dir}/plugins/com.ibm.icu">
<fileset dir="plugins.template/com.ibm.icu"/>
<filterset>
<filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
<filter token="COPYRIGHT" value="${copyright.eclipse}" />
<filter token="IMPL_VERSION" value="${icu4j.impl.version}" />
<filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
</filterset>
</copy>
<!-- license -->
<copy file="${shared.dir}/licenses/LICENSE"
todir="${eclipse.projects.dir}/plugins/com.ibm.icu/about_files" />
<!-- about -->
<copy file="misc/about_icu.html"
tofile="${eclipse.projects.dir}/plugins/com.ibm.icu/about.html" />
<!-- FEATURE FILES -->
<copy todir="${eclipse.projects.dir}/features/com.ibm.icu">
<fileset dir="features.template/com.ibm.icu"/>
<filterset>
<filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
<filter token="COPYRIGHT" value="${copyright.eclipse}" />
<filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
</filterset>
</copy>
</target>
<target name="icuTestsProjectFiles"
depends="initPluginVersion"
description="Copy com.ibm.icu.tests plug-in project files">
<delete failonerror="no">
<fileset dir="${eclipse.projects.dir}/plugins/com.ibm.icu.tests" />
</delete>
<!-- icu test source -->
<copy toDir="${eclipse.projects.dir}/plugins/com.ibm.icu.tests/src">
<fileset dir="${icu4j.test-framework.dir}/src"/>
<fileset dir="${icu4j.core-tests.dir}/src"/>
<fileset dir="${icu4j.collate-tests.dir}/src"/>
<fileset dir="${icu4j.translit-tests.dir}/src"/>
</copy>
<!-- icu test data -->
<unjar src="${icu4j.testdata.jar}" dest="${eclipse.projects.dir}/plugins/com.ibm.icu.tests/src">
<patternset>
<exclude name="**/*.cnv"/>
<exclude name="**/cnvalias.icu"/>
<exclude name="META-INF"/>
<exclude name="META-INF/**/*"/>
</patternset>
</unjar>
<!-- plugin project -->
<copy todir="${eclipse.projects.dir}/plugins/com.ibm.icu.tests">
<fileset dir="plugins.template/com.ibm.icu.tests"/>
<filterset>
<filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
<filter token="COPYRIGHT" value="${copyright.eclipse}" />
<filter token="IMPL_VERSION" value="${icu4j.impl.version}" />
<filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
</filterset>
</copy>
<!-- license -->
<copy file="${shared.dir}/licenses/LICENSE"
todir="${eclipse.projects.dir}/plugins/com.ibm.icu.tests/about_files" />
<!-- about -->
<copy file="misc/about_icu.html"
tofile="${eclipse.projects.dir}/plugins/com.ibm.icu.tests/about.html" />
</target>
<target name="icuBaseProjectFiles"
depends="initPluginVersion"
description="Copy com.ibm.icu.base plug-in project files">
<delete failonerror="no">
<fileset dir="${eclipse.projects.dir}/plugins/com.ibm.icu.base" />
<fileset dir="${eclipse.projects.dir}/features/com.ibm.icu.base" />
</delete>
<!-- plugin project -->
<copy todir="${eclipse.projects.dir}/plugins/com.ibm.icu.base">
<fileset dir="plugins.template/com.ibm.icu.base"/>
<filterset>
<filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
<filter token="COPYRIGHT" value="${copyright.eclipse}" />
<filter token="IMPL_VERSION" value="${icu4j.impl.version}" />
<filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
</filterset>
</copy>
<!-- license -->
<copy file="${shared.dir}/licenses/LICENSE"
todir="${eclipse.projects.dir}/plugins/com.ibm.icu.base/about_files" />
<!-- about -->
<copy file="misc/about_icu.html"
tofile="${eclipse.projects.dir}/plugins/com.ibm.icu.base/about.html" />
<!-- FEATURE FILES -->
<copy todir="${eclipse.projects.dir}/features/com.ibm.icu.base">
<fileset dir="features.template/com.ibm.icu.base"/>
<filterset>
<filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
<filter token="COPYRIGHT" value="${copyright.eclipse}" />
<filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
</filterset>
</copy>
</target>
<target name="icuBaseTestsProjectFiles"
depends="initPluginVersion"
description="Copy com.ibm.icu.base.tests plug-in project files">
<delete failonerror="no">
<fileset dir="${eclipse.projects.dir}/plugins/com.ibm.icu.base.tests" />
</delete>
<!-- plugin project -->
<copy todir="${eclipse.projects.dir}/plugins/com.ibm.icu.base.tests">
<fileset dir="plugins.template/com.ibm.icu.base.tests"/>
<filterset>
<filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
<filter token="COPYRIGHT" value="${copyright.eclipse}" />
<filter token="IMPL_VERSION" value="${icu4j.impl.version}" />
<filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
</filterset>
</copy>
<!-- license -->
<copy file="${shared.dir}/licenses/LICENSE"
todir="${eclipse.projects.dir}/plugins/com.ibm.icu.base.tests/about_files" />
<!-- about -->
<copy file="misc/about_icu.html"
tofile="${eclipse.projects.dir}/plugins/com.ibm.icu.base.tests/about.html" />
</target>
</project>

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.icu.base-feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.FeatureBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
</projectDescription>

View file

@ -1,20 +0,0 @@
###############################################################################
# Copyright (c) 2011,2016 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
bin.includes =\
epl-v10.html,\
eclipse_update_120.jpg,\
feature.xml,\
feature.properties,\
LICENSE
outputUpdateJars = true
generate.plugin@com.ibm.icu.base.source=com.ibm.icu.base

View file

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="com.ibm.icu.base"
label="com.ibm.icu.base"
version="@BUILD_VERSION@">
<description url="http://www.example.com/description">
[Enter Feature Description here.]
</description>
<copyright url="http://www.example.com/copyright">
[Enter Copyright Description here.]
</copyright>
<license url="http://www.example.com/license">
[Enter License Description here.]
</license>
<plugin
id="com.ibm.icu.base"
download-size="0"
install-size="0"
version="@BUILD_VERSION@"
unpack="false"/>
<plugin
id="com.ibm.icu.base.source"
download-size="0"
install-size="0"
version="@BUILD_VERSION@"
unpack="false"/>
</feature>

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.icu-feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.FeatureBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
</projectDescription>

View file

@ -1,20 +0,0 @@
###############################################################################
# Copyright (c) 2000,2016 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
bin.includes =\
epl-v10.html,\
eclipse_update_120.jpg,\
feature.xml,\
feature.properties,\
LICENSE
outputUpdateJars = true
generate.plugin@com.ibm.icu.source=com.ibm.icu

View file

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="com.ibm.icu"
label="com.ibm.icu"
version="@BUILD_VERSION@">
<description url="http://www.example.com/description">
[Enter Feature Description here.]
</description>
<copyright url="http://www.example.com/copyright">
[Enter Copyright Description here.]
</copyright>
<license url="http://www.example.com/license">
[Enter License Description here.]
</license>
<plugin
id="com.ibm.icu"
download-size="0"
install-size="0"
version="@BUILD_VERSION@"
unpack="false"/>
<plugin
id="com.ibm.icu.source"
download-size="0"
install-size="0"
version="@BUILD_VERSION@"
unpack="false"/>
</feature>

View file

@ -1,32 +0,0 @@
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#*******************************************************************************
#* Copyright (C) 2008-2011, International Business Machines Corporation and *
#* others. All Rights Reserved. *
#*******************************************************************************
#* This is the properties contains ICU runtime configuration
#*
#
# The default TimeZone implementation type used by the ICU TimeZone
# factory method. [ ICU | JDK ]
#
com.ibm.icu.util.TimeZone.DefaultTimeZoneType = JDK
#
# By default, DecimalFormat uses some internal equivalent character
# data in addition to ones in DecimalFormatSymbols for parsing
# decimal/grouping separators. When this property is true,
# DecimalFormat uses separators configured by DecimalFormatSymbols only
# and does not try to find a match in the internal equivalent character
# data.
#
com.ibm.icu.text.DecimalFormat.SkipExtendedSeparatorParsing = false
#
# [Internal Use Only]
# Disable resource path scan for building full locale name list
# at run time.
#
com.ibm.icu.impl.ICUResourceBundle.skipRuntimeLocaleResourceScan = false

View file

@ -1,45 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="COPYRIGHT" content="© 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html">
<title>About com.ibm.icu plugin</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>Sept 18, 2018</p>
<h3>License</h3>
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
<h3>Third Party Content</h3>
<p>The Content includes items that have been sourced from third parties as set out below. If you
did not receive this Content directly from the Eclipse Foundation, the following is provided
for informational purposes only, and you should look to the Redistributor's license for
terms and conditions of use.</p>
<p><strong>ICU4J 63.1.0 plug-in</strong></p>
<p>The plug-in includes software (&quot;ICU4J&quot;) developed by Unicode Inc. and others.
Your use of ICU4J is subject to the terms and conditions of the ICU license. A copy of the
license is contained in the file <a href="about_files/LICENSE" target="_blank">about_files/LICENSE</a>.</p>
<p>The project information including source code, documentations and demo programs are available on
the <a href="http://www.icu-project.org">ICU public web site</a>.</p>
</body>
</html>

View file

@ -1,45 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="COPYRIGHT" content="© 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html">
<title>About com.ibm.icu.base plugin</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>Sept 18, 2018</p>
<h3>License</h3>
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
<h3>Third Party Content</h3>
<p>The Content includes items that have been sourced from third parties as set out below. If you
did not receive this Content directly from the Eclipse Foundation, the following is provided
for informational purposes only, and you should look to the Redistributor's license for
terms and conditions of use.</p>
<p><strong>ICU4J 63.1.0 base plug-in</strong></p>
<p>The plug-in includes software (&quot;ICU4J&quot;) developed by Unicode Inc. and others.
Your use of ICU4J is subject to the terms and conditions of the ICU license. A copy of the
license is contained in the file <a href="about_files/LICENSE" target="_blank">about_files/LICENSE</a>.</p>
<p>The project information including source code, documentations and demo programs are available on
the <a href="http://www.icu-project.org">ICU public web site</a>.</p>
</body>
</html>

View file

@ -1,28 +0,0 @@
<project name="allElements Delegator">
<!-- ===================================================================== -->
<!-- Run a given ${target} on all elements being built -->
<!-- Replace element.id with the id of the top level element being built. -->
<!-- If element.id does not exist in ${buildDirectory}/features/element.id -->
<!-- or ${baseLocation}/features/element.id, then you must provide the -->
<!-- location by setting the property "pluginPath" -->
<!-- Add on <ant> task for each top level element being built. -->
<!-- ===================================================================== -->
<target name="allElementsDelegator">
<ant antfile="${genericTargets}" target="${target}">
<property name="type" value="feature" />
<property name="id" value="@PLUGIN_ID@" />
</ant>
</target>
<!-- ===================================================================== -->
<!-- Targets to assemble the built elements for particular configurations -->
<!-- These generally call the generated assemble scripts (named in -->
<!-- ${assembleScriptName}) but may also add pre and post processing -->
<!-- Add one target for each root element and each configuration -->
<!-- Replace element.id with the id of the top level element being built -->
<!-- ===================================================================== -->
<target name="assemble.@PLUGIN_ID@">
<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
</target>
</project>

View file

@ -1,224 +0,0 @@
###############################################################################
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
# Copyright (c) 2003-2015 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
#####################
# Parameters describing how and where to execute the build.
# Typical users need only update the following properties:
# baseLocation - where things you are building against are installed
# bootclasspath - The base jars to compile against (typicaly rt.jar)
# configs - the list of {os, ws, arch} configurations to build.
#
# Of course any of the settings here can be overridden by spec'ing
# them on the command line (e.g., -DbaseLocation=d:/eclipse
############# PRODUCT/PACKAGING CONTROL #############
product=/plugin or feature id/path/to/.product
runPackager=true
#Set the name of the archive that will result from the product build.
#archiveNamePrefix=
# The prefix that will be used in the generated archive.
#archivePrefix=<output archive root>
archivePrefix=
# The location underwhich all of the build output will be collected.
collectingFolder=${archivePrefix}
# The list of {os, ws, arch} configurations to build. This
# value is a '&' separated list of ',' separate triples. For example,
# configs=win32,win32,x86 & linux,motif,x86
# By default the value is *,*,*
#configs=win32, win32, x86 & \
# linux, gtk, ppc &\
# linux, gtk, x86 & \
# linux, gtk, x86_64 & \
# linux, motif, x86 & \
# solaris, motif, sparc & \
# solaris, gtk, sparc & \
# aix, motif, ppc & \
# hpux, motif, PA_RISC & \
# macosx, carbon, ppc
# By default PDE creates one archive (result) per entry listed in the configs property.
# Setting this value to try will cause PDE to only create one output containing all
# artifacts for all the platforms listed in the configs property.
#groupConfigurations=true
#The format of the archive. By default a zip is created using antZip.
#The list can only contain the configuration for which the desired format is different than zip.
#archivesFormat=win32, win32, x86 - antZip& \
# linux, gtk, ppc - antZip &\
# linux, gtk, x86 - antZip& \
# linux, gtk, x86_64 - antZip& \
# linux, motif, x86 - antZip& \
# solaris, motif, sparc - antZip& \
# solaris, gtk, sparc - antZip& \
# aix, motif, ppc - antZip& \
# hpux, motif, PA_RISC - antZip& \
# macosx, carbon, ppc - antZip
#Set to true if you want the output to be ready for an update jar (no site.xml generated)
#outputUpdateJars = false
#Set to true for Jnlp generation
#codebase should be a URL that will be used as the root of all relative URLs in the output.
#generateJnlp=false
#jnlp.codebase=<codebase url>
#jnlp.j2se=<j2se version>
#jnlp.locale=<a locale>
#Set to true if you want to sign jars
#signJars=false
#sign.alias=<alias>
#sign.keystore=<keystore location>
#sign.storepass=<keystore password>
#Arguments to send to the zip executable
zipargs=
#Arguments to send to the tar executable
tarargs=
#Control the creation of a file containing the version included in each configuration - on by default
#generateVersionsLists=false
############## BUILD NAMING CONTROL ################
# The directory into which the build elements are fetched and where
# the build takes place.
buildDirectory=@BUILD_DIR@
# Type of build. Used in naming the build output. Typically this value is
# one of I, N, M, S, ...
buildType=@BUILD_TYPE@
# ID of the build. Used in naming the build output.
buildId=@BUILD_ID@
# Label for the build. Used in naming the build output
buildLabel=${buildType}.${buildId}
# Timestamp for the build. Used in naming the build output
timestamp=007
#The value to be used for the qualifier of a plugin or feature when you want to override the value computed by pde.
#The value will only be applied to plugin or features indicating build.properties, qualifier = context
#forceContextQualifier=<the value for the qualifier>
#Enable / disable the generation of a suffix for the features that use .qualifier.
#The generated suffix is computed according to the content of the feature
#generateFeatureVersionSuffix=true
############# BASE CONTROL #############
# Settings for the base Eclipse components and Java class libraries
# against which you are building.
# Base location for anything the build needs to compile against. For example,
# in most RCP app or a plug-in, the baseLocation should be the location of a previously
# installed Eclipse against which the application or plug-in code will be compiled and the RCP delta pack.
base=<path/to/parent/of/eclipse>
#baseLocation=${base}/eclipse
baseLocation=@BASE_LOCATION@
#Os/Ws/Arch/nl of the eclipse specified by baseLocation
baseos=@BASE_OS@
basews=@BASE_WS@
basearch=@BASE_ARCH@
#this property indicates whether you want the set of plug-ins and features to be considered during the build to be limited to the ones reachable from the features / plugins being built
filteredDependencyCheck=false
#pluginPath is a list of locations in which to find plugins and features. This list is separated by the platform file separator (; or :)
#a location is one of:
#- the location of the jar or folder that is the plugin or feature : /path/to/foo.jar or /path/to/foo
#- a directory that contains a /plugins or /features subdirectory
#- the location of a feature.xml, or for 2.1 style plugins, the plugin.xml or fragment.xml
#pluginPath=
skipBase=true
eclipseURL=<url for eclipse download site>
eclipseBuildId=<Id of Eclipse build to get>
eclipseBaseURL=${eclipseURL}/eclipse-platform-${eclipseBuildId}-win32.zip
############# MAP FILE CONTROL ################
# This section defines CVS tags to use when fetching the map files from the repository.
# If you want to fetch the map file from repository / location, change the getMapFiles target in the customTargets.xml
skipMaps=true
mapsRepo=:pserver:anonymous@example.com/path/to/repo
mapsRoot=path/to/maps
mapsCheckoutTag=HEAD
#tagMaps=true
mapsTagTag=v${buildId}
############ REPOSITORY CONTROL ###############
# This section defines properties parameterizing the repositories where plugins, fragments
# bundles and features are being obtained from.
# The tags to use when fetching elements to build.
# By default thebuilder will use whatever is in the maps.
# This value takes the form of a comma separated list of repository identifier (like used in the map files) and the
# overriding value
# For example fetchTag=CVS=HEAD, SVN=v20050101
# fetchTag=HEAD
skipFetch=true
############# JAVA COMPILER OPTIONS ##############
# The location of the Java jars to compile against. Typically the rt.jar for your JDK/JRE
#bootclasspath=${java.home}/lib/rt.jar
# specific JRE locations to compile against. These values are used to compile bundles specifying a
# Bundle-RequiredExecutionEnvironment. Uncomment and set values for environments that you support
#CDC-1.0/Foundation-1.0= /path/to/rt.jar
#CDC-1.1/Foundation-1.1=
#OSGi/Minimum-1.0=
#OSGi/Minimum-1.1=
#JRE-1.1=
#J2SE-1.2=
#J2SE-1.3=
#J2SE-1.4=
#J2SE-1.5=
#JavaSE-1.6=
#JavaSE-1.7=
JavaSE-1.7=@JAVA_RT@
#PersonalJava-1.1=
#PersonalJava-1.2=
#CDC-1.0/PersonalBasis-1.0=
#CDC-1.0/PersonalJava-1.0=
#CDC-1.1/PersonalBasis-1.1=
#CDC-1.1/PersonalJava-1.1=
# Specify the output format of the compiler log when eclipse jdt is used
logExtension=.log
# Whether or not to include debug info in the output jars
javacDebugInfo=true
# Whether or not to fail the build if there are compiler errors
javacFailOnError=true
# Enable or disable verbose mode of the compiler
javacVerbose=true
# Extra arguments for the compiler. These are specific to the java compiler being used.
compilerArg=-inlineJSR -enableJavadoc -encoding UTF-8
# Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties
javacSource=1.7
# Default value for the version of the byte code targeted. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacTarget in build.properties.
javacTarget=1.7
individualSourceBundles=true

View file

@ -1,161 +0,0 @@
<project name="Build specific targets and properties" default="noDefault">
<!-- ===================================================================== -->
<!-- Run a given ${target} on all elements being built -->
<!-- Add on <ant> task for each top level element being built. -->
<!-- ===================================================================== -->
<property name="allElementsFile" value="${builder}/allElements.xml"/>
<import file="${allElementsFile}" />
<target name="allElements">
<antcall target="allElementsDelegator" />
</target>
<!-- ===================================================================== -->
<!-- ===================================================================== -->
<target name="getBaseComponents" depends="checkLocalBase" unless="skipBase">
<get src="${eclipseBaseURL}" dest="${buildDirectory}/../temp-base.zip" />
<unzip dest="${base}" overwrite="true" src="${buildDirectory}/../temp-base.zip" />
</target>
<target name="checkLocalBase">
<available file="${base}" property="skipBase" />
</target>
<!-- ===================================================================== -->
<!-- Check out map files from correct repository -->
<!-- Replace values for mapsCheckoutTag as desired. -->
<!-- ===================================================================== -->
<target name="getMapFiles" depends="checkLocalMaps" unless="skipMaps">
<property name="mapsCheckoutTag" value="HEAD" />
<cvs cvsRoot="${mapsRepo}" package="${mapsRoot}" dest="${buildDirectory}/maps" tag="${mapsCheckoutTag}" />
</target>
<target name="checkLocalMaps">
<available property="skipMaps" file="${buildDirectory}/maps" />
</target>
<target name="tagMapFiles" if="tagMaps">
<cvs dest="${buildDirectory}/maps/${mapsRoot}" command="tag ${mapsTagTag}" />
</target>
<!-- ===================================================================== -->
<target name="clean" unless="noclean">
<antcall target="allElements">
<param name="target" value="cleanElement" />
</antcall>
</target>
<target name="gatherLogs">
<mkdir dir="${buildDirectory}/${buildLabel}/compilelogs" />
<antcall target="allElements">
<param name="target" value="gatherLogs" />
</antcall>
<unzip dest="${buildDirectory}/${buildLabel}/compilelogs" overwrite="true">
<fileset dir="${buildDirectory}/features">
<include name="**/*.log.zip" />
</fileset>
</unzip>
</target>
<!-- ===================================================================== -->
<!-- Steps to do before setup -->
<!-- ===================================================================== -->
<target name="preSetup">
</target>
<!-- ===================================================================== -->
<!-- Steps to do after setup but before starting the build proper -->
<!-- ===================================================================== -->
<target name="postSetup">
<antcall target="getBaseComponents" />
</target>
<!-- ===================================================================== -->
<!-- Steps to do before fetching the build elements -->
<!-- ===================================================================== -->
<target name="preFetch">
</target>
<!-- ===================================================================== -->
<!-- Steps to do after fetching the build elements -->
<!-- ===================================================================== -->
<target name="postFetch">
</target>
<!-- ===================================================================== -->
<!-- Steps to do before generating the build scripts. -->
<!-- ===================================================================== -->
<target name="preGenerate">
</target>
<!-- ===================================================================== -->
<!-- Steps to do after generating the build scripts. -->
<!-- ===================================================================== -->
<target name="postGenerate">
<antcall target="clean" />
</target>
<!-- ===================================================================== -->
<!-- Steps to do before running the build.xmls for the elements being built. -->
<!-- ===================================================================== -->
<target name="preProcess">
</target>
<!-- ===================================================================== -->
<!-- Steps to do after running the build.xmls for the elements being built. -->
<!-- ===================================================================== -->
<target name="postProcess">
</target>
<!-- ===================================================================== -->
<!-- Steps to do before running assemble. -->
<!-- ===================================================================== -->
<target name="preAssemble">
</target>
<!-- ===================================================================== -->
<!-- Steps to do after running assemble. -->
<!-- ===================================================================== -->
<target name="postAssemble">
</target>
<!-- ===================================================================== -->
<!-- Steps to do before running package. -->
<!-- ===================================================================== -->
<target name="prePackage">
</target>
<!-- ===================================================================== -->
<!-- Steps to do after running package. -->
<!-- ===================================================================== -->
<target name="postPackage">
</target>
<!-- ===================================================================== -->
<!-- Steps to do after the build is done. -->
<!-- ===================================================================== -->
<target name="postBuild">
<antcall target="gatherLogs" />
</target>
<!-- ===================================================================== -->
<!-- Steps to do to test the build results -->
<!-- ===================================================================== -->
<target name="test">
</target>
<!-- ===================================================================== -->
<!-- Steps to do to publish the build results -->
<!-- ===================================================================== -->
<target name="publish">
</target>
<!-- ===================================================================== -->
<!-- Default target -->
<!-- ===================================================================== -->
<target name="noDefault">
<echo message="You must specify a target when invoking this file" />
</target>
</project>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.icu.base.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -1,2 +0,0 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View file

@ -1,77 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=ignore
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.7

View file

@ -1,3 +0,0 @@
#Thu Dec 14 11:51:01 EST 2006
eclipse.preferences.version=1
internal.default.compliance=default

View file

@ -1,10 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: com.ibm.icu.base.tests
Bundle-Version: @BUILD_VERSION@
Bundle-Vendor: %providerName
Fragment-Host: com.ibm.icu.base
Bundle-Copyright: @COPYRIGHT@
Require-Bundle: org.junit
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View file

@ -1,17 +0,0 @@
###############################################################################
# Copyright (c) 2000, 2011 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
source.. = src/
output.. = bin/
bin.includes = .,\
about.html,\
about_files/,\
plugin.properties,\
META-INF/

View file

@ -1,12 +0,0 @@
###############################################################################
# Copyright (c) 2011 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
pluginName = International Components for Unicode for Java (ICU4J) Replacement plug-in Tests
providerName = IBM Corporation

View file

@ -1,361 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.Locale;
import com.ibm.icu.text.BreakIterator;
import com.ibm.icu.util.ULocale;
public class BreakIteratorTest extends ICUTestCase {
// ICU behaves a bit differently with this text, but the tested values aren't
// affected. If Java changes behavior they might need to change.
private static final String text = "Mr. and Mrs. Mumblety-Peg paid $35.97 for a new 12\" cockatoo. " +
"When they got home they both cooed \"Isn't it lovely?\" and sighed softly. " +
"\"Let's name it u\u0308\u5098!\" they said with glee.";
private static int pos = text.indexOf("sn't");
private static BreakIterator cbr;
private static BreakIterator wbr;
private static BreakIterator lbr;
private static BreakIterator sbr;
static {
cbr = BreakIterator.getCharacterInstance();
cbr.setText(text);
wbr = BreakIterator.getWordInstance();
wbr.setText(text);
lbr = BreakIterator.getLineInstance();
lbr.setText(text);
sbr = BreakIterator.getSentenceInstance();
sbr.setText(text);
// diagnostic
// dump(cbr);
// dump(wbr);
// dump(lbr);
// dump(sbr);
}
// private static void dump(BreakIterator bi) {
// for (int ix = bi.first(), lim = text.length(); ix != lim;) {
// int nx = bi.next();
// if (nx < 0) nx = lim;
// System.out.println(Integer.toString(ix) + ": " + text.substring(ix, nx));
// ix = nx;
// }
// }
/*
* Test method for 'com.ibm.icu.text.BreakIterator.hashCode()'
*/
public void testHashCode() {
BreakIterator br = BreakIterator.getWordInstance();
br.setText(text);
BreakIterator brne = BreakIterator.getWordInstance();
brne.setText(text + "X");
wbr.first();
testEHCS(br, wbr, brne);
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.BreakIterator(BreakIterator)'
*/
public void testBreakIterator() {
// implicitly tested everywhere
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.first()'
*/
public void testFirst() {
assertEquals(0, cbr.first());
assertEquals(0, wbr.first());
assertEquals(0, lbr.first());
assertEquals(0, sbr.first());
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.last()'
*/
public void testLast() {
assertEquals(text.length(), cbr.last());
assertEquals(text.length(), wbr.last());
assertEquals(text.length(), lbr.last());
assertEquals(text.length(), sbr.last());
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.next(int)'
*/
public void testNextInt() {
cbr.first();
wbr.first();
lbr.first();
sbr.first();
assertEquals(2, cbr.next(2));
assertEquals(3, wbr.next(2));
assertEquals(8, lbr.next(2));
assertEquals(62, sbr.next(2));
cbr.last();
wbr.last();
lbr.last();
sbr.last();
assertEquals(174, cbr.next(-2));
assertEquals(171, wbr.next(-2));
assertEquals(166, lbr.next(-2));
assertEquals(135, sbr.next(-2));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.next()'
*/
public void testNext() {
cbr.first();
wbr.first();
lbr.first();
sbr.first();
assertEquals(1, cbr.next());
assertEquals(2, wbr.next());
assertEquals(4, lbr.next());
assertEquals(13, sbr.next());
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.previous()'
*/
public void testPrevious() {
cbr.last();
wbr.last();
lbr.last();
sbr.last();
assertEquals(175, cbr.previous());
assertEquals(175, wbr.previous());
assertEquals(171, lbr.previous());
assertEquals(156, sbr.previous());
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.following(int)'
*/
public void testFollowing() {
assertEquals(100, cbr.following(pos));
assertEquals(103, wbr.following(pos));
assertEquals(104, lbr.following(pos));
assertEquals(116, sbr.following(pos));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.preceding(int)'
*/
public void testPreceding() {
assertEquals(98, cbr.preceding(pos));
assertEquals(98, wbr.preceding(pos));
assertEquals(97, lbr.preceding(pos));
assertEquals(62, sbr.preceding(pos));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.isBoundary(int)'
*/
public void testIsBoundary() {
assertTrue(cbr.isBoundary(pos));
assertFalse(wbr.isBoundary(pos));
assertFalse(lbr.isBoundary(pos));
assertFalse(sbr.isBoundary(pos));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.current()'
*/
public void testCurrent() {
cbr.following(pos);
wbr.following(pos);
lbr.following(pos);
sbr.following(pos);
assertEquals(100, cbr.current());
assertEquals(103, wbr.current());
assertEquals(104, lbr.current());
assertEquals(116, sbr.current());
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getText()'
*/
public void testGetText() {
CharacterIterator ci = cbr.getText();
StringBuffer buf = new StringBuffer(ci.getEndIndex() - ci.getBeginIndex());
for (char c = ci.first(); c != CharacterIterator.DONE; c = ci.next()) {
buf.append(c);
}
String result = buf.toString();
assertEquals(text, result);
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.setText(String)'
*/
public void testSetTextString() {
// implicitly tested
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.setText(CharacterIterator)'
*/
public void testSetTextCharacterIterator() {
CharacterIterator ci = new StringCharacterIterator(text, pos);
BreakIterator bi = BreakIterator.getWordInstance();
bi.setText(ci);
assertEquals(2, bi.next());
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance()'
*/
public void testGetWordInstance() {
// implicitly tested
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance(Locale)'
*/
public void testGetWordInstanceLocale() {
assertNotNull(BreakIterator.getWordInstance(Locale.JAPAN));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance(ULocale)'
*/
public void testGetWordInstanceULocale() {
assertNotNull(BreakIterator.getWordInstance(ULocale.JAPAN));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance()'
*/
public void testGetLineInstance() {
// implicitly tested
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance(Locale)'
*/
public void testGetLineInstanceLocale() {
assertNotNull(BreakIterator.getLineInstance(Locale.JAPAN));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance(ULocale)'
*/
public void testGetLineInstanceULocale() {
assertNotNull(BreakIterator.getLineInstance(ULocale.JAPAN));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance()'
*/
public void testGetCharacterInstance() {
// implicitly tested
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance(Locale)'
*/
public void testGetCharacterInstanceLocale() {
assertNotNull(BreakIterator.getCharacterInstance(Locale.JAPAN));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance(ULocale)'
*/
public void testGetCharacterInstanceULocale() {
assertNotNull(BreakIterator.getCharacterInstance(ULocale.JAPAN));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance()'
*/
public void testGetSentenceInstance() {
// implicitly tested
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance(Locale)'
*/
public void testGetSentenceInstanceLocale() {
assertNotNull(BreakIterator.getSentenceInstance(Locale.JAPAN));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance(ULocale)'
*/
public void testGetSentenceInstanceULocale() {
assertNotNull(BreakIterator.getSentenceInstance(ULocale.JAPAN));
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance()'
*/
public void testGetTitleInstance() {
// not implemented
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance(Locale)'
*/
public void testGetTitleInstanceLocale() {
// not implemented
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance(ULocale)'
*/
public void testGetTitleInstanceULocale() {
// not implemented
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getAvailableLocales()'
*/
public void testGetAvailableLocales() {
assertNotNull(BreakIterator.getAvailableLocales());
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.getAvailableULocales()'
*/
public void testGetAvailableULocales() {
assertNotNull(BreakIterator.getAvailableULocales());
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.toString()'
*/
public void testToString() {
assertNotNull(cbr.toString());
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.clone()'
*/
public void testClone() {
// see testHashCode
}
/*
* Test method for 'com.ibm.icu.text.BreakIterator.equals(Object)'
*/
public void testEqualsObject() {
// see testHashCode
}
}

View file

@ -1,553 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.util.Date;
import java.util.Locale;
import com.ibm.icu.text.DateFormat;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
public class CalendarTest extends ICUTestCase {
/*
* Test method for 'com.ibm.icu.util.Calendar.hashCode()'
*/
public void testHashCode() {
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
Calendar cal3 = Calendar.getInstance();
long t = System.currentTimeMillis();
cal1.setTimeInMillis(t);
cal2.setTimeInMillis(t);
cal3.setTimeInMillis(t);
cal3.setMinimalDaysInFirstWeek(cal3.getMinimalDaysInFirstWeek()+1);
testEHCS(cal1, cal2, cal3);
}
/*
* Test method for 'com.ibm.icu.util.Calendar.Calendar(Calendar)'
*/
public void testCalendar() {
// tested implicitly everywhere
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getInstance()'
*/
public void testGetInstance() {
// tested by testEHCS
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getInstance(TimeZone)'
*/
public void testGetInstanceTimeZone() {
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
Calendar cal = Calendar.getInstance(tz);
assertNotNull(cal);
assertNotNull(cal.getTime());
assertEquals(tz, cal.getTimeZone());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getInstance(Locale)'
*/
public void testGetInstanceLocale() {
Calendar cal = Calendar.getInstance(Locale.US);
assertNotNull(cal);
assertNotNull(cal.getTime());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getInstance(ULocale)'
*/
public void testGetInstanceULocale() {
Calendar cal = Calendar.getInstance(ULocale.US);
assertNotNull(cal);
assertNotNull(cal.getTime());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getInstance(TimeZone, Locale)'
*/
public void testGetInstanceTimeZoneLocale() {
TimeZone tz = TimeZone.getTimeZone("America/New_York");
Calendar cal = Calendar.getInstance(tz, Locale.US);
assertNotNull(cal);
assertNotNull(cal.getTime());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getInstance(TimeZone, ULocale)'
*/
public void testGetInstanceTimeZoneULocale() {
TimeZone tz = TimeZone.getTimeZone("America/New_York");
Calendar cal = Calendar.getInstance(tz, ULocale.US);
assertNotNull(cal);
assertNotNull(cal.getTime());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getAvailableLocales()'
*/
public void testGetAvailableLocales() {
assertNotNull(Calendar.getAvailableLocales());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getAvailableULocales()'
*/
public void testGetAvailableULocales() {
assertNotNull(Calendar.getAvailableULocales());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getTime()'
*/
public void testGetTime() {
Calendar cal = Calendar.getInstance();
assertNotNull(cal.getTime());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.setTime(Date)'
*/
public void testSetTime() {
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(2006, 0, 20, 9, 30, 0);
Date date = cal.getTime();
cal = Calendar.getInstance();
cal.setTime(date);
assertEquals(date, cal.getTime());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getTimeInMillis()'
*/
public void testGetTimeInMillis() {
Calendar cal = Calendar.getInstance();
assertTrue(0 != cal.getTimeInMillis());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.setTimeInMillis(long)'
*/
public void testSetTimeInMillis() {
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(2006, 0, 20, 9, 30, 0);
long millis = cal.getTimeInMillis();
Date date = cal.getTime();
cal = Calendar.getInstance();
cal.setTimeInMillis(millis);
assertEquals(date, cal.getTime());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.get(int)'
*/
public void testGet() {
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(2006, 0, 20, 9, 30, 0);
assertEquals(0, cal.get(Calendar.MONTH));
assertEquals(20, cal.get(Calendar.DAY_OF_MONTH));
assertEquals(30, cal.get(Calendar.MINUTE));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.set(int, int)'
*/
public void testSetIntInt() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 1977);
assertEquals(1977, cal.get(Calendar.YEAR));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.set(int, int, int)'
*/
public void testSetIntIntInt() {
Calendar cal = Calendar.getInstance();
cal.set(1997, 9, 15);
assertEquals(15, cal.get(Calendar.DATE));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.set(int, int, int, int, int)'
*/
public void testSetIntIntIntIntInt() {
Calendar cal = Calendar.getInstance();
cal.set(1997, 9, 15, 14, 25);
assertEquals(25, cal.get(Calendar.MINUTE));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.set(int, int, int, int, int, int)'
*/
public void testSetIntIntIntIntIntInt() {
Calendar cal = Calendar.getInstance();
cal.set(1997, 9, 15, 14, 25, 51);
assertEquals(51, cal.get(Calendar.SECOND));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.clear()'
*/
public void testClear() {
Calendar cal = Calendar.getInstance();
cal.set(1997, 9, 15, 14, 25, 51);
cal.clear();
assertEquals(0, cal.get(Calendar.MONTH));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.clear(int)'
*/
public void testClearInt() {
Calendar cal = Calendar.getInstance();
cal.set(1997, 9, 15, 14, 25, 51);
assertTrue(cal.isSet(Calendar.DAY_OF_MONTH));
cal.clear(Calendar.DAY_OF_MONTH);
assertFalse(cal.isSet(Calendar.DAY_OF_MONTH));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.isSet(int)'
*/
public void testIsSet() {
// see testClearInt
}
/*
* Test method for 'com.ibm.icu.util.Calendar.equals(Object)'
*/
public void testEqualsObject() {
// tested by testHashCode
}
/*
* Test method for 'com.ibm.icu.util.Calendar.isEquivalentTo(Calendar)'
*/
public void testIsEquivalentTo() {
Calendar cal = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal2.set(1994, 6, 21, 8, 7);
assertTrue(cal.isEquivalentTo(cal2));
cal.setTimeZone(TimeZone.getTimeZone("CST"));
cal2.setTimeZone(TimeZone.getTimeZone("PDT"));
assertFalse(cal.isEquivalentTo(cal2));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.before(Object)'
*/
public void testBefore() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 1990);
assertTrue(cal.before(new Date()));
assertTrue(cal.before(Calendar.getInstance()));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.after(Object)'
*/
public void testAfter() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 3058);
assertTrue(cal.after(new Date()));
assertTrue(cal.after(Calendar.getInstance()));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getActualMaximum(int)'
*/
public void testGetActualMaximum() {
Calendar cal = Calendar.getInstance(Locale.US);
assertEquals(11, cal.getActualMaximum(Calendar.MONTH));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getActualMinimum(int)'
*/
public void testGetActualMinimum() {
Calendar cal = Calendar.getInstance(Locale.US);
assertEquals(0, cal.getActualMinimum(Calendar.MONTH));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.roll(int, boolean)'
*/
public void testRollIntBoolean() {
Calendar cal = Calendar.getInstance(Locale.US);
cal.set(1997, 1, 27);
cal.roll(Calendar.DATE, true);
assertEquals(28, cal.get(Calendar.DATE));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.roll(int, int)'
*/
public void testRollIntInt() {
Calendar cal = Calendar.getInstance(Locale.US);
cal.set(1997, 1, 27);
cal.roll(Calendar.DATE, 3);
assertEquals(2, cal.get(Calendar.DATE));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.add(int, int)'
*/
public void testAdd() {
Calendar cal = Calendar.getInstance(Locale.US);
cal.set(1997, 1, 27);
cal.add(Calendar.DATE, 3);
assertEquals(2, cal.get(Calendar.DATE));
assertEquals(2, cal.get(Calendar.MONTH));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getDisplayName(Locale)'
*/
public void testGetDisplayNameLocale() {
Calendar cal = Calendar.getInstance();
assertEquals("Gregorian Calendar", cal.getDisplayName(Locale.US));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getDisplayName(ULocale)'
*/
public void testGetDisplayNameULocale() {
Calendar cal = Calendar.getInstance();
assertEquals("Gregorian Calendar", cal.getDisplayName(ULocale.US));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.compareTo(Calendar)'
*/
public void testCompareToCalendar() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 1990);
assertTrue(0 > cal.compareTo(Calendar.getInstance()));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.compareTo(Object)'
*/
public void testCompareToObject() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 1990);
assertTrue(0 > cal.compareTo(Calendar.getInstance()));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getDateTimeFormat(int, int, Locale)'
*/
public void testGetDateTimeFormatIntIntLocale() {
Calendar cal = Calendar.getInstance();
cal.set(1990, 8, 16, 20, 3);
DateFormat df = cal.getDateTimeFormat(DateFormat.LONG, DateFormat.SHORT, Locale.US);
assertEquals("September 16, 1990 8:03 PM", df.format(cal));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getDateTimeFormat(int, int, ULocale)'
*/
public void testGetDateTimeFormatIntIntULocale() {
Calendar cal = Calendar.getInstance();
cal.set(1990, 8, 16, 20, 3);
DateFormat df = cal.getDateTimeFormat(DateFormat.LONG, DateFormat.SHORT, ULocale.US);
assertEquals("September 16, 1990 8:03 PM", df.format(cal));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.fieldDifference(Date, int)'
*/
public void testFieldDifference() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 0);
Date date = cal.getTime();
cal.add(Calendar.DAY_OF_MONTH, 5);
assertEquals(-5, cal.fieldDifference(date, Calendar.DAY_OF_MONTH));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getTimeZone()'
*/
public void testGetTimeZone() {
Calendar cal = Calendar.getInstance();
assertNotNull(cal.getTimeZone());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.setTimeZone(TimeZone)'
*/
public void testSetTimeZone() {
Calendar cal = Calendar.getInstance();
TimeZone value1 = cal.getTimeZone();
String tzn = "PDT".equals(value1.getID()) ? "CST" : "PDT";
TimeZone value2 = TimeZone.getTimeZone(tzn);
cal.setTimeZone(value2);
TimeZone result = cal.getTimeZone();
assertNotEqual(value1, result);
assertEquals(value2, result);
}
/*
* Test method for 'com.ibm.icu.util.Calendar.setLenient(boolean)'
*/
public void testSetLenient() {
Calendar cal = Calendar.getInstance();
boolean lenient = cal.isLenient();
cal.setLenient(!lenient);
assertFalse(lenient == cal.isLenient());
// not testing if it has the expected effect
}
/*
* Test method for 'com.ibm.icu.util.Calendar.isLenient()'
*/
public void testIsLenient() {
// tested by testSetLenient
}
/*
* Test method for 'com.ibm.icu.util.Calendar.setFirstDayOfWeek(int)'
*/
public void testSetFirstDayOfWeek() {
Calendar cal = Calendar.getInstance();
int firstDay = cal.getFirstDayOfWeek();
cal.setFirstDayOfWeek(firstDay+1);
assertEquals(firstDay+1, cal.getFirstDayOfWeek());
// don't test functionality
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getFirstDayOfWeek()'
*/
public void testGetFirstDayOfWeek() {
// tested by testSetFirstDayOfWeek
}
/*
* Test method for 'com.ibm.icu.util.Calendar.setMinimalDaysInFirstWeek(int)'
*/
public void testSetMinimalDaysInFirstWeek() {
Calendar cal = Calendar.getInstance();
int firstDay = cal.getMinimalDaysInFirstWeek();
cal.setMinimalDaysInFirstWeek(firstDay+1);
assertEquals(firstDay+1, cal.getMinimalDaysInFirstWeek());
// don't test functionality
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getMinimalDaysInFirstWeek()'
*/
public void testGetMinimalDaysInFirstWeek() {
// tested by testSetMinimalDaysInFirstWeek
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getMinimum(int)'
*/
public void testGetMinimum() {
Calendar cal = Calendar.getInstance();
assertEquals(1, cal.getMinimum(Calendar.DAY_OF_WEEK));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getMaximum(int)'
*/
public void testGetMaximum() {
Calendar cal = Calendar.getInstance();
assertEquals(7, cal.getMaximum(Calendar.DAY_OF_WEEK));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getGreatestMinimum(int)'
*/
public void testGetGreatestMinimum() {
Calendar cal = Calendar.getInstance();
assertEquals(1, cal.getGreatestMinimum(Calendar.DATE));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getLeastMaximum(int)'
*/
public void testGetLeastMaximum() {
Calendar cal = Calendar.getInstance();
assertEquals(28, cal.getLeastMaximum(Calendar.DATE));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getDayOfWeekType(int)'
*/
public void testGetDayOfWeekType() {
Calendar cal = Calendar.getInstance(Locale.US);
assertEquals(Calendar.WEEKDAY, cal.getDayOfWeekType(Calendar.FRIDAY));
assertEquals(Calendar.WEEKEND, cal.getDayOfWeekType(Calendar.SATURDAY));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.isWeekend(Date)'
*/
public void testIsWeekendDate() {
Calendar cal = Calendar.getInstance(Locale.US);
cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
assertTrue(cal.isWeekend(cal.getTime()));
cal.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
assertFalse(cal.isWeekend(cal.getTime()));
}
/*
* Test method for 'com.ibm.icu.util.Calendar.isWeekend()'
*/
public void testIsWeekend() {
Calendar cal = Calendar.getInstance(Locale.US);
cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
assertTrue(cal.isWeekend());
cal.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
assertFalse(cal.isWeekend());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.clone()'
*/
public void testClone() {
// tested by testHashCode
}
/*
* Test method for 'com.ibm.icu.util.Calendar.toString()'
*/
public void testToString() {
Calendar cal = Calendar.getInstance();
assertNotNull(cal.toString());
}
/*
* Test method for 'com.ibm.icu.util.Calendar.getType()'
*/
public void testGetType() {
Calendar cal = Calendar.getInstance(Locale.US);
assertEquals("gregorian", cal.getType());
}
}

View file

@ -1,104 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import com.ibm.icu.text.CollationKey;
import com.ibm.icu.text.Collator;
public class CollationKeyTest extends ICUTestCase {
/*
* Test method for 'com.ibm.icu.text.CollationKey.hashCode()'
*/
public void testHashCode() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
CollationKey k1 = c.getCollationKey("This");
CollationKey k2 = c.getCollationKey("this");
c.setStrength(Collator.TERTIARY);
CollationKey kn = c.getCollationKey("this");
testEHCS(k1, k2, kn);
}
/*
* Test method for 'com.ibm.icu.text.CollationKey.CollationKey(CollationKey)'
*/
public void testCollationKey() {
// implicitly tested everywhere
}
/*
* Test method for 'com.ibm.icu.text.CollationKey.compareTo(CollationKey)'
*/
public void testCompareToCollationKey() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
CollationKey k1 = c.getCollationKey("This");
CollationKey k2 = c.getCollationKey("this");
c.setStrength(Collator.TERTIARY);
CollationKey k3 = c.getCollationKey("this");
assertTrue(0 == k1.compareTo(k2));
assertFalse(0 == k1.compareTo(k3));
}
/*
* Test method for 'com.ibm.icu.text.CollationKey.compareTo(Object)'
*/
public void testCompareToObject() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
CollationKey k1 = c.getCollationKey("This");
CollationKey k2 = c.getCollationKey("this");
assertTrue(0 == k1.compareTo(k2));
}
/*
* Test method for 'com.ibm.icu.text.CollationKey.equals(Object)'
*/
public void testEqualsObject() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
CollationKey k1 = c.getCollationKey("This");
CollationKey k2 = c.getCollationKey("this");
assertTrue(k1.equals((Object)k2));
}
/*
* Test method for 'com.ibm.icu.text.CollationKey.toString()'
*/
public void testToString() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
CollationKey k1 = c.getCollationKey("This");
assertNotNull(k1.toString());
}
/*
* Test method for 'com.ibm.icu.text.CollationKey.getSourceString()'
*/
public void testGetSourceString() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
CollationKey k1 = c.getCollationKey("This");
assertEquals("This", k1.getSourceString());
}
/*
* Test method for 'com.ibm.icu.text.CollationKey.toByteArray()'
*/
public void testToByteArray() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
CollationKey k1 = c.getCollationKey("This");
byte[] key = k1.toByteArray();
assertNotNull(key);
assertTrue(0 < key.length);
}
}

View file

@ -1,207 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.util.Locale;
import com.ibm.icu.text.CollationKey;
import com.ibm.icu.text.Collator;
import com.ibm.icu.util.ULocale;
public class CollatorTest extends ICUTestCase {
private static final String s1 = "Fu\u0308nf"; // capital F + u + diaresis
private static final String s2 = "fu\u0308nf"; // u + diaresis
private static final String s3 = "f\u00fcnf"; // u-umlaut
private static final String s4 = "fu\u0308\u0316nf"; // u + diaresis above + grave below
private static final String s5 = "fu\u0316\u0308nf"; // u + grave below + diaresis above
/*
* Test method for 'com.ibm.icu.text.Collator.hashCode()'
*/
public void testHashCode() {
Collator c = Collator.getInstance();
c.setStrength(Collator.SECONDARY);
Collator c2 = Collator.getInstance();
c2.setStrength(Collator.SECONDARY);
Collator cn = Collator.getInstance();
cn.setStrength(Collator.TERTIARY);
testEHCS(c, c2, cn);
}
/*
* Test method for 'com.ibm.icu.text.Collator.Collator(Collator)'
*/
public void testCollator() {
// implicitly tested everywhere
}
/*
* Test method for 'com.ibm.icu.text.Collator.setStrength(int)'
*/
public void testSetStrength() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
assertTrue(0 == c.compare(s1, s2));
c.setStrength(Collator.SECONDARY);
assertTrue(0 == c.compare(s1, s2));
c.setStrength(Collator.TERTIARY);
assertTrue(0 < c.compare(s1, s2));
assertTrue(0 == c.compare(s2, s3));
c.setStrength(Collator.QUATERNARY);
assertTrue(0 > c.compare(s2, s3));
}
/*
* Test method for 'com.ibm.icu.text.Collator.setDecomposition(int)'
*/
public void testSetDecomposition() {
Collator c = Collator.getInstance();
c.setStrength(Collator.TERTIARY);
assertTrue(0 != c.compare(s4, s5));
c.setDecomposition(Collator.IDENTICAL);
assertTrue(0 == c.compare(s4, s5));
}
/*
* Test method for 'com.ibm.icu.text.Collator.getInstance()'
*/
public void testGetInstance() {
// implicitly tested everywhere
}
/*
* Test method for 'com.ibm.icu.text.Collator.getInstance(ULocale)'
*/
public void testGetInstanceULocale() {
Collator c = Collator.getInstance(ULocale.GERMANY);
assertNotNull(c);
}
/*
* Test method for 'com.ibm.icu.text.Collator.getInstance(Locale)'
*/
public void testGetInstanceLocale() {
Collator c = Collator.getInstance(Locale.GERMANY);
assertNotNull(c);
}
/*
* Test method for 'com.ibm.icu.text.Collator.getAvailableLocales()'
*/
public void testGetAvailableLocales() {
assertNotNull(Collator.getAvailableLocales());
}
/*
* Test method for 'com.ibm.icu.text.Collator.getAvailableULocales()'
*/
public void testGetAvailableULocales() {
assertNotNull(Collator.getAvailableULocales());
}
/*
* Test method for 'com.ibm.icu.text.Collator.getKeywords()'
*/
public void testGetKeywords() {
assertEquals(0, Collator.getKeywords().length);
}
/*
* Test method for 'com.ibm.icu.text.Collator.getKeywordValues(String)'
*/
public void testGetKeywordValues() {
assertEquals(0, Collator.getKeywordValues("").length);
}
/*
* Test method for 'com.ibm.icu.text.Collator.getStrength()'
*/
public void testGetStrength() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
assertEquals(Collator.PRIMARY, c.getStrength());
c.setStrength(Collator.SECONDARY);
assertEquals(Collator.SECONDARY, c.getStrength());
}
/*
* Test method for 'com.ibm.icu.text.Collator.getDecomposition()'
*/
public void testGetDecomposition() {
Collator c = Collator.getInstance();
c.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
assertEquals(Collator.CANONICAL_DECOMPOSITION, c.getDecomposition());
c.setDecomposition(Collator.NO_DECOMPOSITION);
assertEquals(Collator.NO_DECOMPOSITION, c.getDecomposition());
}
/*
* Test method for 'com.ibm.icu.text.Collator.compare(Object, Object)'
*/
public void testCompareObjectObject() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
assertTrue(0 == c.compare((Object)s1, (Object)s2));
}
/*
* Test method for 'com.ibm.icu.text.Collator.equals(String, String)'
*/
public void testEqualsStringString() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
assertTrue(c.equals(s1, s2));
}
/*
* Test method for 'com.ibm.icu.text.Collator.compare(String, String)'
*/
public void testCompareStringString() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
assertTrue(0 == c.compare(s1, s2));
}
/*
* Test method for 'com.ibm.icu.text.Collator.getCollationKey(String)'
*/
public void testGetCollationKey() {
Collator c = Collator.getInstance();
c.setStrength(Collator.PRIMARY);
CollationKey k1 = c.getCollationKey(s1);
CollationKey k2 = c.getCollationKey(s2);
assertTrue(k1.equals(k2));
c.setStrength(Collator.TERTIARY);
k1 = c.getCollationKey(s1);
k2 = c.getCollationKey(s2);
assertFalse(k1.equals(k2));
}
/*
* Test method for 'com.ibm.icu.text.Collator.toString()'
*/
public void testToString() {
assertNotNull(Collator.getInstance().toString());
}
/*
* Test method for 'com.ibm.icu.text.Collator.clone()'
*/
public void testClone() {
// tested above
}
/*
* Test method for 'com.ibm.icu.text.Collator.equals(Object)'
*/
public void testEqualsObject() {
// tested above
}
}

View file

@ -1,259 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.util.Locale;
import com.ibm.icu.text.DateFormatSymbols;
import com.ibm.icu.util.ULocale;
public class DateFormatSymbolsTest extends ICUTestCase {
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.hashCode()'
*/
public void testHashCode() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
DateFormatSymbols dfs2 = new DateFormatSymbols(ULocale.US);
DateFormatSymbols dfsn = new DateFormatSymbols(Locale.US);
dfsn.setAmPmStrings(new String[] { "sw", "xw" });
testEHCS(dfs, dfs2, dfsn);
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(DateFormatSymbols)'
*/
public void testDateFormatSymbolsDateFormatSymbols() {
// implicitly tested everywhere
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols()'
*/
public void testDateFormatSymbols() {
DateFormatSymbols dfs = new DateFormatSymbols();
assertNotNull(dfs.getWeekdays());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(Locale)'
*/
public void testDateFormatSymbolsLocale() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
assertNotNull(dfs.getWeekdays());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(ULocale)'
*/
public void testDateFormatSymbolsULocale() {
DateFormatSymbols dfs = new DateFormatSymbols(ULocale.US);
assertNotNull(dfs.getWeekdays());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getEras()'
*/
public void testGetEras() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
assertNotNull(dfs.getEras());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setEras(String[])'
*/
public void testSetEras() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
String[] oldvalue = dfs.getEras();
String[] newvalue = (String[])oldvalue.clone();
newvalue[0] = newvalue[0] + "!";
dfs.setEras(newvalue);
String[] result = dfs.getEras();
assertArraysNotEqual(oldvalue, result);
assertArraysEqual(newvalue, result);
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getMonths()'
*/
public void testGetMonths() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
assertNotNull(dfs.getMonths());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setMonths(String[])'
*/
public void testSetMonths() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
String[] oldvalue = dfs.getMonths();
String[] newvalue = (String[])oldvalue.clone();
newvalue[0] = newvalue[0] + "!";
dfs.setMonths(newvalue);
String[] result = dfs.getMonths();
assertArraysNotEqual(oldvalue, result);
assertArraysEqual(newvalue, result);
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortMonths()'
*/
public void testGetShortMonths() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
assertNotNull(dfs.getShortMonths());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortMonths(String[])'
*/
public void testSetShortMonths() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
String[] oldvalue = dfs.getShortMonths();
String[] newvalue = (String[])oldvalue.clone();
newvalue[0] = newvalue[0] + "!";
dfs.setShortMonths(newvalue);
String[] result = dfs.getShortMonths();
assertArraysNotEqual(oldvalue, result);
assertArraysEqual(newvalue, result);
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getWeekdays()'
*/
public void testGetWeekdays() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
assertNotNull(dfs.getShortMonths());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setWeekdays(String[])'
*/
public void testSetWeekdays() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
String[] oldvalue = dfs.getWeekdays();
String[] newvalue = (String[])oldvalue.clone();
newvalue[0] = newvalue[0] + "!";
dfs.setWeekdays(newvalue);
String[] result = dfs.getWeekdays();
assertArraysNotEqual(oldvalue, result);
assertArraysEqual(newvalue, result);
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortWeekdays()'
*/
public void testGetShortWeekdays() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
assertNotNull(dfs.getShortWeekdays());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortWeekdays(String[])'
*/
public void testSetShortWeekdays() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
String[] oldvalue = dfs.getShortWeekdays();
String[] newvalue = (String[])oldvalue.clone();
newvalue[0] = newvalue[0] + "!";
dfs.setShortWeekdays(newvalue);
String[] result = dfs.getShortWeekdays();
assertArraysNotEqual(oldvalue, result);
assertArraysEqual(newvalue, result);
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getAmPmStrings()'
*/
public void testGetAmPmStrings() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
assertNotNull(dfs.getAmPmStrings());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setAmPmStrings(String[])'
*/
public void testSetAmPmStrings() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
String[] oldvalue = dfs.getAmPmStrings();
String[] newvalue = (String[])oldvalue.clone();
newvalue[0] = newvalue[0] + "!";
dfs.setAmPmStrings(newvalue);
String[] result = dfs.getAmPmStrings();
assertArraysNotEqual(oldvalue, result);
assertArraysEqual(newvalue, result);
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getZoneStrings()'
*/
public void testGetZoneStrings() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
assertNotNull(dfs.getZoneStrings());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setZoneStrings(String[][])'
*/
public void testSetZoneStrings() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
String[][] oldvalue = dfs.getZoneStrings();
String[][] newvalue = (String[][])cloneComplex(oldvalue);
newvalue[0][0] = newvalue[0][0] + "!";
dfs.setZoneStrings(newvalue);
String[][] result = dfs.getZoneStrings();
assertArraysNotEqual(oldvalue, result);
assertArraysEqual(newvalue, result);
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getLocalPatternChars()'
*/
public void testGetLocalPatternChars() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
assertNotNull(dfs.getLocalPatternChars());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setLocalPatternChars(String)'
*/
public void testSetLocalPatternChars() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
String pat = dfs.getLocalPatternChars();
StringBuffer buf = new StringBuffer(pat);
buf.setCharAt(0, (char)(pat.charAt(0) + 1));
String pat2 = buf.toString();
dfs.setLocalPatternChars(pat2);
String pat3 = dfs.getLocalPatternChars();
assertNotEqual(pat, pat2);
assertEquals(pat2, pat3);
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.toString()'
*/
public void testToString() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
assertNotNull(dfs.toString());
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.clone()'
*/
public void testClone() {
// tested by testHashCode
}
/*
* Test method for 'com.ibm.icu.text.DateFormatSymbols.equals(Object)'
*/
public void testEqualsObject() {
// tested by testHashCode
}
}

View file

@ -1,456 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.text.FieldPosition;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.Date;
import java.util.Locale;
import com.ibm.icu.text.DateFormat;
import com.ibm.icu.text.NumberFormat;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
public class DateFormatTest extends ICUTestCase {
private Calendar aCal;
private Calendar anESTCal;
private Date aDate;
private String aDateString;
private String aTimeString;
private String anESTTimeString;
private String aDateTimeString;
private String aShortDateTimeString;
private String aDefaultESTDateTimeString;
private DateFormat aDF;
private StringBuffer aBuf;
private FieldPosition anFP;
private FieldPosition anFPField;
private static int YEAR_POS_START = 8;
private static int YEAR_POS_END = 12;
protected void setUp() throws Exception {
super.setUp();
java.util.GregorianCalendar gcal = new java.util.GregorianCalendar();
gcal.clear();
gcal.set(java.util.GregorianCalendar.YEAR, 1990);
gcal.set(java.util.GregorianCalendar.MONTH, java.util.GregorianCalendar.DECEMBER);
gcal.set(java.util.GregorianCalendar.DATE, 17);
gcal.set(java.util.GregorianCalendar.HOUR, 5);
gcal.set(java.util.GregorianCalendar.MINUTE, 17);
aCal = new Calendar(gcal);
anESTCal = Calendar.getInstance();
anESTCal.setTimeZone(TimeZone.getTimeZone("EST"));
aDate = gcal.getTime();
aDateString = "Dec 17, 1990"; // medium -- the default
aTimeString = "5:17:00 AM"; // medium
anESTTimeString = "8:17:00 AM";
aDateTimeString = "Dec 17, 1990 5:17:00 AM"; // medium, medium
aDefaultESTDateTimeString = "Dec 17, 1990 8:17 AM"; // medium, short -- the default
aShortDateTimeString = "12/17/90 5:17 AM"; // short, short
aDF = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US);
aBuf = new StringBuffer();
anFP = new FieldPosition(DateFormat.YEAR_FIELD);
anFPField = new FieldPosition(DateFormat.Field.YEAR);
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.hashCode()'
*/
public final void testHashCode() {
DateFormat df = DateFormat.getInstance();
DateFormat eq = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
testEHCS(df, eq, aDF);
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.DateFormat(DateFormat)'
*/
public final void testDateFormat() {
DateFormat df = new DateFormat(java.text.DateFormat.getInstance());
assertEquals(DateFormat.getInstance(), df);
}
private void assertEqualDateString(StringBuffer buf) {
assertEquals(aDateTimeString, buf.toString());
}
private void assertEqualDateString(String str) {
assertEquals(aDateTimeString, str);
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.format(Object, StringBuffer, FieldPosition)'
*/
public final void testFormatObjectStringBufferFieldPosition() {
assertEqualDateString(aDF.format(aDate, aBuf, anFP));
assertEquals(YEAR_POS_START, anFP.getBeginIndex());
assertEquals(YEAR_POS_END, anFP.getEndIndex());
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.format(Calendar, StringBuffer, FieldPosition)'
*/
public final void testFormatCalendarStringBufferFieldPosition() {
assertEqualDateString(aDF.format(aCal, aBuf, anFP));
assertEquals(YEAR_POS_START, anFP.getBeginIndex());
assertEquals(YEAR_POS_END, anFP.getEndIndex());
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.format(Date, StringBuffer, FieldPosition)'
*/
public final void testFormatDateStringBufferFieldPosition() {
assertEqualDateString(aDF.format(aDate, aBuf, anFPField));
assertEquals(YEAR_POS_START, anFPField.getBeginIndex());
assertEquals(YEAR_POS_END, anFPField.getEndIndex());
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.format(Date)'
*/
public final void testFormatDate() {
assertEqualDateString(aDF.format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.parse(String)'
*/
public final void testParseString() throws Exception {
assertEquals(aDate, aDF.parse(aDateTimeString));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.parse(String, Calendar, ParsePosition)'
*/
public final void testParseStringCalendarParsePosition() {
aDF.parse(aDateTimeString, aCal, new ParsePosition(0));
assertEquals(aDate, aCal.getTime());
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.parse(String, ParsePosition)'
*/
public final void testParseStringParsePosition() {
assertEquals(aDate, aDF.parse(aDateTimeString, new ParsePosition(0)));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.parseObject(String, ParsePosition)'
*/
public final void testParseObjectStringParsePosition() {
assertEquals(aDate, aDF.parseObject(aDateTimeString, new ParsePosition(0)));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance()'
*/
public final void testGetTimeInstance() {
assertEquals(aTimeString, DateFormat.getTimeInstance().format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(int)'
*/
public final void testGetTimeInstanceInt() {
assertEquals(aTimeString, DateFormat.getTimeInstance(DateFormat.MEDIUM).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(int, Locale)'
*/
public final void testGetTimeInstanceIntLocale() {
assertEquals(aTimeString, DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(int, ULocale)'
*/
public final void testGetTimeInstanceIntULocale() {
assertEquals(aTimeString, DateFormat.getTimeInstance(DateFormat.MEDIUM, ULocale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance()'
*/
public final void testGetDateInstance() {
assertEquals(aDateString, DateFormat.getDateInstance().format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(int)'
*/
public final void testGetDateInstanceInt() {
assertEquals(aDateString, DateFormat.getDateInstance(DateFormat.MEDIUM).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(int, Locale)'
*/
public final void testGetDateInstanceIntLocale() {
assertEquals(aDateString, DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(int, ULocale)'
*/
public final void testGetDateInstanceIntULocale() {
assertEquals(aDateString, DateFormat.getDateInstance(DateFormat.MEDIUM, ULocale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance()'
*/
public final void testGetDateTimeInstance() {
assertEquals(aDateTimeString, DateFormat.getDateTimeInstance().format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(int, int)'
*/
public final void testGetDateTimeInstanceIntInt() {
assertEquals(aDateTimeString,
DateFormat.getDateTimeInstance(
DateFormat.MEDIUM, DateFormat.MEDIUM).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(int, int, Locale)'
*/
public final void testGetDateTimeInstanceIntIntLocale() {
assertEquals(aDateTimeString,
DateFormat.getDateTimeInstance(
DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(int, int, ULocale)'
*/
public final void testGetDateTimeInstanceIntIntULocale() {
assertEquals(aDateTimeString,
DateFormat.getDateTimeInstance(
DateFormat.MEDIUM, DateFormat.MEDIUM, ULocale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getInstance()'
*/
public final void testGetInstance() {
assertEquals(aShortDateTimeString, DateFormat.getInstance().format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getAvailableLocales()'
*/
public final void testGetAvailableLocales() {
Locale[] locales = DateFormat.getAvailableLocales();
if (ICUTestCase.testingWrapper) {
ICUTestCase.assertArraysEqual(java.text.DateFormat.getAvailableLocales(), locales);
} else {
assertNotNull(locales);
}
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.setCalendar(Calendar)'
*/
public final void testSetCalendar() {
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("EST"));
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
df.setCalendar(cal);
assertEquals("8:17 AM", df.format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getCalendar()'
*/
public final void testGetCalendar() {
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("EST"));
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
df.setCalendar(cal);
assertEquals(cal, df.getCalendar());
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.setNumberFormat(NumberFormat)'
*/
public final void testSetNumberFormat() {
// no easy way to test effect of setting the number format
NumberFormat nf = NumberFormat.getInstance();
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
df.setNumberFormat(nf);
// note, can't actually USE the dateformat since it changes the calendar
assertEquals(nf, df.getNumberFormat());
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getNumberFormat()'
*/
public final void testGetNumberFormat() {
// see testSetNumberFormat
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.setTimeZone(TimeZone)'
*/
public final void testSetTimeZone() {
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
TimeZone tz = TimeZone.getTimeZone("EST");
df.setTimeZone(tz);
assertEquals("8:17 AM", df.format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getTimeZone()'
*/
public final void testGetTimeZone() {
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
TimeZone tz = TimeZone.getTimeZone("EST");
df.setTimeZone(tz);
assertEquals(tz, df.getTimeZone());
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.setLenient(boolean)'
*/
public final void testSetLenient() throws Exception {
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
df.parse("2/31/90"); // succeeds, default is lenient
df.setLenient(false);
try {
df.parse("2/31/90");
throw new Exception("strict parse should have failed");
}
catch (ParseException e) {
// ok, this is what we expect
}
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.isLenient()'
*/
public final void testIsLenient() {
DateFormat df = DateFormat.getInstance();
assertTrue(df.isLenient());
df.setLenient(false);
assertFalse(df.isLenient());
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(Calendar, int, Locale)'
*/
public final void testGetDateInstanceCalendarIntLocale() {
assertEquals(aDateString, DateFormat.getDateInstance(aCal, DateFormat.MEDIUM, Locale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(Calendar, int, ULocale)'
*/
public final void testGetDateInstanceCalendarIntULocale() {
assertEquals(aDateString, DateFormat.getDateInstance(aCal, DateFormat.MEDIUM, ULocale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(Calendar, int, Locale)'
*/
public final void testGetTimeInstanceCalendarIntLocale() {
assertEquals(anESTTimeString, DateFormat.getTimeInstance(anESTCal, DateFormat.MEDIUM, Locale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(Calendar, int, ULocale)'
*/
public final void testGetTimeInstanceCalendarIntULocale() {
assertEquals(anESTTimeString, DateFormat.getTimeInstance(anESTCal, DateFormat.MEDIUM, ULocale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(Calendar, int, int, Locale)'
*/
public final void testGetDateTimeInstanceCalendarIntIntLocale() {
assertEquals(aDefaultESTDateTimeString, DateFormat.getDateTimeInstance(anESTCal, DateFormat.MEDIUM, DateFormat.SHORT, Locale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(Calendar, int, int, ULocale)'
*/
public final void testGetDateTimeInstanceCalendarIntIntULocale() {
assertEquals(aDefaultESTDateTimeString, DateFormat.getDateTimeInstance(anESTCal, DateFormat.MEDIUM, DateFormat.SHORT, ULocale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getInstance(Calendar, Locale)'
*/
public final void testGetInstanceCalendarLocale() {
assertEquals(aDefaultESTDateTimeString, DateFormat.getInstance(anESTCal, Locale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getInstance(Calendar, ULocale)'
*/
public final void testGetInstanceCalendarULocale() {
assertEquals(aDefaultESTDateTimeString, DateFormat.getInstance(anESTCal, ULocale.US).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getInstance(Calendar)'
*/
public final void testGetInstanceCalendar() {
assertEquals(aDefaultESTDateTimeString, DateFormat.getInstance(anESTCal).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(Calendar, int)'
*/
public final void testGetDateInstanceCalendarInt() {
assertEquals(aDateString, DateFormat.getDateInstance(aCal, DateFormat.MEDIUM).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(Calendar, int)'
*/
public final void testGetTimeInstanceCalendarInt() {
assertEquals(anESTTimeString, DateFormat.getTimeInstance(anESTCal, DateFormat.MEDIUM).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(Calendar, int, int)'
*/
public final void testGetDateTimeInstanceCalendarIntInt() {
assertEquals(aDefaultESTDateTimeString, DateFormat.getDateTimeInstance(anESTCal, DateFormat.MEDIUM, DateFormat.SHORT).format(aDate));
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.toString()'
*/
public final void testToString() {
assertNotNull(aDF.toString());
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.clone()'
*/
public final void testClone() {
// see testHashCode
}
/*
* Test method for 'com.ibm.icu.text.DateFormat.equals(Object)'
*/
public final void testEqualsObject() {
// see testHashCode
}
}

View file

@ -1,346 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.util.Locale;
import com.ibm.icu.text.DecimalFormatSymbols;
import com.ibm.icu.util.ULocale;
public class DecimalFormatSymbolsTest extends ICUTestCase {
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.hashCode()'
*/
public void testHashCode() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
DecimalFormatSymbols dfs2 = new DecimalFormatSymbols(ULocale.US);
DecimalFormatSymbols dfsn = new DecimalFormatSymbols(Locale.FRANCE);
testEHCS(dfs, dfs2, dfsn);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(DecimalFormatSymbols)'
*/
public void testDecimalFormatSymbolsDecimalFormatSymbols() {
// implicitly tested everywhere
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols()'
*/
public void testDecimalFormatSymbols() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
assertTrue(-1 != dfs.getDecimalSeparator());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(Locale)'
*/
public void testDecimalFormatSymbolsLocale() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
assertTrue(-1 != dfs.getDecimalSeparator());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(ULocale)'
*/
public void testDecimalFormatSymbolsULocale() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertTrue(-1 != dfs.getDecimalSeparator());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getZeroDigit()'
*/
public void testGetZeroDigit() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals('0', dfs.getZeroDigit());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setZeroDigit(char)'
*/
public void testSetZeroDigit() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
char value = dfs.getZeroDigit();
char value1 = (char)(value + 1);
dfs.setZeroDigit(value1);
char result = dfs.getZeroDigit();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getGroupingSeparator()'
*/
public void testGetGroupingSeparator() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals(',', dfs.getGroupingSeparator());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setGroupingSeparator(char)'
*/
public void testSetGroupingSeparator() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
char value = dfs.getGroupingSeparator();
char value1 = (char)(value + 1);
dfs.setGroupingSeparator(value1);
char result = dfs.getGroupingSeparator();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDecimalSeparator()'
*/
public void testGetDecimalSeparator() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals('.', dfs.getDecimalSeparator());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDecimalSeparator(char)'
*/
public void testSetDecimalSeparator() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
char value = dfs.getDecimalSeparator();
char value1 = (char)(value + 1);
dfs.setDecimalSeparator(value1);
char result = dfs.getDecimalSeparator();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPerMill()'
*/
public void testGetPerMill() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals('\u2030', dfs.getPerMill());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPerMill(char)'
*/
public void testSetPerMill() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
char value = dfs.getPerMill();
char value1 = (char)(value + 1);
dfs.setPerMill(value1);
char result = dfs.getPerMill();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPercent()'
*/
public void testGetPercent() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals('%', dfs.getPercent());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPercent(char)'
*/
public void testSetPercent() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
char value = dfs.getPercent();
char value1 = (char)(value + 1);
dfs.setPercent(value1);
char result = dfs.getPercent();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDigit()'
*/
public void testGetDigit() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals('#', dfs.getDigit());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDigit(char)'
*/
public void testSetDigit() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
char value = dfs.getDigit();
char value1 = (char)(value + 1);
dfs.setDigit(value1);
char result = dfs.getDigit();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPatternSeparator()'
*/
public void testGetPatternSeparator() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals(';', dfs.getPatternSeparator());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPatternSeparator(char)'
*/
public void testSetPatternSeparator() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
char value = dfs.getPatternSeparator();
char value1 = (char)(value + 1);
dfs.setPatternSeparator(value1);
char result = dfs.getPatternSeparator();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInfinity()'
*/
public void testGetInfinity() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals("\u221e", dfs.getInfinity());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInfinity(String)'
*/
public void testSetInfinity() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
String value = dfs.getInfinity();
String value1 = value + "!";
dfs.setInfinity(value1);
String result = dfs.getInfinity();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getNaN()'
*/
public void testGetNaN() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertNotNull(dfs.getNaN()); // java returns missing character???
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setNaN(String)'
*/
public void testSetNaN() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
String value = dfs.getNaN();
String value1 = value + "!";
dfs.setNaN(value1);
String result = dfs.getNaN();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMinusSign()'
*/
public void testGetMinusSign() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals('-', dfs.getMinusSign());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMinusSign(char)'
*/
public void testSetMinusSign() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
char value = dfs.getMinusSign();
char value1 = (char)(value + 1);
dfs.setMinusSign(value1);
char result = dfs.getMinusSign();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getCurrencySymbol()'
*/
public void testGetCurrencySymbol() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals("$", dfs.getCurrencySymbol());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setCurrencySymbol(String)'
*/
public void testSetCurrencySymbol() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
String value = dfs.getCurrencySymbol();
String value1 = value + "!";
dfs.setCurrencySymbol(value1);
String result = dfs.getCurrencySymbol();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInternationalCurrencySymbol()'
*/
public void testGetInternationalCurrencySymbol() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals("USD", dfs.getInternationalCurrencySymbol());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInternationalCurrencySymbol(String)'
*/
public void testSetInternationalCurrencySymbol() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
String value = dfs.getInternationalCurrencySymbol();
String value1 = value + "!";
dfs.setInternationalCurrencySymbol(value1);
String result = dfs.getInternationalCurrencySymbol();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMonetaryDecimalSeparator()'
*/
public void testGetMonetaryDecimalSeparator() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
assertEquals('.', dfs.getMonetaryDecimalSeparator());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMonetaryDecimalSeparator(char)'
*/
public void testSetMonetaryDecimalSeparator() {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
char value = dfs.getMonetaryDecimalSeparator();
char value1 = (char)(value + 1);
dfs.setMonetaryDecimalSeparator(value1);
char result = dfs.getMonetaryDecimalSeparator();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.clone()'
*/
public void testClone() {
// tested in testHashcode
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.equals(Object)'
*/
public void testEqualsObject() {
// tested in testHashcode
}
}

View file

@ -1,244 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.util.Locale;
import com.ibm.icu.text.DecimalFormat;
import com.ibm.icu.text.DecimalFormatSymbols;
public class DecimalFormatTest extends ICUTestCase {
private static final long lmax = Long.MAX_VALUE;
private static final double dsmall = 23.33;
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.clone()'
*/
public void testClone() {
DecimalFormat df = new DecimalFormat("#,#0.00");
DecimalFormat df2 = new DecimalFormat("#,#0.00");
DecimalFormat dfn = new DecimalFormat("#,#0.00");
dfn.setNegativePrefix(dfn.getNegativePrefix() + '!');
testEHCS(df, df2, dfn);
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat(DecimalFormat)'
*/
public void testDecimalFormatDecimalFormat() {
// tested implicitly
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat()'
*/
public void testDecimalFormat() {
DecimalFormat df = new DecimalFormat();
assertEquals("9,223,372,036,854,775,807", df.format(lmax));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat(String)'
*/
public void testDecimalFormatString() {
DecimalFormat df = new DecimalFormat("#,##0.000");
assertEquals("23.330", df.format(dsmall));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat(String, DecimalFormatSymbols)'
*/
public void testDecimalFormatStringDecimalFormatSymbols() {
DecimalFormatSymbols sym = new DecimalFormatSymbols(Locale.FRANCE);
DecimalFormat df = new DecimalFormat("#,##0.000", sym);
assertEquals("23,330", df.format(dsmall));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.getDecimalFormatSymbols()'
*/
public void testGetDecimalFormatSymbols() {
DecimalFormatSymbols sym = new DecimalFormatSymbols(Locale.FRANCE);
DecimalFormat df = new DecimalFormat("#,##0.000", sym);
assertEquals(sym, df.getDecimalFormatSymbols());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.setDecimalFormatSymbols(DecimalFormatSymbols)'
*/
public void testSetDecimalFormatSymbols() {
DecimalFormat df = new DecimalFormat();
df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.FRANCE));
assertEquals("23,33", df.format(dsmall));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.getPositivePrefix()'
*/
public void testGetPositivePrefix() {
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
assertEquals("+", df.getPositivePrefix());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.setPositivePrefix(String)'
*/
public void testSetPositivePrefix() {
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
df.setPositivePrefix("?");
assertEquals("?23.3", df.format(dsmall));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.getNegativePrefix()'
*/
public void testGetNegativePrefix() {
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
assertEquals("-", df.getNegativePrefix());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.setNegativePrefix(String)'
*/
public void testSetNegativePrefix() {
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
df.setNegativePrefix("~");
assertEquals("~23.3", df.format(-dsmall));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.getPositiveSuffix()'
*/
public void testGetPositiveSuffix() {
DecimalFormat df = new DecimalFormat("+#,##0.#**;-#,##0.#~~");
assertEquals("**", df.getPositiveSuffix());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.setPositiveSuffix(String)'
*/
public void testSetPositiveSuffix() {
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
df.setPositiveSuffix("**");
assertEquals("+23.3**", df.format(dsmall));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.getNegativeSuffix()'
*/
public void testGetNegativeSuffix() {
DecimalFormat df = new DecimalFormat("+#,##0.#**;-#,##0.#~~");
assertEquals("~~", df.getNegativeSuffix());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.setNegativeSuffix(String)'
*/
public void testSetNegativeSuffix() {
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
df.setNegativeSuffix("~~");
assertEquals("-23.3~~", df.format(-dsmall));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.getMultiplier()'
*/
public void testGetMultiplier() {
DecimalFormat df = new DecimalFormat("%000");
df.setMultiplier(1000);
assertEquals(1000, df.getMultiplier());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.setMultiplier(int)'
*/
public void testSetMultiplier() {
DecimalFormat df = new DecimalFormat("%000");
assertEquals("%012", df.format(.123));
df.setMultiplier(1000);
assertEquals("%123", df.format(.123));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.getGroupingSize()'
*/
public void testGetGroupingSize() {
DecimalFormat df = new DecimalFormat("#,#0.#");
assertEquals(2, df.getGroupingSize());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.setGroupingSize(int)'
*/
public void testSetGroupingSize() {
DecimalFormat df = new DecimalFormat("#,##0.##");
assertEquals("1,234,567.89", df.format(1234567.89));
df.setGroupingSize(2);
assertEquals("1,23,45,67.89", df.format(1234567.89));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.isDecimalSeparatorAlwaysShown()'
*/
public void testIsDecimalSeparatorAlwaysShown() {
DecimalFormat df = new DecimalFormat("#.#");
df.setDecimalSeparatorAlwaysShown(false);
assertEquals("1", df.format(1));
assertEquals("1.2", df.format(1.2));
df.setDecimalSeparatorAlwaysShown(true);
assertEquals("1.", df.format(1));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.setDecimalSeparatorAlwaysShown(boolean)'
*/
public void testSetDecimalSeparatorAlwaysShown() {
DecimalFormat df = new DecimalFormat("#.#");
df.setDecimalSeparatorAlwaysShown(false);
assertFalse(df.isDecimalSeparatorAlwaysShown());
df.setDecimalSeparatorAlwaysShown(true);
assertTrue(df.isDecimalSeparatorAlwaysShown());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.toPattern()'
*/
public void testToPattern() {
DecimalFormat df = new DecimalFormat("#,##0.##");
assertEquals("#,##0.##", df.toPattern());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.toLocalizedPattern()'
*/
public void testToLocalizedPattern() {
DecimalFormat df = new DecimalFormat("#,##0.##", new DecimalFormatSymbols(Locale.FRANCE));
assertEquals("#,##0.##", df.toPattern());
assertEquals("#\u00a0##0,##", df.toLocalizedPattern());
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.applyPattern(String)'
*/
public void testApplyPattern() {
DecimalFormat df = new DecimalFormat("#,##0.##");
df.applyPattern("#,0.#");
assertEquals("1,2,3.4", df.format(123.4));
}
/*
* Test method for 'com.ibm.icu.text.DecimalFormat.applyLocalizedPattern(String)'
*/
public void testApplyLocalizedPattern() {
DecimalFormat df = new DecimalFormat("#,##0.##", new DecimalFormatSymbols(Locale.FRANCE));
df.applyLocalizedPattern("#\u00a00,#");
assertEquals("1\u00a02\u00a03,4", df.format(123.4));
}
}

View file

@ -1,288 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Locale;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
import junit.framework.TestCase;
/**
* Implement boilerplate tests.
* Currently there is only one method, testEHCS, which tests equals, hashCode,
* clone, and serialization.
*/
public abstract class ICUTestCase extends TestCase {
private static final Object[] EMPTY_ARGS = {};
private static final Class<?>[] EMPTY_CLASSES = {};
private static final Locale oldLocale = Locale.getDefault();
private static final ULocale oldULocale = ULocale.getDefault();
private static final java.util.TimeZone oldJTimeZone = java.util.TimeZone.getDefault();
private static final TimeZone oldITimeZone = TimeZone.getDefault();
// TODO: what's the best way to check this?
public static final boolean testingWrapper = true;
protected void setUp() throws Exception {
super.setUp();
Locale.setDefault(Locale.US);
ULocale.setDefault(ULocale.US);
java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("PST"));
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
}
protected void tearDown() throws Exception {
ULocale.setDefault(oldULocale);
Locale.setDefault(oldLocale);
TimeZone.setDefault(oldITimeZone);
java.util.TimeZone.setDefault(oldJTimeZone);
super.tearDown();
}
private static final Object test = new Object();
/**
* Assert that two objects are _not_ equal. Curiously missing from Assert.
* @param lhs an object to test, may be null
* @param rhs an object to test, may be null
*/
public static void assertNotEqual(Object lhs, Object rhs) {
if (lhs == null) {
if (rhs == null) fail("null equals null");
} else {
if (lhs.equals(rhs)) {
fail(lhs.toString() + " equals " + rhs);
}
}
}
public static void assertNotEqual(long lhs, long rhs) {
if (lhs == rhs) {
fail("values are equal: " + lhs);
}
}
/**
* Test whether equality, hashCode, clone, and serialization work as expected.
* Equals(Object) is assumed to return false (not throw an exception) if passed
* null or an object of an incompatible class.
* Hashcodes must be equal iff the two objects compare equal. No attempt is made to
* evaluate the quality of the hashcode distribution, so (in particular) degenerate
* hashcode implementations will pass this test.
* Clone will be tested if the method "clone" is public on the class of obj.
* It is assumed to return an object that compares equal to obj.
* Serialization will be tested if object implements Serializable or Externalizable.
* It is assumed the serialized/deserialized object compares equal to obj.
* @param obj the object to test
* @param eq an object that should compare equal to, but is not the same as, obj.
* it should be assignable to the class of obj.
* @param neq a non-null object that should not compare equal to obj.
* it should be assignable to the class of obj.
*/
public static void testEHCS(Object obj, Object eq, Object neq) {
if (obj == null || eq == null || neq == null) {
throw new NullPointerException();
}
Class<? extends Object> cls = obj.getClass();
if (!(cls.isAssignableFrom(eq.getClass()) && cls.isAssignableFrom(neq.getClass()))) {
throw new IllegalArgumentException("unassignable classes");
}
// reflexive
assertEquals(obj, obj);
// should return false, not throw exception
assertNotEqual(obj, test);
assertNotEqual(obj, null);
// commutative
assertEquals(obj, eq);
assertEquals(eq, obj);
assertNotEqual(obj, neq);
assertNotEqual(neq, obj);
// equal objects MUST have equal hashes, unequal objects MAY have equal hashes
assertEquals(obj.hashCode(), eq.hashCode());
Object clone = null;
try {
// look for public clone method and call it if available
Method method_clone = cls.getMethod("clone", EMPTY_CLASSES);
clone = method_clone.invoke(obj, EMPTY_ARGS);
assertNotNull(clone);
}
catch(NoSuchMethodException e) {
// ok
}
catch(InvocationTargetException e) {
// ok
}
catch(IllegalAccessException e) {
// ok
}
if (clone != null) {
assertEquals(obj, clone);
assertEquals(clone, obj);
}
if (obj instanceof Serializable || obj instanceof Externalizable) {
Object ser = null;
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(clone);
oos.close();
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
ser = ois.readObject();
ois.close();
}
catch(IOException e) {
System.err.println(e.getMessage());
throw new RuntimeException(e);
}
catch(ClassNotFoundException e) {
System.err.println(e.getMessage());
throw new RuntimeException(e);
}
if (ser != null) {
assertEquals(obj, ser);
assertEquals(ser, obj);
assertEquals(obj.hashCode(), ser.hashCode());
}
}
}
/**
* Fail if the arrays are not equal. To be equal, the arrays must
* be the same length, and each element in the left array must compare
* equal to the corresponding element of the right array.
* Also fails if one of the objects is not an array.
* @param lhs the left array
* @param rhs the right array
*/
public static void assertArraysEqual(Object lhs, Object rhs) {
Class<? extends Object> lcls = lhs.getClass();
Class<? extends Object> rcls = rhs.getClass();
if (!(lcls.isArray() && rcls.isArray())) {
fail("objects are not arrays");
}
String result = arraysAreEqual(lhs, rhs);
if (result != null) {
fail(result);
}
}
/**
* Fail if the arrays are equal. Also fails if one or the other
* argument is not an array.
* @param lhs the left array
* @param rhs the right array
*/
public static void assertArraysNotEqual(Object lhs, Object rhs) {
Class<? extends Object> lcls = lhs.getClass();
Class<? extends Object> rcls = rhs.getClass();
if (!(lcls.isArray() && rcls.isArray())) {
fail("objects are not arrays");
}
String result = arraysAreEqual(lhs, rhs);
if (result == null) {
fail("arrays are equal");
}
}
// slow but general
private static String arraysAreEqual(Object lhsa, Object rhsa) {
int lhsl = Array.getLength(lhsa);
int rhsl = Array.getLength(rhsa);
if (lhsl != rhsl) {
return "length " + lhsl + " != " + rhsl;
}
boolean lhsaA = lhsa.getClass().getComponentType().isArray();
boolean rhsaA = rhsa.getClass().getComponentType().isArray();
if (lhsaA != rhsaA) {
return (lhsaA ? "" : "non-") + "array != " + (rhsaA ? "" : "non-") + "array";
}
for (int i = 0; i < lhsl; ++i) {
Object lhse = Array.get(lhsa, i);
Object rhse = Array.get(rhsa, i);
if (lhse == null) {
if (rhse != null) {
return "null != " + rhse;
}
} else {
if (lhsaA) {
String result = arraysAreEqual(lhse, rhse);
if (result != null) {
if (result.charAt(0) != '[') {
result = " " + result;
}
return "[" + i + "]" + result;
}
} else {
if (!lhse.equals(rhse)) {
return lhse.toString() + " != " + rhse;
}
}
}
}
return null;
}
// much more painful and slow than it should be... partly because of the
// oddness of clone, partly because arrays don't provide a Method for
// 'clone' despite the fact that they implement it and make it public.
public static Object cloneComplex(Object obj) {
Object result = null;
if (obj != null) {
Class<? extends Object> cls = obj.getClass();
if (cls.isArray()) {
int len = Array.getLength(obj);
Class<?> typ = cls.getComponentType();
result = Array.newInstance(typ, len);
boolean prim = typ.isPrimitive();
for (int i = 0; i < len; ++i) {
Object elem = Array.get(obj, i);
Array.set(result, i, prim ? elem : cloneComplex(elem));
}
} else {
result = obj; // default
try {
Method cloneM = cls.getMethod("clone", EMPTY_CLASSES);
result = cloneM.invoke(obj, EMPTY_ARGS);
}
catch (NoSuchMethodException e) {
}
catch (IllegalAccessException e) {
}
catch (InvocationTargetException e) {
}
}
}
return result;
}
}

View file

@ -1,309 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.text.FieldPosition;
import java.text.Format;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.Date;
import java.util.Locale;
import com.ibm.icu.text.DateFormat;
import com.ibm.icu.text.MessageFormat;
import com.ibm.icu.text.NumberFormat;
import com.ibm.icu.util.ULocale;
public class MessageFormatTest extends ICUTestCase {
private final String pattern = "Deleted {0,number} files at {1,time,short} on {1,date}.";
private final String altPattern = "Deleted {0, number } files at {1, time, short} on {1, date}.";
private final Date date = new Date(716698890835L);
private final Number num = new Long(3456);
private final Object[] args = { num, date };
private final Date dateOnly = new Date(716626800000L);
private final String englishTarget = "Deleted 3,456 files at 8:01 PM on Sep 16, 1992.";
private final String germanTarget = "Deleted 3.456 files at 20:01 on 16.09.1992.";
private final String modifiedTarget = "Deleted 3,456 files at 8:01:30 PM PDT on Sep 16, 1992.";
/*
* Test method for 'com.ibm.icu.text.MessageFormat.hashCode()'
*/
public void testHashCode() {
MessageFormat mf = new MessageFormat(pattern);
MessageFormat eq = new MessageFormat(altPattern);
MessageFormat ne = new MessageFormat("Deleted (0, number, currency} files at {1, time} on {1, date}.");
testEHCS(mf, eq, ne);
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(MessageFormat)'
*/
public void testMessageFormatMessageFormat() {
// implicitly tested everywhere
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(String)'
*/
public void testMessageFormatString() {
MessageFormat mf = new MessageFormat(pattern);
assertEquals(englishTarget, mf.format(args));
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(String, Locale)'
*/
public void testMessageFormatStringLocale() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
assertEquals(englishTarget, mf.format(args));
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(String, ULocale)'
*/
public void testMessageFormatStringULocale() {
MessageFormat mf = new MessageFormat(pattern, ULocale.US);
assertEquals(englishTarget, mf.format(args));
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.setLocale(Locale)'
*/
public void testSetLocaleLocale() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
mf.setLocale(Locale.GERMANY);
mf.applyPattern(pattern);
assertEquals(germanTarget, mf.format(args));
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.setLocale(ULocale)'
*/
public void testSetLocaleULocale() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
mf.setLocale(ULocale.GERMANY);
mf.applyPattern(pattern);
assertEquals(germanTarget, mf.format(args));
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.getLocale()'
*/
public void testGetLocale() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
mf.setLocale(Locale.GERMANY);
assertEquals(Locale.GERMANY, mf.getLocale());
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.getULocale()'
*/
public void testGetULocale() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
mf.setLocale(ULocale.GERMANY);
assertEquals(ULocale.GERMANY, mf.getULocale());
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.applyPattern(String)'
*/
public void testApplyPattern() {
MessageFormat mf = new MessageFormat("foo");
mf.applyPattern(pattern);
assertEquals(englishTarget, mf.format(args));
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.toPattern()'
*/
public void testToPattern() {
MessageFormat mf = new MessageFormat(altPattern);
assertEquals(pattern, mf.toPattern());
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.setFormatsByArgumentIndex(Format[])'
public void testSetFormatsByArgumentIndex() {
// this api is broken. if the same argument is used twice with two different
// formats, this can't be used, since it sets only one format per argument.
MessageFormat mf = new MessageFormat(pattern, Locale.US);
Format[] formats = {
NumberFormat.getIntegerInstance(),
DateFormat.getTimeInstance(DateFormat.SHORT),
DateFormat.getDateInstance(),
};
mf.setFormatsByArgumentIndex(formats);
assertEquals(brokenButConformantTarget, mf.format(args));
}
*/
/*
* Test method for 'com.ibm.icu.text.MessageFormat.setFormats(Format[])'
*/
public void testSetFormats() {
// this api, while it has the problem that the order of formats depends
// on the order in the string, at least lets you set all the formats.
MessageFormat mf = new MessageFormat(pattern, Locale.US);
Format[] formats = {
NumberFormat.getIntegerInstance(),
DateFormat.getTimeInstance(DateFormat.SHORT),
DateFormat.getDateInstance(),
};
mf.setFormats(formats);
assertEquals(englishTarget, mf.format(args));
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.setFormatByArgumentIndex(int, Format)'
public void testSetFormatByArgumentIndex() {
// same problem, once you set a format for an argument, you've set all of them
MessageFormat mf = new MessageFormat(pattern, Locale.US);
mf.setFormatByArgumentIndex(1, DateFormat.getTimeInstance(DateFormat.SHORT));
assertEquals(brokenButConformantTarget, mf.format(args));
}
*/
/*
* Test method for 'com.ibm.icu.text.MessageFormat.setFormat(int, Format)'
*/
public void testSetFormat() {
// and ok again
MessageFormat mf = new MessageFormat(pattern, Locale.US);
mf.setFormat(1, DateFormat.getTimeInstance(DateFormat.LONG));
assertEquals(modifiedTarget, mf.format(args));
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.getFormatsByArgumentIndex()'
public void testGetFormatsByArgumentIndex() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
Format[] formats = mf.getFormatsByArgumentIndex();
NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
assertEquals(formats[0], nf);
DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.US);
assertEquals(formats[1], df);
}
*/
/*
* Test method for 'com.ibm.icu.text.MessageFormat.getFormats()'
*/
public void testGetFormats() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
Format[] formats = mf.getFormats();
NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
assertEquals(formats[0], nf);
DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US);
assertEquals(formats[1], tf);
DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.US);
assertEquals(formats[2], df);
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.format(Object[], StringBuffer, FieldPosition)'
*/
public void testFormatObjectArrayStringBufferFieldPosition() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
StringBuffer buf = new StringBuffer();
FieldPosition fp = new FieldPosition(0);
mf.format(args, buf, fp);
assertEquals(englishTarget, buf.toString());
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.format(String, Object[])'
*/
public void testFormatStringObjectArray() {
assertEquals(englishTarget, MessageFormat.format(pattern, args));
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.format(Object, StringBuffer, FieldPosition)'
*/
public void testFormatObjectStringBufferFieldPosition() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
StringBuffer buf = new StringBuffer();
FieldPosition fp = new FieldPosition(0);
mf.format((Object)args, buf, fp);
assertEquals(englishTarget, buf.toString());
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.parse(String, ParsePosition)'
*/
public void testParseStringParsePosition() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
ParsePosition pp = new ParsePosition(1);
Object[] result = mf.parse("!" + englishTarget, pp);
assertEquals(num, result[0]);
assertEquals(dateOnly, result[1]);
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.parse(String)'
*/
public void testParseString() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
try {
Object[] result = mf.parse(englishTarget);
assertEquals(num, result[0]);
assertEquals(dateOnly, result[1]);
}
catch (ParseException e) {
fail(e.getMessage());
}
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.parseObject(String, ParsePosition)'
*/
public void testParseObjectStringParsePosition() {
MessageFormat mf = new MessageFormat(pattern, Locale.US);
ParsePosition pp = new ParsePosition(0);
Object result = mf.parseObject(englishTarget, pp);
assertEquals(num, ((Object[])result)[0]);
assertEquals(dateOnly, ((Object[])result)[1]);
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.autoQuoteApostrophe(String)'
*/
public void testAutoQuoteApostrophe() {
String str = "Let's meet at {1,time,h 'o'' clock'} at l'Orange Bleue";
String pat = MessageFormat.autoQuoteApostrophe(str);
MessageFormat mf = new MessageFormat(pat, Locale.US);
String result = mf.format(args);
assertEquals("Let's meet at 8 o' clock at l'Orange Bleue", result);
assertEquals("Let''s meet at {1,time,h 'o'' clock'} at l''Orange Bleue", pat);
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.clone()'
*/
public void testClone() {
// tested already in testHashcode
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.equals(Object)'
*/
public void testEqualsObject() {
// tested already in testHashcode
}
/*
* Test method for 'com.ibm.icu.text.MessageFormat.toString()'
*/
public void testToString() {
// no need to test
}
}

View file

@ -1,449 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2007-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.math.BigInteger;
import java.text.FieldPosition;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.Locale;
import com.ibm.icu.text.NumberFormat;
import com.ibm.icu.util.ULocale;
public class NumberFormatTest extends ICUTestCase {
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.NumberFormat(NumberFormat)'
*/
public void testNumberFormat() {
NumberFormat nf = new NumberFormat(java.text.NumberFormat.getInstance());
assertEquals(nf, NumberFormat.getInstance());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(Object, StringBuffer, FieldPosition)'
*/
public void testFormatObjectStringBufferFieldPosition() {
Number num = new Long(1234L);
StringBuffer buf = new StringBuffer();
FieldPosition fp = new FieldPosition(NumberFormat.INTEGER_FIELD);
NumberFormat.getInstance().format(num, buf, fp);
assertEquals("1,234", buf.toString());
assertEquals(0, fp.getBeginIndex());
assertEquals(5, fp.getEndIndex());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.parseObject(String, ParsePosition)'
*/
public void testParseObjectStringParsePosition() {
ParsePosition pp = new ParsePosition(0);
Object result = NumberFormat.getInstance().parse("1,234", pp);
assertEquals(result, new Long(1234));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(double)'
*/
public void testFormatDouble() {
assertEquals("1,234.567", NumberFormat.getInstance().format(1234.567));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(long)'
*/
public void testFormatLong() {
assertEquals("1,234", NumberFormat.getInstance().format(1234L));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(BigInteger)'
*/
public void testFormatBigInteger() {
// note, java doesn't handle biginteger with full precision.
BigInteger bi = new BigInteger("123456");
assertEquals("123,456", java.text.NumberFormat.getInstance().format(bi));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(double, StringBuffer, FieldPosition)'
*/
public void testFormatDoubleStringBufferFieldPosition() {
StringBuffer buf = new StringBuffer();
FieldPosition fp = new FieldPosition(NumberFormat.FRACTION_FIELD);
assertEquals("123,456.789", NumberFormat.getInstance().format(123456.789, buf, fp).toString());
assertEquals(8, fp.getBeginIndex());
assertEquals(11, fp.getEndIndex());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(long, StringBuffer, FieldPosition)'
*/
public void testFormatLongStringBufferFieldPosition() {
StringBuffer buf = new StringBuffer();
FieldPosition fp = new FieldPosition(NumberFormat.Field.GROUPING_SEPARATOR);
assertEquals("123,456", NumberFormat.getInstance().format(123456L, buf, fp).toString());
assertEquals(3, fp.getBeginIndex());
assertEquals(4, fp.getEndIndex());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(BigInteger, StringBuffer, FieldPosition)'
*/
public void testFormatBigIntegerStringBufferFieldPosition() {
// note, java doesn't handle biginteger with full precision.
StringBuffer buf = new StringBuffer();
FieldPosition fp = new FieldPosition(0);
BigInteger bi = new BigInteger("123456");
assertEquals("123,456", java.text.NumberFormat.getInstance().format(bi, buf, fp).toString());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.parse(String, ParsePosition)'
*/
public void testParseStringParsePosition() {
ParsePosition pp = new ParsePosition(3);
assertEquals(new Long(123456), NumberFormat.getInstance().parse("xxx123,456yyy", pp));
assertEquals(10, pp.getIndex());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.parse(String)'
*/
public void testParseString() throws ParseException {
Number result = NumberFormat.getInstance().parse("123,456,yyy");
assertEquals(new Long(123456), result);
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.isParseIntegerOnly()'
*/
public void testIsParseIntegerOnly() {
NumberFormat nf = NumberFormat.getInstance();
nf.setParseIntegerOnly(true);
assertTrue(nf.isParseIntegerOnly());
nf.setParseIntegerOnly(false);
assertFalse(nf.isParseIntegerOnly());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.setParseIntegerOnly(boolean)'
*/
public void testSetParseIntegerOnly() throws ParseException {
String str = "123.456,yyy";
NumberFormat nf = NumberFormat.getInstance();
assertEquals(new Double(123.456), nf.parse(str));
nf.setParseIntegerOnly(true);
assertEquals(new Long(123), nf.parse(str));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getInstance()'
*/
public void testGetInstance() {
// used everywhere, no need to test
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getInstance(Locale)'
*/
public void testGetInstanceLocale() {
NumberFormat nf = NumberFormat.getInstance(Locale.GERMANY);
assertEquals("123,456", nf.format(123.456));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getInstance(ULocale)'
*/
public void testGetInstanceULocale() {
NumberFormat nf = NumberFormat.getInstance(ULocale.GERMANY);
assertEquals("123,456", nf.format(123.456));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getNumberInstance()'
*/
public void testGetNumberInstance() {
NumberFormat nf = NumberFormat.getNumberInstance();
assertEquals("123,456.789", nf.format(123456.789));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getNumberInstance(Locale)'
*/
public void testGetNumberInstanceLocale() {
NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMANY);
assertEquals("123.456,789", nf.format(123456.789));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getNumberInstance(ULocale)'
*/
public void testGetNumberInstanceULocale() {
NumberFormat nf = NumberFormat.getNumberInstance(ULocale.GERMANY);
assertEquals("123.456,789", nf.format(123456.789));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getIntegerInstance()'
*/
public void testGetIntegerInstance() {
NumberFormat nf = NumberFormat.getIntegerInstance();
assertEquals("123,457", nf.format(123456.789)); // rounds
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getIntegerInstance(Locale)'
*/
public void testGetIntegerInstanceLocale() {
NumberFormat nf = NumberFormat.getIntegerInstance(Locale.GERMANY);
assertEquals("123.457", nf.format(123456.789)); // rounds
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getIntegerInstance(ULocale)'
*/
public void testGetIntegerInstanceULocale() {
NumberFormat nf = NumberFormat.getIntegerInstance(ULocale.GERMANY);
assertEquals("123.457", nf.format(123456.789)); // rounds
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getCurrencyInstance()'
*/
public void testGetCurrencyInstance() {
NumberFormat nf = NumberFormat.getCurrencyInstance();
assertEquals("$123,456.99", nf.format(123456.99));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getCurrencyInstance(Locale)'
*/
public void testGetCurrencyInstanceLocale() {
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.GERMANY);
assertEquals("123.456,99 \u20AC", nf.format(123456.99));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getCurrencyInstance(ULocale)'
*/
public void testGetCurrencyInstanceULocale() {
NumberFormat nf = NumberFormat.getCurrencyInstance(ULocale.GERMANY);
assertEquals("123.456,99 \u20AC", nf.format(123456.99));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getPercentInstance()'
*/
public void testGetPercentInstance() {
NumberFormat nf = NumberFormat.getPercentInstance();
assertEquals("123,456%", nf.format(1234.56));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getPercentInstance(Locale)'
*/
public void testGetPercentInstanceLocale() {
NumberFormat nf = NumberFormat.getPercentInstance(Locale.GERMANY);
assertEquals("123.456%", nf.format(1234.56));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getPercentInstance(ULocale)'
*/
public void testGetPercentInstanceULocale() {
NumberFormat nf = NumberFormat.getPercentInstance(ULocale.GERMANY);
assertEquals("123.456%", nf.format(1234.56));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getScientificInstance()'
*/
public void testGetScientificInstance() {
NumberFormat nf = NumberFormat.getScientificInstance();
assertEquals(".123456E4", nf.format(1234.56));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getScientificInstance(Locale)'
*/
public void testGetScientificInstanceLocale() {
NumberFormat nf = NumberFormat.getScientificInstance(Locale.GERMANY);
assertEquals(",123456E4", nf.format(1234.56));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getScientificInstance(ULocale)'
*/
public void testGetScientificInstanceULocale() {
NumberFormat nf = NumberFormat.getScientificInstance(ULocale.GERMANY);
assertEquals(",123456E4", nf.format(1234.56));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getAvailableLocales()'
*/
public void testGetAvailableLocales() {
Locale[] ilocales = NumberFormat.getAvailableLocales();
if (ICUTestCase.testingWrapper) {
Locale[] jlocales = java.text.NumberFormat.getAvailableLocales();
for (int i = 0; i < ilocales.length; ++i) {
assertEquals(jlocales[i], ilocales[i]);
}
}
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getAvailableULocales()'
*/
public void testGetAvailableULocales() {
ULocale[] ulocales = NumberFormat.getAvailableULocales();
if (ICUTestCase.testingWrapper) {
Locale[] jlocales = java.text.NumberFormat.getAvailableLocales();
for (int i = 0; i < ulocales.length; ++i) {
assertEquals(jlocales[i], ulocales[i].toLocale());
}
}
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.isGroupingUsed()'
*/
public void testIsGroupingUsed() {
NumberFormat nf = NumberFormat.getInstance();
nf.setGroupingUsed(true);
assertTrue(nf.isGroupingUsed());
nf.setGroupingUsed(false);
assertFalse(nf.isGroupingUsed());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.setGroupingUsed(boolean)'
*/
public void testSetGroupingUsed() {
NumberFormat nf = NumberFormat.getInstance();
assertEquals("123,456,789", nf.format(123456789));
nf.setGroupingUsed(false);
assertEquals("123456789", nf.format(123456789));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMaximumIntegerDigits()'
*/
public void testGetMaximumIntegerDigits() {
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumIntegerDigits(4);
assertEquals(4, nf.getMaximumIntegerDigits());
nf.setMaximumIntegerDigits(6);
assertEquals(6, nf.getMaximumIntegerDigits());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMaximumIntegerDigits(int)'
*/
public void testSetMaximumIntegerDigits() {
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumIntegerDigits(4);
assertEquals("3,456", nf.format(123456)); // high digits truncated
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMinimumIntegerDigits()'
*/
public void testGetMinimumIntegerDigits() {
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(4);
assertEquals(4, nf.getMinimumIntegerDigits());
nf.setMinimumIntegerDigits(6);
assertEquals(6, nf.getMinimumIntegerDigits());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMinimumIntegerDigits(int)'
*/
public void testSetMinimumIntegerDigits() {
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(4);
assertEquals("0,012", nf.format(12)); // pad out with zero, grouping still used
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMaximumFractionDigits()'
*/
public void testGetMaximumFractionDigits() {
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(4);
assertEquals(4, nf.getMaximumFractionDigits());
nf.setMaximumFractionDigits(6);
assertEquals(6, nf.getMaximumFractionDigits());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMaximumFractionDigits(int)'
*/
public void testSetMaximumFractionDigits() {
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(4);
assertEquals("1.2346", nf.format(1.2345678)); // low digits rounded
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMinimumFractionDigits()'
*/
public void testGetMinimumFractionDigits() {
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumFractionDigits(4);
assertEquals(4, nf.getMinimumFractionDigits());
nf.setMinimumFractionDigits(6);
assertEquals(6, nf.getMinimumFractionDigits());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMinimumFractionDigits(int)'
*/
public void testSetMinimumFractionDigits() {
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumFractionDigits(4);
assertEquals("1.2000", nf.format(1.2));
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.toString()'
*/
public void testToString() {
assertNotNull(NumberFormat.getInstance().toString());
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.hashCode()'
*/
public void testHashCode() {
NumberFormat nf = NumberFormat.getInstance();
NumberFormat eq = NumberFormat.getInstance(Locale.US);
NumberFormat neq = NumberFormat.getInstance(Locale.GERMANY);
ICUTestCase.testEHCS(nf, eq, neq);
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.clone()'
*/
public void testClone() {
// see testHashCode
}
/*
* Test method for 'com.ibm.icu.x.text.NumberFormat.equals(Object)'
*/
public void testEqualsObject() {
// see testHashCode
}
}

View file

@ -1,204 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.text.FieldPosition;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.Date;
import java.util.Locale;
import com.ibm.icu.text.DateFormatSymbols;
import com.ibm.icu.text.SimpleDateFormat;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
public class SimpleDateFormatTest extends ICUTestCase {
private static final String mdy = "MMM dd yyyy";
private static final String md2 = "MMM dd yy";
private static final String hmz = "'The time is' HH:mm:ss zzz";
private static final String hmzmdy = hmz + " 'on' " + mdy;
private static final String hmzmdyStr = "The time is 15:05:20 CST on Jan 10 2006";
private static final TimeZone tzc = TimeZone.getTimeZone("CST");
private static final TimeZone tzp = TimeZone.getTimeZone("PST");
private static final Calendar cal = Calendar.getInstance(tzc);
private static final Date date;
static {
cal.clear();
cal.set(2006, 0, 10, 15, 5, 20); // arrgh, doesn't clear millis
date = cal.getTime();
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.format(Calendar, StringBuffer, FieldPosition)'
*/
public void testFormatCalendarStringBufferFieldPosition() {
StringBuffer buf = new StringBuffer();
FieldPosition fp = new FieldPosition(0);
SimpleDateFormat sdf = new SimpleDateFormat(hmzmdy);
sdf.format(cal, buf, fp);
assertEquals(hmzmdyStr, buf.toString());
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.parse(String, Calendar, ParsePosition)'
*/
public void testParseStringCalendarParsePosition() {
Calendar cal = Calendar.getInstance(tzp);
cal.clear();
ParsePosition pp = new ParsePosition(0);
SimpleDateFormat sdf = new SimpleDateFormat(hmzmdy);
sdf.parse(hmzmdyStr, cal, pp);
assertEquals(date, cal.getTime());
// note: java doesn't return the parsed time zone
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.clone()'
*/
public void testClone() {
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat()'
*/
public void testSimpleDateFormat() {
SimpleDateFormat sdf = new SimpleDateFormat();
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat();
assertEquals(jsdf.format(date), sdf.format(date));
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String)'
*/
public void testSimpleDateFormatString() {
SimpleDateFormat sdf = new SimpleDateFormat(mdy);
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy);
assertEquals(jsdf.format(date), sdf.format(date));
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String, Locale)'
*/
public void testSimpleDateFormatStringLocale() {
Locale l = Locale.JAPAN;
SimpleDateFormat sdf = new SimpleDateFormat(mdy, l);
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy, l);
assertEquals(jsdf.format(date), sdf.format(date));
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String, ULocale)'
*/
public void testSimpleDateFormatStringULocale() {
ULocale l = ULocale.JAPAN;
SimpleDateFormat sdf = new SimpleDateFormat(mdy, l);
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy, l.toLocale());
assertEquals(jsdf.format(date), sdf.format(date));
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String, DateFormatSymbols)'
*/
public void testSimpleDateFormatStringDateFormatSymbols() {
Locale l = Locale.US;
DateFormatSymbols dfs = new DateFormatSymbols(l);
java.text.DateFormatSymbols jdfs = new java.text.DateFormatSymbols(l);
SimpleDateFormat sdf = new SimpleDateFormat(mdy, dfs);
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy, jdfs);
assertEquals(jsdf.format(date), sdf.format(date));
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.set2DigitYearStart(Date)'
*/
public void testSet2DigitYearStart() {
SimpleDateFormat sdf = new SimpleDateFormat(md2);
sdf.set2DigitYearStart(date);
try {
Date d = sdf.parse("Jan 15 04");
assertNotEqual(-1, d.toString().indexOf("2104"));
}
catch (ParseException pe) {
fail(pe.getMessage());
}
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.get2DigitYearStart()'
*/
public void testGet2DigitYearStart() {
SimpleDateFormat sdf = new SimpleDateFormat(md2);
sdf.set2DigitYearStart(date);
assertEquals(date, sdf.get2DigitYearStart());
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.toPattern()'
*/
public void testToPattern() {
SimpleDateFormat sdf = new SimpleDateFormat(mdy);
assertEquals(mdy, sdf.toPattern());
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.toLocalizedPattern()'
*/
public void testToLocalizedPattern() {
Locale l = Locale.getDefault();
Locale.setDefault(Locale.US);
SimpleDateFormat sdf = new SimpleDateFormat(mdy);
assertEquals(mdy, sdf.toLocalizedPattern());
Locale.setDefault(l);
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.applyPattern(String)'
*/
public void testApplyPattern() {
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.setTimeZone(tzc);
sdf.applyPattern(hmzmdy);
assertEquals(hmzmdyStr, sdf.format(date));
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.applyLocalizedPattern(String)'
*/
public void testApplyLocalizedPattern() {
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.setTimeZone(tzc);
sdf.applyLocalizedPattern(hmzmdy);
assertEquals(hmzmdyStr, sdf.format(date));
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.getDateFormatSymbols()'
*/
public void testGetDateFormatSymbols() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
SimpleDateFormat sdf = new SimpleDateFormat(mdy, dfs);
assertEquals(dfs, sdf.getDateFormatSymbols());
}
/*
* Test method for 'com.ibm.icu.text.SimpleDateFormat.setDateFormatSymbols(DateFormatSymbols)'
*/
public void testSetDateFormatSymbols() {
DateFormatSymbols dfs = new DateFormatSymbols(Locale.JAPAN);
SimpleDateFormat sdf = new SimpleDateFormat(hmzmdy);
sdf.setDateFormatSymbols(dfs);
// assumes Japanese symbols do not have gregorian month names
assertEquals(-1, sdf.format(date).indexOf("Jan"));
}
}

View file

@ -1,237 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.util.Date;
import java.util.Locale;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
public class TimeZoneTest extends ICUTestCase {
/*
* Test method for 'com.ibm.icu.util.TimeZone.hashCode()'
*/
public void testHashCode() {
TimeZone tz1 = TimeZone.getTimeZone("PST");
TimeZone tz2 = TimeZone.getTimeZone("PST");
TimeZone tzn = TimeZone.getTimeZone("CST");
testEHCS(tz1, tz2, tzn);
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.TimeZone(TimeZone)'
*/
public void testTimeZone() {
// implicitly tested everywhere
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getOffset(int, int, int, int, int, int)'
*/
public void testGetOffset() {
TimeZone tz = TimeZone.getTimeZone("PST");
int offset = tz.getOffset(1, 2004, 0, 01, 1, 0);
assertEquals(-28800000, offset);
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.setRawOffset(int)'
*/
public void testSetRawOffset() {
TimeZone tz = TimeZone.getTimeZone("PST");
int value = tz.getRawOffset();
int value1 = value + 100000;
tz.setRawOffset(value1);
int result = tz.getRawOffset();
assertNotEqual(value, result);
assertEquals(value1, result);
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getRawOffset()'
*/
public void testGetRawOffset() {
TimeZone tz = TimeZone.getTimeZone("PST");
int offset = tz.getRawOffset();
assertEquals(-28800000, offset);
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getID()'
*/
public void testGetID() {
TimeZone tz = TimeZone.getTimeZone("PST");
assertEquals("PST", tz.getID());
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.setID(String)'
*/
public void testSetID() {
TimeZone tz = TimeZone.getTimeZone("PST");
String value1 = tz.getID();
String value2 = value1 + "!";
tz.setID(value2);
String result = tz.getID();
assertNotEqual(value1, result);
assertEquals(value2, result);
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName()'
*/
public void testGetDisplayName() {
TimeZone tz = TimeZone.getTimeZone("PST");
assertEquals("Pacific Standard Time", tz.getDisplayName());
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(Locale)'
*/
public void testGetDisplayNameLocale() {
TimeZone tz = TimeZone.getTimeZone("PST");
assertEquals("Pacific Standard Time", tz.getDisplayName(Locale.US));
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(ULocale)'
*/
public void testGetDisplayNameULocale() {
TimeZone tz = TimeZone.getTimeZone("PST");
assertEquals("Pacific Standard Time", tz.getDisplayName(ULocale.US));
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int)'
*/
public void testGetDisplayNameBooleanInt() {
TimeZone tz = TimeZone.getTimeZone("PST");
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT));
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG));
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, Locale)'
*/
public void testGetDisplayNameBooleanIntLocale() {
TimeZone tz = TimeZone.getTimeZone("PST");
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT, Locale.US));
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG, Locale.US));
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, ULocale)'
*/
public void testGetDisplayNameBooleanIntULocale() {
TimeZone tz = TimeZone.getTimeZone("PST");
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT, ULocale.US));
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG, ULocale.US));
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getDSTSavings()'
*/
public void testGetDSTSavings() {
TimeZone tz = TimeZone.getTimeZone("PST");
assertEquals(3600000, tz.getDSTSavings());
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.useDaylightTime()'
*/
public void testUseDaylightTime() {
TimeZone tz = TimeZone.getTimeZone("PST");
assertTrue(tz.useDaylightTime());
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.inDaylightTime(Date)'
*/
public void testInDaylightTime() {
TimeZone tz = TimeZone.getTimeZone("PST");
Calendar cal = Calendar.getInstance();
cal.set(2005, 0, 17);
Date date = cal.getTime();
assertFalse(tz.inDaylightTime(date));
cal.set(2005, 6, 17);
date = cal.getTime();
assertTrue(tz.inDaylightTime(date));
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getTimeZone(String)'
*/
public void testGetTimeZone() {
// implicitly tested everywhere
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs(int)'
*/
public void testGetAvailableIDsInt() {
String[] ids = TimeZone.getAvailableIDs(-28800000);
assertNotNull(ids);
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs()'
*/
public void testGetAvailableIDs() {
String[] ids = TimeZone.getAvailableIDs();
assertNotNull(ids);
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.getDefault()'
*/
public void testGetDefault() {
TimeZone tz = TimeZone.getDefault();
assertNotNull(tz);
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.setDefault(TimeZone)'
*/
public void testSetDefault() {
TimeZone tz1 = TimeZone.getDefault();
String newCode = "PDT".equals(tz1.getID()) ? "CST" : "PDT";
TimeZone tz2 = TimeZone.getTimeZone(newCode);
TimeZone.setDefault(tz2);
TimeZone result = TimeZone.getDefault();
assertNotEqual(tz1, result);
assertEquals(tz2, result);
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.hasSameRules(TimeZone)'
*/
public void testHasSameRules() {
TimeZone tz1 = TimeZone.getTimeZone("PST");
TimeZone tz2 = TimeZone.getTimeZone("America/Los_Angeles");
assertTrue(tz1.hasSameRules(tz2));
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.clone()'
*/
public void testClone() {
// tested by testHashCode
}
/*
* Test method for 'com.ibm.icu.util.TimeZone.equals(Object)'
*/
public void testEqualsObject() {
// tested by testHashCode
}
}

View file

@ -1,849 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2006-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.tests;
import java.util.Iterator;
import java.util.Locale;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.ULocale.Category;
public class ULocaleTest extends ICUTestCase {
private String sampleName;
private String longULocaleName;
private String longULocaleBasename;
private String nonNormalizedName;
private ULocale longULocale;
private Locale sampleLocale;
/**
* @Override
*/
protected void setUp() throws Exception {
super.setUp();
sampleName = "ll_CC_VVVV";
longULocaleName = "ll_Ssss_CC_VVVV@collation=phonebook;key=value";
longULocaleBasename = longULocaleName.substring(0, longULocaleName.indexOf('@'));
nonNormalizedName = "LL_ssss_cc_VVVV@ Key = value ; Collation = phonebook ; ";
longULocale = new ULocale(longULocaleName);
sampleLocale = new ULocale(sampleName).toLocale();
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.hashCode()'
*/
public void testHashCode() {
ULocale obj = ULocale.GERMANY;
ULocale eq = new ULocale("de_DE");
ULocale neq = new ULocale("de_DE_FRENCH");
ICUTestCase.testEHCS(obj, eq, neq);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.forLocale(Locale)'
*/
public void testForLocale() {
assertEquals(ULocale.GERMANY, ULocale.forLocale(Locale.GERMANY));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String)'
*/
public void testULocaleString() {
assertEquals(ULocale.GERMAN, new ULocale("de"));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String, String)'
*/
public void testULocaleStringString() {
assertEquals(ULocale.GERMANY, new ULocale("de", "DE"));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String, String, String)'
*/
public void testULocaleStringStringString() {
assertEquals(sampleLocale, new ULocale("ll", "cc", "VVVV").toLocale());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.createCanonical(String)'
*/
public void testCreateCanonical() {
ULocale result = ULocale.createCanonical("de__PHONEBOOK");
assertEquals(new ULocale("de@collation=phonebook"), result);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.toLocale()'
*/
public void testToLocale() {
assertEquals(sampleLocale, new ULocale("ll", "cc", "VVVV").toLocale());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDefault()'
*/
public void testGetDefault() {
assertEquals(Locale.getDefault(), ULocale.getDefault().toLocale());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.setDefault(ULocale)'
*/
public void testSetDefault() {
Locale oldLocale = Locale.getDefault();
ULocale oldULocale = ULocale.getDefault();
try {
ULocale.setDefault(longULocale);
ICUTestCase.assertNotEqual(Locale.getDefault(), oldLocale);
ICUTestCase.assertNotEqual(ULocale.getDefault(), oldULocale);
assertEquals(longULocale, ULocale.getDefault());
assertEquals(sampleLocale, Locale.getDefault());
}
finally {
ULocale.setDefault(oldULocale);
Locale.setDefault(oldLocale); // in case of some error
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.clone()'
*/
public void testClone() {
// see testHashcode
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.equals(Object)'
*/
public void testEqualsObject() {
// see testHashcode
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getAvailableLocales()'
*/
public void testGetAvailableLocales() {
ULocale[] ulocales = ULocale.getAvailableLocales();
if (ICUTestCase.testingWrapper) {
Locale[] locales = Locale.getAvailableLocales();
for (int i = 0; i < ulocales.length; ++i) {
assertEquals(ulocales[i].toLocale(), locales[i]);
}
}
// else nothing to test except that the function returned.
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getISOCountries()'
*/
public void testGetISOCountries() {
String[] ucountries = ULocale.getISOCountries();
assertNotNull(ucountries);
if (ICUTestCase.testingWrapper) {
// keep our own data for now
// our data doesn't match java's so this test would fail
// TODO: enable if we decide to use java's data
// String[] countries = Locale.getISOCountries();
// TestBoilerplate.assertArraysEqual(ucountries, countries);
}
// else nothing to test except that the function returned.
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getISOLanguages()'
*/
public void testGetISOLanguages() {
String[] ulanguages = ULocale.getISOLanguages();
assertNotNull(ulanguages);
if (ICUTestCase.testingWrapper) {
// keep our own data for now
// our data doesn't match java's so this test would fail
// TODO: enable if we decide to use java's data
// String[] languages = Locale.getISOLanguages();
// TestBoilerplate.assertArraysEqual(ulanguages, languages);
}
// else nothing to test except that the function returned.
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getLanguage()'
*/
public void testGetLanguage() {
assertEquals("ll", longULocale.getLanguage());
assertEquals("ll", longULocale.toLocale().getLanguage());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getLanguage(String)'
*/
public void testGetLanguageString() {
assertEquals("ll", ULocale.getLanguage(longULocale.getName()));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getScript()'
*/
public void testGetScript() {
assertEquals("Ssss", longULocale.getScript());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getScript(String)'
*/
public void testGetScriptString() {
assertEquals("Ssss", ULocale.getScript(longULocale.getName()));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getCountry()'
*/
public void testGetCountry() {
assertEquals("CC", longULocale.getCountry());
assertEquals("CC", longULocale.toLocale().getCountry());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getCountry(String)'
*/
public void testGetCountryString() {
assertEquals("CC", ULocale.getCountry(longULocale.getName()));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getVariant()'
*/
public void testGetVariant() {
assertEquals("VVVV", longULocale.getVariant());
assertEquals("VVVV", longULocale.toLocale().getVariant());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getVariant(String)'
*/
public void testGetVariantString() {
assertEquals("VVVV", ULocale.getVariant(longULocale.getName()));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getFallback(String)'
*/
public void testGetFallbackString() {
assertEquals(ULocale.GERMAN, ULocale.getFallback(ULocale.GERMANY.getName()));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getFallback()'
*/
public void testGetFallback() {
assertEquals(ULocale.GERMAN, ULocale.GERMANY.getFallback());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getBaseName()'
*/
public void testGetBaseName() {
assertEquals(longULocaleBasename, longULocale.getBaseName());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getBaseName(String)'
*/
public void testGetBaseNameString() {
assertEquals(longULocaleBasename, longULocale.getBaseName());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getName()'
*/
public void testGetName() {
assertEquals(longULocaleName, longULocale.getName());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getName(String)'
*/
public void testGetNameString() {
assertEquals(longULocaleName, ULocale.getName(nonNormalizedName));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.toString()'
*/
public void testToString() {
assertEquals(longULocaleName, longULocale.toString());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getKeywords()'
*/
public void testGetKeywords() {
Iterator<String> iter = longULocale.getKeywords();
assertEquals(iter.next(), "collation");
assertEquals(iter.next(), "key");
assertFalse(iter.hasNext());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getKeywords(String)'
*/
public void testGetKeywordsString() {
Iterator<String> iter = ULocale.getKeywords(nonNormalizedName);
assertEquals(iter.next(), "collation");
assertEquals(iter.next(), "key");
assertFalse(iter.hasNext());
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getKeywordValue(String)'
*/
public void testGetKeywordValueString() {
assertEquals("value", longULocale.getKeywordValue("key"));
assertEquals("phonebook", longULocale.getKeywordValue("collation"));
assertNull(longULocale.getKeywordValue("zzyzx"));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getKeywordValue(String, String)'
*/
public void testGetKeywordValueStringString() {
assertEquals("value", ULocale.getKeywordValue(longULocaleName, "key"));
assertEquals("phonebook", ULocale.getKeywordValue(longULocaleName, "collation"));
assertNull(ULocale.getKeywordValue(longULocaleName, "zzyzx"));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.canonicalize(String)'
*/
public void testCanonicalize() {
assertEquals("de@collation=phonebook", ULocale.canonicalize("de__PHONEBOOK"));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.setKeywordValue(String, String)'
*/
public void testSetKeywordValueStringString() {
ULocale munged = longULocale.setKeywordValue("key", "C#");
assertEquals("C#", munged.getKeywordValue("key"));
munged = munged.setKeywordValue("zzyzx", "grue");
assertEquals("grue", munged.getKeywordValue("zzyzx"));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.setKeywordValue(String, String, String)'
*/
public void testSetKeywordValueStringStringString() {
String munged = ULocale.setKeywordValue(longULocaleName, "key", "C#");
assertEquals("C#", ULocale.getKeywordValue(munged, "key"));
munged = ULocale.setKeywordValue(munged, "zzyzx", "grue");
assertEquals("grue", ULocale.getKeywordValue(munged, "zzyzx"));
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getISO3Language()'
*/
public void testGetISO3Language() {
String il = ULocale.GERMANY.getISO3Language();
String jl = Locale.GERMANY.getISO3Language();
assertEquals(il, jl);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getISO3Language(String)'
*/
public void testGetISO3LanguageString() {
String il = ULocale.getISO3Language(ULocale.GERMANY.getName());
String jl = Locale.GERMANY.getISO3Language();
assertEquals(il, jl);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getISO3Country()'
*/
public void testGetISO3Country() {
String ic = ULocale.GERMANY.getISO3Country();
String jc = Locale.GERMANY.getISO3Country();
assertEquals(ic, jc);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getISO3Country(String)'
*/
public void testGetISO3CountryString() {
String ic = ULocale.getISO3Country(ULocale.GERMANY.getName());
String jc = Locale.GERMANY.getISO3Country();
assertEquals(ic, jc);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage()'
*/
public void testGetDisplayLanguage() {
String idl = ULocale.GERMANY.getDisplayLanguage();
String jdl = Locale.GERMANY.getDisplayLanguage();
assertEquals(idl, jdl);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(ULocale)'
*/
public void testGetDisplayLanguageULocale() {
String idl = ULocale.GERMANY.getDisplayLanguage(ULocale.GERMANY);
String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
assertEquals(idl, jdl);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(String, String)'
*/
public void testGetDisplayLanguageStringString() {
String idl = ULocale.getDisplayLanguage(ULocale.GERMANY.getName(), "de_DE");
String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
assertEquals(idl, jdl);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(String, ULocale)'
*/
public void testGetDisplayLanguageStringULocale() {
String idl = ULocale.getDisplayLanguage(ULocale.GERMANY.getName(), ULocale.GERMANY);
String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
assertEquals(idl, jdl);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript()'
*/
public void testGetDisplayScript() {
String is = ULocale.TRADITIONAL_CHINESE.getDisplayScript();
if (ICUTestCase.testingWrapper) {
assertEquals("Hant", is);
} else {
assertEquals("Traditional Chinese", is);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(ULocale)'
*/
public void testGetDisplayScriptULocale() {
String is = ULocale.TRADITIONAL_CHINESE.getDisplayScript(ULocale.GERMANY);
if (ICUTestCase.testingWrapper) {
assertEquals("Hant", is);
} else {
// TODO: look up expected value
assertEquals("Hant", is);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(String, String)'
*/
public void testGetDisplayScriptStringString() {
String is = ULocale.getDisplayScript("zh_Hant", "de_DE");
if (ICUTestCase.testingWrapper) {
assertEquals("Hant", is);
} else {
// TODO: look up expected value
assertEquals("Hant", is);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(String, ULocale)'
*/
public void testGetDisplayScriptStringULocale() {
String is = ULocale.getDisplayScript("zh_Hant", ULocale.GERMANY);
if (ICUTestCase.testingWrapper) {
assertEquals("Hant", is);
} else {
// TODO: look up expected value
assertEquals("Hant", is);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry()'
*/
public void testGetDisplayCountry() {
String idc = ULocale.GERMANY.getDisplayCountry();
String jdc = Locale.GERMANY.getDisplayCountry();
assertEquals(idc, jdc);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(ULocale)'
*/
public void testGetDisplayCountryULocale() {
String idc = ULocale.GERMANY.getDisplayCountry(ULocale.GERMANY);
String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
assertEquals(idc, jdc);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(String, String)'
*/
public void testGetDisplayCountryStringString() {
String idc = ULocale.getDisplayCountry("de_DE", "de_DE");
String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
assertEquals(idc, jdc);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(String, ULocale)'
*/
public void testGetDisplayCountryStringULocale() {
String idc = ULocale.getDisplayCountry("de_DE", ULocale.GERMANY);
String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
assertEquals(idc, jdc);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant()'
*/
public void testGetDisplayVariant() {
String idv = new ULocale("de_DE_PHONEBOOK").getDisplayVariant();
String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant();
assertEquals(jdv, idv);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(ULocale)'
*/
public void testGetDisplayVariantULocale() {
String idv = new ULocale("de_DE_PHONEBOOK").getDisplayVariant(ULocale.GERMANY);
String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
assertEquals(jdv, idv);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(String, String)'
*/
public void testGetDisplayVariantStringString() {
String idv = ULocale.getDisplayVariant("de_DE_PHONEBOOK", "de_DE");
String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
assertEquals(jdv, idv);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(String, ULocale)'
*/
public void testGetDisplayVariantStringULocale() {
String idv = ULocale.getDisplayVariant("de_DE_PHONEBOOK", ULocale.GERMANY);
String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
assertEquals(jdv, idv);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String)'
*/
public void testGetDisplayKeywordString() {
String idk = ULocale.getDisplayKeyword("collation");
assertEquals("collation", idk);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String, String)'
*/
public void testGetDisplayKeywordStringString() {
String idk = ULocale.getDisplayKeyword("collation", "de_DE");
if (ICUTestCase.testingWrapper) {
assertEquals("collation", idk);
} else {
// TODO: find real value
assertEquals("collation", idk);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String, ULocale)'
*/
public void testGetDisplayKeywordStringULocale() {
String idk = ULocale.getDisplayKeyword("collation", ULocale.GERMANY);
if (ICUTestCase.testingWrapper) {
assertEquals("collation", idk);
} else {
// TODO: find real value
assertEquals("collation", idk);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String)'
*/
public void testGetDisplayKeywordValueString() {
ULocale ul = new ULocale("de_DE@collation=phonebook");
String idk = ul.getDisplayKeywordValue("collation");
if (ICUTestCase.testingWrapper) {
assertEquals("phonebook", idk);
} else {
// TODO: find real value
assertEquals("phonebook", idk);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, ULocale)'
*/
public void testGetDisplayKeywordValueStringULocale() {
ULocale ul = new ULocale("de_DE@collation=phonebook");
String idk = ul.getDisplayKeywordValue("collation", ULocale.GERMANY);
if (ICUTestCase.testingWrapper) {
assertEquals("phonebook", idk);
} else {
// TODO: find real value
assertEquals("phonebook", idk);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, String, String)'
*/
public void testGetDisplayKeywordValueStringStringString() {
String idk = ULocale.getDisplayKeywordValue("de_DE@collation=phonebook", "collation", "de_DE");
if (ICUTestCase.testingWrapper) {
assertEquals("phonebook", idk);
} else {
// TODO: find real value
assertEquals("phonebook", idk);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, String, ULocale)'
*/
public void testGetDisplayKeywordValueStringStringULocale() {
String idk = ULocale.getDisplayKeywordValue("de_DE@collation=phonebook", "collation", ULocale.GERMANY);
if (ICUTestCase.testingWrapper) {
assertEquals("phonebook", idk);
} else {
// TODO: find real value
assertEquals("phonebook", idk);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName()'
*/
public void testGetDisplayName() {
String idn = ULocale.GERMANY.getDisplayName();
String jdn = Locale.GERMANY.getDisplayName();
assertEquals(idn, jdn);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(ULocale)'
*/
public void testGetDisplayNameULocale() {
String idn = ULocale.GERMANY.getDisplayName(ULocale.GERMANY);
String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
assertEquals(idn, jdn);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(String, String)'
*/
public void testGetDisplayNameStringString() {
String idn = ULocale.getDisplayName("de_DE", "de_DE");
String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
assertEquals(idn, jdn);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(String, ULocale)'
*/
public void testGetDisplayNameStringULocale() {
String idn = ULocale.getDisplayName("de_DE", ULocale.GERMANY);
String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
assertEquals(idn, jdn);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(String, ULocale[], boolean[])'
*/
public void testAcceptLanguageStringULocaleArrayBooleanArray() {
boolean[] fallback = new boolean[1];
ULocale[] locales = {
new ULocale("en_CA"),
new ULocale("es_US"),
};
ULocale result = ULocale.acceptLanguage("en-US, en-GB, en-CA, es-US", locales, fallback);
assertEquals(new ULocale("en_CA"), result);
assertFalse(fallback[0]);
result = ULocale.acceptLanguage("en-US, en-GB, es-US-NEWMEXICO", locales, fallback);
assertEquals(new ULocale("es_US"), result);
assertTrue(fallback[0]);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(ULocale[], ULocale[], boolean[])'
*/
public void testAcceptLanguageULocaleArrayULocaleArrayBooleanArray() {
boolean[] fallback = new boolean[1];
ULocale[] locales = {
new ULocale("en_CA"),
new ULocale("es_US"),
};
ULocale[] accept_locales = {
new ULocale("en_US"),
new ULocale("en_GB"),
new ULocale("en_CA"),
new ULocale("es_US"),
};
ULocale[] accept_locales2 = {
new ULocale("en_US"),
new ULocale("en_GB"),
new ULocale("es_US_NEWMEXICO"),
};
ULocale result = ULocale.acceptLanguage(accept_locales, locales, fallback);
assertEquals(new ULocale("en_CA"), result);
assertFalse(fallback[0]);
result = ULocale.acceptLanguage(accept_locales2, locales, fallback);
assertEquals(new ULocale("es_US"), result);
assertTrue(fallback[0]);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(String, boolean[])'
*/
public void testAcceptLanguageStringBooleanArray() {
boolean[] fallback = new boolean[1];
ULocale result = ULocale.acceptLanguage("en-CA, en-GB, es-US", fallback);
assertEquals(new ULocale("en_CA"), result);
assertFalse(fallback[0]);
result = ULocale.acceptLanguage("es-US-NEWMEXICO", fallback);
assertNotNull(result); // actual result depends on jdk
assertTrue(fallback[0]);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(ULocale[], boolean[])'
*/
public void testAcceptLanguageULocaleArrayBooleanArray() {
boolean[] fallback = new boolean[1];
ULocale[] accept_locales = {
new ULocale("en_CA"),
new ULocale("en_GB"),
new ULocale("es_US"),
};
ULocale[] accept_locales2 = {
new ULocale("es_US_NEWMEXICO"),
};
ULocale result = ULocale.acceptLanguage(accept_locales, fallback);
assertEquals(new ULocale("en_CA"), result);
assertFalse(fallback[0]);
result = ULocale.acceptLanguage(accept_locales2, fallback);
assertNotNull(result); // actual result depends on jdk
assertTrue(fallback[0]);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.toLanguageTag()'
*/
public void testToLanguageTag() {
ULocale[] test_ulocales = {
new ULocale("en_US"),
new ULocale(""),
new ULocale("de_DE@collation=phonebook"),
new ULocale("en_Latn_US_POSIX"),
new ULocale("th_TH@numbers=thai;calendar=buddhist"),
new ULocale("und_CN@timezone=PRC"),
new ULocale("iw_IL"),
};
String[] expected = {
"en-US",
"und",
"de-DE-u-co-phonebk",
"en-Latn-US-u-va-posix",
"th-TH-u-ca-buddhist-nu-thai",
"und-CN-u-tz-cnsha",
"he-IL",
};
for (int i = 0; i < test_ulocales.length; i++) {
String result = test_ulocales[i].toLanguageTag();
assertEquals(expected[i], result);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.forLanguageTag()'
*/
public void testForLanguageTag() {
String[] test_tags = {
"en-us",
"Und-Us",
"ja-jp-u-ca-japanese",
"fr-FR-u-tz-frpar-ca-gregory",
};
ULocale[] expected = {
new ULocale("en_US"),
new ULocale("und_US"),
new ULocale("ja_JP@calendar=japanese"),
new ULocale("fr_FR@calendar=gregorian;timezone=Europe/Paris"),
};
for (int i = 0; i < test_tags.length; i++) {
ULocale result = ULocale.forLanguageTag(test_tags[i]);
assertEquals(expected[i], result);
}
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.getDefault(Category)'
*/
public void testGetDefaultCategory() {
ULocale dispLoc = ULocale.getDefault(Category.DISPLAY);
assertNotNull(dispLoc);
ULocale formLoc = ULocale.getDefault(Category.FORMAT);
assertNotNull(formLoc);
}
/*
* Test method for 'com.ibm.icu.x.util.ULocale.setDefault(Category, ULocale)'
*/
public void testSetDefaultCategoryULocale() {
ULocale orgDefault = ULocale.getDefault();
ULocale orgDisplay = ULocale.getDefault(Category.DISPLAY);
ULocale orgFormat = ULocale.getDefault(Category.FORMAT);
ULocale jaUS = new ULocale("ja_US");
ULocale.setDefault(jaUS);
// setDefault(ULocale) updates category defaults
assertEquals(ULocale.getDefault(), jaUS);
assertEquals(ULocale.getDefault(Category.DISPLAY), jaUS);
assertEquals(ULocale.getDefault(Category.FORMAT), jaUS);
ULocale frDE = new ULocale("fr_DE");
ULocale.setDefault(Category.DISPLAY, frDE);
// setDefault(Category, ULocale) only updates the category default
assertEquals(ULocale.getDefault(), jaUS);
assertEquals(ULocale.getDefault(Category.DISPLAY), frDE);
assertEquals(ULocale.getDefault(Category.FORMAT), jaUS);
// restore the original
ULocale.setDefault(orgDefault);
ULocale.setDefault(Category.DISPLAY, orgDisplay);
ULocale.setDefault(Category.FORMAT, orgFormat);
assertEquals(ULocale.getDefault(), orgDefault);
assertEquals(ULocale.getDefault(Category.DISPLAY), orgDisplay);
assertEquals(ULocale.getDefault(Category.FORMAT), orgFormat);
}
}

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.icu.base</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View file

@ -1,2 +0,0 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View file

@ -1,76 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=ignore
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.7

View file

@ -1,3 +0,0 @@
#Thu Dec 14 11:50:17 EST 2006
eclipse.preferences.version=1
internal.default.compliance=default

View file

@ -1,15 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: com.ibm.icu.base; singleton:=true
Bundle-Version: @BUILD_VERSION@
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-Copyright: @COPYRIGHT@
Export-Package: com.ibm.icu.text;base=true;version="@IMPL_VERSION@",
com.ibm.icu.util;base=true;version="@IMPL_VERSION@",
com.ibm.icu.math;base=true;version="@IMPL_VERSION@",
com.ibm.icu.impl;x-internal:=true,
com.ibm.icu.impl.locale;x-internal:=true
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View file

@ -1,19 +0,0 @@
###############################################################################
# Copyright (c) 2011 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
source.. = src/
output.. = bin/
src.includes = about.html,\
about_files/
bin.includes = .,\
about.html,\
about_files/,\
plugin.properties,\
META-INF/

View file

@ -1,12 +0,0 @@
###############################################################################
# Copyright (c) 2011 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
pluginName = International Components for Unicode for Java (ICU4J) Replacement plug-in
providerName = IBM Corporation

View file

@ -1,23 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
***************************************************************************
* Copyright (c) 2007-2011 International Business Machines Corporation and *
* others. All rights reserved. *
***************************************************************************
*/
package com.ibm.icu.impl;
public interface ICUCache<K, V> {
// Type of reference holding the Map instance
public static final int SOFT = 0;
public static final int WEAK = 1;
// NULL object, which may be used for a cache key
public static final Object NULL = new Object();
public void clear();
public void put(K key, V value);
public V get(Object key);
}

View file

@ -1,745 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
* Copyright (C) 2003-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
package com.ibm.icu.impl;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import com.ibm.icu.impl.locale.AsciiUtil;
/**
* Utility class to parse and normalize locale ids (including POSIX style)
*/
public final class LocaleIDParser {
/**
* Char array representing the locale ID.
*/
private char[] id;
/**
* Current position in {@link #id} (while parsing).
*/
private int index;
/**
* Temporary buffer for parsed sections of data.
*/
private StringBuilder buffer;
// um, don't handle POSIX ids unless we request it. why not? well... because.
private boolean canonicalize;
private boolean hadCountry;
// used when canonicalizing
Map<String, String> keywords;
String baseName;
/**
* Parsing constants.
*/
private static final char KEYWORD_SEPARATOR = '@';
private static final char HYPHEN = '-';
private static final char KEYWORD_ASSIGN = '=';
private static final char COMMA = ',';
private static final char ITEM_SEPARATOR = ';';
private static final char DOT = '.';
private static final char UNDERSCORE = '_';
public LocaleIDParser(String localeID) {
this(localeID, false);
}
public LocaleIDParser(String localeID, boolean canonicalize) {
id = localeID.toCharArray();
index = 0;
buffer = new StringBuilder(id.length + 5);
this.canonicalize = canonicalize;
}
private void reset() {
index = 0;
buffer = new StringBuilder(id.length + 5);
}
// utilities for working on text in the buffer
/**
* Append c to the buffer.
*/
private void append(char c) {
buffer.append(c);
}
private void addSeparator() {
append(UNDERSCORE);
}
/**
* Returns the text in the buffer from start to blen as a String.
*/
private String getString(int start) {
return buffer.substring(start);
}
/**
* Set the length of the buffer to pos, then append the string.
*/
private void set(int pos, String s) {
buffer.delete(pos, buffer.length());
buffer.insert(pos, s);
}
/**
* Append the string to the buffer.
*/
private void append(String s) {
buffer.append(s);
}
// utilities for parsing text out of the id
/**
* Character to indicate no more text is available in the id.
*/
private static final char DONE = '\uffff';
/**
* Returns the character at index in the id, and advance index. The returned character
* is DONE if index was at the limit of the buffer. The index is advanced regardless
* so that decrementing the index will always 'unget' the last character returned.
*/
private char next() {
if (index == id.length) {
index++;
return DONE;
}
return id[index++];
}
/**
* Advance index until the next terminator or id separator, and leave it there.
*/
private void skipUntilTerminatorOrIDSeparator() {
while (!isTerminatorOrIDSeparator(next()));
--index;
}
/**
* Returns true if the character at index in the id is a terminator.
*/
private boolean atTerminator() {
return index >= id.length || isTerminator(id[index]);
}
/**
* Returns true if the character is a terminator (keyword separator, dot, or DONE).
* Dot is a terminator because of the POSIX form, where dot precedes the codepage.
*/
private boolean isTerminator(char c) {
// always terminate at DOT, even if not handling POSIX. It's an error...
return c == KEYWORD_SEPARATOR || c == DONE || c == DOT;
}
/**
* Returns true if the character is a terminator or id separator.
*/
private boolean isTerminatorOrIDSeparator(char c) {
return c == UNDERSCORE || c == HYPHEN || isTerminator(c);
}
/**
* Returns true if the start of the buffer has an experimental or private language
* prefix, the pattern '[ixIX][-_].' shows the syntax checked.
*/
private boolean haveExperimentalLanguagePrefix() {
if (id.length > 2) {
char c = id[1];
if (c == HYPHEN || c == UNDERSCORE) {
c = id[0];
return c == 'x' || c == 'X' || c == 'i' || c == 'I';
}
}
return false;
}
/**
* Returns true if a value separator occurs at or after index.
*/
private boolean haveKeywordAssign() {
// assume it is safe to start from index
for (int i = index; i < id.length; ++i) {
if (id[i] == KEYWORD_ASSIGN) {
return true;
}
}
return false;
}
/**
* Advance index past language, and accumulate normalized language code in buffer.
* Index must be at 0 when this is called. Index is left at a terminator or id
* separator. Returns the start of the language code in the buffer.
*/
private int parseLanguage() {
int startLength = buffer.length();
if (haveExperimentalLanguagePrefix()) {
append(AsciiUtil.toLower(id[0]));
append(HYPHEN);
index = 2;
}
char c;
while(!isTerminatorOrIDSeparator(c = next())) {
append(AsciiUtil.toLower(c));
}
--index; // unget
if (buffer.length() - startLength == 3) {
String lang = LocaleIDs.threeToTwoLetterLanguage(getString(0));
if (lang != null) {
set(0, lang);
}
}
return 0;
}
/**
* Advance index past language. Index must be at 0 when this is called. Index
* is left at a terminator or id separator.
*/
private void skipLanguage() {
if (haveExperimentalLanguagePrefix()) {
index = 2;
}
skipUntilTerminatorOrIDSeparator();
}
/**
* Advance index past script, and accumulate normalized script in buffer.
* Index must be immediately after the language.
* If the item at this position is not a script (is not four characters
* long) leave index and buffer unchanged. Otherwise index is left at
* a terminator or id separator. Returns the start of the script code
* in the buffer (this may be equal to the buffer length, if there is no
* script).
*/
private int parseScript() {
if (!atTerminator()) {
int oldIndex = index; // save original index
++index;
int oldBlen = buffer.length(); // get before append hyphen, if we truncate everything is undone
char c;
boolean firstPass = true;
while(!isTerminatorOrIDSeparator(c = next()) && AsciiUtil.isAlpha(c)) {
if (firstPass) {
addSeparator();
append(AsciiUtil.toUpper(c));
firstPass = false;
} else {
append(AsciiUtil.toLower(c));
}
}
--index; // unget
/* If it's not exactly 4 characters long, then it's not a script. */
if (index - oldIndex != 5) { // +1 to account for separator
index = oldIndex;
buffer.delete(oldBlen, buffer.length());
} else {
oldBlen++; // index past hyphen, for clients who want to extract just the script
}
return oldBlen;
}
return buffer.length();
}
/**
* Advance index past script.
* Index must be immediately after the language and IDSeparator.
* If the item at this position is not a script (is not four characters
* long) leave index. Otherwise index is left at a terminator or
* id separator.
*/
private void skipScript() {
if (!atTerminator()) {
int oldIndex = index;
++index;
char c;
while (!isTerminatorOrIDSeparator(c = next()) && AsciiUtil.isAlpha(c));
--index;
if (index - oldIndex != 5) { // +1 to account for separator
index = oldIndex;
}
}
}
/**
* Advance index past country, and accumulate normalized country in buffer.
* Index must be immediately after the script (if there is one, else language)
* and IDSeparator. Return the start of the country code in the buffer.
*/
private int parseCountry() {
if (!atTerminator()) {
int oldIndex = index;
++index;
int oldBlen = buffer.length();
char c;
boolean firstPass = true;
while (!isTerminatorOrIDSeparator(c = next())) {
if (firstPass) { // first, add hyphen
hadCountry = true; // we have a country, let variant parsing know
addSeparator();
++oldBlen; // increment past hyphen
firstPass = false;
}
append(AsciiUtil.toUpper(c));
}
--index; // unget
int charsAppended = buffer.length() - oldBlen;
if (charsAppended == 0) {
// Do nothing.
}
else if (charsAppended < 2 || charsAppended > 3) {
// It's not a country, so return index and blen to
// their previous values.
index = oldIndex;
--oldBlen;
buffer.delete(oldBlen, buffer.length());
hadCountry = false;
}
else if (charsAppended == 3) {
String region = LocaleIDs.threeToTwoLetterRegion(getString(oldBlen));
if (region != null) {
set(oldBlen, region);
}
}
return oldBlen;
}
return buffer.length();
}
/**
* Advance index past country.
* Index must be immediately after the script (if there is one, else language)
* and IDSeparator.
*/
private void skipCountry() {
if (!atTerminator()) {
if (id[index] == UNDERSCORE || id[index] == HYPHEN) {
++index;
}
/*
* Save the index point after the separator, since the format
* requires two separators if the country is not present.
*/
int oldIndex = index;
skipUntilTerminatorOrIDSeparator();
int charsSkipped = index - oldIndex;
if (charsSkipped < 2 || charsSkipped > 3) {
index = oldIndex;
}
}
}
/**
* Advance index past variant, and accumulate normalized variant in buffer. This ignores
* the codepage information from POSIX ids. Index must be immediately after the country
* or script. Index is left at the keyword separator or at the end of the text. Return
* the start of the variant code in the buffer.
*
* In standard form, we can have the following forms:
* ll__VVVV
* ll_CC_VVVV
* ll_Ssss_VVVV
* ll_Ssss_CC_VVVV
*
* This also handles POSIX ids, which can have the following forms (pppp is code page id):
* ll_CC.pppp --> ll_CC
* ll_CC.pppp@VVVV --> ll_CC_VVVV
* ll_CC@VVVV --> ll_CC_VVVV
*
* We identify this use of '@' in POSIX ids by looking for an '=' following
* the '@'. If there is one, we consider '@' to start a keyword list, instead of
* being part of a POSIX id.
*
* Note: since it was decided that we want an option to not handle POSIX ids, this
* becomes a bit more complex.
*/
private int parseVariant() {
int oldBlen = buffer.length();
boolean start = true;
boolean needSeparator = true;
boolean skipping = false;
char c;
boolean firstPass = true;
while ((c = next()) != DONE) {
if (c == DOT) {
start = false;
skipping = true;
} else if (c == KEYWORD_SEPARATOR) {
if (haveKeywordAssign()) {
break;
}
skipping = false;
start = false;
needSeparator = true; // add another underscore if we have more text
} else if (start) {
start = false;
if (c != UNDERSCORE && c != HYPHEN) {
index--;
}
} else if (!skipping) {
if (needSeparator) {
needSeparator = false;
if (firstPass && !hadCountry) { // no country, we'll need two
addSeparator();
++oldBlen; // for sure
}
addSeparator();
if (firstPass) { // only for the first separator
++oldBlen;
firstPass = false;
}
}
c = AsciiUtil.toUpper(c);
if (c == HYPHEN || c == COMMA) {
c = UNDERSCORE;
}
append(c);
}
}
--index; // unget
return oldBlen;
}
// no need for skipvariant, to get the keywords we'll just scan directly for
// the keyword separator
/**
* Returns the normalized language id, or the empty string.
*/
public String getLanguage() {
reset();
return getString(parseLanguage());
}
/**
* Returns the normalized script id, or the empty string.
*/
public String getScript() {
reset();
skipLanguage();
return getString(parseScript());
}
/**
* return the normalized country id, or the empty string.
*/
public String getCountry() {
reset();
skipLanguage();
skipScript();
return getString(parseCountry());
}
/**
* Returns the normalized variant id, or the empty string.
*/
public String getVariant() {
reset();
skipLanguage();
skipScript();
skipCountry();
return getString(parseVariant());
}
/**
* Returns the language, script, country, and variant as separate strings.
*/
public String[] getLanguageScriptCountryVariant() {
reset();
return new String[] {
getString(parseLanguage()),
getString(parseScript()),
getString(parseCountry()),
getString(parseVariant())
};
}
public void setBaseName(String baseName) {
this.baseName = baseName;
}
public void parseBaseName() {
if (baseName != null) {
set(0, baseName);
} else {
reset();
parseLanguage();
parseScript();
parseCountry();
parseVariant();
// catch unwanted trailing underscore after country if there was no variant
int len = buffer.length();
if (len > 0 && buffer.charAt(len - 1) == UNDERSCORE) {
buffer.deleteCharAt(len - 1);
}
}
}
/**
* Returns the normalized base form of the locale id. The base
* form does not include keywords.
*/
public String getBaseName() {
if (baseName != null) {
return baseName;
}
parseBaseName();
return getString(0);
}
/**
* Returns the normalized full form of the locale id. The full
* form includes keywords if they are present.
*/
public String getName() {
parseBaseName();
parseKeywords();
return getString(0);
}
// keyword utilities
/**
* If we have keywords, advance index to the start of the keywords and return true,
* otherwise return false.
*/
private boolean setToKeywordStart() {
for (int i = index; i < id.length; ++i) {
if (id[i] == KEYWORD_SEPARATOR) {
if (canonicalize) {
for (int j = ++i; j < id.length; ++j) { // increment i past separator for return
if (id[j] == KEYWORD_ASSIGN) {
index = i;
return true;
}
}
} else {
if (++i < id.length) {
index = i;
return true;
}
}
break;
}
}
return false;
}
private static boolean isDoneOrKeywordAssign(char c) {
return c == DONE || c == KEYWORD_ASSIGN;
}
private static boolean isDoneOrItemSeparator(char c) {
return c == DONE || c == ITEM_SEPARATOR;
}
private String getKeyword() {
int start = index;
while (!isDoneOrKeywordAssign(next())) {
}
--index;
return AsciiUtil.toLowerString(new String(id, start, index-start).trim());
}
private String getValue() {
int start = index;
while (!isDoneOrItemSeparator(next())) {
}
--index;
return new String(id, start, index-start).trim(); // leave case alone
}
private Comparator<String> getKeyComparator() {
final Comparator<String> comp = new Comparator<String>() {
public int compare(String lhs, String rhs) {
return lhs.compareTo(rhs);
}
};
return comp;
}
/**
* Returns a map of the keywords and values, or null if there are none.
*/
public Map<String, String> getKeywordMap() {
if (keywords == null) {
TreeMap<String, String> m = null;
if (setToKeywordStart()) {
// trim spaces and convert to lower case, both keywords and values.
do {
String key = getKeyword();
if (key.length() == 0) {
break;
}
char c = next();
if (c != KEYWORD_ASSIGN) {
// throw new IllegalArgumentException("key '" + key + "' missing a value.");
if (c == DONE) {
break;
} else {
continue;
}
}
String value = getValue();
if (value.length() == 0) {
// throw new IllegalArgumentException("key '" + key + "' missing a value.");
continue;
}
if (m == null) {
m = new TreeMap<String, String>(getKeyComparator());
} else if (m.containsKey(key)) {
// throw new IllegalArgumentException("key '" + key + "' already has a value.");
continue;
}
m.put(key, value);
} while (next() == ITEM_SEPARATOR);
}
keywords = m != null ? m : Collections.<String, String>emptyMap();
}
return keywords;
}
/**
* Parse the keywords and return start of the string in the buffer.
*/
private int parseKeywords() {
int oldBlen = buffer.length();
Map<String, String> m = getKeywordMap();
if (!m.isEmpty()) {
boolean first = true;
for (Map.Entry<String, String> e : m.entrySet()) {
append(first ? KEYWORD_SEPARATOR : ITEM_SEPARATOR);
first = false;
append(e.getKey());
append(KEYWORD_ASSIGN);
append(e.getValue());
}
if (first == false) {
++oldBlen;
}
}
return oldBlen;
}
/**
* Returns an iterator over the keywords, or null if we have an empty map.
*/
public Iterator<String> getKeywords() {
Map<String, String> m = getKeywordMap();
return m.isEmpty() ? null : m.keySet().iterator();
}
/**
* Returns the value for the named keyword, or null if the keyword is not
* present.
*/
public String getKeywordValue(String keywordName) {
Map<String, String> m = getKeywordMap();
return m.isEmpty() ? null : m.get(AsciiUtil.toLowerString(keywordName.trim()));
}
/**
* Set the keyword value only if it is not already set to something else.
*/
public void defaultKeywordValue(String keywordName, String value) {
setKeywordValue(keywordName, value, false);
}
/**
* Set the value for the named keyword, or unset it if value is null. If
* keywordName itself is null, unset all keywords. If keywordName is not null,
* value must not be null.
*/
public void setKeywordValue(String keywordName, String value) {
setKeywordValue(keywordName, value, true);
}
/**
* Set the value for the named keyword, or unset it if value is null. If
* keywordName itself is null, unset all keywords. If keywordName is not null,
* value must not be null. If reset is true, ignore any previous value for
* the keyword, otherwise do not change the keyword (including removal of
* one or all keywords).
*/
private void setKeywordValue(String keywordName, String value, boolean reset) {
if (keywordName == null) {
if (reset) {
// force new map, ignore value
keywords = Collections.<String, String>emptyMap();
}
} else {
keywordName = AsciiUtil.toLowerString(keywordName.trim());
if (keywordName.length() == 0) {
throw new IllegalArgumentException("keyword must not be empty");
}
if (value != null) {
value = value.trim();
if (value.length() == 0) {
throw new IllegalArgumentException("value must not be empty");
}
}
Map<String, String> m = getKeywordMap();
if (m.isEmpty()) { // it is EMPTY_MAP
if (value != null) {
// force new map
keywords = new TreeMap<String, String>(getKeyComparator());
keywords.put(keywordName, value.trim());
}
} else {
if (reset || !m.containsKey(keywordName)) {
if (value != null) {
m.put(keywordName, value);
} else {
m.remove(keywordName);
if (m.isEmpty()) {
// force new map
keywords = Collections.<String, String>emptyMap();
}
}
}
}
}
}
}

View file

@ -1,538 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl;
import java.util.MissingResourceException;
import com.ibm.icu.util.ULocale;
/**
* Utilities for mapping between old and new language, country, and other
* locale ID related names.
*/
public class LocaleIDs {
/**
* Returns a list of all 2-letter country codes defined in ISO 3166.
* Can be used to create Locales.
* @stable ICU 3.0
*/
public static String[] getISOCountries() {
initCountryTables();
return _countries.clone();
}
/**
* Returns a list of all 2-letter language codes defined in ISO 639.
* Can be used to create Locales.
* [NOTE: ISO 639 is not a stable standard-- some languages' codes have changed.
* The list this function returns includes both the new and the old codes for the
* languages whose codes have changed.]
* @stable ICU 3.0
*/
public static String[] getISOLanguages() {
initLanguageTables();
return _languages.clone();
}
/**
* Returns a three-letter abbreviation for the provided country. If the provided
* country is empty, returns the empty string. Otherwise, returns
* an uppercase ISO 3166 3-letter country code.
* @exception MissingResourceException Throws MissingResourceException if the
* three-letter country abbreviation is not available for this locale.
* @stable ICU 3.0
*/
public static String getISO3Country(String country){
initCountryTables();
int offset = findIndex(_countries, country);
if(offset>=0){
return _countries3[offset];
}else{
offset = findIndex(_obsoleteCountries, country);
if(offset>=0){
return _obsoleteCountries3[offset];
}
}
return "";
}
/**
* Returns a three-letter abbreviation for the language. If language is
* empty, returns the empty string. Otherwise, returns
* a lowercase ISO 639-2/T language code.
* The ISO 639-2 language codes can be found on-line at
* <a href="ftp://dkuug.dk/i18n/iso-639-2.txt"><code>ftp://dkuug.dk/i18n/iso-639-2.txt</code></a>
* @exception MissingResourceException Throws MissingResourceException if the
* three-letter language abbreviation is not available for this locale.
* @stable ICU 3.0
*/
public static String getISO3Language(String language) {
initLanguageTables();
int offset = findIndex(_languages, language);
if(offset>=0){
return _languages3[offset];
} else {
offset = findIndex(_obsoleteLanguages, language);
if (offset >= 0) {
return _obsoleteLanguages3[offset];
}
}
return "";
}
public static String threeToTwoLetterLanguage(String lang) {
initLanguageTables();
/* convert 3 character code to 2 character code if possible *CWB*/
int offset = findIndex(_languages3, lang);
if (offset >= 0) {
return _languages[offset];
}
offset = findIndex(_obsoleteLanguages3, lang);
if (offset >= 0) {
return _obsoleteLanguages[offset];
}
return null;
}
public static String threeToTwoLetterRegion(String region) {
initCountryTables();
/* convert 3 character code to 2 character code if possible *CWB*/
int offset = findIndex(_countries3, region);
if (offset >= 0) {
return _countries[offset];
}
offset = findIndex(_obsoleteCountries3, region);
if (offset >= 0) {
return _obsoleteCountries[offset];
}
return null;
}
/**
* linear search of the string array. the arrays are unfortunately ordered by the
* two-letter target code, not the three-letter search code, which seems backwards.
*/
private static int findIndex(String[] array, String target){
for (int i = 0; i < array.length; i++) {
if (target.equals(array[i])) {
return i;
}
}
return -1;
}
/**
* Tables used in normalizing portions of the id.
*/
/* tables updated per http://lcweb.loc.gov/standards/iso639-2/
to include the revisions up to 2001/7/27 *CWB*/
/* The 3 character codes are the terminology codes like RFC 3066.
This is compatible with prior ICU codes */
/* "in" "iw" "ji" "jw" & "sh" have been withdrawn but are still in
the table but now at the end of the table because
3 character codes are duplicates. This avoids bad searches
going from 3 to 2 character codes.*/
/* The range qaa-qtz is reserved for local use. */
private static String[] _languages;
private static String[] _replacementLanguages;
private static String[] _obsoleteLanguages;
private static String[] _languages3;
private static String[] _obsoleteLanguages3;
// Avoid initializing languages tables unless we have to.
private static void initLanguageTables() {
if (_languages == null) {
/* This list MUST be in sorted order, and MUST contain the two-letter codes
if one exists otherwise use the three letter code */
String[] tempLanguages = {
"aa", "ab", "ace", "ach", "ada", "ady", "ae", "af", "afa",
"afh", "ak", "akk", "ale", "alg", "am", "an", "ang", "apa",
"ar", "arc", "arn", "arp", "art", "arw", "as", "ast",
"ath", "aus", "av", "awa", "ay", "az", "ba", "bad",
"bai", "bal", "ban", "bas", "bat", "be", "bej",
"bem", "ber", "bg", "bh", "bho", "bi", "bik", "bin",
"bla", "bm", "bn", "bnt", "bo", "br", "bra", "bs",
"btk", "bua", "bug", "byn", "ca", "cad", "cai", "car", "cau",
"ce", "ceb", "cel", "ch", "chb", "chg", "chk", "chm",
"chn", "cho", "chp", "chr", "chy", "cmc", "co", "cop",
"cpe", "cpf", "cpp", "cr", "crh", "crp", "cs", "csb", "cu", "cus",
"cv", "cy", "da", "dak", "dar", "day", "de", "del", "den",
"dgr", "din", "doi", "dra", "dsb", "dua", "dum", "dv", "dyu",
"dz", "ee", "efi", "egy", "eka", "el", "elx", "en",
"enm", "eo", "es", "et", "eu", "ewo", "fa",
"fan", "fat", "ff", "fi", "fiu", "fj", "fo", "fon",
"fr", "frm", "fro", "fur", "fy", "ga", "gaa", "gay",
"gba", "gd", "gem", "gez", "gil", "gl", "gmh", "gn",
"goh", "gon", "gor", "got", "grb", "grc", "gu", "gv",
"gwi", "ha", "hai", "haw", "he", "hi", "hil", "him",
"hit", "hmn", "ho", "hr", "hsb", "ht", "hu", "hup", "hy", "hz",
"ia", "iba", "id", "ie", "ig", "ii", "ijo", "ik",
"ilo", "inc", "ine", "inh", "io", "ira", "iro", "is", "it",
"iu", "ja", "jbo", "jpr", "jrb", "jv", "ka", "kaa", "kab",
"kac", "kam", "kar", "kaw", "kbd", "kg", "kha", "khi",
"kho", "ki", "kj", "kk", "kl", "km", "kmb", "kn",
"ko", "kok", "kos", "kpe", "kr", "krc", "kro", "kru", "ks",
"ku", "kum", "kut", "kv", "kw", "ky", "la", "lad",
"lah", "lam", "lb", "lez", "lg", "li", "ln", "lo", "lol",
"loz", "lt", "lu", "lua", "lui", "lun", "luo", "lus",
"lv", "mad", "mag", "mai", "mak", "man", "map", "mas",
"mdf", "mdr", "men", "mg", "mga", "mh", "mi", "mic", "min",
"mis", "mk", "mkh", "ml", "mn", "mnc", "mni", "mno",
"mo", "moh", "mos", "mr", "ms", "mt", "mul", "mun",
"mus", "mwr", "my", "myn", "myv", "na", "nah", "nai", "nap",
"nb", "nd", "nds", "ne", "new", "ng", "nia", "nic",
"niu", "nl", "nn", "no", "nog", "non", "nr", "nso", "nub",
"nv", "nwc", "ny", "nym", "nyn", "nyo", "nzi", "oc", "oj",
"om", "or", "os", "osa", "ota", "oto", "pa", "paa",
"pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn",
"pi", "pl", "pon", "pra", "pro", "ps", "pt", "qu",
"raj", "rap", "rar", "rm", "rn", "ro", "roa", "rom",
"ru", "rup", "rw", "sa", "sad", "sah", "sai", "sal", "sam",
"sas", "sat", "sc", "sco", "sd", "se", "sel", "sem",
"sg", "sga", "sgn", "shn", "si", "sid", "sio", "sit",
"sk", "sl", "sla", "sm", "sma", "smi", "smj", "smn",
"sms", "sn", "snk", "so", "sog", "son", "sq", "sr",
"srr", "ss", "ssa", "st", "su", "suk", "sus", "sux",
"sv", "sw", "syr", "ta", "tai", "te", "tem", "ter",
"tet", "tg", "th", "ti", "tig", "tiv", "tk", "tkl",
"tl", "tlh", "tli", "tmh", "tn", "to", "tog", "tpi", "tr",
"ts", "tsi", "tt", "tum", "tup", "tut", "tvl", "tw",
"ty", "tyv", "udm", "ug", "uga", "uk", "umb", "und", "ur",
"uz", "vai", "ve", "vi", "vo", "vot", "wa", "wak",
"wal", "war", "was", "wen", "wo", "xal", "xh", "yao", "yap",
"yi", "yo", "ypk", "za", "zap", "zen", "zh", "znd",
"zu", "zun",
};
String[] tempReplacementLanguages = {
"id", "he", "yi", "jv", "sr", "nb",/* replacement language codes */
};
String[] tempObsoleteLanguages = {
"in", "iw", "ji", "jw", "sh", "no", /* obsolete language codes */
};
/* This list MUST contain a three-letter code for every two-letter code in the
list above, and they MUST ne in the same order (i.e., the same language must
be in the same place in both lists)! */
String[] tempLanguages3 = {
/*"aa", "ab", "ace", "ach", "ada", "ady", "ae", "af", "afa", */
"aar", "abk", "ace", "ach", "ada", "ady", "ave", "afr", "afa",
/*"afh", "ak", "akk", "ale", "alg", "am", "an", "ang", "apa", */
"afh", "aka", "akk", "ale", "alg", "amh", "arg", "ang", "apa",
/*"ar", "arc", "arn", "arp", "art", "arw", "as", "ast", */
"ara", "arc", "arn", "arp", "art", "arw", "asm", "ast",
/*"ath", "aus", "av", "awa", "ay", "az", "ba", "bad", */
"ath", "aus", "ava", "awa", "aym", "aze", "bak", "bad",
/*"bai", "bal", "ban", "bas", "bat", "be", "bej", */
"bai", "bal", "ban", "bas", "bat", "bel", "bej",
/*"bem", "ber", "bg", "bh", "bho", "bi", "bik", "bin", */
"bem", "ber", "bul", "bih", "bho", "bis", "bik", "bin",
/*"bla", "bm", "bn", "bnt", "bo", "br", "bra", "bs", */
"bla", "bam", "ben", "bnt", "bod", "bre", "bra", "bos",
/*"btk", "bua", "bug", "byn", "ca", "cad", "cai", "car", "cau", */
"btk", "bua", "bug", "byn", "cat", "cad", "cai", "car", "cau",
/*"ce", "ceb", "cel", "ch", "chb", "chg", "chk", "chm", */
"che", "ceb", "cel", "cha", "chb", "chg", "chk", "chm",
/*"chn", "cho", "chp", "chr", "chy", "cmc", "co", "cop", */
"chn", "cho", "chp", "chr", "chy", "cmc", "cos", "cop",
/*"cpe", "cpf", "cpp", "cr", "crh", "crp", "cs", "csb", "cu", "cus", */
"cpe", "cpf", "cpp", "cre", "crh", "crp", "ces", "csb", "chu", "cus",
/*"cv", "cy", "da", "dak", "dar", "day", "de", "del", "den", */
"chv", "cym", "dan", "dak", "dar", "day", "deu", "del", "den",
/*"dgr", "din", "doi", "dra", "dsb", "dua", "dum", "dv", "dyu", */
"dgr", "din", "doi", "dra", "dsb", "dua", "dum", "div", "dyu",
/*"dz", "ee", "efi", "egy", "eka", "el", "elx", "en", */
"dzo", "ewe", "efi", "egy", "eka", "ell", "elx", "eng",
/*"enm", "eo", "es", "et", "eu", "ewo", "fa", */
"enm", "epo", "spa", "est", "eus", "ewo", "fas",
/*"fan", "fat", "ff", "fi", "fiu", "fj", "fo", "fon", */
"fan", "fat", "ful", "fin", "fiu", "fij", "fao", "fon",
/*"fr", "frm", "fro", "fur", "fy", "ga", "gaa", "gay", */
"fra", "frm", "fro", "fur", "fry", "gle", "gaa", "gay",
/*"gba", "gd", "gem", "gez", "gil", "gl", "gmh", "gn", */
"gba", "gla", "gem", "gez", "gil", "glg", "gmh", "grn",
/*"goh", "gon", "gor", "got", "grb", "grc", "gu", "gv", */
"goh", "gon", "gor", "got", "grb", "grc", "guj", "glv",
/*"gwi", "ha", "hai", "haw", "he", "hi", "hil", "him", */
"gwi", "hau", "hai", "haw", "heb", "hin", "hil", "him",
/*"hit", "hmn", "ho", "hr", "hsb", "ht", "hu", "hup", "hy", "hz", */
"hit", "hmn", "hmo", "hrv", "hsb", "hat", "hun", "hup", "hye", "her",
/*"ia", "iba", "id", "ie", "ig", "ii", "ijo", "ik", */
"ina", "iba", "ind", "ile", "ibo", "iii", "ijo", "ipk",
/*"ilo", "inc", "ine", "inh", "io", "ira", "iro", "is", "it", */
"ilo", "inc", "ine", "inh", "ido", "ira", "iro", "isl", "ita",
/*"iu", "ja", "jbo", "jpr", "jrb", "jv", "ka", "kaa", "kab", */
"iku", "jpn", "jbo", "jpr", "jrb", "jaw", "kat", "kaa", "kab",
/*"kac", "kam", "kar", "kaw", "kbd", "kg", "kha", "khi", */
"kac", "kam", "kar", "kaw", "kbd", "kon", "kha", "khi",
/*"kho", "ki", "kj", "kk", "kl", "km", "kmb", "kn", */
"kho", "kik", "kua", "kaz", "kal", "khm", "kmb", "kan",
/*"ko", "kok", "kos", "kpe", "kr", "krc", "kro", "kru", "ks", */
"kor", "kok", "kos", "kpe", "kau", "krc", "kro", "kru", "kas",
/*"ku", "kum", "kut", "kv", "kw", "ky", "la", "lad", */
"kur", "kum", "kut", "kom", "cor", "kir", "lat", "lad",
/*"lah", "lam", "lb", "lez", "lg", "li", "ln", "lo", "lol", */
"lah", "lam", "ltz", "lez", "lug", "lim", "lin", "lao", "lol",
/*"loz", "lt", "lu", "lua", "lui", "lun", "luo", "lus", */
"loz", "lit", "lub", "lua", "lui", "lun", "luo", "lus",
/*"lv", "mad", "mag", "mai", "mak", "man", "map", "mas", */
"lav", "mad", "mag", "mai", "mak", "man", "map", "mas",
/*"mdf", "mdr", "men", "mg", "mga", "mh", "mi", "mic", "min", */
"mdf", "mdr", "men", "mlg", "mga", "mah", "mri", "mic", "min",
/*"mis", "mk", "mkh", "ml", "mn", "mnc", "mni", "mno", */
"mis", "mkd", "mkh", "mal", "mon", "mnc", "mni", "mno",
/*"mo", "moh", "mos", "mr", "ms", "mt", "mul", "mun", */
"mol", "moh", "mos", "mar", "msa", "mlt", "mul", "mun",
/*"mus", "mwr", "my", "myn", "myv", "na", "nah", "nai", "nap", */
"mus", "mwr", "mya", "myn", "myv", "nau", "nah", "nai", "nap",
/*"nb", "nd", "nds", "ne", "new", "ng", "nia", "nic", */
"nob", "nde", "nds", "nep", "new", "ndo", "nia", "nic",
/*"niu", "nl", "nn", "no", "nog", "non", "nr", "nso", "nub", */
"niu", "nld", "nno", "nor", "nog", "non", "nbl", "nso", "nub",
/*"nv", "nwc", "ny", "nym", "nyn", "nyo", "nzi", "oc", "oj", */
"nav", "nwc", "nya", "nym", "nyn", "nyo", "nzi", "oci", "oji",
/*"om", "or", "os", "osa", "ota", "oto", "pa", "paa", */
"orm", "ori", "oss", "osa", "ota", "oto", "pan", "paa",
/*"pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn", */
"pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn",
/*"pi", "pl", "pon", "pra", "pro", "ps", "pt", "qu", */
"pli", "pol", "pon", "pra", "pro", "pus", "por", "que",
/*"raj", "rap", "rar", "rm", "rn", "ro", "roa", "rom", */
"raj", "rap", "rar", "roh", "run", "ron", "roa", "rom",
/*"ru", "rup", "rw", "sa", "sad", "sah", "sai", "sal", "sam", */
"rus", "rup", "kin", "san", "sad", "sah", "sai", "sal", "sam",
/*"sas", "sat", "sc", "sco", "sd", "se", "sel", "sem", */
"sas", "sat", "srd", "sco", "snd", "sme", "sel", "sem",
/*"sg", "sga", "sgn", "shn", "si", "sid", "sio", "sit", */
"sag", "sga", "sgn", "shn", "sin", "sid", "sio", "sit",
/*"sk", "sl", "sla", "sm", "sma", "smi", "smj", "smn", */
"slk", "slv", "sla", "smo", "sma", "smi", "smj", "smn",
/*"sms", "sn", "snk", "so", "sog", "son", "sq", "sr", */
"sms", "sna", "snk", "som", "sog", "son", "sqi", "srp",
/*"srr", "ss", "ssa", "st", "su", "suk", "sus", "sux", */
"srr", "ssw", "ssa", "sot", "sun", "suk", "sus", "sux",
/*"sv", "sw", "syr", "ta", "tai", "te", "tem", "ter", */
"swe", "swa", "syr", "tam", "tai", "tel", "tem", "ter",
/*"tet", "tg", "th", "ti", "tig", "tiv", "tk", "tkl", */
"tet", "tgk", "tha", "tir", "tig", "tiv", "tuk", "tkl",
/*"tl", "tlh", "tli", "tmh", "tn", "to", "tog", "tpi", "tr", */
"tgl", "tlh", "tli", "tmh", "tsn", "ton", "tog", "tpi", "tur",
/*"ts", "tsi", "tt", "tum", "tup", "tut", "tvl", "tw", */
"tso", "tsi", "tat", "tum", "tup", "tut", "tvl", "twi",
/*"ty", "tyv", "udm", "ug", "uga", "uk", "umb", "und", "ur", */
"tah", "tyv", "udm", "uig", "uga", "ukr", "umb", "und", "urd",
/*"uz", "vai", "ve", "vi", "vo", "vot", "wa", "wak", */
"uzb", "vai", "ven", "vie", "vol", "vot", "wln", "wak",
/*"wal", "war", "was", "wen", "wo", "xal", "xh", "yao", "yap", */
"wal", "war", "was", "wen", "wol", "xal", "xho", "yao", "yap",
/*"yi", "yo", "ypk", "za", "zap", "zen", "zh", "znd", */
"yid", "yor", "ypk", "zha", "zap", "zen", "zho", "znd",
/*"zu", "zun", */
"zul", "zun",
};
String[] tempObsoleteLanguages3 = {
/* "in", "iw", "ji", "jw", "sh", */
"ind", "heb", "yid", "jaw", "srp",
};
synchronized (ULocale.class) {
if (_languages == null) {
_languages = tempLanguages;
_replacementLanguages = tempReplacementLanguages;
_obsoleteLanguages = tempObsoleteLanguages;
_languages3 = tempLanguages3;
_obsoleteLanguages3 = tempObsoleteLanguages3;
}
}
}
}
private static String[] _countries;
private static String[] _deprecatedCountries;
private static String[] _replacementCountries;
private static String[] _obsoleteCountries;
private static String[] _countries3;
private static String[] _obsoleteCountries3;
// Avoid initializing country tables unless we have to.
private static void initCountryTables() {
if (_countries == null) {
/* ZR(ZAR) is now CD(COD) and FX(FXX) is PS(PSE) as per
http://www.evertype.com/standards/iso3166/iso3166-1-en.html
added new codes keeping the old ones for compatibility
updated to include 1999/12/03 revisions *CWB*/
/* RO(ROM) is now RO(ROU) according to
http://www.iso.org/iso/en/prods-services/iso3166ma/03updates-on-iso-3166/nlv3e-rou.html
*/
/* This list MUST be in sorted order, and MUST contain only two-letter codes! */
String[] tempCountries = {
"AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN",
"AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ",
"BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI",
"BJ", "BL", "BM", "BN", "BO", "BR", "BS", "BT", "BV",
"BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG",
"CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR",
"CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK",
"DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER",
"ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR",
"GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL",
"GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU",
"GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU",
"ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS",
"IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI",
"KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA",
"LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU",
"LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK",
"ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS",
"MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA",
"NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP",
"NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG",
"PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT",
"PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA",
"SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ",
"SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV",
"SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ",
"TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV",
"TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ",
"VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF",
"WS", "YE", "YT", "ZA", "ZM", "ZW",
};
/* this table is used for 3 letter codes */
String[] tempObsoleteCountries = {
"FX", "CS", "RO", "TP", "YU", "ZR", /* obsolete country codes */
};
String[] tempDeprecatedCountries = {
"BU", "CS", "DY", "FX", "HV", "NH", "RH", "TP", "YU", "ZR" /* deprecated country list */
};
String[] tempReplacementCountries = {
/* "BU", "CS", "DY", "FX", "HV", "NH", "RH", "TP", "YU", "ZR" */
"MM", "RS", "BJ", "FR", "BF", "VU", "ZW", "TL", "RS", "CD", /* replacement country codes */
};
/* This list MUST contain a three-letter code for every two-letter code in
the above list, and they MUST be listed in the same order! */
String[] tempCountries3 = {
/* "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", */
"AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", "ANT",
/* "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", */
"AGO", "ATA", "ARG", "ASM", "AUT", "AUS", "ABW", "ALA", "AZE",
/* "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", */
"BIH", "BRB", "BGD", "BEL", "BFA", "BGR", "BHR", "BDI",
/* "BJ", "BL", "BM", "BN", "BO", "BR", "BS", "BT", "BV", */
"BEN", "BLM", "BMU", "BRN", "BOL", "BRA", "BHS", "BTN", "BVT",
/* "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", */
"BWA", "BLR", "BLZ", "CAN", "CCK", "COD", "CAF", "COG",
/* "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", */
"CHE", "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI",
/* "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", */
"CUB", "CPV", "CXR", "CYP", "CZE", "DEU", "DJI", "DNK",
/* "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", */
"DMA", "DOM", "DZA", "ECU", "EST", "EGY", "ESH", "ERI",
/* "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", */
"ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA",
/* "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", */
"GAB", "GBR", "GRD", "GEO", "GUF", "GGY", "GHA", "GIB", "GRL",
/* "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", */
"GMB", "GIN", "GLP", "GNQ", "GRC", "SGS", "GTM", "GUM",
/* "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", */
"GNB", "GUY", "HKG", "HMD", "HND", "HRV", "HTI", "HUN",
/* "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS" */
"IDN", "IRL", "ISR", "IMN", "IND", "IOT", "IRQ", "IRN", "ISL",
/* "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", */
"ITA", "JEY", "JAM", "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR",
/* "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", */
"COM", "KNA", "PRK", "KOR", "KWT", "CYM", "KAZ", "LAO",
/* "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", */
"LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU", "LUX",
/* "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", */
"LVA", "LBY", "MAR", "MCO", "MDA", "MNE", "MAF", "MDG", "MHL", "MKD",
/* "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", */
"MLI", "MMR", "MNG", "MAC", "MNP", "MTQ", "MRT", "MSR",
/* "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", */
"MLT", "MUS", "MDV", "MWI", "MEX", "MYS", "MOZ", "NAM",
/* "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", */
"NCL", "NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL",
/* "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", */
"NRU", "NIU", "NZL", "OMN", "PAN", "PER", "PYF", "PNG",
/* "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", */
"PHL", "PAK", "POL", "SPM", "PCN", "PRI", "PSE", "PRT",
/* "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", */
"PLW", "PRY", "QAT", "REU", "ROU", "SRB", "RUS", "RWA", "SAU",
/* "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", */
"SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM",
/* "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", */
"SVK", "SLE", "SMR", "SEN", "SOM", "SUR", "STP", "SLV",
/* "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", */
"SYR", "SWZ", "TCA", "TCD", "ATF", "TGO", "THA", "TJK",
/* "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", */
"TKL", "TLS", "TKM", "TUN", "TON", "TUR", "TTO", "TUV",
/* "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", */
"TWN", "TZA", "UKR", "UGA", "UMI", "USA", "URY", "UZB",
/* "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", */
"VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF",
/* "WS", "YE", "YT", "ZA", "ZM", "ZW" */
"WSM", "YEM", "MYT", "ZAF", "ZMB", "ZWE",
};
String[] tempObsoleteCountries3 = {
/*"FX", "CS", "RO", "TP", "YU", "ZR", */
"FXX", "SCG", "ROM", "TMP", "YUG", "ZAR",
};
synchronized (ULocale.class) {
if (_countries == null) {
_countries = tempCountries;
_deprecatedCountries = tempDeprecatedCountries;
_replacementCountries = tempReplacementCountries;
_obsoleteCountries = tempObsoleteCountries;
_countries3 = tempCountries3;
_obsoleteCountries3 = tempObsoleteCountries3;
}
}
}
}
public static String getCurrentCountryID(String oldID){
initCountryTables();
int offset = findIndex(_deprecatedCountries, oldID);
if (offset >= 0) {
return _replacementCountries[offset];
}
return oldID;
}
public static String getCurrentLanguageID(String oldID){
initLanguageTables();
int offset = findIndex(_obsoleteLanguages, oldID);
if (offset >= 0) {
return _replacementLanguages[offset];
}
return oldID;
}
}

View file

@ -1,134 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
* Copyright (C) 1996-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*
******************************************************************************
*/
package com.ibm.icu.impl;
import java.util.Locale;
/**
* A class to hold utility functions missing from java.util.Locale.
*/
public class LocaleUtility {
/**
* A helper function to convert a string of the form
* aa_BB_CC to a locale object. Why isn't this in Locale?
*/
public static Locale getLocaleFromName(String name) {
String language = "";
String country = "";
String variant = "";
int i1 = name.indexOf('_');
if (i1 < 0) {
language = name;
} else {
language = name.substring(0, i1);
++i1;
int i2 = name.indexOf('_', i1);
if (i2 < 0) {
country = name.substring(i1);
} else {
country = name.substring(i1, i2);
variant = name.substring(i2+1);
}
}
return new Locale(language, country, variant);
}
/**
* Compare two locale strings of the form aa_BB_CC, and
* return true if parent is a 'strict' fallback of child, that is,
* if child =~ "^parent(_.+)*" (roughly).
*/
public static boolean isFallbackOf(String parent, String child) {
if (!child.startsWith(parent)) {
return false;
}
int i = parent.length();
return (i == child.length() ||
child.charAt(i) == '_');
}
/**
* Compare two locales, and return true if the parent is a
* 'strict' fallback of the child (parent string is a fallback
* of child string).
*/
public static boolean isFallbackOf(Locale parent, Locale child) {
return isFallbackOf(parent.toString(), child.toString());
}
/*
* Convenience method that calls canonicalLocaleString(String) with
* locale.toString();
*/
/*public static String canonicalLocaleString(Locale locale) {
return canonicalLocaleString(locale.toString());
}*/
/*
* You'd think that Locale canonicalizes, since it munges the
* renamed languages, but it doesn't quite. It forces the region
* to be upper case but doesn't do anything about the language or
* variant. Our canonical form is 'lower_UPPER_UPPER'.
*/
/*public static String canonicalLocaleString(String id) {
if (id != null) {
int x = id.indexOf("_");
if (x == -1) {
id = id.toLowerCase(Locale.ENGLISH);
} else {
StringBuffer buf = new StringBuffer();
buf.append(id.substring(0, x).toLowerCase(Locale.ENGLISH));
buf.append(id.substring(x).toUpperCase(Locale.ENGLISH));
int len = buf.length();
int n = len;
while (--n >= 0 && buf.charAt(n) == '_') {
}
if (++n != len) {
buf.delete(n, len);
}
id = buf.toString();
}
}
return id;
}*/
/**
* Fallback from the given locale name by removing the rightmost _-delimited
* element. If there is none, return the root locale ("", "", ""). If this
* is the root locale, return null. NOTE: The string "root" is not
* recognized; do not use it.
*
* @return a new Locale that is a fallback from the given locale, or null.
*/
public static Locale fallback(Locale loc) {
// Split the locale into parts and remove the rightmost part
String[] parts = new String[]
{ loc.getLanguage(), loc.getCountry(), loc.getVariant() };
int i;
for (i=2; i>=0; --i) {
if (parts[i].length() != 0) {
parts[i] = "";
break;
}
}
if (i<0) {
return null; // All parts were empty
}
return new Locale(parts[0], parts[1], parts[2]);
}
}

View file

@ -1,75 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
****************************************************************************
* Copyright (c) 2007-2011 International Business Machines Corporation and *
* others. All rights reserved. *
****************************************************************************
*/
package com.ibm.icu.impl;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class SimpleCache<K, V> implements ICUCache<K, V> {
private static final int DEFAULT_CAPACITY = 16;
private Reference<Map<K, V>> cacheRef = null;
private int type = ICUCache.SOFT;
private int capacity = DEFAULT_CAPACITY;
public SimpleCache() {
}
public SimpleCache(int cacheType) {
this(cacheType, DEFAULT_CAPACITY);
}
public SimpleCache(int cacheType, int initialCapacity) {
if (cacheType == ICUCache.WEAK) {
type = cacheType;
}
if (initialCapacity > 0) {
capacity = initialCapacity;
}
}
public V get(Object key) {
Reference<Map<K, V>> ref = cacheRef;
if (ref != null) {
Map<K, V> map = ref.get();
if (map != null) {
return map.get(key);
}
}
return null;
}
public void put(K key, V value) {
Reference<Map<K, V>> ref = cacheRef;
Map<K, V> map = null;
if (ref != null) {
map = ref.get();
}
if (map == null) {
map = Collections.synchronizedMap(new HashMap<K, V>(capacity));
if (type == ICUCache.WEAK) {
ref = new WeakReference<Map<K, V>>(map);
} else {
ref = new SoftReference<Map<K, V>>(map);
}
cacheRef = ref;
}
map.put(key, value);
}
public void clear() {
cacheRef = null;
}
}

View file

@ -1,185 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl.locale;
public final class AsciiUtil {
public static boolean caseIgnoreMatch(String s1, String s2) {
if (s1 == s2) {
return true;
}
int len = s1.length();
if (len != s2.length()) {
return false;
}
int i = 0;
while (i < len) {
char c1 = s1.charAt(i);
char c2 = s2.charAt(i);
if (c1 != c2 && toLower(c1) != toLower(c2)) {
break;
}
i++;
}
return (i == len);
}
public static int caseIgnoreCompare(String s1, String s2) {
if (s1 == s2) {
return 0;
}
return AsciiUtil.toLowerString(s1).compareTo(AsciiUtil.toLowerString(s2));
}
public static char toUpper(char c) {
if (c >= 'a' && c <= 'z') {
c -= 0x20;
}
return c;
}
public static char toLower(char c) {
if (c >= 'A' && c <= 'Z') {
c += 0x20;
}
return c;
}
public static String toLowerString(String s) {
int idx = 0;
for (; idx < s.length(); idx++) {
char c = s.charAt(idx);
if (c >= 'A' && c <= 'Z') {
break;
}
}
if (idx == s.length()) {
return s;
}
StringBuilder buf = new StringBuilder(s.substring(0, idx));
for (; idx < s.length(); idx++) {
buf.append(toLower(s.charAt(idx)));
}
return buf.toString();
}
public static String toUpperString(String s) {
int idx = 0;
for (; idx < s.length(); idx++) {
char c = s.charAt(idx);
if (c >= 'a' && c <= 'z') {
break;
}
}
if (idx == s.length()) {
return s;
}
StringBuilder buf = new StringBuilder(s.substring(0, idx));
for (; idx < s.length(); idx++) {
buf.append(toUpper(s.charAt(idx)));
}
return buf.toString();
}
public static String toTitleString(String s) {
if (s.length() == 0) {
return s;
}
int idx = 0;
char c = s.charAt(idx);
if (!(c >= 'a' && c <= 'z')) {
for (idx = 1; idx < s.length(); idx++) {
if (c >= 'A' && c <= 'Z') {
break;
}
}
}
if (idx == s.length()) {
return s;
}
StringBuilder buf = new StringBuilder(s.substring(0, idx));
if (idx == 0) {
buf.append(toUpper(s.charAt(idx)));
idx++;
}
for (; idx < s.length(); idx++) {
buf.append(toLower(s.charAt(idx)));
}
return buf.toString();
}
public static boolean isAlpha(char c) {
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
}
public static boolean isAlphaString(String s) {
boolean b = true;
for (int i = 0; i < s.length(); i++) {
if (!isAlpha(s.charAt(i))) {
b = false;
break;
}
}
return b;
}
public static boolean isNumeric(char c) {
return (c >= '0' && c <= '9');
}
public static boolean isNumericString(String s) {
boolean b = true;
for (int i = 0; i < s.length(); i++) {
if (!isNumeric(s.charAt(i))) {
b = false;
break;
}
}
return b;
}
public static boolean isAlphaNumeric(char c) {
return isAlpha(c) || isNumeric(c);
}
public static boolean isAlphaNumericString(String s) {
boolean b = true;
for (int i = 0; i < s.length(); i++) {
if (!isAlphaNumeric(s.charAt(i))) {
b = false;
break;
}
}
return b;
}
public static class CaseInsensitiveKey {
private String _key;
private int _hash;
public CaseInsensitiveKey(String key) {
_key = key;
_hash = AsciiUtil.toLowerString(key).hashCode();
}
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o instanceof CaseInsensitiveKey) {
return AsciiUtil.caseIgnoreMatch(_key, ((CaseInsensitiveKey)o)._key);
}
return false;
}
public int hashCode() {
return _hash;
}
}
}

View file

@ -1,259 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl.locale;
public final class BaseLocale {
private static final boolean JDKIMPL = false;
public static final String SEP = "_";
private static final Cache CACHE = new Cache();
public static final BaseLocale ROOT = BaseLocale.getInstance("", "", "", "");
private String _language = "";
private String _script = "";
private String _region = "";
private String _variant = "";
private transient volatile int _hash = 0;
private BaseLocale(String language, String script, String region, String variant) {
if (language != null) {
_language = AsciiUtil.toLowerString(language).intern();
}
if (script != null) {
_script = AsciiUtil.toTitleString(script).intern();
}
if (region != null) {
_region = AsciiUtil.toUpperString(region).intern();
}
if (variant != null) {
if (JDKIMPL) {
// preserve upper/lower cases
_variant = variant.intern();
} else {
_variant = AsciiUtil.toUpperString(variant).intern();
}
}
}
public static BaseLocale getInstance(String language, String script, String region, String variant) {
if (JDKIMPL) {
// JDK uses deprecated ISO639.1 language codes for he, yi and id
if (AsciiUtil.caseIgnoreMatch(language, "he")) {
language = "iw";
} else if (AsciiUtil.caseIgnoreMatch(language, "yi")) {
language = "ji";
} else if (AsciiUtil.caseIgnoreMatch(language, "id")) {
language = "in";
}
}
Key key = new Key(language, script, region, variant);
BaseLocale baseLocale = CACHE.get(key);
return baseLocale;
}
public String getLanguage() {
return _language;
}
public String getScript() {
return _script;
}
public String getRegion() {
return _region;
}
public String getVariant() {
return _variant;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof BaseLocale)) {
return false;
}
BaseLocale other = (BaseLocale)obj;
return hashCode() == other.hashCode()
&& _language.equals(other._language)
&& _script.equals(other._script)
&& _region.equals(other._region)
&& _variant.equals(other._variant);
}
public String toString() {
StringBuilder buf = new StringBuilder();
if (_language.length() > 0) {
buf.append("language=");
buf.append(_language);
}
if (_script.length() > 0) {
if (buf.length() > 0) {
buf.append(", ");
}
buf.append("script=");
buf.append(_script);
}
if (_region.length() > 0) {
if (buf.length() > 0) {
buf.append(", ");
}
buf.append("region=");
buf.append(_region);
}
if (_variant.length() > 0) {
if (buf.length() > 0) {
buf.append(", ");
}
buf.append("variant=");
buf.append(_variant);
}
return buf.toString();
}
public int hashCode() {
int h = _hash;
if (h == 0) {
// Generating a hash value from language, script, region and variant
for (int i = 0; i < _language.length(); i++) {
h = 31*h + _language.charAt(i);
}
for (int i = 0; i < _script.length(); i++) {
h = 31*h + _script.charAt(i);
}
for (int i = 0; i < _region.length(); i++) {
h = 31*h + _region.charAt(i);
}
for (int i = 0; i < _variant.length(); i++) {
h = 31*h + _variant.charAt(i);
}
_hash = h;
}
return h;
}
private static class Key implements Comparable<Key> {
private String _lang = "";
private String _scrt = "";
private String _regn = "";
private String _vart = "";
private volatile int _hash; // Default to 0
public Key(String language, String script, String region, String variant) {
if (language != null) {
_lang = language;
}
if (script != null) {
_scrt = script;
}
if (region != null) {
_regn = region;
}
if (variant != null) {
_vart = variant;
}
}
public boolean equals(Object obj) {
if (JDKIMPL) {
return (this == obj) ||
(obj instanceof Key)
&& AsciiUtil.caseIgnoreMatch(((Key)obj)._lang, this._lang)
&& AsciiUtil.caseIgnoreMatch(((Key)obj)._scrt, this._scrt)
&& AsciiUtil.caseIgnoreMatch(((Key)obj)._regn, this._regn)
&& ((Key)obj)._vart.equals(_vart); // variant is case sensitive in JDK!
}
return (this == obj) ||
(obj instanceof Key)
&& AsciiUtil.caseIgnoreMatch(((Key)obj)._lang, this._lang)
&& AsciiUtil.caseIgnoreMatch(((Key)obj)._scrt, this._scrt)
&& AsciiUtil.caseIgnoreMatch(((Key)obj)._regn, this._regn)
&& AsciiUtil.caseIgnoreMatch(((Key)obj)._vart, this._vart);
}
public int compareTo(Key other) {
int res = AsciiUtil.caseIgnoreCompare(this._lang, other._lang);
if (res == 0) {
res = AsciiUtil.caseIgnoreCompare(this._scrt, other._scrt);
if (res == 0) {
res = AsciiUtil.caseIgnoreCompare(this._regn, other._regn);
if (res == 0) {
if (JDKIMPL) {
res = this._vart.compareTo(other._vart);
} else {
res = AsciiUtil.caseIgnoreCompare(this._vart, other._vart);
}
}
}
}
return res;
}
public int hashCode() {
int h = _hash;
if (h == 0) {
// Generating a hash value from language, script, region and variant
for (int i = 0; i < _lang.length(); i++) {
h = 31*h + AsciiUtil.toLower(_lang.charAt(i));
}
for (int i = 0; i < _scrt.length(); i++) {
h = 31*h + AsciiUtil.toLower(_scrt.charAt(i));
}
for (int i = 0; i < _regn.length(); i++) {
h = 31*h + AsciiUtil.toLower(_regn.charAt(i));
}
for (int i = 0; i < _vart.length(); i++) {
if (JDKIMPL) {
h = 31*h + _vart.charAt(i);
} else {
h = 31*h + AsciiUtil.toLower(_vart.charAt(i));
}
}
_hash = h;
}
return h;
}
public static Key normalize(Key key) {
String lang = AsciiUtil.toLowerString(key._lang).intern();
String scrt = AsciiUtil.toTitleString(key._scrt).intern();
String regn = AsciiUtil.toUpperString(key._regn).intern();
String vart;
if (JDKIMPL) {
// preserve upper/lower cases
vart = key._vart.intern();
} else {
vart = AsciiUtil.toUpperString(key._vart).intern();
}
return new Key(lang, scrt, regn, vart);
}
}
private static class Cache extends LocaleObjectCache<Key, BaseLocale> {
public Cache() {
}
protected Key normalizeKey(Key key) {
return Key.normalize(key);
}
protected BaseLocale createObject(Key key) {
return new BaseLocale(key._lang, key._scrt, key._regn, key._vart);
}
}
}

View file

@ -1,40 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl.locale;
public class Extension {
private char _key;
protected String _value;
protected Extension(char key) {
_key = key;
}
Extension(char key, String value) {
_key = key;
_value = value;
}
public char getKey() {
return _key;
}
public String getValue() {
return _value;
}
public String getID() {
return _key + LanguageTag.SEP + _value;
}
public String toString() {
return getID();
}
}

View file

@ -1,686 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl.locale;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public final class InternalLocaleBuilder {
private static final boolean JDKIMPL = false;
private String _language = "";
private String _script = "";
private String _region = "";
private String _variant = "";
private static final CaseInsensitiveChar PRIVUSE_KEY = new CaseInsensitiveChar(LanguageTag.PRIVATEUSE.charAt(0));
private HashMap<CaseInsensitiveChar, String> _extensions;
private HashSet<CaseInsensitiveString> _uattributes;
private HashMap<CaseInsensitiveString, String> _ukeywords;
public InternalLocaleBuilder() {
}
public InternalLocaleBuilder setLanguage(String language) throws LocaleSyntaxException {
if (language == null || language.length() == 0) {
_language = "";
} else {
if (!LanguageTag.isLanguage(language)) {
throw new LocaleSyntaxException("Ill-formed language: " + language, 0);
}
_language = language;
}
return this;
}
public InternalLocaleBuilder setScript(String script) throws LocaleSyntaxException {
if (script == null || script.length() == 0) {
_script = "";
} else {
if (!LanguageTag.isScript(script)) {
throw new LocaleSyntaxException("Ill-formed script: " + script, 0);
}
_script = script;
}
return this;
}
public InternalLocaleBuilder setRegion(String region) throws LocaleSyntaxException {
if (region == null || region.length() == 0) {
_region = "";
} else {
if (!LanguageTag.isRegion(region)) {
throw new LocaleSyntaxException("Ill-formed region: " + region, 0);
}
_region = region;
}
return this;
}
public InternalLocaleBuilder setVariant(String variant) throws LocaleSyntaxException {
if (variant == null || variant.length() == 0) {
_variant = "";
} else {
// normalize separators to "_"
String var = variant.replaceAll(LanguageTag.SEP, BaseLocale.SEP);
int errIdx = checkVariants(var, BaseLocale.SEP);
if (errIdx != -1) {
throw new LocaleSyntaxException("Ill-formed variant: " + variant, errIdx);
}
_variant = var;
}
return this;
}
public InternalLocaleBuilder addUnicodeLocaleAttribute(String attribute) throws LocaleSyntaxException {
if (attribute == null || !UnicodeLocaleExtension.isAttribute(attribute)) {
throw new LocaleSyntaxException("Ill-formed Unicode locale attribute: " + attribute);
}
// Use case insensitive string to prevent duplication
if (_uattributes == null) {
_uattributes = new HashSet<CaseInsensitiveString>(4);
}
_uattributes.add(new CaseInsensitiveString(attribute));
return this;
}
public InternalLocaleBuilder removeUnicodeLocaleAttribute(String attribute) throws LocaleSyntaxException {
if (attribute == null || !UnicodeLocaleExtension.isAttribute(attribute)) {
throw new LocaleSyntaxException("Ill-formed Unicode locale attribute: " + attribute);
}
if (_uattributes != null) {
_uattributes.remove(new CaseInsensitiveString(attribute));
}
return this;
}
public InternalLocaleBuilder setUnicodeLocaleKeyword(String key, String type) throws LocaleSyntaxException {
if (!UnicodeLocaleExtension.isKey(key)) {
throw new LocaleSyntaxException("Ill-formed Unicode locale keyword key: " + key);
}
CaseInsensitiveString cikey = new CaseInsensitiveString(key);
if (type == null) {
if (_ukeywords != null) {
// null type is used for remove the key
_ukeywords.remove(cikey);
}
} else {
if (type.length() != 0) {
// normalize separator to "-"
String tp = type.replaceAll(BaseLocale.SEP, LanguageTag.SEP);
// validate
StringTokenIterator itr = new StringTokenIterator(tp, LanguageTag.SEP);
while (!itr.isDone()) {
String s = itr.current();
if (!UnicodeLocaleExtension.isTypeSubtag(s)) {
throw new LocaleSyntaxException("Ill-formed Unicode locale keyword type: " + type, itr.currentStart());
}
itr.next();
}
}
if (_ukeywords == null) {
_ukeywords = new HashMap<CaseInsensitiveString, String>(4);
}
_ukeywords.put(cikey, type);
}
return this;
}
public InternalLocaleBuilder setExtension(char singleton, String value) throws LocaleSyntaxException {
// validate key
boolean isBcpPrivateuse = LanguageTag.isPrivateusePrefixChar(singleton);
if (!isBcpPrivateuse && !LanguageTag.isExtensionSingletonChar(singleton)) {
throw new LocaleSyntaxException("Ill-formed extension key: " + singleton);
}
boolean remove = (value == null || value.length() == 0);
CaseInsensitiveChar key = new CaseInsensitiveChar(singleton);
if (remove) {
if (UnicodeLocaleExtension.isSingletonChar(key.value())) {
// clear entire Unicode locale extension
if (_uattributes != null) {
_uattributes.clear();
}
if (_ukeywords != null) {
_ukeywords.clear();
}
} else {
if (_extensions != null && _extensions.containsKey(key)) {
_extensions.remove(key);
}
}
} else {
// validate value
String val = value.replaceAll(BaseLocale.SEP, LanguageTag.SEP);
StringTokenIterator itr = new StringTokenIterator(val, LanguageTag.SEP);
while (!itr.isDone()) {
String s = itr.current();
boolean validSubtag;
if (isBcpPrivateuse) {
validSubtag = LanguageTag.isPrivateuseSubtag(s);
} else {
validSubtag = LanguageTag.isExtensionSubtag(s);
}
if (!validSubtag) {
throw new LocaleSyntaxException("Ill-formed extension value: " + s, itr.currentStart());
}
itr.next();
}
if (UnicodeLocaleExtension.isSingletonChar(key.value())) {
setUnicodeLocaleExtension(val);
} else {
if (_extensions == null) {
_extensions = new HashMap<CaseInsensitiveChar, String>(4);
}
_extensions.put(key, val);
}
}
return this;
}
/*
* Set extension/private subtags in a single string representation
*/
public InternalLocaleBuilder setExtensions(String subtags) throws LocaleSyntaxException {
if (subtags == null || subtags.length() == 0) {
clearExtensions();
return this;
}
subtags = subtags.replaceAll(BaseLocale.SEP, LanguageTag.SEP);
StringTokenIterator itr = new StringTokenIterator(subtags, LanguageTag.SEP);
List<String> extensions = null;
String privateuse = null;
int parsed = 0;
int start;
// Make a list of extension subtags
while (!itr.isDone()) {
String s = itr.current();
if (LanguageTag.isExtensionSingleton(s)) {
start = itr.currentStart();
String singleton = s;
StringBuilder sb = new StringBuilder(singleton);
itr.next();
while (!itr.isDone()) {
s = itr.current();
if (LanguageTag.isExtensionSubtag(s)) {
sb.append(LanguageTag.SEP).append(s);
parsed = itr.currentEnd();
} else {
break;
}
itr.next();
}
if (parsed < start) {
throw new LocaleSyntaxException("Incomplete extension '" + singleton + "'", start);
}
if (extensions == null) {
extensions = new ArrayList<String>(4);
}
extensions.add(sb.toString());
} else {
break;
}
}
if (!itr.isDone()) {
String s = itr.current();
if (LanguageTag.isPrivateusePrefix(s)) {
start = itr.currentStart();
StringBuilder sb = new StringBuilder(s);
itr.next();
while (!itr.isDone()) {
s = itr.current();
if (!LanguageTag.isPrivateuseSubtag(s)) {
break;
}
sb.append(LanguageTag.SEP).append(s);
parsed = itr.currentEnd();
itr.next();
}
if (parsed <= start) {
throw new LocaleSyntaxException("Incomplete privateuse:" + subtags.substring(start), start);
} else {
privateuse = sb.toString();
}
}
}
if (!itr.isDone()) {
throw new LocaleSyntaxException("Ill-formed extension subtags:" + subtags.substring(itr.currentStart()), itr.currentStart());
}
return setExtensions(extensions, privateuse);
}
/*
* Set a list of BCP47 extensions and private use subtags
* BCP47 extensions are already validated and well-formed, but may contain duplicates
*/
private InternalLocaleBuilder setExtensions(List<String> bcpExtensions, String privateuse) {
clearExtensions();
if (bcpExtensions != null && bcpExtensions.size() > 0) {
HashSet<CaseInsensitiveChar> processedExtensions = new HashSet<CaseInsensitiveChar>(bcpExtensions.size());
for (String bcpExt : bcpExtensions) {
CaseInsensitiveChar key = new CaseInsensitiveChar(bcpExt.charAt(0));
// ignore duplicates
if (!processedExtensions.contains(key)) {
// each extension string contains singleton, e.g. "a-abc-def"
if (UnicodeLocaleExtension.isSingletonChar(key.value())) {
setUnicodeLocaleExtension(bcpExt.substring(2));
} else {
if (_extensions == null) {
_extensions = new HashMap<CaseInsensitiveChar, String>(4);
}
_extensions.put(key, bcpExt.substring(2));
}
}
}
}
if (privateuse != null && privateuse.length() > 0) {
// privateuse string contains prefix, e.g. "x-abc-def"
if (_extensions == null) {
_extensions = new HashMap<CaseInsensitiveChar, String>(1);
}
_extensions.put(new CaseInsensitiveChar(privateuse.charAt(0)), privateuse.substring(2));
}
return this;
}
/*
* Reset Builder's internal state with the given language tag
*/
public InternalLocaleBuilder setLanguageTag(LanguageTag langtag) {
clear();
if (langtag.getExtlangs().size() > 0) {
_language = langtag.getExtlangs().get(0);
} else {
String language = langtag.getLanguage();
if (!language.equals(LanguageTag.UNDETERMINED)) {
_language = language;
}
}
_script = langtag.getScript();
_region = langtag.getRegion();
List<String> bcpVariants = langtag.getVariants();
if (bcpVariants.size() > 0) {
StringBuilder var = new StringBuilder(bcpVariants.get(0));
for (int i = 1; i < bcpVariants.size(); i++) {
var.append(BaseLocale.SEP).append(bcpVariants.get(i));
}
_variant = var.toString();
}
setExtensions(langtag.getExtensions(), langtag.getPrivateuse());
return this;
}
public InternalLocaleBuilder setLocale(BaseLocale base, LocaleExtensions extensions) throws LocaleSyntaxException {
String language = base.getLanguage();
String script = base.getScript();
String region = base.getRegion();
String variant = base.getVariant();
if (JDKIMPL) {
// Special backward compatibility support
// Exception 1 - ja_JP_JP
if (language.equals("ja") && region.equals("JP") && variant.equals("JP")) {
// When locale ja_JP_JP is created, ca-japanese is always there.
// The builder ignores the variant "JP"
assert("japanese".equals(extensions.getUnicodeLocaleType("ca")));
variant = "";
}
// Exception 2 - th_TH_TH
else if (language.equals("th") && region.equals("TH") && variant.equals("TH")) {
// When locale th_TH_TH is created, nu-thai is always there.
// The builder ignores the variant "TH"
assert("thai".equals(extensions.getUnicodeLocaleType("nu")));
variant = "";
}
// Exception 3 - no_NO_NY
else if (language.equals("no") && region.equals("NO") && variant.equals("NY")) {
// no_NO_NY is a valid locale and used by Java 6 or older versions.
// The build ignores the variant "NY" and change the language to "nn".
language = "nn";
variant = "";
}
}
// Validate base locale fields before updating internal state.
// LocaleExtensions always store validated/canonicalized values,
// so no checks are necessary.
if (language.length() > 0 && !LanguageTag.isLanguage(language)) {
throw new LocaleSyntaxException("Ill-formed language: " + language);
}
if (script.length() > 0 && !LanguageTag.isScript(script)) {
throw new LocaleSyntaxException("Ill-formed script: " + script);
}
if (region.length() > 0 && !LanguageTag.isRegion(region)) {
throw new LocaleSyntaxException("Ill-formed region: " + region);
}
if (variant.length() > 0) {
int errIdx = checkVariants(variant, BaseLocale.SEP);
if (errIdx != -1) {
throw new LocaleSyntaxException("Ill-formed variant: " + variant, errIdx);
}
}
// The input locale is validated at this point.
// Now, updating builder's internal fields.
_language = language;
_script = script;
_region = region;
_variant = variant;
clearExtensions();
Set<Character> extKeys = (extensions == null) ? null : extensions.getKeys();
if (extKeys != null) {
// map extensions back to builder's internal format
for (Character key : extKeys) {
Extension e = extensions.getExtension(key);
if (e instanceof UnicodeLocaleExtension) {
UnicodeLocaleExtension ue = (UnicodeLocaleExtension)e;
for (String uatr : ue.getUnicodeLocaleAttributes()) {
if (_uattributes == null) {
_uattributes = new HashSet<CaseInsensitiveString>(4);
}
_uattributes.add(new CaseInsensitiveString(uatr));
}
for (String ukey : ue.getUnicodeLocaleKeys()) {
if (_ukeywords == null) {
_ukeywords = new HashMap<CaseInsensitiveString, String>(4);
}
_ukeywords.put(new CaseInsensitiveString(ukey), ue.getUnicodeLocaleType(ukey));
}
} else {
if (_extensions == null) {
_extensions = new HashMap<CaseInsensitiveChar, String>(4);
}
_extensions.put(new CaseInsensitiveChar(key.charValue()), e.getValue());
}
}
}
return this;
}
public InternalLocaleBuilder clear() {
_language = "";
_script = "";
_region = "";
_variant = "";
clearExtensions();
return this;
}
public InternalLocaleBuilder clearExtensions() {
if (_extensions != null) {
_extensions.clear();
}
if (_uattributes != null) {
_uattributes.clear();
}
if (_ukeywords != null) {
_ukeywords.clear();
}
return this;
}
public BaseLocale getBaseLocale() {
String language = _language;
String script = _script;
String region = _region;
String variant = _variant;
// Special private use subtag sequence identified by "lvariant" will be
// interpreted as Java variant.
if (_extensions != null) {
String privuse = _extensions.get(PRIVUSE_KEY);
if (privuse != null) {
StringTokenIterator itr = new StringTokenIterator(privuse, LanguageTag.SEP);
boolean sawPrefix = false;
int privVarStart = -1;
while (!itr.isDone()) {
if (sawPrefix) {
privVarStart = itr.currentStart();
break;
}
if (AsciiUtil.caseIgnoreMatch(itr.current(), LanguageTag.PRIVUSE_VARIANT_PREFIX)) {
sawPrefix = true;
}
itr.next();
}
if (privVarStart != -1) {
StringBuilder sb = new StringBuilder(variant);
if (sb.length() != 0) {
sb.append(BaseLocale.SEP);
}
sb.append(privuse.substring(privVarStart).replaceAll(LanguageTag.SEP, BaseLocale.SEP));
variant = sb.toString();
}
}
}
return BaseLocale.getInstance(language, script, region, variant);
}
public LocaleExtensions getLocaleExtensions() {
if ((_extensions == null || _extensions.size() == 0)
&& (_uattributes == null || _uattributes.size() == 0)
&& (_ukeywords == null || _ukeywords.size() == 0)) {
return LocaleExtensions.EMPTY_EXTENSIONS;
}
return new LocaleExtensions(_extensions, _uattributes, _ukeywords);
}
/*
* Remove special private use subtag sequence identified by "lvariant"
* and return the rest. Only used by LocaleExtensions
*/
static String removePrivateuseVariant(String privuseVal) {
StringTokenIterator itr = new StringTokenIterator(privuseVal, LanguageTag.SEP);
// Note: privateuse value "abc-lvariant" is unchanged
// because no subtags after "lvariant".
int prefixStart = -1;
boolean sawPrivuseVar = false;
while (!itr.isDone()) {
if (prefixStart != -1) {
// Note: privateuse value "abc-lvariant" is unchanged
// because no subtags after "lvariant".
sawPrivuseVar = true;
break;
}
if (AsciiUtil.caseIgnoreMatch(itr.current(), LanguageTag.PRIVUSE_VARIANT_PREFIX)) {
prefixStart = itr.currentStart();
}
itr.next();
}
if (!sawPrivuseVar) {
return privuseVal;
}
assert(prefixStart == 0 || prefixStart > 1);
return (prefixStart == 0) ? null : privuseVal.substring(0, prefixStart -1);
}
/*
* Check if the given variant subtags separated by the given
* separator(s) are valid
*/
private int checkVariants(String variants, String sep) {
StringTokenIterator itr = new StringTokenIterator(variants, sep);
while (!itr.isDone()) {
String s = itr.current();
if (!LanguageTag.isVariant(s)) {
return itr.currentStart();
}
itr.next();
}
return -1;
}
/*
* Private methods parsing Unicode Locale Extension subtags.
* Duplicated attributes/keywords will be ignored.
* The input must be a valid extension subtags (excluding singleton).
*/
private void setUnicodeLocaleExtension(String subtags) {
// wipe out existing attributes/keywords
if (_uattributes != null) {
_uattributes.clear();
}
if (_ukeywords != null) {
_ukeywords.clear();
}
StringTokenIterator itr = new StringTokenIterator(subtags, LanguageTag.SEP);
// parse attributes
while (!itr.isDone()) {
if (!UnicodeLocaleExtension.isAttribute(itr.current())) {
break;
}
if (_uattributes == null) {
_uattributes = new HashSet<CaseInsensitiveString>(4);
}
_uattributes.add(new CaseInsensitiveString(itr.current()));
itr.next();
}
// parse keywords
CaseInsensitiveString key = null;
String type;
int typeStart = -1;
int typeEnd = -1;
while (!itr.isDone()) {
if (key != null) {
if (UnicodeLocaleExtension.isKey(itr.current())) {
// next keyword - emit previous one
assert(typeStart == -1 || typeEnd != -1);
type = (typeStart == -1) ? "" : subtags.substring(typeStart, typeEnd);
if (_ukeywords == null) {
_ukeywords = new HashMap<CaseInsensitiveString, String>(4);
}
_ukeywords.put(key, type);
// reset keyword info
CaseInsensitiveString tmpKey = new CaseInsensitiveString(itr.current());
key = _ukeywords.containsKey(tmpKey) ? null : tmpKey;
typeStart = typeEnd = -1;
} else {
if (typeStart == -1) {
typeStart = itr.currentStart();
}
typeEnd = itr.currentEnd();
}
} else if (UnicodeLocaleExtension.isKey(itr.current())) {
// 1. first keyword or
// 2. next keyword, but previous one was duplicate
key = new CaseInsensitiveString(itr.current());
if (_ukeywords != null && _ukeywords.containsKey(key)) {
// duplicate
key = null;
}
}
if (!itr.hasNext()) {
if (key != null) {
// last keyword
assert(typeStart == -1 || typeEnd != -1);
type = (typeStart == -1) ? "" : subtags.substring(typeStart, typeEnd);
if (_ukeywords == null) {
_ukeywords = new HashMap<CaseInsensitiveString, String>(4);
}
_ukeywords.put(key, type);
}
break;
}
itr.next();
}
}
static class CaseInsensitiveString {
private String _s;
CaseInsensitiveString(String s) {
_s = s;
}
public String value() {
return _s;
}
public int hashCode() {
return AsciiUtil.toLowerString(_s).hashCode();
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof CaseInsensitiveString)) {
return false;
}
return AsciiUtil.caseIgnoreMatch(_s, ((CaseInsensitiveString)obj).value());
}
}
static class CaseInsensitiveChar {
private char _c;
CaseInsensitiveChar(char c) {
_c = c;
}
public char value() {
return _c;
}
public int hashCode() {
return AsciiUtil.toLower(_c);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof CaseInsensitiveChar)) {
return false;
}
return _c == AsciiUtil.toLower(((CaseInsensitiveChar)obj).value());
}
}
}

View file

@ -1,681 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2010-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl.locale;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class LanguageTag {
private static final boolean JDKIMPL = false;
//
// static fields
//
public static final String SEP = "-";
public static final String PRIVATEUSE = "x";
public static String UNDETERMINED = "und";
public static final String PRIVUSE_VARIANT_PREFIX = "lvariant";
//
// Language subtag fields
//
private String _language = ""; // language subtag
private String _script = ""; // script subtag
private String _region = ""; // region subtag
private String _privateuse = ""; // privateuse
private List<String> _extlangs = Collections.emptyList(); // extlang subtags
private List<String> _variants = Collections.emptyList(); // variant subtags
private List<String> _extensions = Collections.emptyList(); // extensions
// The Map contains legacy language tags (marked as Type: grandfathered in BCP 47)
// and their preferred mappings from BCP 47.
private static final Map<AsciiUtil.CaseInsensitiveKey, String[]> LEGACY =
new HashMap<AsciiUtil.CaseInsensitiveKey, String[]>();
static {
// legacy = irregular ; non-redundant tags registered
// / regular ; during the RFC 3066 era
//
// irregular = "en-GB-oed" ; irregular tags do not match
// / "i-ami" ; the 'langtag' production and
// / "i-bnn" ; would not otherwise be
// / "i-default" ; considered 'well-formed'
// / "i-enochian" ; These tags are all valid,
// / "i-hak" ; but most are deprecated
// / "i-klingon" ; in favor of more modern
// / "i-lux" ; subtags or subtag
// / "i-mingo" ; combination
// / "i-navajo"
// / "i-pwn"
// / "i-tao"
// / "i-tay"
// / "i-tsu"
// / "sgn-BE-FR"
// / "sgn-BE-NL"
// / "sgn-CH-DE"
//
// regular = "art-lojban" ; these tags match the 'langtag'
// / "cel-gaulish" ; production, but their subtags
// / "no-bok" ; are not extended language
// / "no-nyn" ; or variant subtags: their meaning
// / "zh-guoyu" ; is defined by their registration
// / "zh-hakka" ; and all of these are deprecated
// / "zh-min" ; in favor of a more modern
// / "zh-min-nan" ; subtag or sequence of subtags
// / "zh-xiang"
final String[][] entries = {
//{"tag", "preferred"},
{"art-lojban", "jbo"},
{"cel-gaulish", "xtg-x-cel-gaulish"}, // fallback
{"en-GB-oed", "en-GB-x-oed"}, // fallback
{"i-ami", "ami"},
{"i-bnn", "bnn"},
{"i-default", "en-x-i-default"}, // fallback
{"i-enochian", "und-x-i-enochian"}, // fallback
{"i-hak", "hak"},
{"i-klingon", "tlh"},
{"i-lux", "lb"},
{"i-mingo", "see-x-i-mingo"}, // fallback
{"i-navajo", "nv"},
{"i-pwn", "pwn"},
{"i-tao", "tao"},
{"i-tay", "tay"},
{"i-tsu", "tsu"},
{"no-bok", "nb"},
{"no-nyn", "nn"},
{"sgn-BE-FR", "sfb"},
{"sgn-BE-NL", "vgt"},
{"sgn-CH-DE", "sgg"},
{"zh-guoyu", "cmn"},
{"zh-hakka", "hak"},
{"zh-min", "nan-x-zh-min"}, // fallback
{"zh-min-nan", "nan"},
{"zh-xiang", "hsn"},
};
for (String[] e : entries) {
LEGACY.put(new AsciiUtil.CaseInsensitiveKey(e[0]), e);
}
}
private LanguageTag() {
}
/**
* See BCP 47 Tags for Identifying Languages:
* https://www.rfc-editor.org/info/bcp47 -->
* https://www.rfc-editor.org/rfc/rfc5646.html#section-2.1
*/
public static LanguageTag parse(String languageTag, ParseStatus sts) {
if (sts == null) {
sts = new ParseStatus();
} else {
sts.reset();
}
StringTokenIterator itr;
String[] gfmap = LEGACY.get(new AsciiUtil.CaseInsensitiveKey(languageTag));
if (gfmap != null) {
// use preferred mapping
itr = new StringTokenIterator(gfmap[1], SEP);
} else {
itr = new StringTokenIterator(languageTag, SEP);
}
LanguageTag tag = new LanguageTag();
// langtag must start with either language or privateuse
if (tag.parseLanguage(itr, sts)) {
tag.parseExtlangs(itr, sts);
tag.parseScript(itr, sts);
tag.parseRegion(itr, sts);
tag.parseVariants(itr, sts);
tag.parseExtensions(itr, sts);
}
tag.parsePrivateuse(itr, sts);
if (!itr.isDone() && !sts.isError()) {
String s = itr.current();
sts._errorIndex = itr.currentStart();
if (s.length() == 0) {
sts._errorMsg = "Empty subtag";
} else {
sts._errorMsg = "Invalid subtag: " + s;
}
}
return tag;
}
//
// Language subtag parsers
//
private boolean parseLanguage(StringTokenIterator itr, ParseStatus sts) {
if (itr.isDone() || sts.isError()) {
return false;
}
boolean found = false;
String s = itr.current();
if (isLanguage(s)) {
found = true;
_language = s;
sts._parseLength = itr.currentEnd();
itr.next();
}
return found;
}
private boolean parseExtlangs(StringTokenIterator itr, ParseStatus sts) {
if (itr.isDone() || sts.isError()) {
return false;
}
boolean found = false;
while (!itr.isDone()) {
String s = itr.current();
if (!isExtlang(s)) {
break;
}
found = true;
if (_extlangs.isEmpty()) {
_extlangs = new ArrayList<String>(3);
}
_extlangs.add(s);
sts._parseLength = itr.currentEnd();
itr.next();
if (_extlangs.size() == 3) {
// Maximum 3 extlangs
break;
}
}
return found;
}
private boolean parseScript(StringTokenIterator itr, ParseStatus sts) {
if (itr.isDone() || sts.isError()) {
return false;
}
boolean found = false;
String s = itr.current();
if (isScript(s)) {
found = true;
_script = s;
sts._parseLength = itr.currentEnd();
itr.next();
}
return found;
}
private boolean parseRegion(StringTokenIterator itr, ParseStatus sts) {
if (itr.isDone() || sts.isError()) {
return false;
}
boolean found = false;
String s = itr.current();
if (isRegion(s)) {
found = true;
_region = s;
sts._parseLength = itr.currentEnd();
itr.next();
}
return found;
}
private boolean parseVariants(StringTokenIterator itr, ParseStatus sts) {
if (itr.isDone() || sts.isError()) {
return false;
}
boolean found = false;
while (!itr.isDone()) {
String s = itr.current();
if (!isVariant(s)) {
break;
}
found = true;
if (_variants.isEmpty()) {
_variants = new ArrayList<String>(3);
}
_variants.add(s);
sts._parseLength = itr.currentEnd();
itr.next();
}
return found;
}
private boolean parseExtensions(StringTokenIterator itr, ParseStatus sts) {
if (itr.isDone() || sts.isError()) {
return false;
}
boolean found = false;
while (!itr.isDone()) {
String s = itr.current();
if (isExtensionSingleton(s)) {
int start = itr.currentStart();
String singleton = s;
StringBuilder sb = new StringBuilder(singleton);
itr.next();
while (!itr.isDone()) {
s = itr.current();
if (isExtensionSubtag(s)) {
sb.append(SEP).append(s);
sts._parseLength = itr.currentEnd();
} else {
break;
}
itr.next();
}
if (sts._parseLength <= start) {
sts._errorIndex = start;
sts._errorMsg = "Incomplete extension '" + singleton + "'";
break;
}
if (_extensions.size() == 0) {
_extensions = new ArrayList<String>(4);
}
_extensions.add(sb.toString());
found = true;
} else {
break;
}
}
return found;
}
private boolean parsePrivateuse(StringTokenIterator itr, ParseStatus sts) {
if (itr.isDone() || sts.isError()) {
return false;
}
boolean found = false;
String s = itr.current();
if (isPrivateusePrefix(s)) {
int start = itr.currentStart();
StringBuilder sb = new StringBuilder(s);
itr.next();
while (!itr.isDone()) {
s = itr.current();
if (!isPrivateuseSubtag(s)) {
break;
}
sb.append(SEP).append(s);
sts._parseLength = itr.currentEnd();
itr.next();
}
if (sts._parseLength <= start) {
// need at least 1 private subtag
sts._errorIndex = start;
sts._errorMsg = "Incomplete privateuse";
} else {
_privateuse = sb.toString();
found = true;
}
}
return found;
}
public static LanguageTag parseLocale(BaseLocale baseLocale, LocaleExtensions localeExtensions) {
LanguageTag tag = new LanguageTag();
String language = baseLocale.getLanguage();
String script = baseLocale.getScript();
String region = baseLocale.getRegion();
String variant = baseLocale.getVariant();
boolean hasSubtag = false;
String privuseVar = null; // store ill-formed variant subtags
if (language.length() > 0 && isLanguage(language)) {
// Convert a deprecated language code used by Java to
// a new code
if (language.equals("iw")) {
language = "he";
} else if (language.equals("ji")) {
language = "yi";
} else if (language.equals("in")) {
language = "id";
}
tag._language = language;
}
if (script.length() > 0 && isScript(script)) {
tag._script = canonicalizeScript(script);
hasSubtag = true;
}
if (region.length() > 0 && isRegion(region)) {
tag._region = canonicalizeRegion(region);
hasSubtag = true;
}
if (JDKIMPL) {
// Special handling for no_NO_NY - use nn_NO for language tag
if (tag._language.equals("no") && tag._region.equals("NO") && variant.equals("NY")) {
tag._language = "nn";
variant = "";
}
}
if (variant.length() > 0) {
List<String> variants = null;
StringTokenIterator varitr = new StringTokenIterator(variant, BaseLocale.SEP);
while (!varitr.isDone()) {
String var = varitr.current();
if (!isVariant(var)) {
break;
}
if (variants == null) {
variants = new ArrayList<String>();
}
if (JDKIMPL) {
variants.add(var); // Do not canonicalize!
} else {
variants.add(canonicalizeVariant(var));
}
varitr.next();
}
if (variants != null) {
tag._variants = variants;
hasSubtag = true;
}
if (!varitr.isDone()) {
// ill-formed variant subtags
StringBuilder buf = new StringBuilder();
while (!varitr.isDone()) {
String prvv = varitr.current();
if (!isPrivateuseSubtag(prvv)) {
// cannot use private use subtag - truncated
break;
}
if (buf.length() > 0) {
buf.append(SEP);
}
if (!JDKIMPL) {
prvv = AsciiUtil.toLowerString(prvv);
}
buf.append(prvv);
varitr.next();
}
if (buf.length() > 0) {
privuseVar = buf.toString();
}
}
}
List<String> extensions = null;
String privateuse = null;
Set<Character> locextKeys = localeExtensions.getKeys();
for (Character locextKey : locextKeys) {
Extension ext = localeExtensions.getExtension(locextKey);
if (isPrivateusePrefixChar(locextKey.charValue())) {
privateuse = ext.getValue();
} else {
if (extensions == null) {
extensions = new ArrayList<String>();
}
extensions.add(locextKey.toString() + SEP + ext.getValue());
}
}
if (extensions != null) {
tag._extensions = extensions;
hasSubtag = true;
}
// append ill-formed variant subtags to private use
if (privuseVar != null) {
if (privateuse == null) {
privateuse = PRIVUSE_VARIANT_PREFIX + SEP + privuseVar;
} else {
privateuse = privateuse + SEP + PRIVUSE_VARIANT_PREFIX + SEP + privuseVar.replace(BaseLocale.SEP, SEP);
}
}
if (privateuse != null) {
tag._privateuse = privateuse;
}
if (tag._language.length() == 0 && (hasSubtag || privateuse == null)) {
// use lang "und" when 1) no language is available AND
// 2) any of other subtags other than private use are available or
// no private use tag is available
tag._language = UNDETERMINED;
}
return tag;
}
//
// Getter methods for language subtag fields
//
public String getLanguage() {
return _language;
}
public List<String> getExtlangs() {
return Collections.unmodifiableList(_extlangs);
}
public String getScript() {
return _script;
}
public String getRegion() {
return _region;
}
public List<String> getVariants() {
return Collections.unmodifiableList(_variants);
}
public List<String> getExtensions() {
return Collections.unmodifiableList(_extensions);
}
public String getPrivateuse() {
return _privateuse;
}
//
// Language subtag syntax checking methods
//
public static boolean isLanguage(String s) {
// language = 2*3ALPHA ; shortest ISO 639 code
// ["-" extlang] ; sometimes followed by
// ; extended language subtags
// / 4ALPHA ; or reserved for future use
// / 5*8ALPHA ; or registered language subtag
return (s.length() >= 2) && (s.length() <= 8) && AsciiUtil.isAlphaString(s);
}
public static boolean isExtlang(String s) {
// extlang = 3ALPHA ; selected ISO 639 codes
// *2("-" 3ALPHA) ; permanently reserved
return (s.length() == 3) && AsciiUtil.isAlphaString(s);
}
public static boolean isScript(String s) {
// script = 4ALPHA ; ISO 15924 code
return (s.length() == 4) && AsciiUtil.isAlphaString(s);
}
public static boolean isRegion(String s) {
// region = 2ALPHA ; ISO 3166-1 code
// / 3DIGIT ; UN M.49 code
return ((s.length() == 2) && AsciiUtil.isAlphaString(s))
|| ((s.length() == 3) && AsciiUtil.isNumericString(s));
}
public static boolean isVariant(String s) {
// variant = 5*8alphanum ; registered variants
// / (DIGIT 3alphanum)
int len = s.length();
if (len >= 5 && len <= 8) {
return AsciiUtil.isAlphaNumericString(s);
}
if (len == 4) {
return AsciiUtil.isNumeric(s.charAt(0))
&& AsciiUtil.isAlphaNumeric(s.charAt(1))
&& AsciiUtil.isAlphaNumeric(s.charAt(2))
&& AsciiUtil.isAlphaNumeric(s.charAt(3));
}
return false;
}
public static boolean isExtensionSingleton(String s) {
// singleton = DIGIT ; 0 - 9
// / %x41-57 ; A - W
// / %x59-5A ; Y - Z
// / %x61-77 ; a - w
// / %x79-7A ; y - z
return (s.length() == 1)
&& AsciiUtil.isAlphaString(s)
&& !AsciiUtil.caseIgnoreMatch(PRIVATEUSE, s);
}
public static boolean isExtensionSingletonChar(char c) {
return isExtensionSingleton(String.valueOf(c));
}
public static boolean isExtensionSubtag(String s) {
// extension = singleton 1*("-" (2*8alphanum))
return (s.length() >= 2) && (s.length() <= 8) && AsciiUtil.isAlphaNumericString(s);
}
public static boolean isPrivateusePrefix(String s) {
// privateuse = "x" 1*("-" (1*8alphanum))
return (s.length() == 1)
&& AsciiUtil.caseIgnoreMatch(PRIVATEUSE, s);
}
public static boolean isPrivateusePrefixChar(char c) {
return (AsciiUtil.caseIgnoreMatch(PRIVATEUSE, String.valueOf(c)));
}
public static boolean isPrivateuseSubtag(String s) {
// privateuse = "x" 1*("-" (1*8alphanum))
return (s.length() >= 1) && (s.length() <= 8) && AsciiUtil.isAlphaNumericString(s);
}
//
// Language subtag canonicalization methods
//
public static String canonicalizeLanguage(String s) {
return AsciiUtil.toLowerString(s);
}
public static String canonicalizeExtlang(String s) {
return AsciiUtil.toLowerString(s);
}
public static String canonicalizeScript(String s) {
return AsciiUtil.toTitleString(s);
}
public static String canonicalizeRegion(String s) {
return AsciiUtil.toUpperString(s);
}
public static String canonicalizeVariant(String s) {
return AsciiUtil.toLowerString(s);
}
public static String canonicalizeExtension(String s) {
return AsciiUtil.toLowerString(s);
}
public static String canonicalizeExtensionSingleton(String s) {
return AsciiUtil.toLowerString(s);
}
public static String canonicalizeExtensionSubtag(String s) {
return AsciiUtil.toLowerString(s);
}
public static String canonicalizePrivateuse(String s) {
return AsciiUtil.toLowerString(s);
}
public static String canonicalizePrivateuseSubtag(String s) {
return AsciiUtil.toLowerString(s);
}
public String toString() {
StringBuilder sb = new StringBuilder();
if (_language.length() > 0) {
sb.append(_language);
for (String extlang : _extlangs) {
sb.append(SEP).append(extlang);
}
if (_script.length() > 0) {
sb.append(SEP).append(_script);
}
if (_region.length() > 0) {
sb.append(SEP).append(_region);
}
for (String variant : _extlangs) {
sb.append(SEP).append(variant);
}
for (String extension : _extensions) {
sb.append(SEP).append(extension);
}
}
if (_privateuse.length() > 0) {
if (sb.length() > 0) {
sb.append(SEP);
}
sb.append(_privateuse);
}
return sb.toString();
}
}

View file

@ -1,223 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl.locale;
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.TreeSet;
import com.ibm.icu.impl.locale.InternalLocaleBuilder.CaseInsensitiveChar;
import com.ibm.icu.impl.locale.InternalLocaleBuilder.CaseInsensitiveString;
public class LocaleExtensions {
private SortedMap<Character, Extension> _map;
private String _id;
private static final SortedMap<Character, Extension> EMPTY_MAP =
Collections.unmodifiableSortedMap(new TreeMap<Character, Extension>());
public static final LocaleExtensions EMPTY_EXTENSIONS;
public static final LocaleExtensions CALENDAR_JAPANESE;
public static final LocaleExtensions NUMBER_THAI;
static {
EMPTY_EXTENSIONS = new LocaleExtensions();
EMPTY_EXTENSIONS._id = "";
EMPTY_EXTENSIONS._map = EMPTY_MAP;
CALENDAR_JAPANESE = new LocaleExtensions();
CALENDAR_JAPANESE._id = "u-ca-japanese";
CALENDAR_JAPANESE._map = new TreeMap<Character, Extension>();
CALENDAR_JAPANESE._map.put(Character.valueOf(UnicodeLocaleExtension.SINGLETON), UnicodeLocaleExtension.CA_JAPANESE);
NUMBER_THAI = new LocaleExtensions();
NUMBER_THAI._id = "u-nu-thai";
NUMBER_THAI._map = new TreeMap<Character, Extension>();
NUMBER_THAI._map.put(Character.valueOf(UnicodeLocaleExtension.SINGLETON), UnicodeLocaleExtension.NU_THAI);
}
private LocaleExtensions() {
}
/*
* Package local constructor, only used by InternalLocaleBuilder.
*/
LocaleExtensions(Map<CaseInsensitiveChar, String> extensions,
Set<CaseInsensitiveString> uattributes, Map<CaseInsensitiveString, String> ukeywords) {
boolean hasExtension = (extensions != null && extensions.size() > 0);
boolean hasUAttributes = (uattributes != null && uattributes.size() > 0);
boolean hasUKeywords = (ukeywords != null && ukeywords.size() > 0);
if (!hasExtension && !hasUAttributes && !hasUKeywords) {
_map = EMPTY_MAP;
_id = "";
return;
}
// Build extension map
_map = new TreeMap<Character, Extension>();
if (hasExtension) {
for (Entry<CaseInsensitiveChar, String> ext : extensions.entrySet()) {
char key = AsciiUtil.toLower(ext.getKey().value());
String value = ext.getValue();
if (LanguageTag.isPrivateusePrefixChar(key)) {
// we need to exclude special variant in privuateuse, e.g. "x-abc-lvariant-DEF"
value = InternalLocaleBuilder.removePrivateuseVariant(value);
if (value == null) {
continue;
}
}
Extension e = new Extension(key, AsciiUtil.toLowerString(value));
_map.put(Character.valueOf(key), e);
}
}
if (hasUAttributes || hasUKeywords) {
TreeSet<String> uaset = null;
TreeMap<String, String> ukmap = null;
if (hasUAttributes) {
uaset = new TreeSet<String>();
for (CaseInsensitiveString cis : uattributes) {
uaset.add(AsciiUtil.toLowerString(cis.value()));
}
}
if (hasUKeywords) {
ukmap = new TreeMap<String, String>();
for (Entry<CaseInsensitiveString, String> kwd : ukeywords.entrySet()) {
String key = AsciiUtil.toLowerString(kwd.getKey().value());
String type = AsciiUtil.toLowerString(kwd.getValue());
ukmap.put(key, type);
}
}
UnicodeLocaleExtension ule = new UnicodeLocaleExtension(uaset, ukmap);
_map.put(Character.valueOf(UnicodeLocaleExtension.SINGLETON), ule);
}
if (_map.size() == 0) {
// this could happen when only privuateuse with special variant
_map = EMPTY_MAP;
_id = "";
} else {
_id = toID(_map);
}
}
public Set<Character> getKeys() {
return Collections.unmodifiableSet(_map.keySet());
}
public Extension getExtension(Character key) {
return _map.get(Character.valueOf(AsciiUtil.toLower(key.charValue())));
}
public String getExtensionValue(Character key) {
Extension ext = _map.get(Character.valueOf(AsciiUtil.toLower(key.charValue())));
if (ext == null) {
return null;
}
return ext.getValue();
}
public Set<String> getUnicodeLocaleAttributes() {
Extension ext = _map.get(Character.valueOf(UnicodeLocaleExtension.SINGLETON));
if (ext == null) {
return Collections.emptySet();
}
assert (ext instanceof UnicodeLocaleExtension);
return ((UnicodeLocaleExtension)ext).getUnicodeLocaleAttributes();
}
public Set<String> getUnicodeLocaleKeys() {
Extension ext = _map.get(Character.valueOf(UnicodeLocaleExtension.SINGLETON));
if (ext == null) {
return Collections.emptySet();
}
assert (ext instanceof UnicodeLocaleExtension);
return ((UnicodeLocaleExtension)ext).getUnicodeLocaleKeys();
}
public String getUnicodeLocaleType(String unicodeLocaleKey) {
Extension ext = _map.get(Character.valueOf(UnicodeLocaleExtension.SINGLETON));
if (ext == null) {
return null;
}
assert (ext instanceof UnicodeLocaleExtension);
return ((UnicodeLocaleExtension)ext).getUnicodeLocaleType(AsciiUtil.toLowerString(unicodeLocaleKey));
}
public boolean isEmpty() {
return _map.isEmpty();
}
public static boolean isValidKey(char c) {
return LanguageTag.isExtensionSingletonChar(c) || LanguageTag.isPrivateusePrefixChar(c);
}
public static boolean isValidUnicodeLocaleKey(String ukey) {
return UnicodeLocaleExtension.isKey(ukey);
}
private static String toID(SortedMap<Character, Extension> map) {
StringBuilder buf = new StringBuilder();
Extension privuse = null;
for (Entry<Character, Extension> entry : map.entrySet()) {
char singleton = entry.getKey().charValue();
Extension extension = entry.getValue();
if (LanguageTag.isPrivateusePrefixChar(singleton)) {
privuse = extension;
} else {
if (buf.length() > 0) {
buf.append(LanguageTag.SEP);
}
buf.append(extension);
}
}
if (privuse != null) {
if (buf.length() > 0) {
buf.append(LanguageTag.SEP);
}
buf.append(privuse);
}
return buf.toString();
}
public String toString() {
return _id;
}
public String getID() {
return _id;
}
public int hashCode() {
return _id.hashCode();
}
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof LocaleExtensions)) {
return false;
}
return this._id.equals(((LocaleExtensions)other)._id);
}
}

View file

@ -1,85 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl.locale;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.util.concurrent.ConcurrentHashMap;
public abstract class LocaleObjectCache<K, V> {
private ConcurrentHashMap<K, CacheEntry<K, V>> _map;
private ReferenceQueue<V> _queue = new ReferenceQueue<V>();
public LocaleObjectCache() {
this(16, 0.75f, 16);
}
public LocaleObjectCache(int initialCapacity, float loadFactor, int concurrencyLevel) {
_map = new ConcurrentHashMap<K, CacheEntry<K, V>>(initialCapacity, loadFactor, concurrencyLevel);
}
public V get(K key) {
V value = null;
cleanStaleEntries();
CacheEntry<K, V> entry = _map.get(key);
if (entry != null) {
value = entry.get();
}
if (value == null) {
key = normalizeKey(key);
V newVal = createObject(key);
if (key == null || newVal == null) {
// subclass must return non-null key/value object
return null;
}
CacheEntry<K, V> newEntry = new CacheEntry<K, V>(key, newVal, _queue);
while (value == null) {
cleanStaleEntries();
entry = _map.putIfAbsent(key, newEntry);
if (entry == null) {
value = newVal;
break;
} else {
value = entry.get();
}
}
}
return value;
}
@SuppressWarnings("unchecked")
private void cleanStaleEntries() {
CacheEntry<K, V> entry;
while ((entry = (CacheEntry<K, V>)_queue.poll()) != null) {
_map.remove(entry.getKey());
}
}
protected abstract V createObject(K key);
protected K normalizeKey(K key) {
return key;
}
private static class CacheEntry<K, V> extends SoftReference<V> {
private K _key;
CacheEntry(K key, V value, ReferenceQueue<V> queue) {
super(value, queue);
_key = key;
}
K getKey() {
return _key;
}
}
}

View file

@ -1,29 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl.locale;
public class LocaleSyntaxException extends Exception {
private static final long serialVersionUID = 1L;
private int _index = -1;
public LocaleSyntaxException(String msg) {
this(msg, 0);
}
public LocaleSyntaxException(String msg, int errorIndex) {
super(msg);
_index = errorIndex;
}
public int getErrorIndex() {
return _index;
}
}

View file

@ -1,37 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2010-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl.locale;
public class ParseStatus {
int _parseLength = 0;
int _errorIndex = -1;
String _errorMsg = null;
public void reset() {
_parseLength = 0;
_errorIndex = -1;
_errorMsg = null;
}
public boolean isError() {
return (_errorIndex >= 0);
}
public int getErrorIndex() {
return _errorIndex;
}
public int getParseLength() {
return _parseLength;
}
public String getErrorMessage() {
return _errorMsg;
}
}

View file

@ -1,95 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl.locale;
public class StringTokenIterator {
private String _text;
private String _dlms;
private String _token;
private int _start;
private int _end;
private boolean _done;
public StringTokenIterator(String text, String dlms) {
_text = text;
_dlms = dlms;
setStart(0);
}
public String first() {
setStart(0);
return _token;
}
public String current() {
return _token;
}
public int currentStart() {
return _start;
}
public int currentEnd() {
return _end;
}
public boolean isDone() {
return _done;
}
public String next() {
if (hasNext()) {
_start = _end + 1;
_end = nextDelimiter(_start);
_token = _text.substring(_start, _end);
} else {
_start = _end;
_token = null;
_done = true;
}
return _token;
}
public boolean hasNext() {
return (_end < _text.length());
}
public StringTokenIterator setStart(int offset) {
if (offset > _text.length()) {
throw new IndexOutOfBoundsException();
}
_start = offset;
_end = nextDelimiter(_start);
_token = _text.substring(_start, _end);
_done = false;
return this;
}
public StringTokenIterator setText(String text) {
_text = text;
setStart(0);
return this;
}
private int nextDelimiter(int start) {
int idx = start;
outer: while (idx < _text.length()) {
char c = _text.charAt(idx);
for (int i = 0; i < _dlms.length(); i++) {
if (c == _dlms.charAt(i)) {
break outer;
}
}
idx++;
}
return idx;
}
}

View file

@ -1,104 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.impl.locale;
import java.util.Collections;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
public class UnicodeLocaleExtension extends Extension {
public static final char SINGLETON = 'u';
private static final SortedSet<String> EMPTY_SORTED_SET = new TreeSet<String>();
private static final SortedMap<String, String> EMPTY_SORTED_MAP = new TreeMap<String, String>();
private SortedSet<String> _attributes = EMPTY_SORTED_SET;
private SortedMap<String, String> _keywords = EMPTY_SORTED_MAP;
public static final UnicodeLocaleExtension CA_JAPANESE;
public static final UnicodeLocaleExtension NU_THAI;
static {
CA_JAPANESE = new UnicodeLocaleExtension();
CA_JAPANESE._keywords = new TreeMap<String, String>();
CA_JAPANESE._keywords.put("ca", "japanese");
CA_JAPANESE._value = "ca-japanese";
NU_THAI = new UnicodeLocaleExtension();
NU_THAI._keywords = new TreeMap<String, String>();
NU_THAI._keywords.put("nu", "thai");
NU_THAI._value = "nu-thai";
}
private UnicodeLocaleExtension() {
super(SINGLETON);
}
UnicodeLocaleExtension(SortedSet<String> attributes, SortedMap<String, String> keywords) {
this();
if (attributes != null && attributes.size() > 0) {
_attributes = attributes;
}
if (keywords != null && keywords.size() > 0) {
_keywords = keywords;
}
if (_attributes.size() > 0 || _keywords.size() > 0) {
StringBuilder sb = new StringBuilder();
for (String attribute : _attributes) {
sb.append(LanguageTag.SEP).append(attribute);
}
for (Entry<String, String> keyword : _keywords.entrySet()) {
String key = keyword.getKey();
String value = keyword.getValue();
sb.append(LanguageTag.SEP).append(key);
if (value.length() > 0) {
sb.append(LanguageTag.SEP).append(value);
}
}
_value = sb.substring(1); // skip leading '-'
}
}
public Set<String> getUnicodeLocaleAttributes() {
return Collections.unmodifiableSet(_attributes);
}
public Set<String> getUnicodeLocaleKeys() {
return Collections.unmodifiableSet(_keywords.keySet());
}
public String getUnicodeLocaleType(String unicodeLocaleKey) {
return _keywords.get(unicodeLocaleKey);
}
public static boolean isSingletonChar(char c) {
return (SINGLETON == AsciiUtil.toLower(c));
}
public static boolean isAttribute(String s) {
// 3*8alphanum
return (s.length() >= 3) && (s.length() <= 8) && AsciiUtil.isAlphaNumericString(s);
}
public static boolean isKey(String s) {
// 2alphanum
return (s.length() == 2) && AsciiUtil.isAlphaNumericString(s);
}
public static boolean isTypeSubtag(String s) {
// 3*8alphanum
return (s.length() >= 3) && (s.length() <= 8) && AsciiUtil.isAlphaNumericString(s);
}
}

View file

@ -1,603 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/* Generated from 'MathContext.nrx' 8 Sep 2000 11:07:48 [v2.00] */
/* Options: Binary Comments Crossref Format Java Logo Strictargs Strictcase Trace2 Verbose3 */
package com.ibm.icu.math;
/* ------------------------------------------------------------------ */
/* MathContext -- Math context settings */
/* ------------------------------------------------------------------ */
/* Copyright IBM Corporation, 1997-2011. All Rights Reserved. */
/* */
/* The MathContext object encapsulates the settings used by the */
/* BigDecimal class; it could also be used by other arithmetics. */
/* ------------------------------------------------------------------ */
/* Notes: */
/* */
/* 1. The properties are checked for validity on construction, so */
/* the BigDecimal class may assume that they are correct. */
/* ------------------------------------------------------------------ */
/* Author: Mike Cowlishaw */
/* 1997.09.03 Initial version (edited from netrexx.lang.RexxSet) */
/* 1997.09.12 Add lostDigits property */
/* 1998.05.02 Make the class immutable and final; drop set methods */
/* 1998.06.05 Add Round (rounding modes) property */
/* 1998.06.25 Rename from DecimalContext; allow digits=0 */
/* 1998.10.12 change to com.ibm.icu.math package */
/* 1999.02.06 add javadoc comments */
/* 1999.03.05 simplify; changes from discussion with J. Bloch */
/* 1999.03.13 1.00 release to IBM Centre for Java Technology */
/* 1999.07.10 1.04 flag serialization unused */
/* 2000.01.01 1.06 copyright update */
/* ------------------------------------------------------------------ */
/**
* The <code>MathContext</code> immutable class encapsulates the
* settings understood by the operator methods of the {@link BigDecimal}
* class (and potentially other classes). Operator methods are those
* that effect an operation on a number or a pair of numbers.
* <p>
* The settings, which are not base-dependent, comprise:
* <ol>
* <li><code>digits</code>:
* the number of digits (precision) to be used for an operation
* <li><code>form</code>:
* the form of any exponent that results from the operation
* <li><code>lostDigits</code>:
* whether checking for lost digits is enabled
* <li><code>roundingMode</code>:
* the algorithm to be used for rounding.
* </ol>
* <p>
* When provided, a <code>MathContext</code> object supplies the
* settings for an operation directly.
* <p>
* When <code>MathContext.DEFAULT</code> is provided for a
* <code>MathContext</code> parameter then the default settings are used
* (<code>9, SCIENTIFIC, false, ROUND_HALF_UP</code>).
* <p>
* In the <code>BigDecimal</code> class, all methods which accept a
* <code>MathContext</code> object defaults) also have a version of the
* method which does not accept a MathContext parameter. These versions
* carry out unlimited precision fixed point arithmetic (as though the
* settings were (<code>0, PLAIN, false, ROUND_HALF_UP</code>).
* <p>
* The instance variables are shared with default access (so they are
* directly accessible to the <code>BigDecimal</code> class), but must
* never be changed.
* <p>
* The rounding mode constants have the same names and values as the
* constants of the same name in <code>java.math.BigDecimal</code>, to
* maintain compatibility with earlier versions of
* <code>BigDecimal</code>.
*
* @see BigDecimal
* @author Mike Cowlishaw
* @stable ICU 2.0
*/
public final class MathContext implements java.io.Serializable{
//private static final java.lang.String $0="MathContext.nrx";
/* ----- Properties ----- */
/* properties public constant */
/**
* Plain (fixed point) notation, without any exponent.
* Used as a setting to control the form of the result of a
* <code>BigDecimal</code> operation.
* A zero result in plain form may have a decimal part of one or
* more zeros.
*
* @see #ENGINEERING
* @see #SCIENTIFIC
* @stable ICU 2.0
*/
public static final int PLAIN=0; // [no exponent]
/**
* Standard floating point notation (with scientific exponential
* format, where there is one digit before any decimal point).
* Used as a setting to control the form of the result of a
* <code>BigDecimal</code> operation.
* A zero result in plain form may have a decimal part of one or
* more zeros.
*
* @see #ENGINEERING
* @see #PLAIN
* @stable ICU 2.0
*/
public static final int SCIENTIFIC=1; // 1 digit before .
/**
* Standard floating point notation (with engineering exponential
* format, where the power of ten is a multiple of 3).
* Used as a setting to control the form of the result of a
* <code>BigDecimal</code> operation.
* A zero result in plain form may have a decimal part of one or
* more zeros.
*
* @see #PLAIN
* @see #SCIENTIFIC
* @stable ICU 2.0
*/
public static final int ENGINEERING=2; // 1-3 digits before .
// The rounding modes match the original BigDecimal class values
/**
* Rounding mode to round to a more positive number.
* Used as a setting to control the rounding mode used during a
* <code>BigDecimal</code> operation.
* <p>
* If any of the discarded digits are non-zero then the result
* should be rounded towards the next more positive digit.
* @stable ICU 2.0
*/
public static final int ROUND_CEILING=2;
/**
* Rounding mode to round towards zero.
* Used as a setting to control the rounding mode used during a
* <code>BigDecimal</code> operation.
* <p>
* All discarded digits are ignored (truncated). The result is
* neither incremented nor decremented.
* @stable ICU 2.0
*/
public static final int ROUND_DOWN=1;
/**
* Rounding mode to round to a more negative number.
* Used as a setting to control the rounding mode used during a
* <code>BigDecimal</code> operation.
* <p>
* If any of the discarded digits are non-zero then the result
* should be rounded towards the next more negative digit.
* @stable ICU 2.0
*/
public static final int ROUND_FLOOR=3;
/**
* Rounding mode to round to nearest neighbor, where an equidistant
* value is rounded down.
* Used as a setting to control the rounding mode used during a
* <code>BigDecimal</code> operation.
* <p>
* If the discarded digits represent greater than half (0.5 times)
* the value of a one in the next position then the result should be
* rounded up (away from zero). Otherwise the discarded digits are
* ignored.
* @stable ICU 2.0
*/
public static final int ROUND_HALF_DOWN=5;
/**
* Rounding mode to round to nearest neighbor, where an equidistant
* value is rounded to the nearest even neighbor.
* Used as a setting to control the rounding mode used during a
* <code>BigDecimal</code> operation.
* <p>
* If the discarded digits represent greater than half (0.5 times)
* the value of a one in the next position then the result should be
* rounded up (away from zero). If they represent less than half,
* then the result should be rounded down.
* <p>
* Otherwise (they represent exactly half) the result is rounded
* down if its rightmost digit is even, or rounded up if its
* rightmost digit is odd (to make an even digit).
* @stable ICU 2.0
*/
public static final int ROUND_HALF_EVEN=6;
/**
* Rounding mode to round to nearest neighbor, where an equidistant
* value is rounded up.
* Used as a setting to control the rounding mode used during a
* <code>BigDecimal</code> operation.
* <p>
* If the discarded digits represent greater than or equal to half
* (0.5 times) the value of a one in the next position then the result
* should be rounded up (away from zero). Otherwise the discarded
* digits are ignored.
* @stable ICU 2.0
*/
public static final int ROUND_HALF_UP=4;
/**
* Rounding mode to assert that no rounding is necessary.
* Used as a setting to control the rounding mode used during a
* <code>BigDecimal</code> operation.
* <p>
* Rounding (potential loss of information) is not permitted.
* If any of the discarded digits are non-zero then an
* <code>ArithmeticException</code> should be thrown.
* @stable ICU 2.0
*/
public static final int ROUND_UNNECESSARY=7;
/**
* Rounding mode to round away from zero.
* Used as a setting to control the rounding mode used during a
* <code>BigDecimal</code> operation.
* <p>
* If any of the discarded digits are non-zero then the result will
* be rounded up (away from zero).
* @stable ICU 2.0
*/
public static final int ROUND_UP=0;
/* properties shared */
/**
* The number of digits (precision) to be used for an operation.
* A value of 0 indicates that unlimited precision (as many digits
* as are required) will be used.
* <p>
* The {@link BigDecimal} operator methods use this value to
* determine the precision of results.
* Note that leading zeros (in the integer part of a number) are
* never significant.
* <p>
* <code>digits</code> will always be non-negative.
*
* @serial
*/
int digits;
/**
* The form of results from an operation.
* <p>
* The {@link BigDecimal} operator methods use this value to
* determine the form of results, in particular whether and how
* exponential notation should be used.
*
* @see #ENGINEERING
* @see #PLAIN
* @see #SCIENTIFIC
* @serial
*/
int form; // values for this must fit in a byte
/**
* Controls whether lost digits checking is enabled for an
* operation.
* Set to <code>true</code> to enable checking, or
* to <code>false</code> to disable checking.
* <p>
* When enabled, the {@link BigDecimal} operator methods check
* the precision of their operand or operands, and throw an
* <code>ArithmeticException</code> if an operand is more precise
* than the digits setting (that is, digits would be lost).
* When disabled, operands are rounded to the specified digits.
*
* @serial
*/
boolean lostDigits;
/**
* The rounding algorithm to be used for an operation.
* <p>
* The {@link BigDecimal} operator methods use this value to
* determine the algorithm to be used when non-zero digits have to
* be discarded in order to reduce the precision of a result.
* The value must be one of the public constants whose name starts
* with <code>ROUND_</code>.
*
* @see #ROUND_CEILING
* @see #ROUND_DOWN
* @see #ROUND_FLOOR
* @see #ROUND_HALF_DOWN
* @see #ROUND_HALF_EVEN
* @see #ROUND_HALF_UP
* @see #ROUND_UNNECESSARY
* @see #ROUND_UP
* @serial
*/
int roundingMode;
/* properties private constant */
// default settings
private static final int DEFAULT_FORM=SCIENTIFIC;
private static final int DEFAULT_DIGITS=9;
private static final boolean DEFAULT_LOSTDIGITS=false;
private static final int DEFAULT_ROUNDINGMODE=ROUND_HALF_UP;
/* properties private constant */
private static final int MIN_DIGITS=0; // smallest value for DIGITS.
private static final int MAX_DIGITS=999999999; // largest value for DIGITS. If increased,
// the BigDecimal class may need update.
// list of valid rounding mode values, most common two first
private static final int ROUNDS[]=new int[]{ROUND_HALF_UP,ROUND_UNNECESSARY,ROUND_CEILING,ROUND_DOWN,ROUND_FLOOR,ROUND_HALF_DOWN,ROUND_HALF_EVEN,ROUND_UP};
private static final java.lang.String ROUNDWORDS[]=new java.lang.String[]{"ROUND_HALF_UP","ROUND_UNNECESSARY","ROUND_CEILING","ROUND_DOWN","ROUND_FLOOR","ROUND_HALF_DOWN","ROUND_HALF_EVEN","ROUND_UP"}; // matching names of the ROUNDS values
/* properties private constant unused */
// Serialization version
private static final long serialVersionUID=7163376998892515376L;
/* properties public constant */
/**
* A <code>MathContext</code> object initialized to the default
* settings for general-purpose arithmetic. That is,
* <code>digits=9 form=SCIENTIFIC lostDigits=false
* roundingMode=ROUND_HALF_UP</code>.
*
* @see #SCIENTIFIC
* @see #ROUND_HALF_UP
* @stable ICU 2.0
*/
public static final com.ibm.icu.math.MathContext DEFAULT=new com.ibm.icu.math.MathContext(DEFAULT_DIGITS,DEFAULT_FORM,DEFAULT_LOSTDIGITS,DEFAULT_ROUNDINGMODE);
/* ----- Constructors ----- */
/**
* Constructs a new <code>MathContext</code> with a specified
* precision.
* The other settings are set to the default values
* (see {@link #DEFAULT}).
*
* An <code>IllegalArgumentException</code> is thrown if the
* <code>setdigits</code> parameter is out of range
* (&lt;0 or &gt;999999999).
*
* @param setdigits The <code>int</code> digits setting
* for this <code>MathContext</code>.
* @throws IllegalArgumentException parameter out of range.
* @stable ICU 2.0
*/
public MathContext(int setdigits){
this(setdigits,DEFAULT_FORM,DEFAULT_LOSTDIGITS,DEFAULT_ROUNDINGMODE);
return;}
/**
* Constructs a new <code>MathContext</code> with a specified
* precision and form.
* The other settings are set to the default values
* (see {@link #DEFAULT}).
*
* An <code>IllegalArgumentException</code> is thrown if the
* <code>setdigits</code> parameter is out of range
* (&lt;0 or &gt;999999999), or if the value given for the
* <code>setform</code> parameter is not one of the appropriate
* constants.
*
* @param setdigits The <code>int</code> digits setting
* for this <code>MathContext</code>.
* @param setform The <code>int</code> form setting
* for this <code>MathContext</code>.
* @throws IllegalArgumentException parameter out of range.
* @stable ICU 2.0
*/
public MathContext(int setdigits,int setform){
this(setdigits,setform,DEFAULT_LOSTDIGITS,DEFAULT_ROUNDINGMODE);
return;}
/**
* Constructs a new <code>MathContext</code> with a specified
* precision, form, and lostDigits setting.
* The roundingMode setting is set to its default value
* (see {@link #DEFAULT}).
*
* An <code>IllegalArgumentException</code> is thrown if the
* <code>setdigits</code> parameter is out of range
* (&lt;0 or &gt;999999999), or if the value given for the
* <code>setform</code> parameter is not one of the appropriate
* constants.
*
* @param setdigits The <code>int</code> digits setting
* for this <code>MathContext</code>.
* @param setform The <code>int</code> form setting
* for this <code>MathContext</code>.
* @param setlostdigits The <code>boolean</code> lostDigits
* setting for this <code>MathContext</code>.
* @throws IllegalArgumentException parameter out of range.
* @stable ICU 2.0
*/
public MathContext(int setdigits,int setform,boolean setlostdigits){
this(setdigits,setform,setlostdigits,DEFAULT_ROUNDINGMODE);
return;}
/**
* Constructs a new <code>MathContext</code> with a specified
* precision, form, lostDigits, and roundingMode setting.
*
* An <code>IllegalArgumentException</code> is thrown if the
* <code>setdigits</code> parameter is out of range
* (&lt;0 or &gt;999999999), or if the value given for the
* <code>setform</code> or <code>setroundingmode</code> parameters is
* not one of the appropriate constants.
*
* @param setdigits The <code>int</code> digits setting
* for this <code>MathContext</code>.
* @param setform The <code>int</code> form setting
* for this <code>MathContext</code>.
* @param setlostdigits The <code>boolean</code> lostDigits
* setting for this <code>MathContext</code>.
* @param setroundingmode The <code>int</code> roundingMode setting
* for this <code>MathContext</code>.
* @throws IllegalArgumentException parameter out of range.
* @stable ICU 2.0
*/
public MathContext(int setdigits,int setform,boolean setlostdigits,int setroundingmode){super();
// set values, after checking
if (setdigits!=DEFAULT_DIGITS)
{
if (setdigits<MIN_DIGITS)
throw new java.lang.IllegalArgumentException("Digits too small:"+" "+setdigits);
if (setdigits>MAX_DIGITS)
throw new java.lang.IllegalArgumentException("Digits too large:"+" "+setdigits);
}
{/*select*/
if (setform==SCIENTIFIC){
// [most common]
}else if (setform==ENGINEERING){
}else if (setform==PLAIN){
}else{
throw new java.lang.IllegalArgumentException("Bad form value:"+" "+setform);
}
}
if ((!(isValidRound(setroundingmode))))
throw new java.lang.IllegalArgumentException("Bad roundingMode value:"+" "+setroundingmode);
digits=setdigits;
form=setform;
lostDigits=setlostdigits; // [no bad value possible]
roundingMode=setroundingmode;
return;}
/**
* Returns the digits setting.
* This value is always non-negative.
*
* @return an <code>int</code> which is the value of the digits
* setting
* @stable ICU 2.0
*/
public int getDigits(){
return digits;
}
/**
* Returns the form setting.
* This will be one of
* {@link #ENGINEERING},
* {@link #PLAIN}, or
* {@link #SCIENTIFIC}.
*
* @return an <code>int</code> which is the value of the form setting
* @stable ICU 2.0
*/
public int getForm(){
return form;
}
/**
* Returns the lostDigits setting.
* This will be either <code>true</code> (enabled) or
* <code>false</code> (disabled).
*
* @return a <code>boolean</code> which is the value of the lostDigits
* setting
* @stable ICU 2.0
*/
public boolean getLostDigits(){
return lostDigits;
}
/**
* Returns the roundingMode setting.
* This will be one of
* {@link #ROUND_CEILING},
* {@link #ROUND_DOWN},
* {@link #ROUND_FLOOR},
* {@link #ROUND_HALF_DOWN},
* {@link #ROUND_HALF_EVEN},
* {@link #ROUND_HALF_UP},
* {@link #ROUND_UNNECESSARY}, or
* {@link #ROUND_UP}.
*
* @return an <code>int</code> which is the value of the roundingMode
* setting
* @stable ICU 2.0
*/
public int getRoundingMode(){
return roundingMode;
}
/** Returns the <code>MathContext</code> as a readable string.
* The <code>String</code> returned represents the settings of the
* <code>MathContext</code> object as four blank-delimited words
* separated by a single blank and with no leading or trailing blanks,
* as follows:
* <ol>
* <li>
* <code>digits=</code>, immediately followed by
* the value of the digits setting as a numeric word.
* <li>
* <code>form=</code>, immediately followed by
* the value of the form setting as an uppercase word
* (one of <code>SCIENTIFIC</code>, <code>PLAIN</code>, or
* <code>ENGINEERING</code>).
* <li>
* <code>lostDigits=</code>, immediately followed by
* the value of the lostDigits setting
* (<code>1</code> if enabled, <code>0</code> if disabled).
* <li>
* <code>roundingMode=</code>, immediately followed by
* the value of the roundingMode setting as a word.
* This word will be the same as the name of the corresponding public
* constant.
* </ol>
* <p>
* For example:
* <br><code>
* digits=9 form=SCIENTIFIC lostDigits=0 roundingMode=ROUND_HALF_UP
* </code>
* <p>
* Additional words may be appended to the result of
* <code>toString</code> in the future if more properties are added
* to the class.
*
* @return a <code>String</code> representing the context settings.
* @stable ICU 2.0
*/
public java.lang.String toString(){
java.lang.String formstr=null;
int r=0;
java.lang.String roundword=null;
{/*select*/
if (form==SCIENTIFIC)
formstr="SCIENTIFIC";
else if (form==ENGINEERING)
formstr="ENGINEERING";
else{
formstr="PLAIN";/* form=PLAIN */
}
}
{int $1=ROUNDS.length;r=0;r:for(;$1>0;$1--,r++){
if (roundingMode==ROUNDS[r])
{
roundword=ROUNDWORDS[r];
break r;
}
}
}/*r*/
return "digits="+digits+" "+"form="+formstr+" "+"lostDigits="+(lostDigits?"1":"0")+" "+"roundingMode="+roundword;
}
/* <sgml> Test whether round is valid. </sgml> */
// This could be made shared for use by BigDecimal for setScale.
private static boolean isValidRound(int testround){
int r=0;
{int $2=ROUNDS.length;for(r=0;$2>0;$2--,r++){
if (testround==ROUNDS[r])
return true;
}
}/*r*/
return false;
}
}

View file

@ -1,835 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 1996-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.text;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.Locale;
import com.ibm.icu.util.ULocale;
/**
* {@icuenhanced java.text.BreakIterator}.{@icu _usage_}
*
* <p>A class that locates boundaries in text. This class defines a protocol for
* objects that break up a piece of natural-language text according to a set
* of criteria. Instances or subclasses of BreakIterator can be provided, for
* example, to break a piece of text into words, sentences, or logical characters
* according to the conventions of some language or group of languages.
*
* We provide five built-in types of BreakIterator:
* <ul><li>getTitleInstance() returns a BreakIterator that locates boundaries
* between title breaks.
* <li>getSentenceInstance() returns a BreakIterator that locates boundaries
* between sentences. This is useful for triple-click selection, for example.
* <li>getWordInstance() returns a BreakIterator that locates boundaries between
* words. This is useful for double-click selection or "find whole words" searches.
* This type of BreakIterator makes sure there is a boundary position at the
* beginning and end of each legal word. (Numbers count as words, too.) Whitespace
* and punctuation are kept separate from real words.
* <li>getLineInstance() returns a BreakIterator that locates positions where it is
* legal for a text editor to wrap lines. This is similar to word breaking, but
* not the same: punctuation and whitespace are generally kept with words (you don't
* want a line to start with whitespace, for example), and some special characters
* can force a position to be considered a line-break position or prevent a position
* from being a line-break position.
* <li>getCharacterInstance() returns a BreakIterator that locates boundaries between
* logical characters. Because of the structure of the Unicode encoding, a logical
* character may be stored internally as more than one Unicode code point. (A with an
* umlaut may be stored as an a followed by a separate combining umlaut character,
* for example, but the user still thinks of it as one character.) This iterator allows
* various processes (especially text editors) to treat as characters the units of text
* that a user would think of as characters, rather than the units of text that the
* computer sees as "characters".</ul>
*
* BreakIterator's interface follows an "iterator" model (hence the name), meaning it
* has a concept of a "current position" and methods like first(), last(), next(),
* and previous() that update the current position. All BreakIterators uphold the
* following invariants:
* <ul><li>The beginning and end of the text are always treated as boundary positions.
* <li>The current position of the iterator is always a boundary position (random-
* access methods move the iterator to the nearest boundary position before or
* after the specified position, not _to_ the specified position).
* <li>DONE is used as a flag to indicate when iteration has stopped. DONE is only
* returned when the current position is the end of the text and the user calls next(),
* or when the current position is the beginning of the text and the user calls
* previous().
* <li>Break positions are numbered by the positions of the characters that follow
* them. Thus, under normal circumstances, the position before the first character
* is 0, the position after the first character is 1, and the position after the
* last character is 1 plus the length of the string.
* <li>The client can change the position of an iterator, or the text it analyzes,
* at will, but cannot change the behavior. If the user wants different behavior, he
* must instantiate a new iterator.</ul>
*
* BreakIterator accesses the text it analyzes through a CharacterIterator, which makes
* it possible to use BreakIterator to analyze text in any text-storage vehicle that
* provides a CharacterIterator interface.
*
* <b>Note:</b> Some types of BreakIterator can take a long time to create, and
* instances of BreakIterator are not currently cached by the system. For
* optimal performance, keep instances of BreakIterator around as long as makes
* sense. For example, when word-wrapping a document, don't create and destroy a
* new BreakIterator for each line. Create one break iterator for the whole document
* (or whatever stretch of text you're wrapping) and use it to do the whole job of
* wrapping the text.
*
* <P>
* <strong>Examples</strong>:<P>
* Creating and using text boundaries
* <blockquote>
* <pre>
* public static void main(String args[]) {
* if (args.length == 1) {
* String stringToExamine = args[0];
* //print each word in order
* BreakIterator boundary = BreakIterator.getWordInstance();
* boundary.setText(stringToExamine);
* printEachForward(boundary, stringToExamine);
* //print each sentence in reverse order
* boundary = BreakIterator.getSentenceInstance(Locale.US);
* boundary.setText(stringToExamine);
* printEachBackward(boundary, stringToExamine);
* printFirst(boundary, stringToExamine);
* printLast(boundary, stringToExamine);
* }
* }
* </pre>
* </blockquote>
*
* Print each element in order
* <blockquote>
* <pre>
* public static void printEachForward(BreakIterator boundary, String source) {
* int start = boundary.first();
* for (int end = boundary.next();
* end != BreakIterator.DONE;
* start = end, end = boundary.next()) {
* System.out.println(source.substring(start,end));
* }
* }
* </pre>
* </blockquote>
*
* Print each element in reverse order
* <blockquote>
* <pre>
* public static void printEachBackward(BreakIterator boundary, String source) {
* int end = boundary.last();
* for (int start = boundary.previous();
* start != BreakIterator.DONE;
* end = start, start = boundary.previous()) {
* System.out.println(source.substring(start,end));
* }
* }
* </pre>
* </blockquote>
*
* Print first element
* <blockquote>
* <pre>
* public static void printFirst(BreakIterator boundary, String source) {
* int start = boundary.first();
* int end = boundary.next();
* System.out.println(source.substring(start,end));
* }
* </pre>
* </blockquote>
*
* Print last element
* <blockquote>
* <pre>
* public static void printLast(BreakIterator boundary, String source) {
* int end = boundary.last();
* int start = boundary.previous();
* System.out.println(source.substring(start,end));
* }
* </pre>
* </blockquote>
*
* Print the element at a specified position
* <blockquote>
* <pre>
* public static void printAt(BreakIterator boundary, int pos, String source) {
* int end = boundary.following(pos);
* int start = boundary.previous();
* System.out.println(source.substring(start,end));
* }
* </pre>
* </blockquote>
*
* Find the next word
* <blockquote>
* <pre>
* public static int nextWordStartAfter(int pos, String text) {
* BreakIterator wb = BreakIterator.getWordInstance();
* wb.setText(text);
* int last = wb.following(pos);
* int current = wb.next();
* while (current != BreakIterator.DONE) {
* for (int p = last; p < current; p++) {
* if (Character.isLetter(text.charAt(p)))
* return last;
* }
* last = current;
* current = wb.next();
* }
* return BreakIterator.DONE;
* }
* </pre>
* (The iterator returned by BreakIterator.getWordInstance() is unique in that
* the break positions it returns don't represent both the start and end of the
* thing being iterated over. That is, a sentence-break iterator returns breaks
* that each represent the end of one sentence and the beginning of the next.
* With the word-break iterator, the characters between two boundaries might be a
* word, or they might be the punctuation or whitespace between two words. The
* above code uses a simple heuristic to determine which boundary is the beginning
* of a word: If the characters between this boundary and the next boundary
* include at least one letter (this can be an alphabetical letter, a CJK ideograph,
* a Hangul syllable, a Kana character, etc.), then the text between this boundary
* and the next is a word; otherwise, it's the material between words.)
* </blockquote>
*
* @see CharacterIterator
* @stable ICU 2.0
*
*/
public abstract class BreakIterator implements Cloneable
{
/**
* Default constructor. There is no state that is carried by this abstract
* base class.
* @stable ICU 2.0
*/
protected BreakIterator()
{
}
/**
* Clone method. Creates another BreakIterator with the same behavior and
* current state as this one.
* @return The clone.
* @stable ICU 2.0
*/
public Object clone()
{
try {
return super.clone();
}
catch (CloneNotSupportedException e) {
///CLOVER:OFF
throw new IllegalStateException();
///CLOVER:ON
}
}
/**
* DONE is returned by previous() and next() after all valid
* boundaries have been returned.
* @stable ICU 2.0
*/
public static final int DONE = -1;
/**
* Return the first boundary position. This is always the beginning
* index of the text this iterator iterates over. For example, if
* the iterator iterates over a whole string, this function will
* always return 0. This function also updates the iteration position
* to point to the beginning of the text.
* @return The character offset of the beginning of the stretch of text
* being broken.
* @stable ICU 2.0
*/
public abstract int first();
/**
* Return the last boundary position. This is always the "past-the-end"
* index of the text this iterator iterates over. For example, if the
* iterator iterates over a whole string (call it "text"), this function
* will always return text.length(). This function also updated the
* iteration position to point to the end of the text.
* @return The character offset of the end of the stretch of text
* being broken.
* @stable ICU 2.0
*/
public abstract int last();
/**
* Advances the specified number of steps forward in the text (a negative
* number, therefore, advances backwards). If this causes the iterator
* to advance off either end of the text, this function returns DONE;
* otherwise, this function returns the position of the appropriate
* boundary. Calling this function is equivalent to calling next() or
* previous() n times.
* @param n The number of boundaries to advance over (if positive, moves
* forward; if negative, moves backwards).
* @return The position of the boundary n boundaries from the current
* iteration position, or DONE if moving n boundaries causes the iterator
* to advance off either end of the text.
* @stable ICU 2.0
*/
public abstract int next(int n);
/**
* Advances the iterator forward one boundary. The current iteration
* position is updated to point to the next boundary position after the
* current position, and this is also the value that is returned. If
* the current position is equal to the value returned by last(), or to
* DONE, this function returns DONE and sets the current position to
* DONE.
* @return The position of the first boundary position following the
* iteration position.
* @stable ICU 2.0
*/
public abstract int next();
/**
* Advances the iterator backward one boundary. The current iteration
* position is updated to point to the last boundary position before
* the current position, and this is also the value that is returned. If
* the current position is equal to the value returned by first(), or to
* DONE, this function returns DONE and sets the current position to
* DONE.
* @return The position of the last boundary position preceding the
* iteration position.
* @stable ICU 2.0
*/
public abstract int previous();
/**
* Sets the iterator's current iteration position to be the first
* boundary position following the specified position. (Whether the
* specified position is itself a boundary position or not doesn't
* matter-- this function always moves the iteration position to the
* first boundary after the specified position.) If the specified
* position is the past-the-end position, returns DONE.
* @param offset The character position to start searching from.
* @return The position of the first boundary position following
* "offset" (whether or not "offset" itself is a boundary position),
* or DONE if "offset" is the past-the-end offset.
* @stable ICU 2.0
*/
public abstract int following(int offset);
/**
* Sets the iterator's current iteration position to be the last
* boundary position preceding the specified position. (Whether the
* specified position is itself a boundary position or not doesn't
* matter-- this function always moves the iteration position to the
* last boundary before the specified position.) If the specified
* position is the starting position, returns DONE.
* @param offset The character position to start searching from.
* @return The position of the last boundary position preceding
* "offset" (whether of not "offset" itself is a boundary position),
* or DONE if "offset" is the starting offset of the iterator.
* @stable ICU 2.0
*/
public int preceding(int offset) {
// NOTE: This implementation is here solely because we can't add new
// abstract methods to an existing class. There is almost ALWAYS a
// better, faster way to do this.
int pos = following(offset);
while (pos >= offset && pos != DONE)
pos = previous();
return pos;
}
/**
* Return true if the specfied position is a boundary position. If the
* function returns true, the current iteration position is set to the
* specified position; if the function returns false, the current
* iteration position is set as though following() had been called.
* @param offset the offset to check.
* @return True if "offset" is a boundary position.
* @stable ICU 2.0
*/
public boolean isBoundary(int offset) {
// Again, this is the default implementation, which is provided solely because
// we couldn't add a new abstract method to an existing class. The real
// implementations will usually need to do a little more work.
if (offset == 0) {
return true;
}
else
return following(offset - 1) == offset;
}
/**
* Return the iterator's current position.
* @return The iterator's current position.
* @stable ICU 2.0
*/
public abstract int current();
/**
* Returns a CharacterIterator over the text being analyzed.
* For at least some subclasses of BreakIterator, this is a reference
* to the <b>actual iterator being used</b> by the BreakIterator,
* and therefore, this function's return value should be treated as
* <tt>const</tt>. No guarantees are made about the current position
* of this iterator when it is returned. If you need to move that
* position to examine the text, clone this function's return value first.
* @return A CharacterIterator over the text being analyzed.
* @stable ICU 2.0
*/
public abstract CharacterIterator getText();
/**
* Sets the iterator to analyze a new piece of text. The new
* piece of text is passed in as a String, and the current
* iteration position is reset to the beginning of the string.
* (The old text is dropped.)
* @param newText A String containing the text to analyze with
* this BreakIterator.
* @stable ICU 2.0
*/
public void setText(String newText)
{
setText(new StringCharacterIterator(newText));
}
/**
* Sets the iterator to analyze a new piece of text. The
* BreakIterator is passed a CharacterIterator through which
* it will access the text itself. The current iteration
* position is reset to the CharacterIterator's start index.
* (The old iterator is dropped.)
* @param newText A CharacterIterator referring to the text
* to analyze with this BreakIterator (the iterator's current
* position is ignored, but its other state is significant).
* @stable ICU 2.0
*/
public abstract void setText(CharacterIterator newText);
/**
* {@icu}
* @stable ICU 2.4
*/
public static final int KIND_CHARACTER = 0;
/**
* {@icu}
* @stable ICU 2.4
*/
public static final int KIND_WORD = 1;
/**
* {@icu}
* @stable ICU 2.4
*/
public static final int KIND_LINE = 2;
/**
* {@icu}
* @stable ICU 2.4
*/
public static final int KIND_SENTENCE = 3;
// /**
// * {@icu}
// * @stable ICU 2.4
// */
// public static final int KIND_TITLE = 4;
/**
* Returns a new instance of BreakIterator that locates word boundaries.
* This function assumes that the text being analyzed is in the default
* locale's language.
* @return An instance of BreakIterator that locates word boundaries.
* @stable ICU 2.0
*/
public static BreakIterator getWordInstance()
{
return getWordInstance(Locale.getDefault());
}
/**
* Returns a new instance of BreakIterator that locates word boundaries.
* @param where A locale specifying the language of the text to be
* analyzed.
* @return An instance of BreakIterator that locates word boundaries.
* @stable ICU 2.0
*/
public static BreakIterator getWordInstance(Locale where)
{
return getBreakInstance(where, KIND_WORD);
}
/**
* {@icu} Returns a new instance of BreakIterator that locates word boundaries.
* @param where A locale specifying the language of the text to be
* analyzed.
* @return An instance of BreakIterator that locates word boundaries.
* @stable ICU 3.2
*/
public static BreakIterator getWordInstance(ULocale where)
{
return getBreakInstance(where.toLocale(), KIND_WORD);
}
/**
* Returns a new instance of BreakIterator that locates legal line-
* wrapping positions. This function assumes the text being broken
* is in the default locale's language.
* @return A new instance of BreakIterator that locates legal
* line-wrapping positions.
* @stable ICU 2.0
*/
public static BreakIterator getLineInstance()
{
return getLineInstance(Locale.getDefault());
}
/**
* Returns a new instance of BreakIterator that locates legal line-
* wrapping positions.
* @param where A Locale specifying the language of the text being broken.
* @return A new instance of BreakIterator that locates legal
* line-wrapping positions.
* @stable ICU 2.0
*/
public static BreakIterator getLineInstance(Locale where)
{
return getBreakInstance(where, KIND_LINE);
}
/**
* {@icu} Returns a new instance of BreakIterator that locates legal line-
* wrapping positions.
* @param where A Locale specifying the language of the text being broken.
* @return A new instance of BreakIterator that locates legal
* line-wrapping positions.
* @stable ICU 3.2
*/
public static BreakIterator getLineInstance(ULocale where)
{
return getBreakInstance(where.toLocale(), KIND_LINE);
}
/**
* Returns a new instance of BreakIterator that locates logical-character
* boundaries. This function assumes that the text being analyzed is
* in the default locale's language.
* @return A new instance of BreakIterator that locates logical-character
* boundaries.
* @stable ICU 2.0
*/
public static BreakIterator getCharacterInstance()
{
return getCharacterInstance(Locale.getDefault());
}
/**
* Returns a new instance of BreakIterator that locates logical-character
* boundaries.
* @param where A Locale specifying the language of the text being analyzed.
* @return A new instance of BreakIterator that locates logical-character
* boundaries.
* @stable ICU 2.0
*/
public static BreakIterator getCharacterInstance(Locale where)
{
return getBreakInstance(where, KIND_CHARACTER);
}
/**
* {@icu} Returns a new instance of BreakIterator that locates logical-character
* boundaries.
* @param where A Locale specifying the language of the text being analyzed.
* @return A new instance of BreakIterator that locates logical-character
* boundaries.
* @stable ICU 3.2
*/
public static BreakIterator getCharacterInstance(ULocale where)
{
return getBreakInstance(where.toLocale(), KIND_CHARACTER);
}
/**
* Returns a new instance of BreakIterator that locates sentence boundaries.
* This function assumes the text being analyzed is in the default locale's
* language.
* @return A new instance of BreakIterator that locates sentence boundaries.
* @stable ICU 2.0
*/
public static BreakIterator getSentenceInstance()
{
return getSentenceInstance(Locale.getDefault());
}
/**
* Returns a new instance of BreakIterator that locates sentence boundaries.
* @param where A Locale specifying the language of the text being analyzed.
* @return A new instance of BreakIterator that locates sentence boundaries.
* @stable ICU 2.0
*/
public static BreakIterator getSentenceInstance(Locale where)
{
return getBreakInstance(where, KIND_SENTENCE);
}
/**
* {@icu} Returns a new instance of BreakIterator that locates sentence boundaries.
* @param where A Locale specifying the language of the text being analyzed.
* @return A new instance of BreakIterator that locates sentence boundaries.
* @stable ICU 3.2
*/
public static BreakIterator getSentenceInstance(ULocale where)
{
return getBreakInstance(where.toLocale(), KIND_SENTENCE);
}
// /**
// * {@icu} Returns a new instance of BreakIterator that locates title boundaries.
// * This function assumes the text being analyzed is in the default locale's
// * language. The iterator returned locates title boundaries as described for
// * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
// * please use a word boundary iterator. {@link #getWordInstance}
// * @return A new instance of BreakIterator that locates title boundaries.
// * @stable ICU 2.0
// */
// public static BreakIterator getTitleInstance()
// {
// return getTitleInstance(Locale.getDefault());
// }
// /**
// * {@icu} Returns a new instance of BreakIterator that locates title boundaries.
// * The iterator returned locates title boundaries as described for
// * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
// * please use Word Boundary iterator.{@link #getWordInstance}
// * @param where A Locale specifying the language of the text being analyzed.
// * @return A new instance of BreakIterator that locates title boundaries.
// * @stable ICU 2.0
// */
// public static BreakIterator getTitleInstance(Locale where)
// {
// return getBreakInstance(where, KIND_TITLE);
// }
// /**
// * {@icu} Returns a new instance of BreakIterator that locates title boundaries.
// * The iterator returned locates title boundaries as described for
// * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
// * please use Word Boundary iterator.{@link #getWordInstance}
// * @param where A Locale specifying the language of the text being analyzed.
// * @return A new instance of BreakIterator that locates title boundaries.
// * @stable ICU 3.2
//s */
// public static BreakIterator getTitleInstance(ULocale where)
// {
// return getBreakInstance(where.toLocale(), KIND_TITLE);
// }
// /**
// * {@icu} Registers a new break iterator of the indicated kind, to use in the given
// * locale. Clones of the iterator will be returned if a request for a break iterator
// * of the given kind matches or falls back to this locale.
// * @param iter the BreakIterator instance to adopt.
// * @param locale the Locale for which this instance is to be registered
// * @param kind the type of iterator for which this instance is to be registered
// * @return a registry key that can be used to unregister this instance
// * @stable ICU 2.4
// */
// public static Object registerInstance(BreakIterator iter, Locale locale, int kind) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Registers a new break iterator of the indicated kind, to use in the given
// * locale. Clones of the iterator will be returned if a request for a break iterator
// * of the given kind matches or falls back to this locale.
// * @param iter the BreakIterator instance to adopt.
// * @param locale the Locale for which this instance is to be registered
// * @param kind the type of iterator for which this instance is to be registered
// * @return a registry key that can be used to unregister this instance
// * @stable ICU 3.2
// */
// public static Object registerInstance(BreakIterator iter, ULocale locale, int kind) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Unregisters a previously-registered BreakIterator using the key returned
// * from the register call. Key becomes invalid after this call and should not be used
// * again.
// * @param key the registry key returned by a previous call to registerInstance
// * @return true if the iterator for the key was successfully unregistered
// * @stable ICU 2.4
// */
// public static boolean unregister(Object key) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// end of registration
/**
* Returns a particular kind of BreakIterator for a locale.
* Avoids writing a switch statement with getXYZInstance(where) calls.
* @internal
* @deprecated This API is ICU internal only.
*/
public static BreakIterator getBreakInstance(ULocale where, int kind) {
return getBreakInstance(where.toLocale(), KIND_SENTENCE);
}
private static BreakIterator getBreakInstance(Locale where, int kind) {
java.text.BreakIterator br = null;
switch(kind) {
case KIND_CHARACTER: br = java.text.BreakIterator.getCharacterInstance(where); break;
case KIND_WORD: br = java.text.BreakIterator.getWordInstance(where); break;
case KIND_LINE: br = java.text.BreakIterator.getLineInstance(where); break;
case KIND_SENTENCE: br = java.text.BreakIterator.getSentenceInstance(where); break;
// case KIND_TITLE: throw new UnsupportedOperationException("Title break is not supported by com.ibm.icu.base");
}
return new BreakIteratorHandle(br);
}
/**
* Returns a list of locales for which BreakIterators can be used.
* @return An array of Locales. All of the locales in the array can
* be used when creating a BreakIterator.
* @stable ICU 2.6
*/
public static synchronized Locale[] getAvailableLocales() {
return java.text.BreakIterator.getAvailableLocales();
}
/**
* {@icu} Returns a list of locales for which BreakIterators can be used.
* @return An array of Locales. All of the locales in the array can
* be used when creating a BreakIterator.
* @draft ICU 3.2 (retain)
* @provisional This API might change or be removed in a future release.
*/
public static synchronized ULocale[] getAvailableULocales() {
Locale[] locales = java.text.BreakIterator.getAvailableLocales();
ULocale[] ulocales = new ULocale[locales.length];
for (int i = 0; i < locales.length; ++i) {
ulocales[i] = ULocale.forLocale(locales[i]);
}
return ulocales;
}
// /**
// * {@icu} Returns the locale that was used to create this object, or null.
// * This may may differ from the locale requested at the time of
// * this object's creation. For example, if an object is created
// * for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
// * drawn from <tt>en</tt> (the <i>actual</i> locale), and
// * <tt>en_US</tt> may be the most specific locale that exists (the
// * <i>valid</i> locale).
// *
// * <p>Note: The <i>actual</i> locale is returned correctly, but the <i>valid</i>
// * locale is not, in most cases.
// * @param type type of information requested, either {@link
// * com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
// * com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
// * @return the information specified by <i>type</i>, or null if
// * this object was not constructed from locale data.
// * @see com.ibm.icu.util.ULocale
// * @see com.ibm.icu.util.ULocale#VALID_LOCALE
// * @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
// * @draft ICU 2.8 (retain)
// * @provisional This API might change or be removed in a future release.
// */
// public final ULocale getLocale(ULocale.Type type) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// forwarding implementation class
static final class BreakIteratorHandle extends BreakIterator {
/**
* @internal
*/
public final java.text.BreakIterator breakIterator;
/**
* @internal
* @param delegate the BreakIterator to which to delegate
*/
public BreakIteratorHandle(java.text.BreakIterator delegate) {
this.breakIterator = delegate;
}
public int first() {
return breakIterator.first();
}
public int last() {
return breakIterator.last();
}
public int next(int n) {
return breakIterator.next(n);
}
public int next() {
return breakIterator.next();
}
public int previous() {
return breakIterator.previous();
}
public int following(int offset) {
return breakIterator.following(offset);
}
public int preceding(int offset) {
return breakIterator.preceding(offset);
}
public boolean isBoundary(int offset) {
return breakIterator.isBoundary(offset);
}
public int current() {
return breakIterator.current();
}
public CharacterIterator getText() {
return breakIterator.getText();
}
public void setText(CharacterIterator newText) {
breakIterator.setText(newText);
}
/**
* Return a string suitable for debugging.
* @return a string suitable for debugging
* @stable ICU 3.4.3
*/
public String toString() {
return breakIterator.toString();
}
/**
* Return a clone of this BreakIterator.
* @return a clone of this BreakIterator
* @stable ICU 3.4.3
*/
public Object clone() {
return new BreakIteratorHandle((java.text.BreakIterator)breakIterator.clone());
}
/**
* Return true if rhs is a BreakIterator with the same break behavior as this.
* @return true if rhs equals this
* @stable ICU 3.4.3
*/
public boolean equals(Object rhs) {
try {
return breakIterator.equals(((BreakIteratorHandle)rhs).breakIterator);
}
catch (Exception e) {
return false;
}
}
/**
* Return a hashCode.
* @return a hashCode
* @stable ICU 3.4.3
*/
public int hashCode() {
return breakIterator.hashCode();
}
}
}

View file

@ -1,417 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/**
*******************************************************************************
* Copyright (C) 1996-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.text;
/**
* <p>A <code>CollationKey</code> represents a <code>String</code>
* under the rules of a specific <code>Collator</code>
* object. Comparing two <code>CollationKey</code>s returns the
* relative order of the <code>String</code>s they represent.</p>
*
* <p>Since the rule set of <code>Collator</code>s can differ, the
* sort orders of the same string under two different
* <code>Collator</code>s might differ. Hence comparing
* <code>CollationKey</code>s generated from different
* <code>Collator</code>s can give incorrect results.</p>
* <p>Both the method
* <code>CollationKey.compareTo(CollationKey)</code> and the method
* <code>Collator.compare(String, String)</code> compare two strings
* and returns their relative order. The performance characteristics
* of these two approaches can differ.</p>
*
* <p>During the construction of a <code>CollationKey</code>, the
* entire source string is examined and processed into a series of
* bits terminated by a null, that are stored in the <code>CollationKey</code>.
* When <code>CollationKey.compareTo(CollationKey)</code> executes, it
* performs bitwise comparison on the bit sequences. This can incurs
* startup cost when creating the <code>CollationKey</code>, but once
* the key is created, binary comparisons are fast. This approach is
* recommended when the same strings are to be compared over and over
* again.</p>
*
* <p>On the other hand, implementations of
* <code>Collator.compare(String, String)</code> can examine and
* process the strings only until the first characters differing in
* order. This approach is recommended if the strings are to be
* compared only once.</p>
*
* <p>More information about the composition of the bit sequence can
* be found in the
* <a href="http://www.icu-project.org/userguide/Collate_ServiceArchitecture.html">
* user guide</a>.</p>
*
* <p>The following example shows how <code>CollationKey</code>s can be used
* to sort a list of <code>String</code>s.</p>
* <blockquote>
* <pre>
* // Create an array of CollationKeys for the Strings to be sorted.
* Collator myCollator = Collator.getInstance();
* CollationKey[] keys = new CollationKey[3];
* keys[0] = myCollator.getCollationKey("Tom");
* keys[1] = myCollator.getCollationKey("Dick");
* keys[2] = myCollator.getCollationKey("Harry");
* sort( keys );
* <br>
* //...
* <br>
* // Inside body of sort routine, compare keys this way
* if( keys[i].compareTo( keys[j] ) > 0 )
* // swap keys[i] and keys[j]
* <br>
* //...
* <br>
* // Finally, when we've returned from sort.
* System.out.println( keys[0].getSourceString() );
* System.out.println( keys[1].getSourceString() );
* System.out.println( keys[2].getSourceString() );
* </pre>
* </blockquote>
* </p>
* <p>
* This class is not subclassable
* </p>
* @see Collator
* @see RuleBasedCollator
* @author Syn Wee Quek
* @stable ICU 2.8
*/
public final class CollationKey implements Comparable<CollationKey>
{
/**
* @internal
*/
final java.text.CollationKey key;
/**
* @internal
*/
CollationKey(java.text.CollationKey delegate) {
this.key = delegate;
}
// public inner classes -------------------------------------------------
// /**
// * Options that used in the API CollationKey.getBound() for getting a
// * CollationKey based on the bound mode requested.
// * @stable ICU 2.6
// */
// public static final class BoundMode
// {
// /*
// * do not change the values assigned to the members of this enum.
// * Underlying code depends on them having these numbers
// */
//
// /**
// * Lower bound
// * @stable ICU 2.6
// */
// public static final int LOWER = 0;
//
// /**
// * Upper bound that will match strings of exact size
// * @stable ICU 2.6
// */
// public static final int UPPER = 1;
//
// /**
// * Upper bound that will match all the strings that have the same
// * initial substring as the given string
// * @stable ICU 2.6
// */
// public static final int UPPER_LONG = 2;
//
// /**
// * Number of bound mode
// * @stable ICU 2.6
// */
// public static final int COUNT = 3;
//
// /**
// * Private Constructor
// */
// ///CLOVER:OFF
// private BoundMode(){}
// ///CLOVER:ON
// }
// public constructor ---------------------------------------------------
// /**
// * CollationKey constructor.
// * This constructor is given public access, unlike the JDK version, to
// * allow access to users extending the Collator class. See
// * {@link Collator#getCollationKey(String)}.
// * @param source string this CollationKey is to represent
// * @param key array of bytes that represent the collation order of argument
// * source terminated by a null
// * @see Collator
// * @stable ICU 2.8
// */
// public CollationKey(String source, byte key[])
// {
// throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
// }
// /**
// * CollationKey constructor that forces key to release its internal byte
// * array for adoption. key will have a null byte array after this
// * construction.
// * @param source string this CollationKey is to represent
// * @param key RawCollationKey object that represents the collation order of
// * argument source.
// * @see Collator
// * @see RawCollationKey
// * @stable ICU 2.8
// */
// public CollationKey(String source, RawCollationKey key)
// {
// throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
// }
// public getters -------------------------------------------------------
/**
* Return the source string that this CollationKey represents.
* @return source string that this CollationKey represents
* @stable ICU 2.8
*/
public String getSourceString()
{
return key.getSourceString();
}
/**
* <p>Duplicates and returns the value of this CollationKey as a sequence
* of big-endian bytes terminated by a null.</p>
*
* <p>If two CollationKeys can be legitimately compared, then one can
* compare the byte arrays of each to obtain the same result, e.g.
* <pre>
* byte key1[] = collationkey1.toByteArray();
* byte key2[] = collationkey2.toByteArray();
* int key, targetkey;
* int i = 0;
* do {
* key = key1[i] & 0xFF;
* targetkey = key2[i] & 0xFF;
* if (key &lt; targetkey) {
* System.out.println("String 1 is less than string 2");
* return;
* }
* if (targetkey &lt; key) {
* System.out.println("String 1 is more than string 2");
* }
* i ++;
* } while (key != 0 && targetKey != 0);
*
* System.out.println("Strings are equal.");
* </pre>
* </p>
* @return CollationKey value in a sequence of big-endian byte bytes
* terminated by a null.
* @stable ICU 2.8
*/
public byte[] toByteArray()
{
return key.toByteArray();
}
// public other methods -------------------------------------------------
/**
* <p>Compare this CollationKey to another CollationKey. The
* collation rules of the Collator that created this key are
* applied.</p>
*
* <p><strong>Note:</strong> Comparison between CollationKeys
* created by different Collators might return incorrect
* results. See class documentation.</p>
*
* @param target target CollationKey
* @return an integer value. If the value is less than zero this CollationKey
* is less than than target, if the value is zero they are equal, and
* if the value is greater than zero this CollationKey is greater
* than target.
* @exception NullPointerException is thrown if argument is null.
* @see Collator#compare(String, String)
* @stable ICU 2.8
*/
public int compareTo(CollationKey target)
{
return key.compareTo(target.key);
}
/**
* <p>Compare this CollationKey and the specified Object for
* equality. The collation rules of the Collator that created
* this key are applied.</p>
*
* <p>See note in compareTo(CollationKey) for warnings about
* possible incorrect results.</p>
*
* @param target the object to compare to.
* @return true if the two keys compare as equal, false otherwise.
* @see #compareTo(CollationKey)
* @exception ClassCastException is thrown when the argument is not
* a CollationKey. NullPointerException is thrown when the argument
* is null.
* @stable ICU 2.8
*/
public boolean equals(Object target)
{
if (!(target instanceof CollationKey)) {
return false;
}
return equals((CollationKey)target);
}
/**
* <p>
* Compare this CollationKey and the argument target CollationKey for
* equality.
* The collation
* rules of the Collator object which created these objects are applied.
* </p>
* <p>
* See note in compareTo(CollationKey) for warnings of incorrect results
* </p>
* @param target the CollationKey to compare to.
* @return true if two objects are equal, false otherwise.
* @exception NullPointerException is thrown when the argument is null.
* @stable ICU 2.8
*/
public boolean equals(CollationKey target)
{
return key.equals(target.key);
}
/**
* <p>Returns a hash code for this CollationKey. The hash value is calculated
* on the key itself, not the String from which the key was created. Thus
* if x and y are CollationKeys, then x.hashCode(x) == y.hashCode()
* if x.equals(y) is true. This allows language-sensitive comparison in a
* hash table.
* </p>
* @return the hash value.
* @stable ICU 2.8
*/
public int hashCode()
{
return key.hashCode();
}
// /**
// * <p>
// * Produce a bound for the sort order of a given collation key and a
// * strength level. This API does not attempt to find a bound for the
// * CollationKey String representation, hence null will be returned in its
// * place.
// * </p>
// * <p>
// * Resulting bounds can be used to produce a range of strings that are
// * between upper and lower bounds. For example, if bounds are produced
// * for a sortkey of string "smith", strings between upper and lower
// * bounds with primary strength would include "Smith", "SMITH", "sMiTh".
// * </p>
// * <p>
// * There are two upper bounds that can be produced. If BoundMode.UPPER
// * is produced, strings matched would be as above. However, if a bound
// * is produced using BoundMode.UPPER_LONG is used, the above example will
// * also match "Smithsonian" and similar.
// * </p>
// * <p>
// * For more on usage, see example in test procedure
// * <a href="http://source.icu-project.org/repos/icu/icu4j/trunk/src/com/ibm/icu/dev/test/collator/CollationAPITest.java">
// * src/com/ibm/icu/dev/test/collator/CollationAPITest/TestBounds.
// * </a>
// * </p>
// * <p>
// * Collation keys produced may be compared using the <TT>compare</TT> API.
// * </p>
// * @param boundType Mode of bound required. It can be BoundMode.LOWER, which
// * produces a lower inclusive bound, BoundMode.UPPER, that
// * produces upper bound that matches strings of the same
// * length or BoundMode.UPPER_LONG that matches strings that
// * have the same starting substring as the source string.
// * @param noOfLevels Strength levels required in the resulting bound
// * (for most uses, the recommended value is PRIMARY). This
// * strength should be less than the maximum strength of
// * this CollationKey.
// * See users guide for explanation on the strength levels a
// * collation key can have.
// * @return the result bounded CollationKey with a valid sort order but
// * a null String representation.
// * @exception IllegalArgumentException thrown when the strength level
// * requested is higher than or equal to the strength in this
// * CollationKey.
// * In the case of an Exception, information
// * about the maximum strength to use will be returned in the
// * Exception. The user can then call getBound() again with the
// * appropriate strength.
// * @see CollationKey
// * @see CollationKey.BoundMode
// * @see Collator#PRIMARY
// * @see Collator#SECONDARY
// * @see Collator#TERTIARY
// * @see Collator#QUATERNARY
// * @see Collator#IDENTICAL
// * @stable ICU 2.6
// */
// public CollationKey getBound(int boundType, int noOfLevels)
// {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* <p>
* Merges this CollationKey with another. Only the sorting order of the
* CollationKeys will be merged. This API does not attempt to merge the
* String representations of the CollationKeys, hence null will be returned
* as the String representation.
* </p>
* <p>
* The strength levels are merged with their corresponding counterparts
* (PRIMARIES with PRIMARIES, SECONDARIES with SECONDARIES etc.).
* </p>
* <p>
* The merged String representation of the result CollationKey will be a
* concatenation of the String representations of the 2 source
* CollationKeys.
* </p>
* <p>
* Between the values from the same level a separator is inserted.
* example (uncompressed):
* <pre>
* 191B1D 01 050505 01 910505 00 and 1F2123 01 050505 01 910505 00
* will be merged as
* 191B1D 02 1F212301 050505 02 050505 01 910505 02 910505 00
* </pre>
* </p>
* <p>
* This allows for concatenating of first and last names for sorting, among
* other things.
* </p>
* </p>
* @param source CollationKey to merge with
* @return a CollationKey that contains the valid merged sorting order
* with a null String representation,
* i.e. <tt>new CollationKey(null, merge_sort_order)</tt>
* @exception IllegalArgumentException thrown if source CollationKey
* argument is null or of 0 length.
* @stable ICU 2.6
*/
public CollationKey merge(CollationKey source)
{
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
}
}

View file

@ -1,845 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 1996-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.text;
import java.io.Serializable;
import java.util.Locale;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.ULocale.Category;
/**
* {@icuenhanced java.text.DateFormatSymbols}.{@icu _usage_}
*
* <p><code>DateFormatSymbols</code> is a public class for encapsulating
* localizable date-time formatting data, such as the names of the
* months, the names of the days of the week, and the time zone data.
* <code>DateFormat</code> and <code>SimpleDateFormat</code> both use
* <code>DateFormatSymbols</code> to encapsulate this information.
*
* <p>Typically you shouldn't use <code>DateFormatSymbols</code> directly.
* Rather, you are encouraged to create a date-time formatter with the
* <code>DateFormat</code> class's factory methods: <code>getTimeInstance</code>,
* <code>getDateInstance</code>, or <code>getDateTimeInstance</code>.
* These methods automatically create a <code>DateFormatSymbols</code> for
* the formatter so that you don't have to. After the
* formatter is created, you may modify its format pattern using the
* <code>setPattern</code> method. For more information about
* creating formatters using <code>DateFormat</code>'s factory methods,
* see {@link DateFormat}.
*
* <p>If you decide to create a date-time formatter with a specific
* format pattern for a specific locale, you can do so with:
* <blockquote>
* <pre>
* new SimpleDateFormat(aPattern, new DateFormatSymbols(aLocale)).
* </pre>
* </blockquote>
*
* <p><code>DateFormatSymbols</code> objects are clonable. When you obtain
* a <code>DateFormatSymbols</code> object, feel free to modify the
* date-time formatting data. For instance, you can replace the localized
* date-time format pattern characters with the ones that you feel easy
* to remember. Or you can change the representative cities
* to your favorite ones.
*
* <p>New <code>DateFormatSymbols</code> subclasses may be added to support
* <code>SimpleDateFormat</code> for date-time formatting for additional locales.
*
* @see DateFormat
* @see SimpleDateFormat
* @see com.ibm.icu.util.SimpleTimeZone
* @author Chen-Lieh Huang
* @stable ICU 2.0
*/
public class DateFormatSymbols implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
/** @internal */
public java.text.DateFormatSymbols dfs;
/** @internal */
public DateFormatSymbols(java.text.DateFormatSymbols delegate) {
this.dfs = delegate;
}
// TODO make sure local pattern char string is 18 characters long,
// that is, that it encompasses the new 'u' char for
// EXTENDED_YEAR. Two options: 1. Make sure resource data is
// correct; 2. Make code add in 'u' at end if len == 17.
// Constants for context
/**
* {@icu} Constant for context.
* @stable ICU 3.6
*/
public static final int FORMAT = 0;
/**
* {@icu} Constant for context.
* @stable ICU 3.6
*/
public static final int STANDALONE = 1;
/**
* {@icu} Constant for context.
* @internal
* @deprecated This API is ICU internal only.
*/
public static final int DT_CONTEXT_COUNT = 2;
// Constants for width
/**
* {@icu} Constant for width.
* @stable ICU 3.6
*/
public static final int ABBREVIATED = 0;
/**
* {@icu} Constant for width.
* @stable ICU 3.6
*/
public static final int WIDE = 1;
/**
* {@icu} Constant for width.
* @stable ICU 3.6
*/
public static final int NARROW = 2;
/**
* {@icu} Constant for width.
* @internal
* @deprecated This API is ICU internal only.
*/
public static final int DT_WIDTH_COUNT = 3;
/**
* Constructs a DateFormatSymbols object by loading format data from
* resources for the default locale.
*
* @throws java.util.MissingResourceException if the resources for the default locale
* cannot be found or cannot be loaded.
* @stable ICU 2.0
*/
public DateFormatSymbols()
{
this(new java.text.DateFormatSymbols(ULocale.getDefault(Category.FORMAT).toLocale()));
}
/**
* Constructs a DateFormatSymbols object by loading format data from
* resources for the given locale.
*
* @throws java.util.MissingResourceException if the resources for the specified
* locale cannot be found or cannot be loaded.
* @stable ICU 2.0
*/
public DateFormatSymbols(Locale locale)
{
this(new java.text.DateFormatSymbols(locale));
}
/**
* {@icu} Constructs a DateFormatSymbols object by loading format data from
* resources for the given ulocale.
*
* @throws java.util.MissingResourceException if the resources for the specified
* locale cannot be found or cannot be loaded.
* @stable ICU 3.2
*/
public DateFormatSymbols(ULocale locale)
{
this(new java.text.DateFormatSymbols(locale.toLocale()));
}
/**
* Returns a DateFormatSymbols instance for the default locale.
*
* {@icunote} Unlike <code>java.text.DateFormatSymbols#getInstance</code>,
* this method simply returns <code>new com.ibm.icu.text.DateFormatSymbols()</code>.
* ICU does not support <code>DateFormatSymbolsProvider</code> introduced in Java 6
* or its equivalent implementation for now.
*
* @return A DateFormatSymbols instance.
* @stable ICU 3.8
*/
public static DateFormatSymbols getInstance() {
return new DateFormatSymbols();
}
/**
* Returns a DateFormatSymbols instance for the given locale.
*
* {@icunote} Unlike <code>java.text.DateFormatSymbols#getInstance</code>,
* this method simply returns <code>new com.ibm.icu.text.DateFormatSymbols(locale)</code>.
* ICU does not support <code>DateFormatSymbolsProvider</code> introduced in Java 6
* or its equivalent implementation for now.
*
* @param locale the locale.
* @return A DateFormatSymbols instance.
* @stable ICU 3.8
*/
public static DateFormatSymbols getInstance(Locale locale) {
return new DateFormatSymbols(new java.text.DateFormatSymbols(locale));
}
/**
* {@icu} Returns a DateFormatSymbols instance for the given locale.
*
* {@icunote} Unlike <code>java.text.DateFormatSymbols#getInstance</code>,
* this method simply returns <code>new com.ibm.icu.text.DateFormatSymbols(locale)</code>.
* ICU does not support <code>DateFormatSymbolsProvider</code> introduced in Java 6
* or its equivalent implementation for now.
*
* @param locale the locale.
* @return A DateFormatSymbols instance.
* @stable ICU 3.8
*/
public static DateFormatSymbols getInstance(ULocale locale) {
return new DateFormatSymbols(new java.text.DateFormatSymbols(locale.toLocale()));
}
/**
* Returns an array of all locales for which the <code>getInstance</code> methods of
* this class can return localized instances.
*
* {@icunote} Unlike <code>java.text.DateFormatSymbols#getAvailableLocales</code>,
* this method simply returns the array of <code>Locale</code>s available in this
* class. ICU does not support <code>DateFormatSymbolsProvider</code> introduced in
* Java 6 or its equivalent implementation for now.
*
* @return An array of <code>Locale</code>s for which localized
* <code>DateFormatSymbols</code> instances are available.
* @stable ICU 3.8
*/
public static Locale[] getAvailableLocales() {
return java.text.DateFormat.getAvailableLocales();
}
/**
* {@icu} Returns an array of all locales for which the <code>getInstance</code>
* methods of this class can return localized instances.
*
* {@icunote} Unlike <code>java.text.DateFormatSymbols#getAvailableLocales</code>,
* this method simply returns the array of <code>ULocale</code>s available in this
* class. ICU does not support <code>DateFormatSymbolsProvider</code> introduced in
* Java 6 or its equivalent implementation for now.
*
* @return An array of <code>ULocale</code>s for which localized
* <code>DateFormatSymbols</code> instances are available.
* @draft ICU 3.8 (retain)
* @provisional This API might change or be removed in a future release.
*/
public static ULocale[] getAvailableULocales() {
Locale[] locales = getAvailableLocales();
ULocale[] ulocales = new ULocale[locales.length];
for (int i = 0; i < locales.length; ++i) {
ulocales[i] = ULocale.forLocale(locales[i]);
}
return ulocales;
}
/**
* Returns era strings. For example: "AD" and "BC".
* @return the era strings.
* @stable ICU 2.0
*/
public String[] getEras() {
return dfs.getEras();
}
/**
* Sets era strings. For example: "AD" and "BC".
* @param newEras the new era strings.
* @stable ICU 2.0
*/
public void setEras(String[] newEras) {
dfs.setEras(newEras);
}
/**
* {@icu} Returns era name strings. For example: "Anno Domini" and "Before Christ".
* @return the era strings.
* @stable ICU 3.4
*/
public String[] getEraNames() {
return getEras(); // Java has no distinction between era strings and era name strings
}
/**
* {@icu} Sets era name strings. For example: "Anno Domini" and "Before Christ".
* @param newEraNames the new era strings.
* @stable ICU 3.8
*/
public void setEraNames(String[] newEraNames) {
setEras(newEraNames); // Java has no distinction between era strings and era name strings
}
/**
* Returns month strings. For example: "January", "February", etc.
* @return the month strings.
* @stable ICU 2.0
*/
public String[] getMonths() {
return dfs.getMonths();
}
/**
* Returns month strings. For example: "January", "February", etc.
* @param context The month context, FORMAT or STANDALONE.
* @param width The width or the returned month string,
* either WIDE, ABBREVIATED, or NARROW.
* @return the month strings.
* @stable ICU 3.4
*/
public String[] getMonths(int context, int width) {
// JDK does not support context / narrow months
switch (width) {
case WIDE:
return dfs.getMonths();
case ABBREVIATED:
case NARROW:
return dfs.getShortMonths();
default:
throw new IllegalArgumentException("Unsupported width argument value");
}
}
/**
* Sets month strings. For example: "January", "February", etc.
* @param newMonths the new month strings.
* @stable ICU 2.0
*/
public void setMonths(String[] newMonths) {
dfs.setMonths(newMonths);
}
/**
* Sets month strings. For example: "January", "February", etc.
* @param newMonths the new month strings.
* @param context The formatting context, FORMAT or STANDALONE.
* @param width The width of the month string,
* either WIDE, ABBREVIATED, or NARROW.
* @stable ICU 3.8
*/
public void setMonths(String[] newMonths, int context, int width) {
// JDK does not support context / narrow months
switch (width) {
case WIDE:
dfs.setMonths(newMonths);
break;
case ABBREVIATED:
case NARROW:
dfs.setShortMonths(newMonths);
break;
default:
throw new IllegalArgumentException("Unsupported width argument value");
}
}
/**
* Returns short month strings. For example: "Jan", "Feb", etc.
* @return the short month strings.
* @stable ICU 2.0
*/
public String[] getShortMonths() {
return dfs.getShortMonths();
}
/**
* Sets short month strings. For example: "Jan", "Feb", etc.
* @param newShortMonths the new short month strings.
* @stable ICU 2.0
*/
public void setShortMonths(String[] newShortMonths) {
dfs.setShortMonths(newShortMonths);
}
/**
* Returns weekday strings. For example: "Sunday", "Monday", etc.
* @return the weekday strings. Use <code>Calendar.SUNDAY</code>,
* <code>Calendar.MONDAY</code>, etc. to index the result array.
* @stable ICU 2.0
*/
public String[] getWeekdays() {
return dfs.getWeekdays();
}
/**
* Returns weekday strings. For example: "Sunday", "Monday", etc.
* @return the weekday strings. Use <code>Calendar.SUNDAY</code>,
* <code>Calendar.MONDAY</code>, etc. to index the result array.
* @param context Formatting context, either FORMAT or STANDALONE.
* @param width Width of strings to be returned, either
* WIDE, ABBREVIATED, or NARROW
* @stable ICU 3.4
*/
public String[] getWeekdays(int context, int width) {
// JDK does not support context / narrow weekdays
switch (width) {
case WIDE:
return dfs.getWeekdays();
case ABBREVIATED:
case NARROW:
return dfs.getShortWeekdays();
default:
throw new IllegalArgumentException("Unsupported width argument value");
}
}
/**
* Sets weekday strings. For example: "Sunday", "Monday", etc.
* @param newWeekdays The new weekday strings.
* @param context The formatting context, FORMAT or STANDALONE.
* @param width The width of the strings,
* either WIDE, ABBREVIATED, or NARROW.
* @stable ICU 3.8
*/
public void setWeekdays(String[] newWeekdays, int context, int width) {
// JDK does not support context / narrow weekdays
switch (width) {
case WIDE:
dfs.setWeekdays(newWeekdays);
break;
case ABBREVIATED:
case NARROW:
dfs.setShortWeekdays(newWeekdays);
break;
default:
throw new IllegalArgumentException("Unsupported width argument value");
}
}
/**
* Sets weekday strings. For example: "Sunday", "Monday", etc.
* @param newWeekdays the new weekday strings. The array should
* be indexed by <code>Calendar.SUNDAY</code>,
* <code>Calendar.MONDAY</code>, etc.
* @stable ICU 2.0
*/
public void setWeekdays(String[] newWeekdays) {
dfs.setWeekdays(newWeekdays);
}
/**
* Returns short weekday strings. For example: "Sun", "Mon", etc.
* @return the short weekday strings. Use <code>Calendar.SUNDAY</code>,
* <code>Calendar.MONDAY</code>, etc. to index the result array.
* @stable ICU 2.0
*/
public String[] getShortWeekdays() {
return dfs.getShortWeekdays();
}
/**
* Sets short weekday strings. For example: "Sun", "Mon", etc.
* @param newShortWeekdays the new short weekday strings. The array should
* be indexed by <code>Calendar.SUNDAY</code>,
* <code>Calendar.MONDAY</code>, etc.
* @stable ICU 2.0
*/
public void setShortWeekdays(String[] newShortWeekdays) {
dfs.setShortWeekdays(newShortWeekdays);
}
// /**
// * {@icu} Returns quarter strings. For example: "1st Quarter", "2nd Quarter", etc.
// * @param context The quarter context, FORMAT or STANDALONE.
// * @param width The width or the returned quarter string,
// * either WIDE or ABBREVIATED. There are no NARROW quarters.
// * @return the quarter strings.
// * @stable ICU 3.6
// */
// public String[] getQuarters(int context, int width) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Sets quarter strings. For example: "1st Quarter", "2nd Quarter", etc.
// * @param newQuarters the new quarter strings.
// * @param context The formatting context, FORMAT or STANDALONE.
// * @param width The width of the quarter string,
// * either WIDE or ABBREVIATED. There are no NARROW quarters.
// * @stable ICU 3.8
// */
// public void setQuarters(String[] newQuarters, int context, int width) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Returns am/pm strings. For example: "AM" and "PM".
* @return the weekday strings.
* @stable ICU 2.0
*/
public String[] getAmPmStrings() {
return dfs.getAmPmStrings();
}
/**
* Sets am/pm strings. For example: "AM" and "PM".
* @param newAmpms the new ampm strings.
* @stable ICU 2.0
*/
public void setAmPmStrings(String[] newAmpms) {
dfs.setAmPmStrings(newAmpms);
}
/**
* Returns timezone strings.
* @return the timezone strings.
* @stable ICU 2.0
*/
public String[][] getZoneStrings() {
return dfs.getZoneStrings();
}
/**
* Sets timezone strings.
* @param newZoneStrings the new timezone strings.
* @stable ICU 2.0
*/
public void setZoneStrings(String[][] newZoneStrings) {
dfs.setZoneStrings(newZoneStrings);
}
/**
* Returns localized date-time pattern characters. For example: 'u', 't', etc.
*
* <p>Note: ICU no longer provides localized date-time pattern characters for a locale
* starting ICU 3.8. This method returns the non-localized date-time pattern
* characters unless user defined localized data is set by setLocalPatternChars.
* @return the localized date-time pattern characters.
* @stable ICU 2.0
*/
public String getLocalPatternChars() {
return dfs.getLocalPatternChars();
}
/**
* Sets localized date-time pattern characters. For example: 'u', 't', etc.
* @param newLocalPatternChars the new localized date-time
* pattern characters.
* @stable ICU 2.0
*/
public void setLocalPatternChars(String newLocalPatternChars) {
dfs.setLocalPatternChars(newLocalPatternChars);
}
/**
* Overrides clone.
* @stable ICU 2.0
*/
public Object clone()
{
return new DateFormatSymbols((java.text.DateFormatSymbols)dfs.clone());
}
/**
* Override hashCode.
* Generates a hash code for the DateFormatSymbols object.
* @stable ICU 2.0
*/
public int hashCode() {
return dfs.hashCode();
}
/**
* Overrides equals.
* @stable ICU 2.0
*/
public boolean equals(Object obj)
{
try {
return dfs.equals(((DateFormatSymbols)obj).dfs);
}
catch (Exception e) {
return false;
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// /**
// * Returns the {@link DateFormatSymbols} object that should be used to format a
// * calendar system's dates in the given locale.
// * <p>
// * <b>Subclassing:</b><br>
// * When creating a new Calendar subclass, you must create the
// * {@link ResourceBundle ResourceBundle}
// * containing its {@link DateFormatSymbols DateFormatSymbols} in a specific place.
// * The resource bundle name is based on the calendar's fully-specified
// * class name, with ".resources" inserted at the end of the package name
// * (just before the class name) and "Symbols" appended to the end.
// * For example, the bundle corresponding to "com.ibm.icu.util.HebrewCalendar"
// * is "com.ibm.icu.impl.data.HebrewCalendarSymbols".
// * <p>
// * Within the ResourceBundle, this method searches for five keys:
// * <ul>
// * <li><b>DayNames</b> -
// * An array of strings corresponding to each possible
// * value of the <code>DAY_OF_WEEK</code> field. Even though
// * <code>DAY_OF_WEEK</code> starts with <code>SUNDAY</code> = 1,
// * This array is 0-based; the name for Sunday goes in the
// * first position, at index 0. If this key is not found
// * in the bundle, the day names are inherited from the
// * default <code>DateFormatSymbols</code> for the requested locale.
// *
// * <li><b>DayAbbreviations</b> -
// * An array of abbreviated day names corresponding
// * to the values in the "DayNames" array. If this key
// * is not found in the resource bundle, the "DayNames"
// * values are used instead. If neither key is found,
// * the day abbreviations are inherited from the default
// * <code>DateFormatSymbols</code> for the locale.
// *
// * <li><b>MonthNames</b> -
// * An array of strings corresponding to each possible
// * value of the <code>MONTH</code> field. If this key is not found
// * in the bundle, the month names are inherited from the
// * default <code>DateFormatSymbols</code> for the requested locale.
// *
// * <li><b>MonthAbbreviations</b> -
// * An array of abbreviated day names corresponding
// * to the values in the "MonthNames" array. If this key
// * is not found in the resource bundle, the "MonthNames"
// * values are used instead. If neither key is found,
// * the day abbreviations are inherited from the default
// * <code>DateFormatSymbols</code> for the locale.
// *
// * <li><b>Eras</b> -
// * An array of strings corresponding to each possible
// * value of the <code>ERA</code> field. If this key is not found
// * in the bundle, the era names are inherited from the
// * default <code>DateFormatSymbols</code> for the requested locale.
// * </ul>
// * <p>
// * @param cal The calendar system whose date format symbols are desired.
// * @param locale The locale whose symbols are desired.
// *
// * @see DateFormatSymbols#DateFormatSymbols(java.util.Locale)
// * @stable ICU 2.0
// */
// public DateFormatSymbols(Calendar cal, Locale locale) {
// throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
// }
// /**
// * Returns the {@link DateFormatSymbols} object that should be used to format a
// * calendar system's dates in the given locale.
// * <p>
// * <b>Subclassing:</b><br>
// * When creating a new Calendar subclass, you must create the
// * {@link ResourceBundle ResourceBundle}
// * containing its {@link DateFormatSymbols DateFormatSymbols} in a specific place.
// * The resource bundle name is based on the calendar's fully-specified
// * class name, with ".resources" inserted at the end of the package name
// * (just before the class name) and "Symbols" appended to the end.
// * For example, the bundle corresponding to "com.ibm.icu.util.HebrewCalendar"
// * is "com.ibm.icu.impl.data.HebrewCalendarSymbols".
// * <p>
// * Within the ResourceBundle, this method searches for five keys:
// * <ul>
// * <li><b>DayNames</b> -
// * An array of strings corresponding to each possible
// * value of the <code>DAY_OF_WEEK</code> field. Even though
// * <code>DAY_OF_WEEK</code> starts with <code>SUNDAY</code> = 1,
// * This array is 0-based; the name for Sunday goes in the
// * first position, at index 0. If this key is not found
// * in the bundle, the day names are inherited from the
// * default <code>DateFormatSymbols</code> for the requested locale.
// *
// * <li><b>DayAbbreviations</b> -
// * An array of abbreviated day names corresponding
// * to the values in the "DayNames" array. If this key
// * is not found in the resource bundle, the "DayNames"
// * values are used instead. If neither key is found,
// * the day abbreviations are inherited from the default
// * <code>DateFormatSymbols</code> for the locale.
// *
// * <li><b>MonthNames</b> -
// * An array of strings corresponding to each possible
// * value of the <code>MONTH</code> field. If this key is not found
// * in the bundle, the month names are inherited from the
// * default <code>DateFormatSymbols</code> for the requested locale.
// *
// * <li><b>MonthAbbreviations</b> -
// * An array of abbreviated day names corresponding
// * to the values in the "MonthNames" array. If this key
// * is not found in the resource bundle, the "MonthNames"
// * values are used instead. If neither key is found,
// * the day abbreviations are inherited from the default
// * <code>DateFormatSymbols</code> for the locale.
// *
// * <li><b>Eras</b> -
// * An array of strings corresponding to each possible
// * value of the <code>ERA</code> field. If this key is not found
// * in the bundle, the era names are inherited from the
// * default <code>DateFormatSymbols</code> for the requested locale.
// * </ul>
// * <p>
// * @param cal The calendar system whose date format symbols are desired.
// * @param locale The ulocale whose symbols are desired.
// *
// * @see DateFormatSymbols#DateFormatSymbols(java.util.Locale)
// * @stable ICU 3.2
// */
// public DateFormatSymbols(Calendar cal, ULocale locale) {
// throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
// }
// /**
// * Variant of DateFormatSymbols(Calendar, Locale) that takes the Calendar class
// * instead of a Calendar instance.
// * @see #DateFormatSymbols(Calendar, Locale)
// * @stable ICU 2.2
// */
// public DateFormatSymbols(Class<? extends Calendar> calendarClass, Locale locale) {
// throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
// }
// /**
// * Variant of DateFormatSymbols(Calendar, ULocale) that takes the Calendar class
// * instead of a Calendar instance.
// * @see #DateFormatSymbols(Calendar, Locale)
// * @stable ICU 3.2
// */
// public DateFormatSymbols(Class<? extends Calendar> calendarClass, ULocale locale) {
// throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
// }
// /**
// * Fetches a custom calendar's DateFormatSymbols out of the given resource
// * bundle. Symbols that are not overridden are inherited from the
// * default DateFormatSymbols for the locale.
// * @see DateFormatSymbols#DateFormatSymbols(java.util.Locale)
// * @stable ICU 2.0
// */
// public DateFormatSymbols(ResourceBundle bundle, Locale locale) {
// throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
// }
// /**
// * Fetches a custom calendar's DateFormatSymbols out of the given resource
// * bundle. Symbols that are not overridden are inherited from the
// * default DateFormatSymbols for the locale.
// * @see DateFormatSymbols#DateFormatSymbols(java.util.Locale)
// * @stable ICU 3.2
// */
// public DateFormatSymbols(ResourceBundle bundle, ULocale locale) {
// throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
// }
// /**
// * Finds the ResourceBundle containing the date format information for
// * a specified calendar subclass in a given locale.
// * <p>
// * The resource bundle name is based on the calendar's fully-specified
// * class name, with ".resources" inserted at the end of the package name
// * (just before the class name) and "Symbols" appended to the end.
// * For example, the bundle corresponding to "com.ibm.icu.util.HebrewCalendar"
// * is "com.ibm.icu.impl.data.HebrewCalendarSymbols".
// * <p>
// * <b>Note:</b>Because of the structural changes in the ICU locale bundle,
// * this API no longer works as described. This method always returns null.
// * @deprecated ICU 4.0
// */
// // This API was formerly @stable ICU 2.0
// static public ResourceBundle getDateFormatBundle(Class<? extends Calendar> calendarClass,
// Locale locale) throws MissingResourceException {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Finds the ResourceBundle containing the date format information for
// * a specified calendar subclass in a given locale.
// * <p>
// * The resource bundle name is based on the calendar's fully-specified
// * class name, with ".resources" inserted at the end of the package name
// * (just before the class name) and "Symbols" appended to the end.
// * For example, the bundle corresponding to "com.ibm.icu.util.HebrewCalendar"
// * is "com.ibm.icu.impl.data.HebrewCalendarSymbols".
// * <p>
// * <b>Note:</b>Because of the structural changes in the ICU locale bundle,
// * this API no longer works as described. This method always returns null.
// * @deprecated ICU 4.0
// */
// // This API was formerly @stable ICU 3.2
// static public ResourceBundle getDateFormatBundle(Class<? extends Calendar> calendarClass,
// ULocale locale) throws MissingResourceException {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Variant of getDateFormatBundle(java.lang.Class, java.util.Locale) that takes
// * a Calendar instance instead of a Calendar class.
// * <p>
// * <b>Note:</b>Because of the structural changes in the ICU locale bundle,
// * this API no longer works as described. This method always returns null.
// * @see #getDateFormatBundle(java.lang.Class, java.util.Locale)
// * @deprecated ICU 4.0
// */
// // This API was formerly @stable ICU 2.2
// public static ResourceBundle getDateFormatBundle(Calendar cal, Locale locale) throws MissingResourceException {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Variant of getDateFormatBundle(java.lang.Class, java.util.Locale) that takes
// * a Calendar instance instead of a Calendar class.
// * <p>
// * <b>Note:</b>Because of the structural changes in the ICU locale bundle,
// * this API no longer works as described. This method always returns null.
// * @see #getDateFormatBundle(java.lang.Class, java.util.Locale)
// * @deprecated ICU 4.0
// */
// // This API was formerly @stable ICU 3.2
// public static ResourceBundle getDateFormatBundle(Calendar cal, ULocale locale) throws MissingResourceException {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Returns the locale that was used to create this object, or null.
// * This may may differ from the locale requested at the time of
// * this object's creation. For example, if an object is created
// * for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
// * drawn from <tt>en</tt> (the <i>actual</i> locale), and
// * <tt>en_US</tt> may be the most specific locale that exists (the
// * <i>valid</i> locale).
// *
// * <p>Note: This method will be implemented in ICU 3.0; ICU 2.8
// * contains a partial preview implementation. The * <i>actual</i>
// * locale is returned correctly, but the <i>valid</i> locale is
// * not, in most cases.
// * @param type type of information requested, either {@link
// * com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
// * com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
// * @return the information specified by <i>type</i>, or null if
// * this object was not constructed from locale data.
// * @see com.ibm.icu.util.ULocale
// * @see com.ibm.icu.util.ULocale#VALID_LOCALE
// * @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
// * @draft ICU 2.8 (retain)
// * @provisional This API might change or be removed in a future release.
// */
// public final ULocale getLocale(ULocale.Type type) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
}

View file

@ -1,710 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 1996-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.text;
import java.io.Serializable;
import java.util.Locale;
import com.ibm.icu.util.Currency;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.ULocale.Category;
/**
* This class represents the set of symbols (such as the decimal separator, the
* grouping separator, and so on) needed by <code>DecimalFormat</code> to format
* numbers. <code>DecimalFormat</code> creates for itself an instance of
* <code>DecimalFormatSymbols</code> from its locale data. If you need to
* change any of these symbols, you can get the
* <code>DecimalFormatSymbols</code> object from your <code>DecimalFormat</code>
* and modify it.
*
* <p><strong>This is an enhanced version of <code>DecimalFormatSymbols</code> that
* is based on the standard version in the JDK. New or changed functionality
* is labeled
* <strong><font face=helvetica color=red>NEW</font></strong>.</strong>
*
* @see java.util.Locale
* @see DecimalFormat
* @author Mark Davis
* @author Alan Liu
* @stable ICU 2.0
*/
final public class DecimalFormatSymbols implements Cloneable, Serializable {
private static final long serialVersionUID =1L;
/**
* @internal
*/
public final java.text.DecimalFormatSymbols dfs;
/**
* @internal
*/
public DecimalFormatSymbols(java.text.DecimalFormatSymbols delegate) {
this.dfs = delegate;
}
/**
* Create a DecimalFormatSymbols object for the default locale.
* @stable ICU 2.0
*/
public DecimalFormatSymbols() {
this(new java.text.DecimalFormatSymbols(ULocale.getDefault(Category.FORMAT).toLocale()));
}
/**
* Create a DecimalFormatSymbols object for the given locale.
* @param locale the locale
* @stable ICU 2.0
*/
public DecimalFormatSymbols(Locale locale) {
this(new java.text.DecimalFormatSymbols(locale));
}
/**
* Create a DecimalFormatSymbols object for the given locale.
* @param locale the locale
* @stable ICU 3.2
*/
public DecimalFormatSymbols(ULocale locale) {
this(new java.text.DecimalFormatSymbols(locale.toLocale()));
}
/**
* Returns a DecimalFormatSymbols instance for the default locale.
*
* <p><strong>Note:</strong> Unlike
* <code>java.text.DecimalFormatSymbols#getInstance</code>, this method simply returns
* <code>new com.ibm.icu.text.DecimalFormatSymbols()</code>. ICU currently does not
* support <code>DecimalFormatSymbolsProvider</code>, which was introduced in Java 6.
*
* @return A DecimalFormatSymbols instance.
* @stable ICU 3.8
*/
public static DecimalFormatSymbols getInstance() {
return new DecimalFormatSymbols();
}
/**
* Returns a DecimalFormatSymbols instance for the given locale.
*
* <p><strong>Note:</strong> Unlike
* <code>java.text.DecimalFormatSymbols#getInstance</code>, this method simply returns
* <code>new com.ibm.icu.text.DecimalFormatSymbols(locale)</code>. ICU currently does
* not support <code>DecimalFormatSymbolsProvider</code>, which was introduced in Java
* 6.
*
* @param locale the locale.
* @return A DecimalFormatSymbols instance.
* @stable ICU 3.8
*/
public static DecimalFormatSymbols getInstance(Locale locale) {
return new DecimalFormatSymbols(locale);
}
/**
* Returns a DecimalFormatSymbols instance for the given locale.
*
* <p><strong>Note:</strong> Unlike
* <code>java.text.DecimalFormatSymbols#getInstance</code>, this method simply returns
* <code>new com.ibm.icu.text.DecimalFormatSymbols(locale)</code>. ICU currently does
* not support <code>DecimalFormatSymbolsProvider</code>, which was introduced in Java
* 6.
*
* @param locale the locale.
* @return A DecimalFormatSymbols instance.
* @stable ICU 3.8
*/
public static DecimalFormatSymbols getInstance(ULocale locale) {
return new DecimalFormatSymbols(locale);
}
// /**
// * Returns an array of all locales for which the <code>getInstance</code> methods of
// * this class can return localized instances.
// *
// * <p><strong>Note:</strong> Unlike
// * <code>java.text.DecimalFormatSymbols#getAvailableLocales</code>, this method simply
// * returns the array of <code>Locale</code>s available for this class. ICU currently
// * does not support <code>DecimalFormatSymbolsProvider</code>, which was introduced in
// * Java 6.
// *
// * @return An array of <code>Locale</code>s for which localized
// * <code>DecimalFormatSymbols</code> instances are available.
// * @stable ICU 3.8
// */
// public static Locale[] getAvailableLocales() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Returns an array of all locales for which the <code>getInstance</code>
// * methods of this class can return localized instances.
// *
// * <p><strong>Note:</strong> Unlike
// * <code>java.text.DecimalFormatSymbols#getAvailableLocales</code>, this method simply
// * returns the array of <code>ULocale</code>s available in this class. ICU currently
// * does not support <code>DecimalFormatSymbolsProvider</code>, which was introduced in
// * Java 6.
// *
// * @return An array of <code>ULocale</code>s for which localized
// * <code>DecimalFormatSymbols</code> instances are available.
// * @stable ICU 3.8 (retain)
// * @provisional This API might change or be removed in a future release.
// */
// public static ULocale[] getAvailableULocales() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Return the character used for zero. Different for Arabic, etc.
* @return the character
* @stable ICU 2.0
*/
public char getZeroDigit() {
return dfs.getZeroDigit();
}
/**
* Set the character used for zero.
* @param zeroDigit the zero character.
* @stable ICU 2.0
*/
public void setZeroDigit(char zeroDigit) {
dfs.setZeroDigit(zeroDigit);
}
// /**
// * Returns the character used to represent a significant digit in a pattern.
// * @return the significant digit pattern character
// * @stable ICU 3.0
// */
// public char getSignificantDigit() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Sets the character used to represent a significant digit in a pattern.
// * @param sigDigit the significant digit pattern character
// * @stable ICU 3.0
// */
// public void setSignificantDigit(char sigDigit) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Return the character used for thousands separator. Different for French, etc.
* @return the thousands character
* @stable ICU 2.0
*/
public char getGroupingSeparator() {
return dfs.getGroupingSeparator();
}
/**
* Set the character used for thousands separator. Different for French, etc.
* @param groupingSeparator the thousands character
* @stable ICU 2.0
*/
public void setGroupingSeparator(char groupingSeparator) {
dfs.setGroupingSeparator(groupingSeparator);
}
/**
* Return the character used for decimal sign. Different for French, etc.
* @return the decimal character
* @stable ICU 2.0
*/
public char getDecimalSeparator() {
return dfs.getDecimalSeparator();
}
/**
* Set the character used for decimal sign. Different for French, etc.
* @param decimalSeparator the decimal character
* @stable ICU 2.0
*/
public void setDecimalSeparator(char decimalSeparator) {
dfs.setDecimalSeparator(decimalSeparator);
}
/**
* Return the character used for mille percent sign. Different for Arabic, etc.
* @return the mille percent character
* @stable ICU 2.0
*/
public char getPerMill() {
return dfs.getPerMill();
}
/**
* Set the character used for mille percent sign. Different for Arabic, etc.
* @param perMill the mille percent character
* @stable ICU 2.0
*/
public void setPerMill(char perMill) {
dfs.setPerMill(perMill);
}
/**
* Return the character used for percent sign. Different for Arabic, etc.
* @return the percent character
* @stable ICU 2.0
*/
public char getPercent() {
return dfs.getPercent();
}
/**
* Set the character used for percent sign. Different for Arabic, etc.
* @param percent the percent character
* @stable ICU 2.0
*/
public void setPercent(char percent) {
dfs.setPercent(percent);
}
/**
* Return the character used for a digit in a pattern.
* @return the digit pattern character
* @stable ICU 2.0
*/
public char getDigit() {
return dfs.getDigit();
}
/**
* Returns the array of characters used as digits, in order from 0 through 9
* @return The array
* @draft ICU 4.6
* @provisional This API might change or be removed in a future release.
*/
public char[] getDigits() {
char [] digitArray = new char[10];
for ( int i = 0 ; i < 10 ; i++ ) {
digitArray[i] = (char) (getZeroDigit() + i);
}
return digitArray;
}
/**
* Set the character used for a digit in a pattern.
* @param digit the digit pattern character
* @stable ICU 2.0
*/
public void setDigit(char digit) {
dfs.setDigit(digit);
}
/**
* Return the character used to separate positive and negative subpatterns
* in a pattern.
* @return the pattern separator character
* @stable ICU 2.0
*/
public char getPatternSeparator() {
return dfs.getPatternSeparator();
}
/**
* Set the character used to separate positive and negative subpatterns
* in a pattern.
* @param patternSeparator the pattern separator character
* @stable ICU 2.0
*/
public void setPatternSeparator(char patternSeparator) {
dfs.setPatternSeparator(patternSeparator);
}
/**
* Return the String used to represent infinity. Almost always left
* unchanged.
* @return the Infinity string
* @stable ICU 2.0
*/
public String getInfinity() {
return dfs.getInfinity();
}
/**
* Set the String used to represent infinity. Almost always left
* unchanged.
* @param infinity the Infinity String
* @stable ICU 2.0
*/
public void setInfinity(String infinity) {
dfs.setInfinity(infinity);
}
/**
* Return the String used to represent NaN. Almost always left
* unchanged.
* @return the NaN String
* @stable ICU 2.0
*/
public String getNaN() {
return dfs.getNaN();
}
/**
* Set the String used to represent NaN. Almost always left
* unchanged.
* @param NaN the NaN String
* @stable ICU 2.0
*/
public void setNaN(String NaN) {
dfs.setNaN(NaN);
}
/**
* Return the character used to represent minus sign. If no explicit
* negative format is specified, one is formed by prefixing
* minusSign to the positive format.
* @return the minus sign character
* @stable ICU 2.0
*/
public char getMinusSign() {
return dfs.getMinusSign();
}
/**
* Set the character used to represent minus sign. If no explicit
* negative format is specified, one is formed by prefixing
* minusSign to the positive format.
* @param minusSign the minus sign character
* @stable ICU 2.0
*/
public void setMinusSign(char minusSign) {
dfs.setMinusSign(minusSign);
}
/**
* Return the string denoting the local currency.
* @return the local currency String.
* @stable ICU 2.0
*/
public String getCurrencySymbol() {
return dfs.getCurrencySymbol();
}
/**
* Set the string denoting the local currency.
* @param currency the local currency String.
* @stable ICU 2.0
*/
public void setCurrencySymbol(String currency) {
dfs.setCurrencySymbol(currency);
}
/**
* Returns the currency symbol, for JDK 1.4 compatibility only.
* ICU clients should use the Currency API directly.
* @return the currency used, or null
* @stable ICU 3.4
*/
public Currency getCurrency() {
return new Currency(dfs.getCurrency());
}
/**
* Sets the currency.
*
* <p><strong>Note:</strong> ICU does not use the DecimalFormatSymbols for the currency
* any more. This API is present for API compatibility only.
*
* <p>This also sets the currency symbol attribute to the currency's symbol
* in the DecimalFormatSymbols' locale, and the international currency
* symbol attribute to the currency's ISO 4217 currency code.
*
* @param currency the new currency to be used
* @throws NullPointerException if <code>currency</code> is null
* @see #setCurrencySymbol
* @see #setInternationalCurrencySymbol
*
* @stable ICU 3.4
*/
public void setCurrency(Currency currency) {
dfs.setCurrency(java.util.Currency.getInstance(currency.getCurrencyCode()));
}
/**
* Return the international string denoting the local currency.
* @return the international string denoting the local currency
* @stable ICU 2.0
*/
public String getInternationalCurrencySymbol() {
return dfs.getInternationalCurrencySymbol();
}
/**
* Set the international string denoting the local currency.
* @param currency the international string denoting the local currency.
* @stable ICU 2.0
*/
public void setInternationalCurrencySymbol(String currency) {
dfs.setInternationalCurrencySymbol(currency);
}
/**
* Return the monetary decimal separator.
* @return the monetary decimal separator character
* @stable ICU 2.0
*/
public char getMonetaryDecimalSeparator() {
return dfs.getMonetaryDecimalSeparator();
}
/**
* Set the monetary decimal separator.
* @param sep the monetary decimal separator character
* @stable ICU 2.0
*/
public void setMonetaryDecimalSeparator(char sep) {
dfs.setMonetaryDecimalSeparator(sep);
}
// /**
// * {@icu} Returns the monetary grouping separator.
// * @return the monetary grouping separator character
// * @stable ICU 3.6
// */
// public char getMonetaryGroupingSeparator() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Sets the monetary decimal separator.
// * @param sep the monetary decimal separator character
// * @stable ICU 3.6
// */
// public void setMonetaryGroupingSeparator(char sep) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Returns the string used to separate the mantissa from the exponent.
// * Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
// * @return the localized exponent symbol, used in localized patterns
// * and formatted strings
// * @see #setExponentSeparator
// * @stable ICU 2.0
// */
// public String getExponentSeparator() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Sets the string used to separate the mantissa from the exponent.
// * Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
// * @param exp the localized exponent symbol, used in localized patterns
// * and formatted strings
// * @see #getExponentSeparator
// * @stable ICU 2.0
// */
// public void setExponentSeparator(String exp) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Returns the localized plus sign.
// * @return the plus sign, used in localized patterns and formatted
// * strings
// * @see #setPlusSign
// * @see #setMinusSign
// * @see #getMinusSign
// * @stable ICU 2.0
// */
// public char getPlusSign() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Sets the localized plus sign.
// * @param plus the plus sign, used in localized patterns and formatted
// * strings
// * @see #getPlusSign
// * @see #setMinusSign
// * @see #getMinusSign
// * @stable ICU 2.0
// */
// public void setPlusSign(char plus) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Returns the character used to pad numbers out to a specified width. This is
// * not the pad character itself; rather, it is the special pattern character
// * <em>preceding</em> the pad character. In the pattern "*_#,##0", '*' is the pad
// * escape, and '_' is the pad character.
// * @return the character
// * @see #setPadEscape
// * @see DecimalFormat#getFormatWidth
// * @see DecimalFormat#getPadPosition
// * @see DecimalFormat#getPadCharacter
// * @stable ICU 2.0
// */
// public char getPadEscape() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Sets the character used to pad numbers out to a specified width. This is not
// * the pad character itself; rather, it is the special pattern character
// * <em>preceding</em> the pad character. In the pattern "*_#,##0", '*' is the pad
// * escape, and '_' is the pad character.
// * @see #getPadEscape
// * @see DecimalFormat#setFormatWidth
// * @see DecimalFormat#setPadPosition
// * @see DecimalFormat#setPadCharacter
// * @stable ICU 2.0
// */
// public void setPadEscape(char c) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Indicates the currency match pattern used in {@link #getPatternForCurrencySpacing}.
// * @stable ICU 4.2
// */
// public static final int CURRENCY_SPC_CURRENCY_MATCH = 0;
//
// /**
// * {@icu} Indicates the surrounding match pattern used in {@link
// * #getPatternForCurrencySpacing}.
// * @stable ICU 4.2
// */
// public static final int CURRENCY_SPC_SURROUNDING_MATCH = 1;
//
// /**
// * {@icu} Indicates the insertion value used in {@link #getPatternForCurrencySpacing}.
// * @stable ICU 4.4
// */
// public static final int CURRENCY_SPC_INSERT = 2;
// /**
// * {@icu} Returns the desired currency spacing value. Original values come from ICU's
// * CLDR data based on the locale provided during construction, and can be null. These
// * values govern what and when text is inserted between a currency code/name/symbol
// * and the currency amount when formatting money.
// *
// * <p>For more information, see <a href="http://www.unicode.org/reports/tr35/#Currencies"
// * >UTS#35 section 5.10.2</a>.
// *
// * <p><strong>Note:</strong> ICU4J does not currently use this information.
// *
// * @param itemType one of CURRENCY_SPC_CURRENCY_MATCH, CURRENCY_SPC_SURROUNDING_MATCH
// * or CURRENCY_SPC_INSERT
// * @param beforeCurrency true to get the <code>beforeCurrency</code> values, false
// * to get the <code>afterCurrency</code> values.
// * @return the value, or null.
// * @see #setPatternForCurrencySpacing(int, boolean, String)
// * @stable ICU 4.2
// */
// public String getPatternForCurrencySpacing(int itemType, boolean beforeCurrency) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Sets the indicated currency spacing pattern or value. See {@link
// * #getPatternForCurrencySpacing} for more information.
// *
// * <p>Values for currency match and surrounding match must be {@link
// * com.ibm.icu.text.UnicodeSet} patterns. Values for insert can be any string.
// *
// * <p><strong>Note:</strong> ICU4J does not currently use this information.
// *
// * @param itemType one of CURRENCY_SPC_CURRENCY_MATCH, CURRENCY_SPC_SURROUNDING_MATCH
// * or CURRENCY_SPC_INSERT
// * @param beforeCurrency true if the pattern is for before the currency symbol.
// * false if the pattern is for after it.
// * @param pattern string to override current setting; can be null.
// * @see #getPatternForCurrencySpacing(int, boolean)
// * @stable ICU 4.2
// */
// public void setPatternForCurrencySpacing(int itemType, boolean beforeCurrency, String pattern) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Returns the locale for which this object was constructed.
// * @return the locale for which this object was constructed
// * @stable ICU 2.0
// */
// public Locale getLocale() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Returns the locale for which this object was constructed.
// * @return the locale for which this object was constructed
// * @stable ICU 3.2
// */
// public ULocale getULocale() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Returns the locale that was used to create this object, or null.
// * This may may differ from the locale requested at the time of
// * this object's creation. For example, if an object is created
// * for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
// * drawn from <tt>en</tt> (the <i>actual</i> locale), and
// * <tt>en_US</tt> may be the most specific locale that exists (the
// * <i>valid</i> locale).
// *
// * <p>Note: The <i>actual</i> locale is returned correctly, but the <i>valid</i>
// * locale is not, in most cases.
// * @param type type of information requested, either {@link
// * com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
// * com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
// * @return the information specified by <i>type</i>, or null if
// * this object was not constructed from locale data.
// * @see com.ibm.icu.util.ULocale
// * @see com.ibm.icu.util.ULocale#VALID_LOCALE
// * @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
// * @draft ICU 2.8 (retain)
// * @provisional This API might change or be removed in a future release.
// */
// public final ULocale getLocale(ULocale.Type type) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Standard override.
* @stable ICU 2.0
*/
public Object clone() {
return new DecimalFormatSymbols((java.text.DecimalFormatSymbols)dfs.clone());
}
/**
* Override equals.
* @stable ICU 2.0
*/
public boolean equals(Object obj) {
try {
return dfs.equals(((DecimalFormatSymbols)obj).dfs);
}
catch (Exception e) {
return false;
}
}
/**
* Override hashCode
* @stable ICU 2.0
*/
public int hashCode() {
return dfs.hashCode();
}
}

View file

@ -1,540 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 1996-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.text;
import java.text.AttributedCharacterIterator;
import java.text.AttributedCharacterIterator.Attribute;
import java.text.AttributedString;
import java.text.CharacterIterator;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.ULocale;
/**
* {@icuenhanced java.text.SimpleDateFormat}.{@icu _usage_}
*
* <p><code>SimpleDateFormat</code> is a concrete class for formatting and
* parsing dates in a locale-sensitive manner. It allows for formatting
* (date -> text), parsing (text -> date), and normalization.
*
* <p>
* <code>SimpleDateFormat</code> allows you to start by choosing
* any user-defined patterns for date-time formatting. However, you
* are encouraged to create a date-time formatter with either
* <code>getTimeInstance</code>, <code>getDateInstance</code>, or
* <code>getDateTimeInstance</code> in <code>DateFormat</code>. Each
* of these class methods can return a date/time formatter initialized
* with a default format pattern. You may modify the format pattern
* using the <code>applyPattern</code> methods as desired.
* For more information on using these methods, see
* {@link DateFormat}.
*
* <p>
* <strong>Time Format Syntax:</strong>
* <p>
* To specify the time format use a <em>time pattern</em> string.
* In this pattern, all ASCII letters are reserved as pattern letters,
* which are defined as the following:
* <blockquote>
* <pre>
* Symbol Meaning Presentation Example
* ------ ------- ------------ -------
* G era designator (Text) AD
* y&#x2020; year (Number) 1996
* Y* year (week of year) (Number) 1997
* u* extended year (Number) 4601
* M month in year (Text & Number) July & 07
* d day in month (Number) 10
* h hour in am/pm (1~12) (Number) 12
* H hour in day (0~23) (Number) 0
* m minute in hour (Number) 30
* s second in minute (Number) 55
* S fractional second (Number) 978
* E day of week (Text) Tuesday
* e* day of week (local 1~7) (Text & Number) Tuesday & 2
* D day in year (Number) 189
* F day of week in month (Number) 2 (2nd Wed in July)
* w week in year (Number) 27
* W week in month (Number) 2
* a am/pm marker (Text) PM
* k hour in day (1~24) (Number) 24
* K hour in am/pm (0~11) (Number) 0
* z time zone (Text) Pacific Standard Time
* Z time zone (RFC 822) (Number) -0800
* v time zone (generic) (Text) Pacific Time
* V time zone (location) (Text) United States (Los Angeles)
* g* Julian day (Number) 2451334
* A* milliseconds in day (Number) 69540000
* Q* quarter in year (Text & Number) Q1 & 01
* c* stand alone day of week (Text & Number) Tuesday & 2
* L* stand alone month (Text & Number) July & 07
* q* stand alone quarter (Text & Number) Q1 & 01
* ' escape for text (Delimiter) 'Date='
* '' single quote (Literal) 'o''clock'
* </pre>
* </blockquote>
* <tt><b>*</b></tt> These items are not supported by Java's SimpleDateFormat.<br>
* <tt><b>&#x2020;</b></tt> ICU interprets a single 'y' differently than Java.</p>
* <p>
* The count of pattern letters determine the format.
* <p>
* <strong>(Text)</strong>: 4 or more pattern letters--use full form,
* &lt; 4--use short or abbreviated form if one exists.
* <p>
* <strong>(Number)</strong>: the minimum number of digits. Shorter
* numbers are zero-padded to this amount. Year is handled specially;
* that is, if the count of 'y' is 2, the Year will be truncated to 2 digits.
* (e.g., if "yyyy" produces "1997", "yy" produces "97".)
* Unlike other fields, fractional seconds are padded on the right with zero.
* <p>
* <strong>(Text & Number)</strong>: 3 or over, use text, otherwise use number.
* <p>
* Any characters in the pattern that are not in the ranges of ['a'..'z']
* and ['A'..'Z'] will be treated as quoted text. For instance, characters
* like ':', '.', ' ', '#' and '@' will appear in the resulting time text
* even they are not embraced within single quotes.
* <p>
* A pattern containing any invalid pattern letter will result in a thrown
* exception during formatting or parsing.
*
* <p>
* <strong>Examples Using the US Locale:</strong>
* <blockquote>
* <pre>
* Format Pattern Result
* -------------- -------
* "yyyy.MM.dd G 'at' HH:mm:ss vvvv" ->> 1996.07.10 AD at 15:08:56 Pacific Time
* "EEE, MMM d, ''yy" ->> Wed, July 10, '96
* "h:mm a" ->> 12:08 PM
* "hh 'o''clock' a, zzzz" ->> 12 o'clock PM, Pacific Daylight Time
* "K:mm a, vvv" ->> 0:00 PM, PT
* "yyyyy.MMMMM.dd GGG hh:mm aaa" ->> 01996.July.10 AD 12:08 PM
* </pre>
* </blockquote>
* <strong>Code Sample:</strong>
* <blockquote>
* <pre>
* SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "PST");
* pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2*60*60*1000);
* pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000);
* <br>
* // Format the current time.
* SimpleDateFormat formatter
* = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss a zzz");
* Date currentTime_1 = new Date();
* String dateString = formatter.format(currentTime_1);
* <br>
* // Parse the previous string back into a Date.
* ParsePosition pos = new ParsePosition(0);
* Date currentTime_2 = formatter.parse(dateString, pos);
* </pre>
* </blockquote>
* In the example, the time value <code>currentTime_2</code> obtained from
* parsing will be equal to <code>currentTime_1</code>. However, they may not be
* equal if the am/pm marker 'a' is left out from the format pattern while
* the "hour in am/pm" pattern symbol is used. This information loss can
* happen when formatting the time in PM.
*
* <p>When parsing a date string using the abbreviated year pattern ("yy"),
* SimpleDateFormat must interpret the abbreviated year
* relative to some century. It does this by adjusting dates to be
* within 80 years before and 20 years after the time the SimpleDateFormat
* instance is created. For example, using a pattern of "MM/dd/yy" and a
* SimpleDateFormat instance created on Jan 1, 1997, the string
* "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/64"
* would be interpreted as May 4, 1964.
* During parsing, only strings consisting of exactly two digits, as defined by
* {@link com.ibm.icu.lang.UCharacter#isDigit(int)}, will be parsed into the default
* century.
* Any other numeric string, such as a one digit string, a three or more digit
* string, or a two digit string that isn't all digits (for example, "-1"), is
* interpreted literally. So "01/02/3" or "01/02/003" are parsed, using the
* same pattern, as Jan 2, 3 AD. Likewise, "01/02/-3" is parsed as Jan 2, 4 BC.
*
* <p>If the year pattern does not have exactly two 'y' characters, the year is
* interpreted literally, regardless of the number of digits. So using the
* pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D.
*
* <p>When numeric fields abut one another directly, with no intervening delimiter
* characters, they constitute a run of abutting numeric fields. Such runs are
* parsed specially. For example, the format "HHmmss" parses the input text
* "123456" to 12:34:56, parses the input text "12345" to 1:23:45, and fails to
* parse "1234". In other words, the leftmost field of the run is flexible,
* while the others keep a fixed width. If the parse fails anywhere in the run,
* then the leftmost field is shortened by one character, and the entire run is
* parsed again. This is repeated until either the parse succeeds or the
* leftmost field is one character in length. If the parse still fails at that
* point, the parse of the run fails.
*
* <p>For time zones that have no names, use strings GMT+hours:minutes or
* GMT-hours:minutes.
*
* <p>The calendar defines what is the first day of the week, the first week
* of the year, whether hours are zero based or not (0 vs 12 or 24), and the
* time zone. There is one common decimal format to handle all the numbers;
* the digit count is handled programmatically according to the pattern.
*
* <h4>Synchronization</h4>
*
* Date formats are not synchronized. It is recommended to create separate
* format instances for each thread. If multiple threads access a format
* concurrently, it must be synchronized externally.
*
* @see com.ibm.icu.util.Calendar
* @see com.ibm.icu.util.GregorianCalendar
* @see com.ibm.icu.util.TimeZone
* @see DateFormat
* @see DateFormatSymbols
* @see DecimalFormat
* @author Mark Davis, Chen-Lieh Huang, Alan Liu
* @stable ICU 2.0
*/
public class SimpleDateFormat extends DateFormat {
private static final long serialVersionUID = 1L;
/**
* Constructs a SimpleDateFormat using the default pattern for the default
* locale. <b>Note:</b> Not all locales support SimpleDateFormat; for full
* generality, use the factory methods in the DateFormat class.
*
* @see DateFormat
* @stable ICU 2.0
*/
public SimpleDateFormat() {
super(new java.text.SimpleDateFormat());
}
/**
* Constructs a SimpleDateFormat using the given pattern in the default
* locale. <b>Note:</b> Not all locales support SimpleDateFormat; for full
* generality, use the factory methods in the DateFormat class.
* @stable ICU 2.0
*/
public SimpleDateFormat(String pattern)
{
super(new java.text.SimpleDateFormat(pattern));
}
/**
* Constructs a SimpleDateFormat using the given pattern and locale.
* <b>Note:</b> Not all locales support SimpleDateFormat; for full
* generality, use the factory methods in the DateFormat class.
* @stable ICU 2.0
*/
public SimpleDateFormat(String pattern, Locale loc)
{
super(new java.text.SimpleDateFormat(pattern, loc));
}
/**
* Constructs a SimpleDateFormat using the given pattern and locale.
* <b>Note:</b> Not all locales support SimpleDateFormat; for full
* generality, use the factory methods in the DateFormat class.
* @stable ICU 3.2
*/
public SimpleDateFormat(String pattern, ULocale loc)
{
this(pattern, loc.toLocale());
}
// /**
// * Constructs a SimpleDateFormat using the given pattern , override and locale.
// * @param pattern The pattern to be used
// * @param override The override string. A numbering system override string can take one of the following forms:
// * 1). If just a numbering system name is specified, it applies to all numeric fields in the date format pattern.
// * 2). To specify an alternate numbering system on a field by field basis, use the field letters from the pattern
// * followed by an = sign, followed by the numbering system name. For example, to specify that just the year
// * be formatted using Hebrew digits, use the override "y=hebr". Multiple overrides can be specified in a single
// * string by separating them with a semi-colon. For example, the override string "m=thai;y=deva" would format using
// * Thai digits for the month and Devanagari digits for the year.
// * @param loc The locale to be used
// * @stable ICU 4.2
// */
// public SimpleDateFormat(String pattern, String override, ULocale loc)
// {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Constructs a SimpleDateFormat using the given pattern and
* locale-specific symbol data.
* Warning: uses default locale for digits!
* @stable ICU 2.0
*/
public SimpleDateFormat(String pattern, DateFormatSymbols formatData)
{
super(new java.text.SimpleDateFormat(pattern, formatData.dfs));
}
/**
* Sets the 100-year period 2-digit years will be interpreted as being in
* to begin on the date the user specifies.
* @param startDate During parsing, two digit years will be placed in the range
* <code>startDate</code> to <code>startDate + 100 years</code>.
* @stable ICU 2.0
*/
public void set2DigitYearStart(Date startDate) {
((java.text.SimpleDateFormat)dateFormat).set2DigitYearStart(startDate);
}
/**
* Returns the beginning date of the 100-year period 2-digit years are interpreted
* as being within.
* @return the start of the 100-year period into which two digit years are
* parsed
* @stable ICU 2.0
*/
public Date get2DigitYearStart() {
return ((java.text.SimpleDateFormat)dateFormat).get2DigitYearStart();
}
/**
* Formats a date or time, which is the standard millis
* since January 1, 1970, 00:00:00 GMT.
* <p>Example: using the US locale:
* "yyyy.MM.dd G 'at' HH:mm:ss zzz" ->> 1996.07.10 AD at 15:08:56 PDT
* @param cal the calendar whose date-time value is to be formatted into a date-time string
* @param toAppendTo where the new date-time text is to be appended
* @param pos the formatting position. On input: an alignment field,
* if desired. On output: the offsets of the alignment field.
* @return the formatted date-time string.
* @see DateFormat
* @stable ICU 2.0
*/
public StringBuffer format(Calendar cal, StringBuffer toAppendTo,
FieldPosition pos) {
StringBuffer result;
FieldPosition jdkPos = toJDKFieldPosition(pos);
synchronized(dateFormat) {
java.util.Calendar oldCal = dateFormat.getCalendar();
dateFormat.setCalendar(cal.calendar);
result = dateFormat.format(cal.getTime(), toAppendTo, jdkPos);
dateFormat.setCalendar(oldCal);
}
if (jdkPos != null) {
pos.setBeginIndex(jdkPos.getBeginIndex());
pos.setEndIndex(jdkPos.getEndIndex());
}
return result;
}
/**
* Overrides superclass method
* @stable ICU 2.0
*/
public void setNumberFormat(NumberFormat newNumberFormat) {
super.setNumberFormat(newNumberFormat);
}
/**
* Overrides DateFormat
* @see DateFormat
* @stable ICU 2.0
*/
public void parse(String text, Calendar cal, ParsePosition parsePos)
{
// Note: parsed time zone won't be set in the result calendar
cal.setTime(dateFormat.parse(text, parsePos));
}
/**
* Return a pattern string describing this date format.
* @stable ICU 2.0
*/
public String toPattern() {
return ((java.text.SimpleDateFormat)dateFormat).toPattern();
}
/**
* Return a localized pattern string describing this date format.
* @stable ICU 2.0
*/
public String toLocalizedPattern() {
return ((java.text.SimpleDateFormat)dateFormat).toLocalizedPattern();
}
/**
* Apply the given unlocalized pattern string to this date format.
* @stable ICU 2.0
*/
public void applyPattern(String pat) {
((java.text.SimpleDateFormat)dateFormat).applyPattern(pat);
}
/**
* Apply the given localized pattern string to this date format.
* @stable ICU 2.0
*/
public void applyLocalizedPattern(String pat) {
((java.text.SimpleDateFormat)dateFormat).applyLocalizedPattern(pat);
}
/**
* Gets the date/time formatting data.
* @return a copy of the date-time formatting data associated
* with this date-time formatter.
* @stable ICU 2.0
*/
public DateFormatSymbols getDateFormatSymbols() {
return new DateFormatSymbols(((java.text.SimpleDateFormat)dateFormat).getDateFormatSymbols());
}
/**
* Allows you to set the date/time formatting data.
* @param newFormatSymbols the new symbols
* @stable ICU 2.0
*/
public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols) {
((java.text.SimpleDateFormat)dateFormat).setDateFormatSymbols(newFormatSymbols.dfs);
}
// /**
// * {@icu} Gets the time zone formatter which this date/time
// * formatter uses to format and parse a time zone.
// *
// * @return the time zone formatter which this date/time
// * formatter uses.
// * @draft ICU 49
// * @provisional This API might change or be removed in a future release.
// */
// public TimeZoneFormat getTimeZoneFormat() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * {@icu} Allows you to set the time zone formatter.
// *
// * @param tzfmt the new time zone formatter
// * @draft ICU 49
// * @provisional This API might change or be removed in a future release.
// */
// public void setTimeZoneFormat(TimeZoneFormat tzfmt) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// For clone to use
private SimpleDateFormat(java.text.SimpleDateFormat sdf) {
super(sdf);
}
/**
* Overrides Cloneable
* @stable ICU 2.0
*/
public Object clone() {
return new SimpleDateFormat((java.text.SimpleDateFormat)dateFormat.clone());
}
/**
* Override hashCode.
* Generates the hash code for the SimpleDateFormat object
* @stable ICU 2.0
*/
public int hashCode()
{
return super.hashCode();
}
/**
* Override equals.
* @stable ICU 2.0
*/
public boolean equals(Object obj)
{
return super.equals(obj);
}
/**
* Format the object to an attributed string, and return the corresponding iterator
* Overrides superclass method.
*
* @param obj The object to format
* @return <code>AttributedCharacterIterator</code> describing the formatted value.
*
* @stable ICU 3.8
*/
public AttributedCharacterIterator formatToCharacterIterator(Object obj) {
AttributedCharacterIterator it = dateFormat.formatToCharacterIterator(obj);
// Extract formatted String first
StringBuilder sb = new StringBuilder();
for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
sb.append(c);
}
// Create AttributedString
AttributedString attrstr = new AttributedString(sb.toString());
// Map JDK Field to ICU Field
int idx = 0;
it.first();
while (idx < it.getEndIndex()) {
int end = it.getRunLimit();
Map<Attribute, Object> attributes = it.getAttributes();
if (attributes != null) {
for (Entry<Attribute, Object> entry : attributes.entrySet()) {
Attribute attr = entry.getKey();
Object val = entry.getValue();
if (attr.equals(java.text.DateFormat.Field.AM_PM)) {
val = attr = Field.AM_PM;
} else if (attr.equals(java.text.DateFormat.Field.DAY_OF_MONTH)) {
val = attr = Field.DAY_OF_MONTH;
} else if (attr.equals(java.text.DateFormat.Field.DAY_OF_WEEK)) {
val = attr = Field.DAY_OF_WEEK ;
} else if (attr.equals(java.text.DateFormat.Field.DAY_OF_WEEK_IN_MONTH)) {
val = attr = Field.DAY_OF_WEEK_IN_MONTH ;
} else if (attr.equals(java.text.DateFormat.Field.DAY_OF_YEAR)) {
val = attr = Field.DAY_OF_YEAR;
} else if (attr.equals(java.text.DateFormat.Field.ERA)) {
val = attr = Field.ERA;
} else if (attr.equals(java.text.DateFormat.Field.HOUR_OF_DAY0)) {
val = attr = Field.HOUR_OF_DAY0;
} else if (attr.equals(java.text.DateFormat.Field.HOUR_OF_DAY1)) {
val = attr = Field.HOUR_OF_DAY1;
} else if (attr.equals(java.text.DateFormat.Field.HOUR0)) {
val = attr = Field.HOUR0;
} else if (attr.equals(java.text.DateFormat.Field.HOUR1)) {
val = attr = Field.HOUR1;
} else if (attr.equals(java.text.DateFormat.Field.MILLISECOND)) {
val = attr = Field.MILLISECOND;
} else if (attr.equals(java.text.DateFormat.Field.MINUTE)) {
val = attr = Field.MINUTE;
} else if (attr.equals(java.text.DateFormat.Field.MONTH)) {
val = attr = Field.MONTH;
} else if (attr.equals(java.text.DateFormat.Field.SECOND)) {
val = attr = Field.SECOND;
} else if (attr.equals(java.text.DateFormat.Field.TIME_ZONE)) {
val = attr = Field.TIME_ZONE;
} else if (attr.equals(java.text.DateFormat.Field.WEEK_OF_MONTH)) {
val = attr = Field.WEEK_OF_MONTH;
} else if (attr.equals(java.text.DateFormat.Field.WEEK_OF_YEAR)) {
val = attr = Field.WEEK_OF_YEAR;
} else if (attr.equals(java.text.DateFormat.Field.YEAR)) {
val = attr = Field.YEAR;
}
attrstr.addAttribute(attr, val, idx, end);
}
}
idx = end;
while (it.getIndex() < idx) {
it.next();
}
}
return attrstr.getIterator();
}
}

View file

@ -1,80 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2003-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.text;
import java.text.Format;
/**
* An abstract class that extends {@link java.text.Format} to provide
* additional ICU protocol, specifically, the <tt>getLocale()</tt>
* API. All ICU format classes are subclasses of this class.
*
* @see com.ibm.icu.util.ULocale
* @author weiv
* @author Alan Liu
* @draft ICU 2.8 (retain)
* @provisional This API might change or be removed in a future release.
*/
public abstract class UFormat extends Format {
private static final long serialVersionUID = 1L;
/**
* @draft ICU 2.8 (retain)
* @provisional This API might change or be removed in a future release.
*/
public UFormat() {}
// /**
// * Return the locale that was used to create this object, or null.
// * This may may differ from the locale requested at the time of
// * this object's creation. For example, if an object is created
// * for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
// * drawn from <tt>en</tt> (the <i>actual</i> locale), and
// * <tt>en_US</tt> may be the most specific locale that exists (the
// * <i>valid</i> locale).
// *
// * <p>Note: This method will be implemented in ICU 3.0; ICU 2.8
// * contains a partial preview implementation. The <i>actual</i>
// * locale is returned correctly, but the <i>valid</i> locale is
// * not, in most cases.
// * @param type type of information requested, either {@link
// * com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
// * com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
// * @return the information specified by <i>type</i>, or null if
// * this object was not constructed from locale data.
// * @see com.ibm.icu.util.ULocale
// * @see com.ibm.icu.util.ULocale#VALID_LOCALE
// * @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
// * @draft ICU 2.8 (retain)
// * @provisional This API might change or be removed in a future release.
// */
// public final ULocale getLocale(ULocale.Type type) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Set information about the locales that were used to create this
// * object. If the object was not constructed from locale data,
// * both arguments should be set to null. Otherwise, neither
// * should be null. The actual locale must be at the same level or
// * less specific than the valid locale. This method is intended
// * for use by factories or other entities that create objects of
// * this class.
// * @param valid the most specific locale containing any resource
// * data, or null
// * @param actual the locale containing data used to construct this
// * object, or null
// * @see com.ibm.icu.util.ULocale
// * @see com.ibm.icu.util.ULocale#VALID_LOCALE
// * @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
// */
// final void setLocale(ULocale valid, ULocale actual) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
}

View file

@ -1,510 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/**
*******************************************************************************
* Copyright (C) 2001-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.util;
import java.io.Serializable;
import java.util.Locale;
import com.ibm.icu.util.ULocale.Category;
/**
* A class encapsulating a currency, as defined by ISO 4217. A
* <tt>Currency</tt> object can be created given a <tt>Locale</tt> or
* given an ISO 4217 code. Once created, the <tt>Currency</tt> object
* can return various data necessary to its proper display:
*
* <ul><li>A display symbol, for a specific locale
* <li>The number of fraction digits to display
* <li>A rounding increment
* </ul>
*
* The <tt>DecimalFormat</tt> class uses these data to display
* currencies.
*
* <p>Note: This class deliberately resembles
* <tt>java.util.Currency</tt> but it has a completely independent
* implementation, and adds features not present in the JDK.
* @author Alan Liu
* @stable ICU 2.2
*/
public class Currency implements Serializable {
private static final long serialVersionUID = 1L;
/**
* @internal
*/
public final java.util.Currency currency;
/**
* @internal
* @param delegate the NumberFormat to which to delegate
*/
public Currency(java.util.Currency delegate) {
this.currency = delegate;
}
/**
* Selector for getName() indicating a symbolic name for a
* currency, such as "$" for USD.
* @stable ICU 2.6
*/
public static final int SYMBOL_NAME = 0;
/**
* Selector for ucurr_getName indicating the long name for a
* currency, such as "US Dollar" for USD.
* @stable ICU 2.6
*/
public static final int LONG_NAME = 1;
/**
* Selector for getName() indicating the plural long name for a
* currency, such as "US dollar" for USD in "1 US dollar",
* and "US dollars" for USD in "2 US dollars".
* @stable ICU 4.2
*/
public static final int PLURAL_LONG_NAME = 2;
/**
* Returns a currency object for the default currency in the given
* locale.
* @param locale the locale
* @return the currency object for this locale
* @stable ICU 2.2
*/
public static Currency getInstance(Locale locale) {
return new Currency(java.util.Currency.getInstance(locale));
}
/**
* Returns a currency object for the default currency in the given
* locale.
* @stable ICU 3.2
*/
public static Currency getInstance(ULocale locale) {
return new Currency(java.util.Currency.getInstance(locale.toLocale()));
}
// /**
// * Returns an array of Strings which contain the currency
// * identifiers that are valid for the given locale on the
// * given date. If there are no such identifiers, returns null.
// * Returned identifiers are in preference order.
// * @param loc the locale for which to retrieve currency codes.
// * @param d the date for which to retrieve currency codes for the given locale.
// * @return The array of ISO currency codes.
// * @stable ICU 4.0
// */
// public static String[] getAvailableCurrencyCodes(ULocale loc, Date d) {
// throw new UnsupportedOperationException("Method not supproted by com.ibm.icu.base");
// }
// /**
// * Returns the set of available currencies. The returned set of currencies contains all of the
// * available currencies, including obsolete ones. The result set can be modified without
// * affecting the available currencies in the runtime.
// *
// * @return The set of available currencies. The returned set could be empty if there is no
// * currency data available.
// *
// * @stable ICU 49
// */
// public static Set<Currency> getAvailableCurrencies() {
// throw new UnsupportedOperationException("Method not supproted by com.ibm.icu.base");
// }
/**
* Returns a currency object given an ISO 4217 3-letter code.
* @param theISOCode the iso code
* @return the currency for this iso code
* @throws NullPointerException if <code>theISOCode</code> is null.
* @throws IllegalArgumentException if <code>theISOCode</code> is not a
* 3-letter alpha code.
* @stable ICU 2.2
*/
public static Currency getInstance(String theISOCode) {
return new Currency(java.util.Currency.getInstance(theISOCode));
}
// /**
// * Registers a new currency for the provided locale. The returned object
// * is a key that can be used to unregister this currency object.
// * @param currency the currency to register
// * @param locale the ulocale under which to register the currency
// * @return a registry key that can be used to unregister this currency
// * @see #unregister
// * @stable ICU 3.2
// */
// public static Object registerInstance(Currency currency, ULocale locale) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Unregister the currency associated with this key (obtained from
// * registerInstance).
// * @param registryKey the registry key returned from registerInstance
// * @see #registerInstance
// * @stable ICU 2.6
// */
// public static boolean unregister(Object registryKey) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Return an array of the locales for which a currency
// * is defined.
// * @return an array of the available locales
// * @stable ICU 2.2
// */
// public static Locale[] getAvailableLocales() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Return an array of the ulocales for which a currency
// * is defined.
// * @return an array of the available ulocales
// * @stable ICU 3.2
// */
// public static ULocale[] getAvailableULocales() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Given a key and a locale, returns an array of values for the key for which data
// * exists. If commonlyUsed is true, these are the values that typically are used
// * with this locale, otherwise these are all values for which data exists.
// * This is a common service API.
// * <p>
// * The only supported key is "currency", other values return an empty array.
// * <p>
// * Currency information is based on the region of the locale. If the locale does not
// * indicate a region, {@link ULocale#addLikelySubtags(ULocale)} is used to infer a region,
// * except for the 'und' locale.
// * <p>
// * If commonlyUsed is true, only the currencies known to be in use as of the current date
// * are returned. When there are more than one, these are returned in preference order
// * (typically, this occurs when a country is transitioning to a new currency, and the
// * newer currency is preferred), see
// * <a href="http://unicode.org/reports/tr35/#Supplemental_Currency_Data">Unicode TR#35 Sec. C1</a>.
// * If commonlyUsed is false, all currencies ever used in any locale are returned, in no
// * particular order.
// *
// * @param key key whose values to look up. the only recognized key is "currency"
// * @param locale the locale
// * @param commonlyUsed if true, return only values that are currently used in the locale.
// * Otherwise returns all values.
// * @return an array of values for the given key and the locale. If there is no data, the
// * array will be empty.
// * @stable ICU 4.2
// */
// public static final String[] getKeywordValuesForLocale(String key, ULocale locale,
// boolean commonlyUsed) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Return a hashcode for this currency.
* @stable ICU 2.2
*/
public int hashCode() {
return currency.hashCode();
}
/**
* Return true if rhs is a Currency instance,
* is non-null, and has the same currency code.
* @stable ICU 2.2
*/
public boolean equals(Object rhs) {
try {
return currency.equals(((Currency)rhs).currency);
}
catch (Exception e) {
return false;
}
}
/**
* Returns the ISO 4217 3-letter code for this currency object.
* @stable ICU 2.2
*/
public String getCurrencyCode() {
return currency.getCurrencyCode();
}
// /**
// * Returns the ISO 4217 numeric code for this currency object.
// * <p>Note: If the ISO 4217 numeric code is not assigned for the currency or
// * the currency is unknown, this method returns 0.</p>
// * @return The ISO 4217 numeric code of this currency.
// * @stable ICU 49
// */
// public int getNumericCode() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Convenience and compatibility override of getName that
* requests the symbol name.
* @see #getName
* @stable ICU 3.4
*/
public String getSymbol() {
return currency.getSymbol(ULocale.getDefault(Category.DISPLAY).toLocale());
}
/**
* Convenience and compatibility override of getName that
* requests the symbol name.
* @param loc the Locale for the symbol
* @see #getName
* @stable ICU 3.4
*/
public String getSymbol(Locale loc) {
return currency.getSymbol(loc);
}
/**
* Convenience and compatibility override of getName that
* requests the symbol name.
* @param uloc the ULocale for the symbol
* @see #getName
* @stable ICU 3.4
*/
public String getSymbol(ULocale uloc) {
return currency.getSymbol(uloc.toLocale());
}
// /**
// * Returns the display name for the given currency in the
// * given locale.
// * This is a convenient method for
// * getName(ULocale, int, boolean[]);
// * @stable ICU 3.2
// */
// public String getName(Locale locale,
// int nameStyle,
// boolean[] isChoiceFormat) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Returns the display name for the given currency in the
// * given locale. For example, the display name for the USD
// * currency object in the en_US locale is "$".
// * @param locale locale in which to display currency
// * @param nameStyle selector for which kind of name to return.
// * The nameStyle should be either SYMBOL_NAME or
// * LONG_NAME. Otherwise, throw IllegalArgumentException.
// * @param isChoiceFormat fill-in; isChoiceFormat[0] is set to true
// * if the returned value is a ChoiceFormat pattern; otherwise it
// * is set to false
// * @return display string for this currency. If the resource data
// * contains no entry for this currency, then the ISO 4217 code is
// * returned. If isChoiceFormat[0] is true, then the result is a
// * ChoiceFormat pattern. Otherwise it is a static string. <b>Note:</b>
// * as of ICU 4.4, choice formats are not used, and the value returned
// * in isChoiceFormat is always false.
// * <p>
// * @throws IllegalArgumentException if the nameStyle is not SYMBOL_NAME
// * or LONG_NAME.
// * @see #getName(ULocale, int, String, boolean[])
// * @stable ICU 3.2
// */
// public String getName(ULocale locale, int nameStyle, boolean[] isChoiceFormat) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Returns the display name for the given currency in the given locale.
// * This is a convenience overload of getName(ULocale, int, String, boolean[]);
// * @stable ICU 4.2
// */
// public String getName(Locale locale, int nameStyle, String pluralCount,
// boolean[] isChoiceFormat) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Returns the display name for this currency in the default locale.
// * If the resource data for the default locale contains no entry for this currency,
// * then the ISO 4217 code is returned.
// * <p>
// * Note: This method was added for JDK compatibility support and equivalent to
// * <code>getName(Locale.getDefault(), LONG_NAME, null)</code>.
// *
// * @return The display name of this currency
// * @see #getDisplayName(Locale)
// * @see #getName(Locale, int, boolean[])
// * @stable ICU 49
// */
// public String getDisplayName() {
// //return getName(Locale.getDefault(), LONG_NAME, null);
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Returns the display name for this currency in the given locale.
// * If the resource data for the given locale contains no entry for this currency,
// * then the ISO 4217 code is returned.
// * <p>
// * Note: This method was added for JDK compatibility support and equivalent to
// * <code>getName(locale, LONG_NAME, null)</code>.
// *
// * @param locale locale in which to display currency
// * @return The display name of this currency for the specified locale
// * @see #getDisplayName(Locale)
// * @see #getName(Locale, int, boolean[])
// * @stable ICU 49
// */
// public String getDisplayName(Locale locale) {
// //return getName(locale, LONG_NAME, null);
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Returns the display name for the given currency in the
// * given locale. For example, the SYMBOL_NAME for the USD
// * currency object in the en_US locale is "$".
// * The PLURAL_LONG_NAME for the USD currency object when the currency
// * amount is plural is "US dollars", such as in "3.00 US dollars";
// * while the PLURAL_LONG_NAME for the USD currency object when the currency
// * amount is singular is "US dollar", such as in "1.00 US dollar".
// * @param locale locale in which to display currency
// * @param nameStyle selector for which kind of name to return
// * @param pluralCount plural count string for this locale
// * @param isChoiceFormat fill-in; isChoiceFormat[0] is set to true
// * if the returned value is a ChoiceFormat pattern; otherwise it
// * is set to false
// * @return display string for this currency. If the resource data
// * contains no entry for this currency, then the ISO 4217 code is
// * returned. If isChoiceFormat[0] is true, then the result is a
// * ChoiceFormat pattern. Otherwise it is a static string. <b>Note:</b>
// * as of ICU 4.4, choice formats are not used, and the value returned
// * in isChoiceFormat is always false.
// * @throws IllegalArgumentException if the nameStyle is not SYMBOL_NAME,
// * LONG_NAME, or PLURAL_LONG_NAME.
// * @stable ICU 4.2
// */
// public String getName(ULocale locale, int nameStyle, String pluralCount,
// boolean[] isChoiceFormat) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Attempt to parse the given string as a currency, either as a
// * display name in the given locale, or as a 3-letter ISO 4217
// * code. If multiple display names match, then the longest one is
// * selected. If both a display name and a 3-letter ISO code
// * match, then the display name is preferred, unless it's length
// * is less than 3.
// *
// * @param locale the locale of the display names to match
// * @param text the text to parse
// * @param type parse against currency type: LONG_NAME only or not
// * @param pos input-output position; on input, the position within
// * text to match; must have 0 <= pos.getIndex() < text.length();
// * on output, the position after the last matched character. If
// * the parse fails, the position in unchanged upon output.
// * @return the ISO 4217 code, as a string, of the best match, or
// * null if there is no match
// *
// * @internal
// * @deprecated This API is ICU internal only.
// */
// public static String parse(ULocale locale, String text, int type, ParsePosition pos) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Returns the number of the number of fraction digits that should
* be displayed for this currency.
* @return a non-negative number of fraction digits to be
* displayed
* @stable ICU 2.2
*/
public int getDefaultFractionDigits() {
return currency.getDefaultFractionDigits();
}
// /**
// * Returns the rounding increment for this currency, or 0.0 if no
// * rounding is done by this currency.
// * @return the non-negative rounding increment, or 0.0 if none
// * @stable ICU 2.2
// */
// public double getRoundingIncrement() {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Returns the ISO 4217 code for this currency.
* @stable ICU 2.2
*/
public String toString() {
return currency.toString();
}
// /**
// * Return the locale that was used to create this object, or null.
// * This may may differ from the locale requested at the time of
// * this object's creation. For example, if an object is created
// * for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
// * drawn from <tt>en</tt> (the <i>actual</i> locale), and
// * <tt>en_US</tt> may be the most specific locale that exists (the
// * <i>valid</i> locale).
// *
// * <p>Note: This method will be obsoleted. The implementation is
// * no longer locale-specific and so there is no longer a valid or
// * actual locale associated with the Currency object. Until
// * it is removed, this method will return the root locale.
// * @param type type of information requested, either {@link
// * com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
// * com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
// * @return the information specified by <i>type</i>, or null if
// * this object was not constructed from locale data.
// * @see com.ibm.icu.util.ULocale
// * @see com.ibm.icu.util.ULocale#VALID_LOCALE
// * @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
// * @obsolete ICU 3.2 to be removed
// * @deprecated This API is obsolete.
// */
// public final ULocale getLocale(ULocale.Type type) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Queries if the given ISO 4217 3-letter code is available on the specified date range.
// * <p>
// * Note: For checking availability of a currency on a specific date, specify the date on both <code>from</code> and
// * <code>to</code>. When both <code>from</code> and <code>to</code> are null, this method checks if the specified
// * currency is available all time.
// *
// * @param code
// * The ISO 4217 3-letter code.
// * @param from
// * The lower bound of the date range, inclusive. When <code>from</code> is null, check the availability
// * of the currency any date before <code>to</code>
// * @param to
// * The upper bound of the date range, inclusive. When <code>to</code> is null, check the availability of
// * the currency any date after <code>from</code>
// * @return true if the given ISO 4217 3-letter code is supported on the specified date range.
// * @throws IllegalArgumentException when <code>to</code> is before <code>from</code>.
// *
// * @draft ICU 4.6
// * @provisional This API might change or be removed in a future release.
// */
// public static boolean isAvailable(String code, Date from, Date to) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
}
//eof

View file

@ -1,322 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
* Copyright (C) 2005-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
package com.ibm.icu.util;
/**
* Provides a flexible mechanism for controlling access, without requiring that
* a class be immutable. Once frozen, an object can never be unfrozen, so it is
* thread-safe from that point onward. Once the object has been frozen,
* it must guarantee that no changes can be made to it. Any attempt to alter
* it must raise an UnsupportedOperationException exception. This means that when
* the object returns internal objects, or if anyone has references to those internal
* objects, that those internal objects must either be immutable, or must also
* raise exceptions if any attempt to modify them is made. Of course, the object
* can return clones of internal objects, since those are safe.
* <h2>Background</h2>
* <p>
* There are often times when you need objects to be objects 'safe', so that
* they can't be modified. Examples are when objects need to be thread-safe, or
* in writing robust code, or in caches. If you are only creating your own
* objects, you can guarantee this, of course -- but only if you don't make a
* mistake. If you have objects handed into you, or are creating objects using
* others handed into you, it is a different story. It all comes down to whether
* you want to take the Blanche Dubois approach (&quot;depend on the kindness of
* strangers&quot;) or the Andy Grove approach (&quot;Only the Paranoid
* Survive&quot;).
* </p>
* <p>
* For example, suppose we have a simple class:
* </p>
*
* <pre>
* public class A {
* protected Collection b;
*
* protected Collection c;
*
* public Collection get_b() {
* return b;
* }
*
* public Collection get_c() {
* return c;
* }
*
* public A(Collection new_b, Collection new_c) {
* b = new_b;
* c = new_c;
* }
* }
* </pre>
*
* <p>
* Since the class doesn't have any setters, someone might think that it is
* immutable. You know where this is leading, of course; this class is unsafe in
* a number of ways. The following illustrates that.
* </p>
*
* <pre>
* public test1(SupposedlyImmutableClass x, SafeStorage y) {
* // unsafe getter
* A a = x.getA();
* Collection col = a.get_b();
* col.add(something); // a has now been changed, and x too
*
* // unsafe constructor
* a = new A(col, col);
* y.store(a);
* col.add(something); // a has now been changed, and y too
* }
* </pre>
*
* <p>
* There are a few different techniques for having safe classes.
* </p>
* <ol>
* <li>Const objects. In C++, you can declare parameters const.</li>
* <li>Immutable wrappers. For example, you can put a collection in an
* immutable wrapper.</li>
* <li>Always-Immutable objects. Java uses this approach, with a few
* variations. Examples:
* <ol>
* <li>Simple. Once a Color is created (eg from R, G, and B integers) it is
* immutable.</li>
* <li>Builder Class. There is a separate 'builder' class. For example,
* modifiable Strings are created using StringBuffer (which doesn't have the
* full String API available). Once you want an immutable form, you create one
* with toString().</li>
* <li>Primitives. These are always safe, since they are copied on input/output
* from methods.</li>
* </ol>
* </li>
* <li>Cloning. Where you need an object to be safe, you clone it.</li>
* </ol>
* <p>
* There are advantages and disadvantages of each of these.
* </p>
* <ol>
* <li>Const provides a certain level of protection, but since const can be and
* is often cast away, it only protects against most inadvertent mistakes. It
* also offers no threading protection, since anyone who has a pointer to the
* (unconst) object in another thread can mess you up.</li>
* <li>Immutable wrappers are safer than const in that the constness can't be
* cast away. But other than that they have all the same problems: not safe if
* someone else keeps hold of the original object, or if any of the objects
* returned by the class are mutable.</li>
* <li>Always-Immutable Objects are safe, but usage can require excessive
* object creation.</li>
* <li>Cloning is only safe if the object truly has a 'safe' clone; defined as
* one that <i>ensures that no change to the clone affects the original</i>.
* Unfortunately, many objects don't have a 'safe' clone, and always cloning can
* require excessive object creation.</li>
* </ol>
* <h2>Freezable Model</h2>
* <p>
* The <code>Freezable</code> model supplements these choices by giving you
* the ability to build up an object by calling various methods, then when it is
* in a final state, you can <i>make</i> it immutable. Once immutable, an
* object cannot <i>ever </i>be modified, and is completely thread-safe: that
* is, multiple threads can have references to it without any synchronization.
* If someone needs a mutable version of an object, they can use
* <code>cloneAsThawed()</code>, and modify the copy. This provides a simple,
* effective mechanism for safe classes in circumstances where the alternatives
* are insufficient or clumsy. (If an object is shared before it is immutable,
* then it is the responsibility of each thread to mutex its usage (as with
* other objects).)
* </p>
* <p>
* Here is what needs to be done to implement this interface, depending on the
* type of the object.
* </p>
* <h3><b>Immutable Objects</b></h3>
* <p>
* These are the easiest. You just use the interface to reflect that, by adding
* the following:
* </p>
*
* <pre>
* public class A implements Freezable<A> {
* ...
* public final boolean isFrozen() {return true;}
* public final A freeze() {return this;}
* public final A cloneAsThawed() { return this; }
* }
* </pre>
*
* <p>
* These can be final methods because subclasses of immutable objects must
* themselves be immutable. (Note: <code>freeze</code> is returning
* <code>this</code> for chaining.)
* </p>
* <h3><b>Mutable Objects</b></h3>
* <p>
* Add a protected 'flagging' field:
* </p>
*
* <pre>
* protected boolean immutable;
* </pre>
*
* <p>
* Add the following methods:
* </p>
*
* <pre>
* public final boolean isFrozen() {
* return frozen;
* };
*
* public A freeze() {
* frozen = true;
* return this;
* }
* </pre>
*
* <p>
* Add a <code>cloneAsThawed()</code> method following the normal pattern for
* <code>clone()</code>, except that <code>frozen=false</code> in the new
* clone.
* </p>
* <p>
* Then take the setters (that is, any method that can change the internal state
* of the object), and add the following as the first statement:
* </p>
*
* <pre>
* if (isFrozen()) {
* throw new UnsupportedOperationException(&quot;Attempt to modify frozen object&quot;);
* }
* </pre>
*
* <h4><b>Subclassing</b></h4>
* <p>
* Any subclass of a <code>Freezable</code> will just use its superclass's
* flagging field. It must override <code>freeze()</code> and
* <code>cloneAsThawed()</code> to call the superclass, but normally does not
* override <code>isFrozen()</code>. It must then just pay attention to its
* own getters, setters and fields.
* </p>
* <h4><b>Internal Caches</b></h4>
* <p>
* Internal caches are cases where the object is logically unmodified, but
* internal state of the object changes. For example, there are const C++
* functions that cast away the const on the &quot;this&quot; pointer in order
* to modify an object cache. These cases are handled by mutexing the internal
* cache to ensure thread-safety. For example, suppose that UnicodeSet had an
* internal marker to the last code point accessed. In this case, the field is
* not externally visible, so the only thing you need to do is to synchronize
* the field for thread safety.
* </p>
* <h4>Unsafe Internal Access</h4>
* <p>
* Internal fields are called <i>safe</i> if they are either
* <code>frozen</code> or immutable (such as String or primitives). If you've
* never allowed internal access to these, then you are all done. For example,
* converting UnicodeSet to be <code>Freezable</code> is just accomplished
* with the above steps. But remember that you <i><b>have</b></i> allowed
* access to unsafe internals if you have any code like the following, in a
* getter, setter, or constructor:
* </p>
*
* <pre>
* Collection getStuff() {
* return stuff;
* } // caller could keep reference &amp; modify
*
* void setStuff(Collection x) {
* stuff = x;
* } // caller could keep reference &amp; modify
*
* MyClass(Collection x) {
* stuff = x;
* } // caller could keep reference &amp; modify
* </pre>
*
* <p>
* These also illustrated in the code sample in <b>Background</b> above.
* </p>
* <p>
* To deal with unsafe internals, the simplest course of action is to do the
* work in the <code>freeze()</code> function. Just make all of your internal
* fields frozen, and set the frozen flag. Any subsequent getter/setter will
* work properly. Here is an example:
* </p>
*
* <pre>
* public A freeze() {
* if (!frozen) {
* foo.freeze();
* frozen = true;
* }
* return this;
* }
* </pre>
*
* <p>
* If the field is a <code>Collection</code> or <code>Map</code>, then to
* make it frozen you have two choices. If you have never allowed access to the
* collection from outside your object, then just wrap it to prevent future
* modification.
* </p>
*
* <pre>
* zone_to_country = Collections.unmodifiableMap(zone_to_country);
* </pre>
*
* <p>
* If you have <i>ever</i> allowed access, then do a <code>clone()</code>
* before wrapping it.
* </p>
*
* <pre>
* zone_to_country = Collections.unmodifiableMap(zone_to_country.clone());
* </pre>
*
* <p>
* If a collection <i>(or any other container of objects)</i> itself can
* contain mutable objects, then for a safe clone you need to recurse through it
* to make the entire collection immutable. The recursing code should pick the
* most specific collection available, to avoid the necessity of later
* downcasing.
* </p>
* <blockquote>
* <p>
* <b>Note: </b>An annoying flaw in Java is that the generic collections, like
* <code>Map</code> or <code>Set</code>, don't have a <code>clone()</code>
* operation. When you don't know the type of the collection, the simplest
* course is to just create a new collection:
* </p>
*
* <pre>
* zone_to_country = Collections.unmodifiableMap(new HashMap(zone_to_country));
* </pre>
*
* </blockquote>
* @stable ICU 3.8
*/
public interface Freezable<T> extends Cloneable {
/**
* Determines whether the object has been frozen or not.
* @stable ICU 3.8
*/
public boolean isFrozen();
/**
* Freezes the object.
* @return the object itself.
* @stable ICU 3.8
*/
public T freeze();
/**
* Provides for the clone operation. Any clone is initially unfrozen.
* @stable ICU 3.8
*/
public T cloneAsThawed();
}

View file

@ -1,75 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.util;
/**
* Thrown by methods in {@link ULocale} and {@link ULocale.Builder} to
* indicate that an argument is not a well-formed BCP 47 tag.
*
* @see ULocale
* @draft ICU 4.2
* @provisional This API might change or be removed in a future release.
*/
public class IllformedLocaleException extends RuntimeException {
private static final long serialVersionUID = 1L;
private int _errIdx = -1;
/**
* Constructs a new <code>IllformedLocaleException</code> with no
* detail message and -1 as the error index.
* @draft ICU 4.6
* @provisional This API might change or be removed in a future release.
*/
public IllformedLocaleException() {
super();
}
/**
* Constructs a new <code>IllformedLocaleException</code> with the
* given message and -1 as the error index.
*
* @param message the message
* @draft ICU 4.2
* @provisional This API might change or be removed in a future release.
*/
public IllformedLocaleException(String message) {
super(message);
}
/**
* Constructs a new <code>IllformedLocaleException</code> with the
* given message and the error index. The error index is the approximate
* offset from the start of the ill-formed value to the point where the
* parse first detected an error. A negative error index value indicates
* either the error index is not applicable or unknown.
*
* @param message the message
* @param errorIndex the index
* @draft ICU 4.2
* @provisional This API might change or be removed in a future release.
*/
public IllformedLocaleException(String message, int errorIndex) {
super(message + ((errorIndex < 0) ? "" : " [at index " + errorIndex + "]"));
_errIdx = errorIndex;
}
/**
* Returns the index where the error was found. A negative value indicates
* either the error index is not applicable or unknown.
*
* @return the error index
* @draft ICU 4.2
* @provisional This API might change or be removed in a future release.
*/
public int getErrorIndex() {
return _errIdx;
}
}

View file

@ -1,878 +0,0 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
* @(#)TimeZone.java 1.51 00/01/19
*
* Copyright (C) 1996-2016, International Business Machines
* Corporation and others. All Rights Reserved.
*/
package com.ibm.icu.util;
import java.io.Serializable;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.SimpleTimeZone;
import com.ibm.icu.util.ULocale.Category;
/**
* {@icuenhanced java.util.TimeZone}.{@icu _usage_}
*
* <p><code>TimeZone</code> represents a time zone offset, and also computes daylight
* savings.
*
* <p>Typically, you get a <code>TimeZone</code> using {@link #getDefault()}
* which creates a <code>TimeZone</code> based on the time zone where the program
* is running. For example, for a program running in Japan, <code>getDefault</code>
* creates a <code>TimeZone</code> object based on Japanese Standard Time.
*
* <p>You can also get a <code>TimeZone</code> using {@link #getTimeZone(String)}
* along with a time zone ID. For instance, the time zone ID for the
* U.S. Pacific Time zone is "America/Los_Angeles". So, you can get a
* U.S. Pacific Time <code>TimeZone</code> object with:
*
* <blockquote>
* <pre>
* TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
* </pre>
* </blockquote>
* You can use the {@link #getAvailableIDs()} method to iterate through
* all the supported time zone IDs. You can then choose a
* supported ID to get a <code>TimeZone</code>.
* If the time zone you want is not represented by one of the
* supported IDs, then you can create a custom time zone ID with
* the following syntax:
*
* <blockquote>
* <pre>
* GMT[+|-]hh[[:]mm]
* </pre>
* </blockquote>
*
* For example, you might specify GMT+14:00 as a custom
* time zone ID. The <code>TimeZone</code> that is returned
* when you specify a custom time zone ID does not include
* daylight savings time.
*
* <p>For compatibility with JDK 1.1.x, some other three-letter time zone IDs
* (such as "PST", "CTT", "AST") are also supported. However, <strong>their
* use is deprecated</strong> because the same abbreviation is often used
* for multiple time zones (for example, "CST" could be U.S. "Central Standard
* Time" and "China Standard Time"), and the Java platform can then only
* recognize one of them.
*
* <p><strong>Note:</strong> Starting from ICU4J 4.0, you can optionally choose
* JDK <code>TimeZone</code> as the time zone implementation. The TimeZone factory
* method <code>getTimeZone</code> creates an instance of ICU's own <code>TimeZone</code>
* subclass by default. If you want to use the JDK implementation always, you can
* set the default time zone implementation type by the new method
* <code>setDefaultTimeZoneType</code>. Alternatively, you can change the initial
* default implementation type by setting a property below.
*
* <blockquote>
* <pre>
* #
* # The default TimeZone implementation type used by the ICU TimeZone
* # factory method. [ ICU | JDK ]
* #
* com.ibm.icu.util.TimeZone.DefaultTimeZoneType = ICU
* </pre>
* </blockquote>
*
* <p>This property is included in ICUConfig.properties in com.ibm.icu package. When the
* <code>TimeZone</code> class is loaded, the initialization code checks if the property
* <code>com.ibm.icu.util.TimeZone.DefaultTimeZoneType=xxx</code> is defined by the system
* properties. If not available, then it loads ICUConfig.properties to get the default
* time zone implementation type. The property setting is only used for the initial
* default value and you can change the default type by calling
* <code>setDefaultTimeZoneType</code> at runtime.
*
* @see Calendar
* @see GregorianCalendar
* @see SimpleTimeZone
* @author Mark Davis, Deborah Goldsmith, Chen-Lieh Huang, Alan Liu
* @stable ICU 2.0
*/
public class TimeZone implements Serializable, Cloneable, Freezable<TimeZone> {
private static final long serialVersionUID = 1L;
/**
* @internal
*/
public final java.util.TimeZone timeZone;
/**
* @internal
* @param delegate the TimeZone to which to delegate
*/
public TimeZone(java.util.TimeZone delegate) {
this.timeZone = delegate;
}
// /**
// * {@icu} A logger for TimeZone. Will be null if logging is not on by way of system
// * property: "icu4j.debug.logging"
// * @draft ICU 4.4
// * @provisional This API might change or be removed in a future release.
// */
// public static ICULogger TimeZoneLogger = ICULogger.getICULogger(TimeZone.class.getName());
/**
* Default constructor. (For invocation by subclass constructors,
* typically implicit.)
* @stable ICU 2.8
*/
public TimeZone() {
this.timeZone = java.util.TimeZone.getDefault();
}
/**
* {@icu} A time zone implementation type indicating ICU's own TimeZone used by
* <code>getTimeZone</code>, <code>setDefaultTimeZoneType</code>
* and <code>getDefaultTimeZoneType</code>.
* @stable ICU 4.0
*/
public static final int TIMEZONE_ICU = 0;
/**
* {@icu} A time zone implementation type indicating JDK TimeZone used by
* <code>getTimeZone</code>, <code>setDefaultTimeZoneType</code>
* and <code>getDefaultTimeZoneType</code>.
* @stable ICU 4.0
*/
public static final int TIMEZONE_JDK = 1;
/**
* A style specifier for <code>getDisplayName()</code> indicating
* a short name, such as "PST."
* @see #LONG
* @stable ICU 2.0
*/
public static final int SHORT = 0;
/**
* A style specifier for <code>getDisplayName()</code> indicating
* a long name, such as "Pacific Standard Time."
* @see #SHORT
* @stable ICU 2.0
*/
public static final int LONG = 1;
// /**
// * {@icu} A style specifier for <code>getDisplayName()</code> indicating
// * a short generic name, such as "PT."
// * @see #LONG_GENERIC
// * @draft ICU 4.4
// * @provisional This API might change or be removed in a future release.
// */
// public static final int SHORT_GENERIC = 2;
//
// /**
// * {@icu} A style specifier for <code>getDisplayName()</code> indicating
// * a long generic name, such as "Pacific Time."
// * @see #SHORT_GENERIC
// * @draft ICU 4.4
// * @provisional This API might change or be removed in a future release.
// */
// public static final int LONG_GENERIC = 3;
//
// /**
// * {@icu} A style specifier for <code>getDisplayName()</code> indicating
// * a short name derived from the timezone's offset, such as "-0800."
// * @see #LONG_GMT
// * @draft ICU 4.4
// * @provisional This API might change or be removed in a future release.
// */
// public static final int SHORT_GMT = 4;
//
// /**
// * {@icu} A style specifier for <code>getDisplayName()</code> indicating
// * a long name derived from the timezone's offset, such as "GMT-08:00."
// * @see #SHORT_GMT
// * @draft ICU 4.4
// * @provisional This API might change or be removed in a future release.
// */
// public static final int LONG_GMT = 5;
//
// /**
// * {@icu} A style specifier for <code>getDisplayName()</code> indicating
// * a short name derived from the timezone's short standard or daylight
// * timezone name ignoring commonlyUsed, such as "PDT."
// * @draft ICU 4.4
// * @provisional This API might change or be removed in a future release.
// */
//
// public static final int SHORT_COMMONLY_USED = 6;
//
// /**
// * {@icu} A style specifier for <code>getDisplayName()</code> indicating
// * a long name derived from the timezone's fallback name, such as
// * "United States (Los Angeles)."
// * @draft ICU 4.4
// * @provisional This API might change or be removed in a future release.
// */
// public static final int GENERIC_LOCATION = 7;
//
// /**
// * Gets the time zone offset, for current date, modified in case of
// * daylight savings. This is the offset to add *to* UTC to get local time.
// * @param era the era of the given date.
// * @param year the year in the given date.
// * @param month the month in the given date.
// * Month is 0-based. e.g., 0 for January.
// * @param day the day-in-month of the given date.
// * @param dayOfWeek the day-of-week of the given date.
// * @param milliseconds the millis in day in <em>standard</em> local time.
// * @return the offset to add *to* GMT to get local time.
// * @stable ICU 2.0
// */
// /**
// * {@icu} System time zone type constants used by filtering zones in
// * {@link TimeZone#getAvailableIDs(SystemTimeZoneType, String, Integer)}
// *
// * @draft ICU 4.8
// * @provisional This API might change or be removed in a future release.
// */
// public enum SystemTimeZoneType {
// /**
// * Any system zones.
// * @draft ICU 4.8
// * @provisional This API might change or be removed in a future release.
// */
// ANY,
//
// /**
// * Canonical system zones.
// * @draft ICU 4.8
// * @provisional This API might change or be removed in a future release.
// */
// CANONICAL,
//
// /**
// * Canonical system zones associated with actual locations.
// * @draft ICU 4.8
// * @provisional This API might change or be removed in a future release.
// */
// CANONICAL_LOCATION,
// }
public int getOffset(int era, int year, int month, int day,
int dayOfWeek, int milliseconds) {
return timeZone.getOffset(era, year, month, day, dayOfWeek, milliseconds);
}
/**
* Returns the offset of this time zone from UTC at the specified
* date. If Daylight Saving Time is in effect at the specified
* date, the offset value is adjusted with the amount of daylight
* saving.
*
* @param date the date represented in milliseconds since January 1, 1970 00:00:00 GMT
* @return the amount of time in milliseconds to add to UTC to get local time.
*
* @see Calendar#ZONE_OFFSET
* @see Calendar#DST_OFFSET
* @see #getOffset(long, boolean, int[])
* @stable ICU 2.8
*/
public int getOffset(long date) {
return timeZone.getOffset(date);
}
// /**
// * Returns the time zone raw and GMT offset for the given moment
// * in time. Upon return, local-millis = GMT-millis + rawOffset +
// * dstOffset. All computations are performed in the proleptic
// * Gregorian calendar. The default implementation in the TimeZone
// * class delegates to the 8-argument getOffset().
// *
// * @param date moment in time for which to return offsets, in
// * units of milliseconds from January 1, 1970 0:00 GMT, either GMT
// * time or local wall time, depending on `local'.
// * @param local if true, `date' is local wall time; otherwise it
// * is in GMT time.
// * @param offsets output parameter to receive the raw offset, that
// * is, the offset not including DST adjustments, in offsets[0],
// * and the DST offset, that is, the offset to be added to
// * `rawOffset' to obtain the total offset between local and GMT
// * time, in offsets[1]. If DST is not in effect, the DST offset is
// * zero; otherwise it is a positive value, typically one hour.
// *
// * @stable ICU 2.8
// */
// public void getOffset(long date, boolean local, int[] offsets) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Sets the base time zone offset to GMT.
* This is the offset to add *to* UTC to get local time.
* @param offsetMillis the given base time zone offset to GMT.
* @stable ICU 2.0
*/
public void setRawOffset(int offsetMillis) {
if (isFrozen) {
throw new UnsupportedOperationException("Attempt to modify a frozen TimeZone instance.");
}
timeZone.setRawOffset(offsetMillis);
}
/**
* Gets unmodified offset, NOT modified in case of daylight savings.
* This is the offset to add *to* UTC to get local time.
* @return the unmodified offset to add *to* UTC to get local time.
* @stable ICU 2.0
*/
public int getRawOffset() {
return timeZone.getRawOffset();
}
/**
* Gets the ID of this time zone.
* @return the ID of this time zone.
* @stable ICU 2.0
*/
public String getID() {
return timeZone.getID();
}
/**
* Sets the time zone ID. This does not change any other data in
* the time zone object.
* @param ID the new time zone ID.
* @stable ICU 2.0
*/
public void setID(String ID) {
if (isFrozen) {
throw new UnsupportedOperationException("Attempt to modify a frozen TimeZone instance.");
}
timeZone.setID(ID);
}
/**
* Returns a name of this time zone suitable for presentation to the user
* in the default locale.
* This method returns the long generic name.
* If the display name is not available for the locale,
* a fallback based on the country, city, or time zone id will be used.
* @return the human-readable name of this time zone in the default locale.
* @stable ICU 2.0
*/
public final String getDisplayName() {
return timeZone.getDisplayName(ULocale.getDefault(Category.DISPLAY).toLocale());
}
/**
* Returns a name of this time zone suitable for presentation to the user
* in the specified locale.
* This method returns the long generic name.
* If the display name is not available for the locale,
* a fallback based on the country, city, or time zone id will be used.
* @param locale the locale in which to supply the display name.
* @return the human-readable name of this time zone in the given locale
* or in the default locale if the given locale is not recognized.
* @stable ICU 2.0
*/
public final String getDisplayName(Locale locale) {
return timeZone.getDisplayName(locale);
}
/**
* Returns a name of this time zone suitable for presentation to the user
* in the specified locale.
* This method returns the long name, not including daylight savings.
* If the display name is not available for the locale,
* a fallback based on the country, city, or time zone id will be used.
* @param locale the ulocale in which to supply the display name.
* @return the human-readable name of this time zone in the given locale
* or in the default ulocale if the given ulocale is not recognized.
* @stable ICU 3.2
*/
public final String getDisplayName(ULocale locale) {
return timeZone.getDisplayName(locale.toLocale());
}
/**
* Returns a name of this time zone suitable for presentation to the user
* in the default locale.
* If the display name is not available for the locale,
* then this method returns a string in the format
* <code>GMT[+-]hh:mm</code>.
* @param daylight if true, return the daylight savings name.
* @param style the output style of the display name. Valid styles are
* <code>SHORT</code>, <code>LONG</code>, <code>SHORT_GENERIC</code>,
* <code>LONG_GENERIC</code>, <code>SHORT_GMT</code>, <code>LONG_GMT</code>,
* <code>SHORT_COMMONLY_USED</code> or <code>GENERIC_LOCATION</code>.
* @return the human-readable name of this time zone in the default locale.
* @stable ICU 2.0
*/
public final String getDisplayName(boolean daylight, int style) {
return getDisplayName(daylight, style, ULocale.getDefault(Category.DISPLAY));
}
/**
* Returns a name of this time zone suitable for presentation to the user
* in the specified locale.
* If the display name is not available for the locale,
* then this method returns a string in the format
* <code>GMT[+-]hh:mm</code>.
* @param daylight if true, return the daylight savings name.
* @param style the output style of the display name. Valid styles are
* <code>SHORT</code>, <code>LONG</code>, <code>SHORT_GENERIC</code>,
* <code>LONG_GENERIC</code>, <code>SHORT_GMT</code>, <code>LONG_GMT</code>,
* <code>SHORT_COMMONLY_USED</code> or <code>GENERIC_LOCATION</code>.
* @param locale the locale in which to supply the display name.
* @return the human-readable name of this time zone in the given locale
* or in the default locale if the given locale is not recognized.
* @exception IllegalArgumentException style is invalid.
* @stable ICU 2.0
*/
public String getDisplayName(boolean daylight, int style, Locale locale) {
return getDisplayName(daylight, style, ULocale.forLocale(locale));
}
/**
* Returns a name of this time zone suitable for presentation to the user
* in the specified locale.
* If the display name is not available for the locale,
* then this method returns a string in the format
* <code>GMT[+-]hh:mm</code>.
* @param daylight if true, return the daylight savings name.
* @param style the output style of the display name. Valid styles are
* <code>SHORT</code>, <code>LONG</code>, <code>SHORT_GENERIC</code>,
* <code>LONG_GENERIC</code>, <code>SHORT_GMT</code>, <code>LONG_GMT</code>,
* <code>SHORT_COMMONLY_USED</code> or <code>GENERIC_LOCATION</code>.
* @param locale the locale in which to supply the display name.
* @return the human-readable name of this time zone in the given locale
* or in the default locale if the given locale is not recognized.
* @exception IllegalArgumentException style is invalid.
* @stable ICU 3.2
*/
public String getDisplayName(boolean daylight, int style, ULocale locale) {
if (style == SHORT) {
return timeZone.getDisplayName(daylight, java.util.TimeZone.SHORT, locale.toLocale());
} else if (style == LONG) {
return timeZone.getDisplayName(daylight, java.util.TimeZone.LONG, locale.toLocale());
} else {
throw new UnsupportedOperationException("Specified time zone format style is not supported by com.ibm.icu.base");
}
}
/**
* Returns the amount of time to be added to local standard time
* to get local wall clock time.
* <p>
* The default implementation always returns 3600000 milliseconds
* (i.e., one hour) if this time zone observes Daylight Saving
* Time. Otherwise, 0 (zero) is returned.
* <p>
* If an underlying TimeZone implementation subclass supports
* historical Daylight Saving Time changes, this method returns
* the known latest daylight saving value.
*
* @return the amount of saving time in milliseconds
* @stable ICU 2.8
*/
public int getDSTSavings() {
return timeZone.getDSTSavings();
}
/**
* Queries if this time zone uses daylight savings time.
* @return true if this time zone uses daylight savings time,
* false, otherwise.
* @stable ICU 2.0
*/
public boolean useDaylightTime() {
return timeZone.useDaylightTime();
}
// /**
// * Queries if this time zone is in daylight saving time or will observe
// * daylight saving time at any future time.
// * <p>The default implementation in this class returns <code>true</code> if {@link #useDaylightTime()}
// * or {@link #inDaylightTime(Date) inDaylightTime(new Date())} returns <code>true</code>.
// * <p>
// * <strong>Note:</strong> This method was added for JDK compatibility support.
// * The JDK's <code>useDaylightTime()</code> only checks the last known rule(s), therefore
// * it may return false even the zone observes daylight saving time currently. JDK added
// * <code>observesDaylightTime()</code> to resolve the issue. In ICU, {@link #useDaylightTime()}
// * works differently. The ICU implementation checks if the zone uses daylight saving time
// * in the current calendar year. Therefore, it will never return <code>false</code> if
// * daylight saving time is currently used.
// * <p>
// * ICU's TimeZone subclass implementations override this method to support the same behavior
// * with JDK's <code>observesDaylightSavingTime()</code>. Unlike {@link #useDaylightTime()},
// * the implementation does not take past daylight saving time into account, so
// * that this method may return <code>false</code> even when {@link #useDaylightTime()} returns
// * <code>true</code>.
// *
// * @return <code>true</code> if this time zone is in daylight saving time or will observe
// * daylight saving time at any future time.
// * @see #useDaylightTime
// * @stable ICU 49
// */
// public boolean observesDaylightTime() {
// throw new UnsupportedOperationException("Method not supproted by com.ibm.icu.base");
// }
/**
* Queries if the given date is in daylight savings time in
* this time zone.
* @param date the given Date.
* @return true if the given date is in daylight savings time,
* false, otherwise.
* @stable ICU 2.0
*/
public boolean inDaylightTime(Date date) {
return timeZone.inDaylightTime(date);
}
/**
* Gets the <code>TimeZone</code> for the given ID.
*
* @param ID the ID for a <code>TimeZone</code>, such as "America/Los_Angeles",
* or a custom ID such as "GMT-8:00". Note that the support of abbreviations,
* such as "PST", is for JDK 1.1.x compatibility only and full names should be used.
*
* @return the specified <code>TimeZone</code>, or the GMT zone if the given ID
* cannot be understood.
* @stable ICU 2.0
*/
public static synchronized TimeZone getTimeZone(String ID) {
return new TimeZone(java.util.TimeZone.getTimeZone(ID));
}
/**
* Gets the <code>TimeZone</code> for the given ID. The instance of <code>TimeZone</code>
* returned by this method is immutable. Any methods mutate the instance({@link #setID(String)},
* {@link #setRawOffset(int)}) will throw <code>UnsupportedOperationException</code> upon its
* invocation.
*
* @param ID the ID for a <code>TimeZone</code>, such as "America/Los_Angeles",
* or a custom ID such as "GMT-8:00". Note that the support of abbreviations,
* such as "PST", is for JDK 1.1.x compatibility only and full names should be used.
*
* @return the specified <code>TimeZone</code>, or the UNKNOWN_ZONE
* if the given ID cannot be understood.
* @see #UNKNOWN_ZONE
* @draft ICU 49
* @provisional This API might change or be removed in a future release.
*/
public static TimeZone getFrozenTimeZone(String ID) {
return getTimeZone(ID).freeze();
}
/**
* Gets the <code>TimeZone</code> for the given ID and the timezone type.
* @param ID the ID for a <code>TimeZone</code>, such as "America/Los_Angeles", or a
* custom ID such as "GMT-8:00". Note that the support of abbreviations, such as
* "PST", is for JDK 1.1.x compatibility only and full names should be used.
* @param type Time zone type, either <code>TIMEZONE_ICU</code> or
* <code>TIMEZONE_JDK</code>.
* @return the specified <code>TimeZone</code>, or the GMT zone if the given ID
* cannot be understood.
* @stable ICU 4.0
*/
public static synchronized TimeZone getTimeZone(String ID, int type) {
if (type == TIMEZONE_JDK) {
return new TimeZone(java.util.TimeZone.getTimeZone(ID));
}
throw new UnsupportedOperationException("TIMEZONE_ICU not supported by com.ibm.icu.base");
}
/**
* Sets the default time zone type used by <code>getTimeZone</code>.
* @param type time zone type, either <code>TIMEZONE_ICU</code> or
* <code>TIMEZONE_JDK</code>.
* @stable ICU 4.0
*/
public static synchronized void setDefaultTimeZoneType(int type) {
if (type != TIMEZONE_JDK) {
throw new UnsupportedOperationException("TimeZone type other than TIMEZONE_JDK is not supported by com.ibm.icu.base");
}
}
/**
* {@icu} Returns the default time zone type currently used.
* @return The default time zone type, either <code>TIMEZONE_ICU</code> or
* <code>TIMEZONE_JDK</code>.
* @stable ICU 4.0
*/
public static int getDefaultTimeZoneType() {
return TIMEZONE_JDK;
}
// /**
// * {@icu} Returns a set of time zone ID strings with the given filter conditions.
// * <p><b>Note:</b>A <code>Set</code> returned by this method is
// * immutable.
// * @param zoneType The system time zone type.
// * @param region The ISO 3166 two-letter country code or UN M.49 three-digit area code.
// * When null, no filtering done by region.
// * @param rawOffset An offset from GMT in milliseconds, ignoring the effect of daylight savings
// * time, if any. When null, no filtering done by zone offset.
// * @return an immutable set of system time zone IDs.
// * @see SystemTimeZoneType
// *
// * @draft ICU 4.8
// * @provisional This API might change or be removed in a future release.
// */
// public static Set<String> getAvailableIDs(SystemTimeZoneType zoneType,
// String region, Integer rawOffset) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Return a new String array containing all system TimeZone IDs
* with the given raw offset from GMT. These IDs may be passed to
* <code>get()</code> to construct the corresponding TimeZone
* object.
* @param rawOffset the offset in milliseconds from GMT
* @return an array of IDs for system TimeZones with the given
* raw offset. If there are none, return a zero-length array.
* @stable ICU 2.0
*/
public static String[] getAvailableIDs(int rawOffset) {
return java.util.TimeZone.getAvailableIDs(rawOffset);
}
// /**
// * Return a new String array containing all system TimeZone IDs
// * associated with the given country. These IDs may be passed to
// * <code>get()</code> to construct the corresponding TimeZone
// * object.
// * @param country a two-letter ISO 3166 country code, or <code>null</code>
// * to return zones not associated with any country
// * @return an array of IDs for system TimeZones in the given
// * country. If there are none, return a zero-length array.
// * @stable ICU 2.0
// */
// public static String[] getAvailableIDs(String country) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Return a new String array containing all system TimeZone IDs.
* These IDs (and only these IDs) may be passed to
* <code>get()</code> to construct the corresponding TimeZone
* object.
* @return an array of all system TimeZone IDs
* @stable ICU 2.0
*/
public static String[] getAvailableIDs() {
return java.util.TimeZone.getAvailableIDs();
}
// /**
// * {@icu} Returns the number of IDs in the equivalency group that
// * includes the given ID. An equivalency group contains zones
// * that have the same GMT offset and rules.
// *
// * <p>The returned count includes the given ID; it is always >= 1
// * for valid IDs. The given ID must be a system time zone. If it
// * is not, returns zero.
// * @param id a system time zone ID
// * @return the number of zones in the equivalency group containing
// * 'id', or zero if 'id' is not a valid system ID
// * @see #getEquivalentID
// * @stable ICU 2.0
// */
// public static int countEquivalentIDs(String id) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
// /**
// * Returns an ID in the equivalency group that
// * includes the given ID. An equivalency group contains zones
// * that have the same GMT offset and rules.
// *
// * <p>The given index must be in the range 0..n-1, where n is the
// * value returned by <code>countEquivalentIDs(id)</code>. For
// * some value of 'index', the returned value will be equal to the
// * given id. If the given id is not a valid system time zone, or
// * if 'index' is out of range, then returns an empty string.
// * @param id a system time zone ID
// * @param index a value from 0 to n-1, where n is the value
// * returned by <code>countEquivalentIDs(id)</code>
// * @return the ID of the index-th zone in the equivalency group
// * containing 'id', or an empty string if 'id' is not a valid
// * system ID or 'index' is out of range
// * @see #countEquivalentIDs
// * @stable ICU 2.0
// */
// public static String getEquivalentID(String id, int index) {
// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
// }
/**
* Gets the default <code>TimeZone</code> for this host.
* The source of the default <code>TimeZone</code>
* may vary with implementation.
* @return a default <code>TimeZone</code>.
* @stable ICU 2.0
*/
public static TimeZone getDefault() {
return new TimeZone(java.util.TimeZone.getDefault());
}
/**
* Sets the <code>TimeZone</code> that is
* returned by the <code>getDefault</code> method. If <code>zone</code>
* is null, reset the default to the value it had originally when the
* VM first started.
* @param tz the new default time zone
* @stable ICU 2.0
*/
public static void setDefault(TimeZone tz) {
java.util.TimeZone.setDefault(tz.timeZone);
}
/**
* Returns true if this zone has the same rule and offset as another zone.
* That is, if this zone differs only in ID, if at all. Returns false
* if the other zone is null.
* @param other the <code>TimeZone</code> object to be compared with
* @return true if the other zone is not null and is the same as this one,
* with the possible exception of the ID
* @stable ICU 2.0
*/
public boolean hasSameRules(TimeZone other) {
return timeZone.hasSameRules(other.timeZone);
}
/**
* Overrides clone.
* @stable ICU 2.0
*/
public Object clone() {
return new TimeZone((java.util.TimeZone)timeZone.clone());
}
/**
* Overrides equals.
* @stable ICU 3.6
*/
public boolean equals(Object obj){
try {
return timeZone.equals(((TimeZone)obj).timeZone);
} catch (Exception e) {
return false;
}
}
/**
* Overrides hashCode.
* @stable ICU 3.6
*/
public int hashCode(){
return timeZone.hashCode();
}
// /**
// * {@icu} Returns the time zone data version currently used by ICU.
// *
// * @return the version string, such as "2007f"
// * @throws MissingResourceException if ICU time zone resource bundle
// * is missing or the version information is not available.
// *
// * @stable ICU 3.8
// */
// public static synchronized String getTZDataVersion() {
// throw new UnsupportedOperationException("Method not supproted by com.ibm.icu.base");
// }
// /**
// * {@icu} Returns the canonical system time zone ID or the normalized
// * custom time zone ID for the given time zone ID.
// * @param id The input time zone ID to be canonicalized.
// * @return The canonical system time zone ID or the custom time zone ID
// * in normalized format for the given time zone ID. When the given time zone ID
// * is neither a known system time zone ID nor a valid custom time zone ID,
// * null is returned.
// * @stable ICU 4.0
// */
// public static String getCanonicalID(String id) {
// throw new UnsupportedOperationException("Method not supproted by com.ibm.icu.base");
// }
// /**
// * {@icu} Returns the canonical system time zone ID or the normalized
// * custom time zone ID for the given time zone ID.
// * @param id The input time zone ID to be canonicalized.
// * @param isSystemID When non-null boolean array is specified and
// * the given ID is a known system time zone ID, true is set to <code>isSystemID[0]</code>
// * @return The canonical system time zone ID or the custom time zone ID
// * in normalized format for the given time zone ID. When the given time zone ID
// * is neither a known system time zone ID nor a valid custom time zone ID,
// * null is returned.
// * @stable ICU 4.0
// */
// public static String getCanonicalID(String id, boolean[] isSystemID) {
// throw new UnsupportedOperationException("Method not supproted by com.ibm.icu.base");
// }
// /**
// * {@icu} Returns the region code associated with the given
// * system time zone ID. The region code is either ISO 3166
// * 2-letter country code or UN M.49 3-digit area code.
// * When the time zone is not associated with a specific location,
// * for example - "Etc/UTC", "EST5EDT", then this method returns
// * "001" (UN M.49 area code for World).
// * @param id the system time zone ID.
// * @return the region code associated with the given
// * system time zone ID.
// * @throws IllegalArgumentException if <code>id</code> is not a known system ID.
// * @see #getAvailableIDs(String)
// *
// * @draft ICU 4.8
// * @provisional This API might change or be removed in a future release.
// */
// public static String getRegion(String id) {
// throw new UnsupportedOperationException("Method not supproted by com.ibm.icu.base");
// }
private transient boolean isFrozen = false;
/**
* {@inheritDoc}
* @draft ICU 49
* @provisional This API might change or be removed in a future release.
*/
public boolean isFrozen() {
return isFrozen;
}
/**
* {@inheritDoc}
* @draft ICU 49
* @provisional This API might change or be removed in a future release.
*/
public TimeZone freeze() {
isFrozen = true;
return this;
}
/**
* {@inheritDoc}
* @draft ICU 49
* @provisional This API might change or be removed in a future release.
*/
public TimeZone cloneAsThawed() {
try {
TimeZone other = (TimeZone) super.clone();
other.isFrozen = false;
return other;
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}
}
//eof

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.icu.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -1,2 +0,0 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View file

@ -1,77 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=ignore
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.7

View file

@ -1,3 +0,0 @@
#Thu Dec 14 11:51:01 EST 2006
eclipse.preferences.version=1
internal.default.compliance=default

View file

@ -1,10 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: com.ibm.icu.tests
Bundle-Version: @BUILD_VERSION@
Bundle-Vendor: %providerName
Fragment-Host: com.ibm.icu
Bundle-Copyright: @COPYRIGHT@
Require-Bundle: org.junit
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View file

@ -1,17 +0,0 @@
###############################################################################
# Copyright (c) 2000, 2011 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
source.. = src/
output.. = bin/
bin.includes = .,\
about.html,\
about_files/,\
plugin.properties,\
META-INF/

View file

@ -1,12 +0,0 @@
###############################################################################
# Copyright (c) 2011 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
pluginName = International Components for Unicode for Java (ICU4J) Tests
providerName = IBM Corporation

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.icu</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View file

@ -1,2 +0,0 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View file

@ -1,76 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=ignore
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.7

View file

@ -1,3 +0,0 @@
#Thu Dec 14 11:50:17 EST 2006
eclipse.preferences.version=1
internal.default.compliance=default

View file

@ -1,29 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: com.ibm.icu; singleton:=true
Bundle-Version: @BUILD_VERSION@
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-Copyright: @COPYRIGHT@
Export-Package: com.ibm.icu.lang;base=true;full=true;version="@IMPL_VERSION@",
com.ibm.icu.math;base=true;full=true;version="@IMPL_VERSION@",
com.ibm.icu.text;base=true;full=true;version="@IMPL_VERSION@",
com.ibm.icu.util;base=true;full=true;version="@IMPL_VERSION@",
com.ibm.icu.impl;x-internal:=true,
com.ibm.icu.impl.data;x-internal:=true,
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b;x-internal:=true,
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.brkitr;x-internal:=true,
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.coll;x-internal:=true,
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.curr;x-internal:=true,
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.lang;x-internal:=true,
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.rbnf;x-internal:=true,
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.region;x-internal:=true,
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.translit;x-internal:=true,
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.zone;x-internal:=true,
com.ibm.icu.impl.duration;x-internal:=true,
com.ibm.icu.impl.locale;x-internal:=true
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: icu-data.jar,.
Eclipse-ExtensibleAPI: true

View file

@ -1,19 +0,0 @@
###############################################################################
# Copyright (c) 2000, 2008 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
source.. = src/
output.. = bin/
src.includes = about.html,\
about_files/
bin.includes = .,\
about.html,\
about_files/,\
plugin.properties,\
META-INF/

View file

@ -1,12 +0,0 @@
###############################################################################
# Copyright (c) 2000, 2008 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
pluginName = International Components for Unicode for Java (ICU4J)
providerName = IBM Corporation