mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-8581 ICU4J 4.8 maintenance branch copied from trunk at r30135
X-SVN-Rev: 30137
This commit is contained in:
commit
5a8dc8f3b3
1609 changed files with 1675311 additions and 0 deletions
454
.gitattributes
vendored
Normal file
454
.gitattributes
vendored
Normal file
|
@ -0,0 +1,454 @@
|
|||
* text=auto !eol
|
||||
|
||||
*.c text !eol
|
||||
*.cc text !eol
|
||||
*.classpath text !eol
|
||||
*.cpp text !eol
|
||||
*.css text !eol
|
||||
*.dsp text !eol
|
||||
*.dsw text !eol
|
||||
*.filters text !eol
|
||||
*.h text !eol
|
||||
*.htm text !eol
|
||||
*.html text !eol
|
||||
*.in text !eol
|
||||
*.java text !eol
|
||||
*.launch text !eol
|
||||
*.mak text !eol
|
||||
*.md text !eol
|
||||
*.MF text !eol
|
||||
*.mk text !eol
|
||||
*.pl text !eol
|
||||
*.pm text !eol
|
||||
*.project text !eol
|
||||
*.properties text !eol
|
||||
*.py text !eol
|
||||
*.rc text !eol
|
||||
*.sh text eol=lf
|
||||
*.sln text !eol
|
||||
*.stub text !eol
|
||||
*.txt text !eol
|
||||
*.ucm text !eol
|
||||
*.vcproj text !eol
|
||||
*.vcxproj text !eol
|
||||
*.xml text !eol
|
||||
*.xsl text !eol
|
||||
*.xslt text !eol
|
||||
Makefile text !eol
|
||||
configure text !eol
|
||||
LICENSE text !eol
|
||||
README text !eol
|
||||
|
||||
*.bin -text
|
||||
*.brk -text
|
||||
*.cnv -text
|
||||
*.icu -text
|
||||
*.res -text
|
||||
*.nrm -text
|
||||
*.spp -text
|
||||
*.tri2 -text
|
||||
|
||||
/build.properties -text
|
||||
demos/.settings/org.eclipse.core.resources.prefs -text
|
||||
demos/manifest.stub -text
|
||||
eclipse-build/features.template/com.ibm.icu.base/.project -text
|
||||
eclipse-build/features.template/com.ibm.icu.base/build.properties -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base.tests/.classpath -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base.tests/.project -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base.tests/.settings/org.eclipse.jdt.core.prefs -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base.tests/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base.tests/META-INF/MANIFEST.MF -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base.tests/build.properties -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base.tests/plugin.properties -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base/.classpath -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base/.project -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base/.settings/org.eclipse.jdt.core.prefs -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base/META-INF/MANIFEST.MF -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base/build.properties -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.base/plugin.properties -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.tests/META-INF/MANIFEST.MF -text
|
||||
eclipse-build/plugins.template/com.ibm.icu.tests/plugin.properties -text
|
||||
eclipse-build/plugins.template/com.ibm.icu/META-INF/MANIFEST.MF -text
|
||||
main/classes/charset/.classpath -text
|
||||
main/classes/charset/.project -text
|
||||
main/classes/charset/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/classes/charset/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/classes/charset/manifest.stub -text
|
||||
main/classes/collate/.classpath -text
|
||||
main/classes/collate/.project -text
|
||||
main/classes/collate/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/classes/collate/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/classes/collate/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
main/classes/collate/collate-build.launch -text
|
||||
main/classes/core/.classpath -text
|
||||
main/classes/core/.project -text
|
||||
main/classes/core/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/classes/core/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/classes/core/manifest.stub -text
|
||||
main/classes/currdata/.externalToolBuilders/copy-data-currdata.launch -text
|
||||
main/classes/currdata/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/classes/currdata/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/classes/currdata/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
main/classes/currdata/currdata-build.launch -text
|
||||
main/classes/langdata/.externalToolBuilders/copy-data-langdata.launch -text
|
||||
main/classes/langdata/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/classes/langdata/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/classes/langdata/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
main/classes/langdata/langdata-build.launch -text
|
||||
main/classes/localespi/.classpath -text
|
||||
main/classes/localespi/.project -text
|
||||
main/classes/localespi/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/classes/localespi/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/classes/localespi/manifest.stub -text
|
||||
main/classes/localespi/src/META-INF/services/java.text.spi.BreakIteratorProvider -text
|
||||
main/classes/localespi/src/META-INF/services/java.text.spi.CollatorProvider -text
|
||||
main/classes/localespi/src/META-INF/services/java.text.spi.DateFormatProvider -text
|
||||
main/classes/localespi/src/META-INF/services/java.text.spi.DateFormatSymbolsProvider -text
|
||||
main/classes/localespi/src/META-INF/services/java.text.spi.DecimalFormatSymbolsProvider -text
|
||||
main/classes/localespi/src/META-INF/services/java.text.spi.NumberFormatProvider -text
|
||||
main/classes/localespi/src/META-INF/services/java.util.spi.CurrencyNameProvider -text
|
||||
main/classes/localespi/src/META-INF/services/java.util.spi.LocaleNameProvider -text
|
||||
main/classes/localespi/src/META-INF/services/java.util.spi.TimeZoneNameProvider -text
|
||||
main/classes/localespi/src/com/ibm/icu/impl/javaspi/ICULocaleServiceProviderConfig.properties -text
|
||||
main/classes/regiondata/.externalToolBuilders/copy-data-regiondata.launch -text
|
||||
main/classes/regiondata/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/classes/regiondata/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/classes/regiondata/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
main/classes/regiondata/regiondata-build.launch -text
|
||||
main/classes/translit/.externalToolBuilders/copy-data-translit.launch -text
|
||||
main/classes/translit/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/classes/translit/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/classes/translit/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
main/classes/translit/translit-build.launch -text
|
||||
main/shared/.project -text
|
||||
main/shared/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/shared/data/icudata.jar -text
|
||||
main/shared/data/testdata.jar -text
|
||||
main/tests/charset/.classpath -text
|
||||
main/tests/charset/.project -text
|
||||
main/tests/charset/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/tests/charset/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/tests/charset/manifest.stub -text
|
||||
main/tests/collate/.classpath -text
|
||||
main/tests/collate/.project -text
|
||||
main/tests/collate/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/tests/collate/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/tests/collate/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
main/tests/collate/collate-tests-build.launch -text
|
||||
main/tests/core/.classpath -text
|
||||
main/tests/core/.project -text
|
||||
main/tests/core/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/tests/core/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/tests/core/manifest.stub -text
|
||||
main/tests/core/src/com/ibm/icu/dev/data/rbbi/english.dict -text
|
||||
main/tests/core/src/com/ibm/icu/dev/data/resources/testmessages.properties -text
|
||||
main/tests/core/src/com/ibm/icu/dev/data/thai6.ucs -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.impl.OlsonTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.impl.TimeZoneAdapter.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.math.BigDecimal.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.math.MathContext.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.ArabicShapingException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.ChineseDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.ChineseDateFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.DateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.DateFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.DecimalFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.DecimalFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.MessageFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.NumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.RuleBasedNumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.SimpleDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.text.StringPrepParseException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.BuddhistCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.Calendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.ChineseCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.CopticCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.Currency.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.EthiopicCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.GregorianCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.HebrewCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.IslamicCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.JapaneseCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.SimpleTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.TimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.ULocale.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.6/com.ibm.icu.util.UResourceTypeMismatchException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.impl.DateNumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.impl.InvalidFormatException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.impl.OlsonTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.impl.RelativeDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.impl.TimeZoneAdapter.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.impl.duration.BasicDurationFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.math.BigDecimal.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.math.MathContext.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.ArabicShapingException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.ChineseDateFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.ChineseDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.ChineseDateFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.DateFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.DateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.DateFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.DecimalFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.DecimalFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.MessageFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.MessageFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.NumberFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.NumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.PluralFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.PluralRules.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.RuleBasedNumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.SimpleDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.text.StringPrepParseException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.AnnualTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.BuddhistCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.Calendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.ChineseCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.CopticCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.Currency.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.DateTimeRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.EthiopicCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.GregorianCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.HebrewCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.IndianCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.InitialTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.IslamicCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.JapaneseCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.RuleBasedTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.SimpleTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.TaiwanCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.TimeArrayTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.TimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.ULocale.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.UResourceTypeMismatchException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_3.8.1/com.ibm.icu.util.VTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.impl.DateNumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.impl.InvalidFormatException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.impl.JavaTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.impl.OlsonTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.impl.RelativeDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.impl.TimeZoneAdapter.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.impl.duration.BasicDurationFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.math.BigDecimal.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.math.MathContext.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.ArabicShapingException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.ChineseDateFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.ChineseDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.ChineseDateFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.DateFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.DateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.DateFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.DateIntervalFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.DateIntervalInfo$PatternInfo.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.DateIntervalInfo.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.DecimalFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.DecimalFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.MessageFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.MessageFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.NumberFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.NumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.PluralFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.PluralRules.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.RuleBasedNumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.SimpleDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.StringPrepParseException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.text.TimeUnitFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.AnnualTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.BuddhistCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.Calendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.ChineseCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.CopticCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.Currency.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.DateInterval.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.DateTimeRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.EthiopicCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.GregorianCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.HebrewCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.IndianCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.InitialTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.IslamicCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.JapaneseCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.RuleBasedTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.SimpleTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.TaiwanCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.TimeArrayTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.TimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.ULocale.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.UResourceTypeMismatchException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.0/com.ibm.icu.util.VTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.impl.DateNumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.impl.IllegalIcuArgumentException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.impl.InvalidFormatException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.impl.JavaTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.impl.OlsonTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.impl.RelativeDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.impl.TimeZoneAdapter.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.impl.duration.BasicDurationFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.impl.locale.LocaleSyntaxException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.math.BigDecimal.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.math.MathContext.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.ArabicShapingException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.ChineseDateFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.ChineseDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.ChineseDateFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.CurrencyPluralInfo.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.DateFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.DateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.DateFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.DateIntervalFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.DateIntervalInfo$PatternInfo.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.DateIntervalInfo.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.DecimalFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.DecimalFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.MessageFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.MessageFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.NumberFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.NumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.PluralFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.PluralRules.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.RuleBasedNumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.SimpleDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.StringPrepParseException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.text.TimeUnitFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.AnnualTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.BuddhistCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.Calendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.ChineseCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.CopticCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.Currency.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.DateInterval.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.DateTimeRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.EthiopicCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.GregorianCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.HebrewCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.IllformedLocaleException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.IndianCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.InitialTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.IslamicCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.JapaneseCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.RuleBasedTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.SimpleTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.TaiwanCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.TimeArrayTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.TimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.ULocale.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.UResourceTypeMismatchException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.2.1/com.ibm.icu.util.VTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.impl.DateNumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.impl.IllegalIcuArgumentException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.impl.InvalidFormatException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.impl.JavaTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.impl.OlsonTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.impl.RelativeDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.impl.TimeZoneAdapter.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.impl.duration.BasicDurationFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.impl.locale.LocaleSyntaxException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.math.BigDecimal.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.math.MathContext.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.ArabicShapingException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.ChineseDateFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.ChineseDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.ChineseDateFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.CurrencyPluralInfo.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.DateFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.DateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.DateFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.DateIntervalFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.DateIntervalInfo$PatternInfo.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.DateIntervalInfo.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.DecimalFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.DecimalFormatSymbols.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.MessageFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.MessageFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.NumberFormat$Field.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.NumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.PluralFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.PluralRules.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.RuleBasedNumberFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.SelectFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.SimpleDateFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.StringPrepParseException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.text.TimeUnitFormat.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.AnnualTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.BuddhistCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.Calendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.ChineseCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.CopticCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.Currency.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.DateInterval.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.DateTimeRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.EthiopicCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.GregorianCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.HebrewCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.IllformedLocaleException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.IndianCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.InitialTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.IslamicCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.JapaneseCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.RuleBasedTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.SimpleTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.TaiwanCalendar.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.TimeArrayTimeZoneRule.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.TimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.ULocale.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.UResourceTypeMismatchException.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.VTimeZone.dat -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRanges1.16.tri2 -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRanges1.32.tri2 -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRanges2.16.tri2 -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRanges2.32.tri2 -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRanges3.16.tri2 -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRanges3.32.tri2 -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRangesEmpty.16.tri2 -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRangesEmpty.32.tri2 -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRangesSingleValue.16.tri2 -text
|
||||
main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRangesSingleValue.32.tri2 -text
|
||||
main/tests/framework/.classpath -text
|
||||
main/tests/framework/.project -text
|
||||
main/tests/framework/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/tests/framework/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/tests/framework/manifest.stub -text
|
||||
main/tests/localespi/.classpath -text
|
||||
main/tests/localespi/.project -text
|
||||
main/tests/localespi/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/tests/localespi/manifest.stub -text
|
||||
main/tests/packaging/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/tests/packaging/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/tests/packaging/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
main/tests/packaging/packaging-tests-build.launch -text
|
||||
main/tests/translit/.externalToolBuilders/copy-translit-test-data.launch -text
|
||||
main/tests/translit/.settings/org.eclipse.core.resources.prefs -text
|
||||
main/tests/translit/.settings/org.eclipse.jdt.core.prefs -text
|
||||
main/tests/translit/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
main/tests/translit/translit-tests-build.launch -text
|
||||
/manifest.stub -text
|
||||
tools/build/.settings/org.eclipse.core.resources.prefs -text
|
||||
tools/build/icu4j28.api.gz -text
|
||||
tools/build/icu4j30.api.gz -text
|
||||
tools/build/icu4j32.api.gz -text
|
||||
tools/build/icu4j34.api.gz -text
|
||||
tools/build/icu4j341.api.gz -text
|
||||
tools/build/icu4j342.api.gz -text
|
||||
tools/build/icu4j343.api.gz -text
|
||||
tools/build/icu4j36.api.gz -text
|
||||
tools/build/icu4j38.api.gz -text
|
||||
tools/build/icu4j381.api.gz -text
|
||||
tools/build/icu4j400.api.gz -text
|
||||
tools/build/icu4j401.api.gz -text
|
||||
tools/build/icu4j42.api.gz -text
|
||||
tools/build/icu4j421.api.gz -text
|
||||
tools/build/icu4j44.api.gz -text
|
||||
tools/build/icu4j44.api2.gz -text
|
||||
tools/build/icu4j46.api2.gz -text
|
||||
tools/build/manifest.stub -text
|
||||
tools/misc/.settings/org.eclipse.core.resources.prefs -text
|
||||
tools/misc/manifest.stub -text
|
||||
|
||||
# The following file types are stored in Git-LFS.
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.dat filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gif filter=lfs diff=lfs merge=lfs -text
|
||||
|
22
.gitignore
vendored
Normal file
22
.gitignore
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*.jar
|
||||
/.project
|
||||
demos/out
|
||||
/doc
|
||||
main/classes/charset/out
|
||||
main/classes/collate/out
|
||||
main/classes/core/out
|
||||
main/classes/currdata/out
|
||||
main/classes/langdata/out
|
||||
main/classes/localespi/out
|
||||
main/classes/regiondata/out
|
||||
main/classes/translit/out
|
||||
main/tests/charset/out
|
||||
main/tests/collate/out
|
||||
main/tests/core/out
|
||||
main/tests/framework/out
|
||||
main/tests/localespi/out
|
||||
main/tests/packaging/out
|
||||
main/tests/translit/out
|
||||
/out
|
||||
tools/build/out
|
||||
tools/misc/out
|
208
APIChangeReport.html
Normal file
208
APIChangeReport.html
Normal file
|
@ -0,0 +1,208 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>ICU4J API Comparison: ICU4J 4.6 with ICU4J 4.8</title>
|
||||
<!-- Copyright 2011, IBM, All Rights Reserved. -->
|
||||
</head>
|
||||
<body>
|
||||
<h1>ICU4J API Comparison: ICU4J 4.6 with ICU4J 4.8</h1>
|
||||
|
||||
<hr/>
|
||||
<h2>Removed from ICU4J 4.6</h2>
|
||||
|
||||
<h3>Package com.ibm.icu.lang</h3>
|
||||
<ul>
|
||||
UCharacter
|
||||
<ul>
|
||||
<li>(stable) public static int <i>getPropertyEnum</i>(java.lang.String)</li>
|
||||
<li>(stable) public static int <i>getPropertyValueEnum</i>(int, java.lang.String)</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Package com.ibm.icu.text</h3>
|
||||
<ul>
|
||||
SpoofChecker
|
||||
<ul>
|
||||
<li>(draft) public boolean <i>check</i>(java.lang.String)</li>
|
||||
<li>(draft) public boolean <i>check</i>(java.lang.String, SpoofChecker.CheckResult)</li>
|
||||
</ul>
|
||||
UnicodeSet
|
||||
<ul>
|
||||
<li>(stable) public final UnicodeSet <i>add</i>(java.lang.String)</li>
|
||||
<li>(stable) public final UnicodeSet <i>addAll</i>(java.lang.String)</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Package com.ibm.icu.util</h3>
|
||||
<ul>
|
||||
Currency
|
||||
<ul>
|
||||
<li>(obsolete) public final ULocale <i>getLocale</i>(ULocale.Type)</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
<h2>Deprecated or Obsoleted in ICU4J 4.8</h2>
|
||||
<p>(no API obsoleted)</p>
|
||||
|
||||
<hr/>
|
||||
<h2>Changed in ICU4J 4.8 (old, new)</h2>
|
||||
|
||||
<h3>Package com.ibm.icu.text</h3>
|
||||
<ul>
|
||||
<li> (stable) public abstract class <i>Collator</i> extends java.lang.Object implements java.util.Comparator, java.lang.Cloneable</br>
|
||||
(stable) public abstract class <i>Collator</i> extends java.lang.Object implements java.util.Comparator, com.ibm.icu.util.Freezable</li>
|
||||
MessageFormat
|
||||
<ul>
|
||||
<li> (stable) public static java.lang.String <i>format</i>(java.lang.String, java.lang.Object[])</br>
|
||||
(stable) public static java.lang.String <i>format</i>(java.lang.String, java.lang.Object...)</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
<h2>Promoted to stable in ICU4J 4.8</h2>
|
||||
|
||||
<h3>Package com.ibm.icu.text</h3>
|
||||
<ul>
|
||||
DateFormat
|
||||
<ul>
|
||||
<li>(stable) public static final int MILLISECOND_FIELD</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
<h2>Added in ICU4J 4.8</h2>
|
||||
|
||||
<h3>Package com.ibm.icu.charset</h3>
|
||||
<ul>
|
||||
CharsetDecoderICU
|
||||
<ul>
|
||||
<li>(draft) public final float <i>maxBytesPerChar</i>()</li>
|
||||
</ul>
|
||||
CharsetEncoderICU
|
||||
<ul>
|
||||
<li>(draft) public final float <i>maxCharsPerByte</i>()</li>
|
||||
</ul>
|
||||
CharsetICU
|
||||
<ul>
|
||||
<li>(draft) public boolean <i>isFixedWidth</i>()</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Package com.ibm.icu.lang</h3>
|
||||
<ul>
|
||||
UCharacter
|
||||
<ul>
|
||||
<li>(stable) public static int <i>getPropertyEnum</i>(java.lang.CharSequence)</li>
|
||||
<li>(stable) public static int <i>getPropertyValueEnum</i>(int, java.lang.CharSequence)</li>
|
||||
</ul>
|
||||
UScript
|
||||
<ul>
|
||||
<li>(stable) public static final int AFAKA</li>
|
||||
<li>(stable) public static final int JURCHEN</li>
|
||||
<li>(stable) public static final int MRO</li>
|
||||
<li>(stable) public static final int NUSHU</li>
|
||||
<li>(stable) public static final int SHARADA</li>
|
||||
<li>(stable) public static final int SORA_SOMPENG</li>
|
||||
<li>(stable) public static final int TAKRI</li>
|
||||
<li>(stable) public static final int TANGUT</li>
|
||||
<li>(stable) public static final int WOLEAI</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Package com.ibm.icu.text</h3>
|
||||
<ul>
|
||||
<li>(draft) public static interface <i>Collator.ReorderCodes</i></li>
|
||||
<li>(draft) public final class <i>MessagePattern</i></li>
|
||||
<li>(draft) public static final class <i>MessagePattern.ApostropheMode</i></li>
|
||||
<li>(draft) public static final class <i>MessagePattern.ArgType</i></li>
|
||||
<li>(draft) public static final class <i>MessagePattern.Part</i></li>
|
||||
<li>(draft) public static final class <i>MessagePattern.Part.Type</i></li>
|
||||
Bidi
|
||||
<ul>
|
||||
<li>(draft) public void <i>setContext</i>(java.lang.String, java.lang.String)</li>
|
||||
</ul>
|
||||
Collator
|
||||
<ul>
|
||||
<li>(draft) public Collator <i>cloneAsThawed</i>()</li>
|
||||
<li>(draft) public Collator <i>freeze</i>()</li>
|
||||
<li>(draft) public static int[] <i>getEquivalentReorderCodes</i>(int)</li>
|
||||
<li>(draft) public int[] <i>getReorderCodes</i>()</li>
|
||||
<li>(draft) public boolean <i>isFrozen</i>()</li>
|
||||
<li>(draft) public void <i>setReorderCodes</i>(int...)</li>
|
||||
</ul>
|
||||
MessageFormat
|
||||
<ul>
|
||||
<li>(draft) public void <i>applyPattern</i>(java.lang.String, MessagePattern.ApostropheMode)</li>
|
||||
<li>(draft) public MessagePattern.ApostropheMode <i>getApostropheMode</i>()</li>
|
||||
<li>(draft) public java.util.Set<java.lang.String> <i>getArgumentNames</i>()</li>
|
||||
<li>(draft) public java.text.Format <i>getFormatByArgumentName</i>(java.lang.String)</li>
|
||||
</ul>
|
||||
PluralRules
|
||||
<ul>
|
||||
<li>(draft) public static final double NO_UNIQUE_VALUE</li>
|
||||
<li>(draft) public java.util.Collection<java.lang.Double> <i>getAllKeywordValues</i>(java.lang.String)</li>
|
||||
<li>(draft) public java.util.Collection<java.lang.Double> <i>getSamples</i>(java.lang.String)</li>
|
||||
<li>(draft) public double <i>getUniqueKeywordValue</i>(java.lang.String)</li>
|
||||
</ul>
|
||||
RuleBasedBreakIterator
|
||||
<ul>
|
||||
<li>(draft) public static void <i>compileRules</i>(java.lang.String, java.io.OutputStream)</li>
|
||||
<li>(draft) public static RuleBasedBreakIterator <i>getInstanceFromCompiledRules</i>(java.io.InputStream)</li>
|
||||
</ul>
|
||||
RuleBasedCollator
|
||||
<ul>
|
||||
<li>(draft) public RuleBasedCollator <i>cloneAsThawed</i>()</li>
|
||||
<li>(draft) public Collator <i>freeze</i>()</li>
|
||||
<li>(draft) public static int[] <i>getEquivalentReorderCodes</i>(int)</li>
|
||||
<li>(draft) public int[] <i>getReorderCodes</i>()</li>
|
||||
<li>(draft) public boolean <i>isFrozen</i>()</li>
|
||||
<li>(draft) public void <i>setReorderCodes</i>(int...)</li>
|
||||
</ul>
|
||||
SpoofChecker
|
||||
<ul>
|
||||
<li>(draft) public boolean <i>failsChecks</i>(java.lang.String)</li>
|
||||
<li>(draft) public boolean <i>failsChecks</i>(java.lang.String, SpoofChecker.CheckResult)</li>
|
||||
</ul>
|
||||
UnicodeSet
|
||||
<ul>
|
||||
<li>(draft) public static final UnicodeSet ALL_CODE_POINTS</li>
|
||||
<li>(draft) public static final UnicodeSet EMPTY</li>
|
||||
<li>(stable) public final UnicodeSet <i>add</i>(java.lang.CharSequence)</li>
|
||||
<li>(stable) public final UnicodeSet <i>addAll</i>(java.lang.CharSequence)</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Package com.ibm.icu.util</h3>
|
||||
<ul>
|
||||
<li>(draft) public final class <i>BytesTrie</i></li>
|
||||
<li>(draft) public static final class <i>BytesTrie.Entry</i></li>
|
||||
<li>(draft) public static final class <i>BytesTrie.Iterator</i></li>
|
||||
<li>(draft) public static final class <i>BytesTrie.Result</i></li>
|
||||
<li>(draft) public static final class <i>BytesTrie.State</i></li>
|
||||
<li>(draft) public final class <i>BytesTrieBuilder</i></li>
|
||||
<li>(draft) public final class <i>CharsTrie</i></li>
|
||||
<li>(draft) public static final class <i>CharsTrie.Entry</i></li>
|
||||
<li>(draft) public static final class <i>CharsTrie.Iterator</i></li>
|
||||
<li>(draft) public static final class <i>CharsTrie.State</i></li>
|
||||
<li>(draft) public final class <i>CharsTrieBuilder</i></li>
|
||||
<li>(draft) public class <i>Output</i></li>
|
||||
<li>(draft) public abstract class <i>StringTrieBuilder</i></li>
|
||||
<li>(draft) public static final class <i>StringTrieBuilder.Option</i></li>
|
||||
<li>(draft) public static final class <i>TimeZone.SystemTimeZoneType</i></li>
|
||||
TimeZone
|
||||
<ul>
|
||||
<li>(draft) public static final java.lang.String UNKNOWN_ZONE_ID</li>
|
||||
<li>(draft) public static java.util.Set<java.lang.String> <i>getAvailableIDs</i>(TimeZone.SystemTimeZoneType, java.lang.String, java.lang.Integer)</li>
|
||||
<li>(draft) public static java.lang.String <i>getRegion</i>(java.lang.String)</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<hr/>
|
||||
<p><i><font size="-1">Contents generated by ReportAPI tool on Fri May 13 12:38:20 EDT 2011<br/>Copyright (C) 2011, International Business Machines Corporation, All Rights Reserved.</font></i></p>
|
||||
</body>
|
||||
</html>
|
8
build.properties
Normal file
8
build.properties
Normal file
|
@ -0,0 +1,8 @@
|
|||
#*******************************************************************************
|
||||
#* Copyright (C) 2009-2011, International Business Machines Corporation and *
|
||||
#* others. All Rights Reserved. *
|
||||
#*******************************************************************************
|
||||
api.report.version = 48
|
||||
api.report.prev.version = 46
|
||||
release.file.ver = 4_8
|
||||
|
9
demos/.classpath
Normal file
9
demos/.classpath
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?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/J2SE-1.5"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/icu4j-charset"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/icu4j-core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/icu4j-translit"/>
|
||||
<classpathentry kind="output" path="out/bin"/>
|
||||
</classpath>
|
20
demos/.project
Normal file
20
demos/.project
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>icu4j-demos</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>icu4j-charset</project>
|
||||
<project>icu4j-core</project>
|
||||
<project>icu4j-shared</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
3
demos/.settings/org.eclipse.core.resources.prefs
Normal file
3
demos/.settings/org.eclipse.core.resources.prefs
Normal file
|
@ -0,0 +1,3 @@
|
|||
#Fri Nov 05 14:18:21 EDT 2010
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
330
demos/.settings/org.eclipse.jdt.core.prefs
Normal file
330
demos/.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,330 @@
|
|||
#Fri Aug 28 16:05:27 EDT 2009
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
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=enabled
|
||||
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.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.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.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.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=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_header=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.comment.line_length=120
|
||||
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.jdt.core.formatter.indentation.size=4
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.lineSplit=120
|
||||
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.jdt.core.formatter.tabulation.char=space
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=4
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
|
6
demos/.settings/org.eclipse.jdt.ui.prefs
Normal file
6
demos/.settings/org.eclipse.jdt.ui.prefs
Normal file
File diff suppressed because one or more lines are too long
5
demos/build.properties
Normal file
5
demos/build.properties
Normal file
|
@ -0,0 +1,5 @@
|
|||
#*******************************************************************************
|
||||
#* Copyright (C) 2009, International Business Machines Corporation and *
|
||||
#* others. All Rights Reserved. *
|
||||
#*******************************************************************************
|
||||
shared.dir = ../main/shared
|
31
demos/build.xml
Normal file
31
demos/build.xml
Normal file
|
@ -0,0 +1,31 @@
|
|||
<!--
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2009-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
-->
|
||||
<project name="demos" default="build" basedir=".">
|
||||
<property file="build-local.properties"/>
|
||||
<property file="build.properties"/>
|
||||
<import file="${shared.dir}/build/common-targets.xml"/>
|
||||
|
||||
<path id="javac.classpathref">
|
||||
<path refid="javac.classpathref.${ant.project.name}"/>
|
||||
</path>
|
||||
<property name="jar.name" value="icu4j-${ant.project.name}.jar"/>
|
||||
<property name="src.jar.name" value="icu4j-${ant.project.name}-src.jar"/>
|
||||
|
||||
<target name="build" depends="compile, copy, jar, src-jar" description="Build the project"/>
|
||||
|
||||
<target name="build-all" depends="@build-all" description="Build the project including all dependencies"/>
|
||||
|
||||
<target name="clean" depends="@clean" description="Clean up the build outputs"/>
|
||||
|
||||
<target name="compile" depends="@compile" description="Compile java source files"/>
|
||||
|
||||
<target name="copy" depends="@copy" description="Copy non-java runtime files to the project's binary directory"/>
|
||||
|
||||
<target name="jar" depends="compile, copy, @jar" description="Create the project's jar file"/>
|
||||
|
||||
<target name="src-jar" depends="@src-jar" description="Create the proeject's source jar file"/>
|
||||
</project>
|
21
demos/demos-build.launch
Normal file
21
demos/demos-build.launch
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntLaunchConfigurationType">
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/icu4j-demos/build.xml"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="icu4j-demos"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_ANT_PROPERTIES">
|
||||
<mapEntry key="eclipse.pdebuild.templates" value="/D:/eclipse-SDK-3.4.2-win32/eclipse/plugins/org.eclipse.pde.build_3.4.1.R34x_v20081217/templates/"/>
|
||||
<mapEntry key="eclipse.pdebuild.home" value="/D:/eclipse-SDK-3.4.2-win32/eclipse/plugins/org.eclipse.pde.build_3.4.1.R34x_v20081217/./"/>
|
||||
<mapEntry key="eclipse.pdebuild.scripts" value="/D:/eclipse-SDK-3.4.2-win32/eclipse/plugins/org.eclipse.pde.build_3.4.1.R34x_v20081217/scripts/"/>
|
||||
</mapAttribute>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_ANT_PROPERTY_FILES" value="${workspace_loc:/icu4j-shared/build/locations-eclipse.properties},"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/icu4j-demos/build.xml}"/>
|
||||
<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
|
||||
</launchConfiguration>
|
13
demos/manifest.stub
Normal file
13
demos/manifest.stub
Normal file
|
@ -0,0 +1,13 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: com.ibm.icu.dev.demo.Launcher
|
||||
Class-Path: icu4j.jar
|
||||
|
||||
Name: com/ibm/icu/dev/demo
|
||||
Specification-Title: ICU for Java Demo
|
||||
Specification-Version: @SPECVERSION@
|
||||
Specification-Vendor: ICU
|
||||
Implementation-Title: ICU for Java Demo
|
||||
Implementation-Version: @IMPLVERSION@
|
||||
Implementation-Vendor: IBM Corporation
|
||||
Implementation-Vendor-Id: com.ibm
|
||||
Copyright-Info: @COPYRIGHT@
|
192
demos/src/com/ibm/icu/dev/demo/Launcher.java
Normal file
192
demos/src/com/ibm/icu/dev/demo/Launcher.java
Normal file
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Button;
|
||||
import java.awt.Color;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Label;
|
||||
import java.awt.Panel;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.ibm.icu.dev.demo.impl.DemoApplet;
|
||||
import com.ibm.icu.dev.demo.impl.DemoUtility;
|
||||
import com.ibm.icu.util.VersionInfo;
|
||||
|
||||
|
||||
/**
|
||||
* @author srl
|
||||
* Application to provide a panel of demos to launch
|
||||
*/
|
||||
public class Launcher extends DemoApplet {
|
||||
private static final long serialVersionUID = -8054963875776183877L;
|
||||
|
||||
/**
|
||||
* base package of all demos
|
||||
*/
|
||||
public static final String demoBase = "com.ibm.icu.dev.demo";
|
||||
/**
|
||||
* list of classes, relative to the demoBase. all must have a static void main(String[])
|
||||
*/
|
||||
public static final String demoList[] = {
|
||||
"calendar.CalendarApp",
|
||||
"charsetdet.DetectingViewer",
|
||||
"holiday.HolidayCalendarDemo",
|
||||
// "number.CurrencyDemo", -- console
|
||||
// "rbbi.DBBIDemo",
|
||||
// "rbbi.RBBIDemo",
|
||||
// "rbbi.TextBoundDemo",
|
||||
"rbnf.RbnfDemo",
|
||||
// "timescale.PivotDemo", -- console
|
||||
"translit.Demo",
|
||||
};
|
||||
|
||||
public class LauncherFrame extends Frame implements ActionListener {
|
||||
private static final long serialVersionUID = -8054963875776183878L;
|
||||
|
||||
public Button buttonList[] = new Button[demoList.length]; // one button for each demo
|
||||
public Label statusLabel;
|
||||
private DemoApplet applet;
|
||||
|
||||
LauncherFrame(DemoApplet applet) {
|
||||
init();
|
||||
this.applet = applet;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
// close down when close is clicked.
|
||||
// TODO: this should be factored..
|
||||
addWindowListener(
|
||||
new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
|
||||
if (applet != null) {
|
||||
applet.demoClosed();
|
||||
} else System.exit(0);
|
||||
}
|
||||
} );
|
||||
|
||||
setBackground(DemoUtility.bgColor);
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
Panel topPanel = new Panel();
|
||||
topPanel.setLayout(new GridLayout(5,3));
|
||||
|
||||
for(int i=0;i<buttonList.length;i++) {
|
||||
String demo = demoList[i];
|
||||
Button b = new Button(demo);
|
||||
b.addActionListener(this);
|
||||
buttonList[i]=b;
|
||||
topPanel.add(b);
|
||||
}
|
||||
add(BorderLayout.CENTER,topPanel);
|
||||
statusLabel = new Label("");
|
||||
statusLabel.setAlignment(Label.LEFT);
|
||||
String javaVersion = "";
|
||||
try {
|
||||
javaVersion = "* Java: "+System.getProperty("java.version");
|
||||
} catch (Throwable t) {
|
||||
javaVersion = "";
|
||||
}
|
||||
add(BorderLayout.NORTH, new Label(
|
||||
"ICU Demos * ICU version "+VersionInfo.ICU_VERSION +
|
||||
" * http://icu-project.org "+javaVersion));
|
||||
add(BorderLayout.SOUTH,statusLabel);
|
||||
// set up an initial status.
|
||||
showStatus(buttonList.length+" demos ready. ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the 'status' field, and set it to black
|
||||
* @param status
|
||||
*/
|
||||
void showStatus(String status) {
|
||||
statusLabel.setText(status);
|
||||
statusLabel.setForeground(Color.BLACK);
|
||||
statusLabel.setBackground(Color.WHITE);
|
||||
// statusLabel.setFont(Font.PLAIN);
|
||||
doLayout();
|
||||
}
|
||||
void showStatus(String demo, String status) {
|
||||
showStatus(demo+": "+status);
|
||||
}
|
||||
void showFailure(String status) {
|
||||
statusLabel.setText(status);
|
||||
statusLabel.setBackground(Color.GRAY);
|
||||
statusLabel.setForeground(Color.RED);
|
||||
// statusLabel.setFont(Font.BOLD);
|
||||
doLayout();
|
||||
}
|
||||
void showFailure(String demo, String status) {
|
||||
showFailure(demo+": "+status);
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// find button
|
||||
for(int i=0;i<buttonList.length;i++) {
|
||||
if(e.getSource() == buttonList[i]) {
|
||||
String demoShort = demoList[i];
|
||||
String demo = demoBase+'.'+demoShort;
|
||||
showStatus(demoShort, "launching");
|
||||
try {
|
||||
Class c = Class.forName(demo);
|
||||
String args[] = new String[0];
|
||||
Class params[] = new Class[1];
|
||||
params[0] = args.getClass();
|
||||
Method m = c.getMethod("main", params );
|
||||
Object[] argList = { args };
|
||||
m.invoke(null, argList);
|
||||
showStatus(demoShort, "launched.");
|
||||
} catch (ClassNotFoundException e1) {
|
||||
showFailure(demoShort,e1.toString());
|
||||
e1.printStackTrace();
|
||||
} catch (SecurityException se) {
|
||||
showFailure(demoShort,se.toString());
|
||||
se.printStackTrace();
|
||||
} catch (NoSuchMethodException nsme) {
|
||||
showFailure(demoShort,nsme.toString());
|
||||
nsme.printStackTrace();
|
||||
} catch (IllegalArgumentException iae) {
|
||||
showFailure(demoShort,iae.toString());
|
||||
iae.printStackTrace();
|
||||
} catch (IllegalAccessException iae) {
|
||||
showFailure(demoShort,iae.toString());
|
||||
iae.printStackTrace();
|
||||
} catch (InvocationTargetException ite) {
|
||||
showFailure(demoShort,ite.toString());
|
||||
ite.printStackTrace();
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* This creates a Frame for the demo applet. */
|
||||
protected Frame createDemoFrame(DemoApplet applet) {
|
||||
return new LauncherFrame(applet);
|
||||
}
|
||||
|
||||
/**
|
||||
* The main function which defines the behavior of the Demo
|
||||
* applet when an applet is started.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new Launcher().showDemo();
|
||||
}
|
||||
}
|
37
demos/src/com/ibm/icu/dev/demo/calendar/CalendarApp.java
Normal file
37
demos/src/com/ibm/icu/dev/demo/calendar/CalendarApp.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.calendar;
|
||||
|
||||
import java.awt.Frame;
|
||||
|
||||
import com.ibm.icu.dev.demo.impl.DemoApplet;
|
||||
|
||||
/**
|
||||
* CalendarApp demonstrates how Calendar works.
|
||||
*/
|
||||
public class CalendarApp extends DemoApplet
|
||||
{
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = -4270137898405840825L;
|
||||
|
||||
/**
|
||||
* The main function which defines the behavior of the CalendarDemo
|
||||
* applet when an applet is started.
|
||||
*/
|
||||
public static void main(String argv[]) {
|
||||
|
||||
new CalendarApp().showDemo();
|
||||
}
|
||||
|
||||
/* This creates a CalendarFrame for the demo applet. */
|
||||
public Frame createDemoFrame(DemoApplet applet) {
|
||||
return new CalendarFrame(applet);
|
||||
}
|
||||
}
|
595
demos/src/com/ibm/icu/dev/demo/calendar/CalendarCalc.java
Normal file
595
demos/src/com/ibm/icu/dev/demo/calendar/CalendarCalc.java
Normal file
|
@ -0,0 +1,595 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.calendar;
|
||||
|
||||
import java.awt.Button;
|
||||
import java.awt.Checkbox;
|
||||
import java.awt.CheckboxGroup;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Label;
|
||||
import java.awt.Panel;
|
||||
import java.awt.TextField;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import com.ibm.icu.dev.demo.impl.DemoApplet;
|
||||
import com.ibm.icu.dev.demo.impl.DemoUtility;
|
||||
import com.ibm.icu.text.DateFormat;
|
||||
import com.ibm.icu.text.SimpleDateFormat;
|
||||
import com.ibm.icu.util.BuddhistCalendar;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.GregorianCalendar;
|
||||
import com.ibm.icu.util.HebrewCalendar;
|
||||
import com.ibm.icu.util.IslamicCalendar;
|
||||
import com.ibm.icu.util.JapaneseCalendar;
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
|
||||
/**
|
||||
* CalendarCalc demonstrates how Date/Time formatter works.
|
||||
*/
|
||||
public class CalendarCalc extends DemoApplet
|
||||
{
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = 4540103433916539296L;
|
||||
|
||||
/**
|
||||
* The main function which defines the behavior of the MultiCalendarDemo
|
||||
* applet when an applet is started.
|
||||
*/
|
||||
public static void main(String argv[]) {
|
||||
new CalendarCalc().showDemo();
|
||||
}
|
||||
|
||||
/**
|
||||
* This creates a CalendarCalcFrame for the demo applet.
|
||||
*/
|
||||
public Frame createDemoFrame(DemoApplet applet) {
|
||||
return new CalendarCalcFrame(applet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A Frame is a top-level window with a title. The default layout for a frame
|
||||
* is BorderLayout. The CalendarCalcFrame class defines the window layout of
|
||||
* MultiCalendarDemo.
|
||||
*/
|
||||
class CalendarCalcFrame extends Frame implements ActionListener
|
||||
{
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = 8901485296258761846L;
|
||||
|
||||
static final Locale[] locales = DemoUtility.getG7Locales();
|
||||
|
||||
private DemoApplet applet;
|
||||
private long time = System.currentTimeMillis();
|
||||
|
||||
private static final RollAddField kRollAddFields[] = {
|
||||
new RollAddField(Calendar.YEAR, "Year" ),
|
||||
new RollAddField(Calendar.MONTH, "Month" ),
|
||||
new RollAddField(Calendar.WEEK_OF_MONTH, "Week of Month" ),
|
||||
new RollAddField(Calendar.WEEK_OF_YEAR, "Week of Year" ),
|
||||
new RollAddField(Calendar.DAY_OF_MONTH, "Day of Month" ),
|
||||
new RollAddField(Calendar.DAY_OF_WEEK, "Day of Week" ),
|
||||
new RollAddField(Calendar.DAY_OF_WEEK_IN_MONTH, "Day of Week in Month" ),
|
||||
new RollAddField(Calendar.DAY_OF_YEAR, "Day of Year" ),
|
||||
new RollAddField(Calendar.AM_PM, "AM/PM" ),
|
||||
new RollAddField(Calendar.HOUR_OF_DAY, "Hour of day" ),
|
||||
new RollAddField(Calendar.HOUR, "Hour" ),
|
||||
new RollAddField(Calendar.MINUTE, "Minute" ),
|
||||
new RollAddField(Calendar.SECOND, "Second" ),
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a new CalendarCalcFrame that is initially invisible.
|
||||
*/
|
||||
public CalendarCalcFrame(DemoApplet applet)
|
||||
{
|
||||
super("Multiple Calendar Demo");
|
||||
this.applet = applet;
|
||||
init();
|
||||
start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the applet. You never need to call this directly, it
|
||||
* is called automatically by the system once the applet is created.
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
buildGUI();
|
||||
|
||||
patternText.setText( calendars[0].toPattern() );
|
||||
|
||||
// Force an update of the display
|
||||
cityChanged();
|
||||
millisFormat();
|
||||
enableEvents(KeyEvent.KEY_RELEASED);
|
||||
enableEvents(WindowEvent.WINDOW_CLOSING);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
// package private
|
||||
//------------------------------------------------------------
|
||||
void addWithFont(Container container, Component foo, Font font) {
|
||||
if (font != null)
|
||||
foo.setFont(font);
|
||||
container.add(foo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to start the applet. You never need to call this method
|
||||
* directly, it is called when the applet's document is visited.
|
||||
*/
|
||||
public void start()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
TextField patternText;
|
||||
|
||||
Choice dateMenu;
|
||||
Choice localeMenu;
|
||||
|
||||
Button up;
|
||||
Button down;
|
||||
|
||||
Checkbox getRoll;
|
||||
Checkbox getAdd;
|
||||
|
||||
public void buildGUI()
|
||||
{
|
||||
setBackground(DemoUtility.bgColor);
|
||||
setLayout(new FlowLayout()); // shouldn't be necessary, but it is.
|
||||
|
||||
// TITLE
|
||||
Label label1=new Label("Calendar Converter", Label.CENTER);
|
||||
label1.setFont(DemoUtility.titleFont);
|
||||
add(label1);
|
||||
add(DemoUtility.createSpacer());
|
||||
|
||||
// IO Panel
|
||||
Panel topPanel = new Panel();
|
||||
topPanel.setLayout(new FlowLayout());
|
||||
|
||||
CheckboxGroup group1= new CheckboxGroup();
|
||||
|
||||
// Set up the controls for each calendar we're demonstrating
|
||||
for (int i = 0; i < calendars.length; i++)
|
||||
{
|
||||
Label label = new Label(calendars[i].name, Label.RIGHT);
|
||||
label.setFont(DemoUtility.labelFont);
|
||||
topPanel.add(label);
|
||||
|
||||
topPanel.add(calendars[i].text);
|
||||
|
||||
final int j = i;
|
||||
calendars[i].text.addActionListener( new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
textChanged(j);
|
||||
}
|
||||
} );
|
||||
|
||||
calendars[i].rollAdd.setCheckboxGroup(group1);
|
||||
topPanel.add(calendars[i].rollAdd);
|
||||
}
|
||||
calendars[0].rollAdd.setState(true); // Make the first one selected
|
||||
|
||||
Label label4=new Label("Pattern", Label.RIGHT);
|
||||
label4.setFont(DemoUtility.labelFont);
|
||||
topPanel.add(label4);
|
||||
|
||||
patternText=new TextField(FIELD_COLUMNS);
|
||||
patternText.setFont(DemoUtility.editFont);
|
||||
topPanel.add(patternText);
|
||||
topPanel.add(new Label(""));
|
||||
|
||||
DemoUtility.fixGrid(topPanel,3);
|
||||
add(topPanel);
|
||||
add(DemoUtility.createSpacer());
|
||||
|
||||
// ROLL / ADD
|
||||
Panel rollAddPanel=new Panel();
|
||||
{
|
||||
rollAddPanel.setLayout(new FlowLayout());
|
||||
|
||||
Panel rollAddBoxes = new Panel();
|
||||
{
|
||||
rollAddBoxes.setLayout(new GridLayout(2,1));
|
||||
CheckboxGroup group2= new CheckboxGroup();
|
||||
getRoll = new Checkbox("Roll",group2, false);
|
||||
getAdd = new Checkbox("Add",group2, true);
|
||||
|
||||
rollAddBoxes.add(getRoll);
|
||||
rollAddBoxes.add(getAdd);
|
||||
}
|
||||
|
||||
Label dateLabel=new Label("Date Fields");
|
||||
dateLabel.setFont(DemoUtility.labelFont);
|
||||
|
||||
dateMenu= new Choice();
|
||||
dateMenu.setBackground(DemoUtility.choiceColor);
|
||||
for (int i = 0; i < kRollAddFields.length; i++) {
|
||||
dateMenu.addItem(kRollAddFields[i].name);
|
||||
if (kRollAddFields[i].field == Calendar.MONTH) {
|
||||
dateMenu.select(i);
|
||||
}
|
||||
}
|
||||
|
||||
Panel upDown = new Panel();
|
||||
{
|
||||
upDown.setLayout(new GridLayout(2,1));
|
||||
|
||||
// *** If the images are not found, we use the label.
|
||||
up = new Button("^");
|
||||
down = new Button("v");
|
||||
up.setBackground(DemoUtility.bgColor);
|
||||
down.setBackground(DemoUtility.bgColor);
|
||||
upDown.add(up);
|
||||
upDown.add(down);
|
||||
up.addActionListener(this);
|
||||
down.addActionListener(this);
|
||||
}
|
||||
|
||||
rollAddPanel.add(dateLabel);
|
||||
rollAddPanel.add(dateMenu);
|
||||
rollAddPanel.add(rollAddBoxes);
|
||||
rollAddPanel.add(upDown);
|
||||
|
||||
}
|
||||
Panel localePanel = new Panel();
|
||||
{
|
||||
// Make the locale popup menus
|
||||
localeMenu= new Choice();
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
int bestMatch = -1, thisMatch = -1;
|
||||
int selectMe = 0;
|
||||
|
||||
for (int i = 0; i < locales.length; i++) {
|
||||
if (i > 0 && locales[i].getLanguage().equals(locales[i-1].getLanguage()) ||
|
||||
i < locales.length - 1 &&
|
||||
locales[i].getLanguage().equals(locales[i+1].getLanguage()))
|
||||
{
|
||||
localeMenu.addItem( locales[i].getDisplayName() );
|
||||
} else {
|
||||
localeMenu.addItem( locales[i].getDisplayLanguage());
|
||||
}
|
||||
|
||||
thisMatch = DemoUtility.compareLocales(locales[i], defaultLocale);
|
||||
|
||||
if (thisMatch >= bestMatch) {
|
||||
bestMatch = thisMatch;
|
||||
selectMe = i;
|
||||
}
|
||||
}
|
||||
|
||||
localeMenu.setBackground(DemoUtility.choiceColor);
|
||||
localeMenu.select(selectMe);
|
||||
|
||||
Label localeLabel =new Label("Display Locale");
|
||||
localeLabel.setFont(DemoUtility.labelFont);
|
||||
|
||||
localePanel.add(localeLabel);
|
||||
localePanel.add(localeMenu);
|
||||
DemoUtility.fixGrid(localePanel,2);
|
||||
|
||||
localeMenu.addItemListener( new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
Locale loc = locales[localeMenu.getSelectedIndex()];
|
||||
System.out.println("Change locale to " + loc.getDisplayName());
|
||||
|
||||
for (int i = 0; i < calendars.length; i++) {
|
||||
calendars[i].setLocale(loc);
|
||||
}
|
||||
millisFormat();
|
||||
}
|
||||
} );
|
||||
}
|
||||
add(rollAddPanel);
|
||||
add(DemoUtility.createSpacer());
|
||||
add(localePanel);
|
||||
add(DemoUtility.createSpacer());
|
||||
|
||||
// COPYRIGHT
|
||||
Panel copyrightPanel = new Panel();
|
||||
addWithFont (copyrightPanel,new Label(DemoUtility.copyright1, Label.LEFT),
|
||||
DemoUtility.creditFont);
|
||||
DemoUtility.fixGrid(copyrightPanel,1);
|
||||
add(copyrightPanel);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called when users change the pattern text.
|
||||
*/
|
||||
public void setFormatFromPattern() {
|
||||
String timePattern = patternText.getText();
|
||||
|
||||
for (int i = 0; i < calendars.length; i++) {
|
||||
calendars[i].applyPattern(timePattern);
|
||||
}
|
||||
|
||||
millisFormat();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called when it is necessary to parse the time
|
||||
* string in one of the formatted date fields
|
||||
*/
|
||||
public void textChanged(int index) {
|
||||
String rightString = calendars[index].text.getText();
|
||||
|
||||
ParsePosition status = new ParsePosition(0);
|
||||
|
||||
if (rightString.length() == 0)
|
||||
{
|
||||
errorText("Error: no input to parse!");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Date date = calendars[index].format.parse(rightString, status);
|
||||
time = date.getTime();
|
||||
}
|
||||
catch (Exception e) {
|
||||
for (int i = 0; i < calendars.length; i++) {
|
||||
if (i != index) {
|
||||
calendars[i].text.setText("ERROR");
|
||||
}
|
||||
}
|
||||
errorText("Exception: " + e.getClass().toString() + " parsing: "+rightString);
|
||||
return;
|
||||
}
|
||||
|
||||
int start = calendars[index].text.getSelectionStart();
|
||||
int end = calendars[index].text.getSelectionEnd();
|
||||
|
||||
millisFormat();
|
||||
|
||||
calendars[index].text.select(start,end);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called when it is necessary to format the time
|
||||
* in the "Millis" text field.
|
||||
*/
|
||||
public void millisFormat() {
|
||||
String out = "";
|
||||
|
||||
for (int i = 0; i < calendars.length; i++) {
|
||||
try {
|
||||
out = calendars[i].format.format(new Date(time));
|
||||
calendars[i].text.setText(out);
|
||||
}
|
||||
catch (Exception e) {
|
||||
calendars[i].text.setText("ERROR");
|
||||
errorText("Exception: " + e.getClass().toString() + " formatting "
|
||||
+ calendars[i].name + " " + time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is called when users change the pattern text.
|
||||
*/
|
||||
public void patternTextChanged() {
|
||||
setFormatFromPattern();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called when users select a new representative city.
|
||||
*/
|
||||
public void cityChanged() {
|
||||
TimeZone timeZone = TimeZone.getDefault();
|
||||
|
||||
for (int i = 0; i < calendars.length; i++) {
|
||||
calendars[i].format.setTimeZone(timeZone);
|
||||
}
|
||||
millisFormat();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called when users select a new time field
|
||||
* to add or roll its value.
|
||||
*/
|
||||
public void dateFieldChanged(boolean isUp) {
|
||||
int field = kRollAddFields[dateMenu.getSelectedIndex()].field;
|
||||
|
||||
for (int i = 0; i < calendars.length; i++)
|
||||
{
|
||||
if (calendars[i].rollAdd.getState())
|
||||
{
|
||||
Calendar c = calendars[i].calendar;
|
||||
c.setTime(new Date(time));
|
||||
|
||||
if (getAdd.getState()) {
|
||||
c.add(field, isUp ? 1 : -1);
|
||||
} else {
|
||||
c.roll(field, isUp);
|
||||
}
|
||||
|
||||
time = c.getTime().getTime();
|
||||
millisFormat();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out the error message while debugging this program.
|
||||
*/
|
||||
public void errorText(String s)
|
||||
{
|
||||
if (true) {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called if an action occurs in the CalendarCalcFrame object.
|
||||
*/
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
// *** Button events are handled here.
|
||||
Object obj = evt.getSource();
|
||||
System.out.println("action " + obj);
|
||||
if (obj instanceof Button) {
|
||||
if (evt.getSource() == up) {
|
||||
dateFieldChanged(false);
|
||||
} else
|
||||
if (evt.getSource() == down) {
|
||||
dateFieldChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the event. Returns true if the event is handled and should not
|
||||
* be passed to the parent of this component. The default event handler
|
||||
* calls some helper methods to make life easier on the programmer.
|
||||
*/
|
||||
protected void processKeyEvent(KeyEvent evt)
|
||||
{
|
||||
System.out.println("key " + evt);
|
||||
if (evt.getID() == KeyEvent.KEY_RELEASED) {
|
||||
if (evt.getSource() == patternText) {
|
||||
patternTextChanged();
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < calendars.length; i++) {
|
||||
if (evt.getSource() == calendars[i].text) {
|
||||
textChanged(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void processWindowEvent(WindowEvent evt)
|
||||
{
|
||||
System.out.println("window " + evt);
|
||||
if (evt.getID() == WindowEvent.WINDOW_CLOSING &&
|
||||
evt.getSource() == this) {
|
||||
this.hide();
|
||||
this.dispose();
|
||||
|
||||
if (applet != null) {
|
||||
applet.demoClosed();
|
||||
} else System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
protected void processEvent(AWTEvent evt)
|
||||
{
|
||||
if (evt.getID() == AWTEvent. Event.ACTION_EVENT && evt.target == up) {
|
||||
dateFieldChanged(true);
|
||||
return true;
|
||||
}
|
||||
else if (evt.id == Event.ACTION_EVENT && evt.target == down) {
|
||||
dateFieldChanged(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private static final int FIELD_COLUMNS = 35;
|
||||
|
||||
|
||||
class CalendarRec {
|
||||
public CalendarRec(String nameStr, Calendar cal)
|
||||
{
|
||||
name = nameStr;
|
||||
calendar = cal;
|
||||
rollAdd = new Checkbox();
|
||||
|
||||
text = new JTextField("",FIELD_COLUMNS);
|
||||
text.setFont(DemoUtility.editFont);
|
||||
|
||||
format = DateFormat.getDateInstance(cal, DateFormat.FULL,
|
||||
Locale.getDefault());
|
||||
//format.applyPattern(DEFAULT_FORMAT);
|
||||
}
|
||||
|
||||
public void setLocale(Locale loc) {
|
||||
String pattern = toPattern();
|
||||
|
||||
format = DateFormat.getDateInstance(calendar, DateFormat.FULL,
|
||||
loc);
|
||||
applyPattern(pattern);
|
||||
}
|
||||
|
||||
public void applyPattern(String pattern) {
|
||||
if (format instanceof SimpleDateFormat) {
|
||||
((SimpleDateFormat)format).applyPattern(pattern);
|
||||
//hey {al} -
|
||||
// } else if (format instanceof java.text.SimpleDateFormat) {
|
||||
// ((java.text.SimpleDateFormat)format).applyPattern(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
private String toPattern() {
|
||||
if (format instanceof SimpleDateFormat) {
|
||||
return ((SimpleDateFormat)format).toPattern();
|
||||
//hey {al} -
|
||||
// } else if (format instanceof java.text.SimpleDateFormat) {
|
||||
// return ((java.text.SimpleDateFormat)format).toPattern();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
Calendar calendar;
|
||||
DateFormat format;
|
||||
String name;
|
||||
JTextField text;
|
||||
Checkbox rollAdd;
|
||||
}
|
||||
|
||||
private final CalendarRec[] calendars = {
|
||||
new CalendarRec("Gregorian", new GregorianCalendar()),
|
||||
new CalendarRec("Hebrew", new HebrewCalendar()),
|
||||
new CalendarRec("Islamic (civil)", makeIslamic(true)),
|
||||
new CalendarRec("Islamic (true)", makeIslamic(false)),
|
||||
new CalendarRec("Buddhist", new BuddhistCalendar()),
|
||||
new CalendarRec("Japanese", new JapaneseCalendar()),
|
||||
// new CalendarRec("Chinese", new ChineseCalendar()),
|
||||
};
|
||||
|
||||
static private final Calendar makeIslamic(boolean civil) {
|
||||
IslamicCalendar cal = new IslamicCalendar();
|
||||
cal.setCivil(civil);
|
||||
return cal;
|
||||
}
|
||||
}
|
||||
|
||||
class RollAddField {
|
||||
RollAddField(int field, String name) {
|
||||
this.field = field;
|
||||
this.name = name;
|
||||
}
|
||||
int field;
|
||||
String name;
|
||||
}
|
442
demos/src/com/ibm/icu/dev/demo/calendar/CalendarFrame.java
Normal file
442
demos/src/com/ibm/icu/dev/demo/calendar/CalendarFrame.java
Normal file
|
@ -0,0 +1,442 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.calendar;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Button;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Label;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.dev.demo.impl.DemoApplet;
|
||||
import com.ibm.icu.dev.demo.impl.DemoUtility;
|
||||
import com.ibm.icu.text.DateFormat;
|
||||
import com.ibm.icu.util.BuddhistCalendar;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.GregorianCalendar;
|
||||
import com.ibm.icu.util.HebrewCalendar;
|
||||
import com.ibm.icu.util.IslamicCalendar;
|
||||
import com.ibm.icu.util.JapaneseCalendar;
|
||||
import com.ibm.icu.util.SimpleTimeZone;
|
||||
|
||||
/**
|
||||
* A Frame is a top-level window with a title. The default layout for a frame
|
||||
* is BorderLayout. The CalendarFrame class defines the window layout of
|
||||
* CalendarDemo.
|
||||
*/
|
||||
class CalendarFrame extends Frame
|
||||
{
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = -4289697663503820619L;
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private DemoApplet applet;
|
||||
|
||||
/**
|
||||
* Constructs a new CalendarFrame that is initially invisible.
|
||||
*/
|
||||
public CalendarFrame(DemoApplet myApplet)
|
||||
{
|
||||
super("Calendar Demo");
|
||||
this.applet = myApplet;
|
||||
init();
|
||||
|
||||
// When the window is closed, we want to shut down the applet or application
|
||||
addWindowListener(
|
||||
new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
|
||||
if (applet != null) {
|
||||
applet.demoClosed();
|
||||
} else System.exit(0);
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private Choice displayMenu;
|
||||
private Locale[] locales = DemoUtility.getG7Locales();
|
||||
|
||||
private Calendar calendars[] = new Calendar[2];
|
||||
private Choice calMenu[] = new Choice[2];
|
||||
private ColoredLabel monthLabel[] = new ColoredLabel[2];
|
||||
private DateFormat monthFormat[] = new DateFormat[2];
|
||||
|
||||
private Button prevYear;
|
||||
private Button prevMonth;
|
||||
private Button gotoToday;
|
||||
private Button nextMonth;
|
||||
private Button nextYear;
|
||||
private CalendarPanel calendarPanel;
|
||||
|
||||
private static void add(Container container, Component component,
|
||||
GridBagLayout g, GridBagConstraints c,
|
||||
int gridwidth, int weightx)
|
||||
{
|
||||
c.gridwidth = gridwidth;
|
||||
c.weightx = weightx;
|
||||
g.setConstraints(component, c);
|
||||
container.add(component);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the applet. You never need to call this directly, it
|
||||
* is called automatically by the system once the applet is created.
|
||||
*/
|
||||
public void init() {
|
||||
setBackground(DemoUtility.bgColor);
|
||||
setLayout(new BorderLayout(10,10));
|
||||
|
||||
Panel topPanel = new Panel();
|
||||
GridBagLayout g = new GridBagLayout();
|
||||
topPanel.setLayout(g);
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
|
||||
// Build the two menus for selecting which calendar is displayed,
|
||||
// plus the month/year label for each calendar
|
||||
for (int i = 0; i < 2; i++) {
|
||||
calMenu[i] = new Choice();
|
||||
for (int j = 0; j < CALENDARS.length; j++) {
|
||||
calMenu[i].addItem(CALENDARS[j].name);
|
||||
}
|
||||
calMenu[i].setBackground(DemoUtility.choiceColor);
|
||||
calMenu[i].select(i);
|
||||
calMenu[i].addItemListener(new CalMenuListener());
|
||||
|
||||
// Label for the current month name
|
||||
monthLabel[i] = new ColoredLabel("", COLORS[i]);
|
||||
monthLabel[i].setFont(DemoUtility.titleFont);
|
||||
|
||||
// And the default calendar to use for this slot
|
||||
calendars[i] = CALENDARS[i].calendar;
|
||||
|
||||
add(topPanel, calMenu[i], g, c, 5, 0);
|
||||
add(topPanel, monthLabel[i], g, c, GridBagConstraints.REMAINDER, 1);
|
||||
}
|
||||
|
||||
// Now add the next/previous year/month buttons:
|
||||
prevYear = new Button("<<");
|
||||
prevYear.addActionListener(new AddAction(Calendar.YEAR, -1));
|
||||
|
||||
prevMonth = new Button("<");
|
||||
prevMonth.addActionListener(new AddAction(Calendar.MONTH, -1));
|
||||
|
||||
gotoToday = new Button("Today");
|
||||
gotoToday.addActionListener( new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
calendarPanel.setDate( new Date() );
|
||||
updateMonthName();
|
||||
}
|
||||
} );
|
||||
|
||||
nextMonth = new Button(">");
|
||||
nextMonth.addActionListener(new AddAction(Calendar.MONTH, 1));
|
||||
|
||||
nextYear = new Button(">>");
|
||||
nextYear.addActionListener(new AddAction(Calendar.YEAR, 1));
|
||||
|
||||
c.fill = GridBagConstraints.NONE;
|
||||
add(topPanel, prevYear, g, c, 1, 0);
|
||||
add(topPanel, prevMonth, g, c, 1, 0);
|
||||
add(topPanel, gotoToday, g, c, 1, 0);
|
||||
add(topPanel, nextMonth, g, c, 1, 0);
|
||||
add(topPanel, nextYear, g, c, 1, 0);
|
||||
|
||||
// Now add the menu for selecting the display language
|
||||
Panel displayPanel = new Panel();
|
||||
{
|
||||
displayMenu = new Choice();
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
int bestMatch = -1, thisMatch = -1;
|
||||
int selectMe = 0;
|
||||
|
||||
for (int i = 0; i < locales.length; i++) {
|
||||
if (i > 0 &&
|
||||
locales[i].getLanguage().equals(locales[i-1].getLanguage()) ||
|
||||
i < locales.length - 1 &&
|
||||
locales[i].getLanguage().equals(locales[i+1].getLanguage()))
|
||||
{
|
||||
displayMenu.addItem( locales[i].getDisplayName() );
|
||||
} else {
|
||||
displayMenu.addItem( locales[i].getDisplayLanguage());
|
||||
}
|
||||
|
||||
thisMatch = DemoUtility.compareLocales(locales[i], defaultLocale);
|
||||
|
||||
if (thisMatch >= bestMatch) {
|
||||
bestMatch = thisMatch;
|
||||
selectMe = i;
|
||||
}
|
||||
}
|
||||
|
||||
displayMenu.setBackground(DemoUtility.choiceColor);
|
||||
displayMenu.select(selectMe);
|
||||
|
||||
displayMenu.addItemListener( new ItemListener()
|
||||
{
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
Locale loc = locales[displayMenu.getSelectedIndex()];
|
||||
calendarPanel.setLocale( loc );
|
||||
monthFormat[0] = monthFormat[1] = null;
|
||||
updateMonthName();
|
||||
repaint();
|
||||
}
|
||||
} );
|
||||
|
||||
Label l1 = new Label("Display Language:", Label.RIGHT);
|
||||
l1.setFont(DemoUtility.labelFont);
|
||||
|
||||
displayPanel.setLayout(new FlowLayout());
|
||||
displayPanel.add(l1);
|
||||
displayPanel.add(displayMenu);
|
||||
|
||||
}
|
||||
c.fill = GridBagConstraints.NONE;
|
||||
c.anchor = GridBagConstraints.EAST;
|
||||
|
||||
add(topPanel, displayPanel, g, c, GridBagConstraints.REMAINDER, 0);
|
||||
|
||||
// The title, buttons, etc. go in a panel at the top of the window
|
||||
add("North", topPanel);
|
||||
|
||||
// The copyright notice goes at the bottom of the window
|
||||
Label copyright = new Label(DemoUtility.copyright1, Label.LEFT);
|
||||
copyright.setFont(DemoUtility.creditFont);
|
||||
add("South", copyright);
|
||||
|
||||
// Now create the big calendar panel and stick it in the middle
|
||||
calendarPanel = new CalendarPanel( locales[displayMenu.getSelectedIndex()] );
|
||||
add("Center", calendarPanel);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
calendarPanel.setCalendar(i, calendars[i]);
|
||||
calendarPanel.setColor(i, COLORS[i]);
|
||||
}
|
||||
|
||||
updateMonthName();
|
||||
}
|
||||
|
||||
|
||||
private void updateMonthName()
|
||||
{
|
||||
for (int i = 0; i < 2; i++) {
|
||||
try {
|
||||
if (monthFormat[i] == null) { // TODO: optimize
|
||||
DateFormat f = DateFormat.getDateTimeInstance(
|
||||
calendars[i], DateFormat.MEDIUM, -1,
|
||||
locales[displayMenu.getSelectedIndex()]);
|
||||
if (f instanceof com.ibm.icu.text.SimpleDateFormat) {
|
||||
com.ibm.icu.text.SimpleDateFormat f1 = (com.ibm.icu.text.SimpleDateFormat) f;
|
||||
f1.applyPattern("MMMM, yyyy G");
|
||||
f1.setTimeZone(new SimpleTimeZone(0, "UTC"));
|
||||
}
|
||||
monthFormat[i] = f;
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
//hey {lw} - there's something wrong in this routine that cuases exceptions.
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
monthLabel[i].setText( monthFormat[i].format( calendarPanel.firstOfMonth() ));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CalMenuListener responds to events in the two popup menus that select
|
||||
* the calendar systems to be used in the display. It figures out which
|
||||
* of the two menus the event occurred in and updates the corresponding
|
||||
* element of the calendars[] array to match the new selection.
|
||||
*/
|
||||
private class CalMenuListener implements ItemListener
|
||||
{
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
for (int i = 0; i < calMenu.length; i++)
|
||||
{
|
||||
if (e.getItemSelectable() == calMenu[i])
|
||||
{
|
||||
// We found the menu that the event happened in.
|
||||
// Figure out which new calendar they selected.
|
||||
Calendar newCal = CALENDARS[ calMenu[i].getSelectedIndex() ].calendar;
|
||||
|
||||
if (newCal != calendars[i])
|
||||
{
|
||||
// If any of the other menus are set to the same new calendar
|
||||
// we're about to use for this menu, set them to the current
|
||||
// calendar from *this* menu so we won't have two the same
|
||||
for (int j = 0; j < calendars.length; j++) {
|
||||
if (j != i && calendars[j] == newCal) {
|
||||
calendars[j] = calendars[i];
|
||||
calendarPanel.setCalendar(j, calendars[j]);
|
||||
monthFormat[j] = null;
|
||||
|
||||
for (int k = 0; k < CALENDARS.length; k++) {
|
||||
if (calendars[j] == CALENDARS[k].calendar) {
|
||||
calMenu[j].select(k);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Now update this menu to use the new calendar the user selected
|
||||
calendars[i] = newCal;
|
||||
calendarPanel.setCalendar(i, newCal);
|
||||
monthFormat[i] = null;
|
||||
|
||||
updateMonthName();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AddAction handles the next/previous year/month buttons...
|
||||
*/
|
||||
private class AddAction implements ActionListener {
|
||||
AddAction(int field, int amount) {
|
||||
this.field = field;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
calendarPanel.add(field, amount);
|
||||
updateMonthName();
|
||||
}
|
||||
|
||||
private int field, amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* ColoredLabel is similar to java.awt.Label, with two differences:
|
||||
*
|
||||
* - You can set its text color
|
||||
*
|
||||
* - It draws text using drawString rather than using a host-specific
|
||||
* "Peer" object like AWT does. On 1.2, using drawString gives
|
||||
* us Bidi reordering for free.
|
||||
*/
|
||||
static private class ColoredLabel extends Component {
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = 5004484960341875722L;
|
||||
public ColoredLabel(String label) {
|
||||
text = label;
|
||||
}
|
||||
|
||||
public ColoredLabel(String label, Color c) {
|
||||
text = label;
|
||||
color = c;
|
||||
}
|
||||
|
||||
public void setText(String label) {
|
||||
text = label;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void setFont(Font f) {
|
||||
font = f;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
FontMetrics fm = g.getFontMetrics(font);
|
||||
|
||||
Rectangle bounds = getBounds();
|
||||
|
||||
g.setColor(color);
|
||||
g.setFont(font);
|
||||
g.drawString(text, fm.stringWidth("\u00a0"),
|
||||
bounds.height/2 + fm.getHeight()
|
||||
- fm.getAscent() + fm.getLeading()/2);
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
FontMetrics fm = getFontMetrics(font);
|
||||
|
||||
return new Dimension( fm.stringWidth(text) + 2*fm.stringWidth("\u00a0"),
|
||||
fm.getHeight() + fm.getLeading()*2);
|
||||
}
|
||||
|
||||
String text;
|
||||
Color color = Color.black;
|
||||
Font font = DemoUtility.labelFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out the error message while debugging this program.
|
||||
*/
|
||||
public void errorText(String s)
|
||||
{
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
||||
class CalendarRec {
|
||||
public CalendarRec(String nameStr, Calendar cal)
|
||||
{
|
||||
name = nameStr;
|
||||
calendar = cal;
|
||||
}
|
||||
|
||||
Calendar calendar;
|
||||
String name;
|
||||
}
|
||||
|
||||
private final CalendarRec[] CALENDARS = {
|
||||
new CalendarRec("Gregorian Calendar", new GregorianCalendar()),
|
||||
new CalendarRec("Hebrew Calendar", new HebrewCalendar()),
|
||||
new CalendarRec("Islamic Calendar", makeIslamic(false)),
|
||||
new CalendarRec("Islamic Civil Calendar ", makeIslamic(true)),
|
||||
new CalendarRec("Buddhist Calendar", new BuddhistCalendar()),
|
||||
new CalendarRec("Japanese Calendar", new JapaneseCalendar()),
|
||||
};
|
||||
|
||||
static private final Calendar makeIslamic(boolean civil) {
|
||||
IslamicCalendar cal = new IslamicCalendar();
|
||||
cal.setCivil(civil);
|
||||
return cal;
|
||||
}
|
||||
|
||||
static final Color[] COLORS = { Color.blue, Color.black };
|
||||
}
|
||||
|
365
demos/src/com/ibm/icu/dev/demo/calendar/CalendarPanel.java
Normal file
365
demos/src/com/ibm/icu/dev/demo/calendar/CalendarPanel.java
Normal file
|
@ -0,0 +1,365 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.calendar;
|
||||
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Point;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.dev.demo.impl.DemoUtility;
|
||||
import com.ibm.icu.text.DateFormatSymbols;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.SimpleTimeZone;
|
||||
|
||||
class CalendarPanel extends Canvas {
|
||||
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = 625400018027387141L;
|
||||
|
||||
public CalendarPanel( Locale locale ) {
|
||||
setLocale(locale);
|
||||
}
|
||||
|
||||
public void setLocale(Locale locale) {
|
||||
if (fDisplayLocale == null || !fDisplayLocale.equals(locale)) {
|
||||
fDisplayLocale = locale;
|
||||
dirty = true;
|
||||
|
||||
for (int i = 0; i < fCalendar.length; i++) {
|
||||
if (fCalendar[i] != null) {
|
||||
fSymbols[i] = new DateFormatSymbols(fCalendar[i],
|
||||
fDisplayLocale);
|
||||
}
|
||||
}
|
||||
String lang = locale.getLanguage();
|
||||
leftToRight = !(lang.equals("iw") || lang.equals("ar"));
|
||||
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
fStartOfMonth = date;
|
||||
dirty = true;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void add(int field, int delta)
|
||||
{
|
||||
synchronized(fCalendar) {
|
||||
fCalendar[0].setTime(fStartOfMonth);
|
||||
fCalendar[0].add(field, delta);
|
||||
fStartOfMonth = fCalendar[0].getTime();
|
||||
}
|
||||
dirty = true;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void setColor(int index, Color c) {
|
||||
fColor[index] = c;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void setCalendar(int index, Calendar c) {
|
||||
Date date = (fCalendar[index] == null) ? new Date()
|
||||
: fCalendar[index].getTime();
|
||||
|
||||
fCalendar[index] = c;
|
||||
fCalendar[index].setTime(date);
|
||||
|
||||
fSymbols[index] = new DateFormatSymbols(c, fDisplayLocale);
|
||||
dirty = true;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public Calendar getCalendar(int index) {
|
||||
return fCalendar[index];
|
||||
}
|
||||
|
||||
public Locale getDisplayLocale() {
|
||||
return fDisplayLocale;
|
||||
}
|
||||
|
||||
public Date firstOfMonth() {
|
||||
return fStartOfMonth;
|
||||
}
|
||||
|
||||
private Date startOfMonth(Date dateInMonth)
|
||||
{
|
||||
synchronized(fCalendar) {
|
||||
fCalendar[0].setTime(dateInMonth);
|
||||
|
||||
int era = fCalendar[0].get(Calendar.ERA);
|
||||
int year = fCalendar[0].get(Calendar.YEAR);
|
||||
int month = fCalendar[0].get(Calendar.MONTH);
|
||||
|
||||
fCalendar[0].clear();
|
||||
fCalendar[0].set(Calendar.ERA, era);
|
||||
fCalendar[0].set(Calendar.YEAR, year);
|
||||
fCalendar[0].set(Calendar.MONTH, month);
|
||||
fCalendar[0].set(Calendar.DATE, 1);
|
||||
|
||||
return fCalendar[0].getTime();
|
||||
}
|
||||
}
|
||||
|
||||
private void calculate()
|
||||
{
|
||||
//
|
||||
// As a workaround for JDK 1.1.3 and below, where Calendars and time
|
||||
// zones are a bit goofy, always set my calendar's time zone to UTC.
|
||||
// You would think I would want to do this in the "set" function above,
|
||||
// but if I do that, the program hangs when this class is loaded,
|
||||
// perhaps due to some sort of static initialization ordering problem.
|
||||
// So I do it here instead.
|
||||
//
|
||||
fCalendar[0].setTimeZone(new SimpleTimeZone(0, "UTC"));
|
||||
|
||||
Calendar c = (Calendar)fCalendar[0].clone(); // Temporary copy
|
||||
|
||||
fStartOfMonth = startOfMonth(fStartOfMonth);
|
||||
|
||||
// Stash away a few useful constants for this calendar and display
|
||||
minDay = c.getMinimum(Calendar.DAY_OF_WEEK);
|
||||
daysInWeek = c.getMaximum(Calendar.DAY_OF_WEEK) - minDay + 1;
|
||||
|
||||
firstDayOfWeek = Calendar.getInstance(fDisplayLocale).getFirstDayOfWeek();
|
||||
|
||||
// Stash away a Date for the start of this month
|
||||
|
||||
// Find the day of week of the first day in this month
|
||||
c.setTime(fStartOfMonth);
|
||||
firstDayInMonth = c.get(Calendar.DAY_OF_WEEK);
|
||||
int firstWeek = c.get(Calendar.WEEK_OF_MONTH);
|
||||
|
||||
// Now find the # of days in the month
|
||||
c.roll(Calendar.DATE, false);
|
||||
daysInMonth = c.get(Calendar.DATE);
|
||||
|
||||
// Finally, find the end of the month, i.e. the start of the next one
|
||||
c.roll(Calendar.DATE, true);
|
||||
c.add(Calendar.MONTH, 1);
|
||||
c.getTime(); // JDK 1.1.2 bug workaround
|
||||
c.add(Calendar.SECOND, -1);
|
||||
Date endOfMonth = c.getTime();
|
||||
if(endOfMonth==null){
|
||||
//do nothing
|
||||
}
|
||||
endOfMonth = null;
|
||||
int lastWeek = c.get(Calendar.WEEK_OF_MONTH);
|
||||
|
||||
// Calculate the number of full or partial weeks in this month.
|
||||
numWeeks = lastWeek - firstWeek + 1;
|
||||
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
static final int XINSET = 4;
|
||||
static final int YINSET = 2;
|
||||
|
||||
/*
|
||||
* Convert from the day number within a month (1-based)
|
||||
* to the cell coordinates on the calendar (0-based)
|
||||
*/
|
||||
private void dateToCell(int date, Point pos)
|
||||
{
|
||||
int cell = (date + firstDayInMonth - firstDayOfWeek - minDay);
|
||||
if (firstDayInMonth < firstDayOfWeek) {
|
||||
cell += daysInWeek;
|
||||
}
|
||||
|
||||
pos.x = cell % daysInWeek;
|
||||
pos.y = cell / daysInWeek;
|
||||
}
|
||||
//private Point dateToCell(int date) {
|
||||
// Point p = new Point(0,0);
|
||||
// dateToCell(date, p);
|
||||
// return p;
|
||||
//}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
|
||||
if (dirty) {
|
||||
calculate();
|
||||
}
|
||||
|
||||
Point cellPos = new Point(0,0); // Temporary variable
|
||||
Dimension d = this.getSize();
|
||||
|
||||
g.setColor(Color.lightGray);
|
||||
g.fillRect(0,0,d.width,d.height);
|
||||
|
||||
// Draw the day names at the top
|
||||
g.setColor(Color.black);
|
||||
g.setFont(DemoUtility.labelFont);
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
int labelHeight = fm.getHeight() + YINSET * 2;
|
||||
|
||||
int v = fm.getAscent() + YINSET;
|
||||
for (int i = 0; i < daysInWeek; i++) {
|
||||
int dayNum = (i + minDay + firstDayOfWeek - 2) % daysInWeek + 1;
|
||||
String dayName = fSymbols[0].getWeekdays()[dayNum];
|
||||
|
||||
|
||||
double h;
|
||||
if (leftToRight) {
|
||||
h = d.width*(i + 0.5) / daysInWeek;
|
||||
} else {
|
||||
h = d.width*(daysInWeek - i - 0.5) / daysInWeek;
|
||||
}
|
||||
h -= fm.stringWidth(dayName) / 2;
|
||||
|
||||
g.drawString(dayName, (int)h, v);
|
||||
}
|
||||
|
||||
double cellHeight = (d.height - labelHeight - 1) / numWeeks;
|
||||
double cellWidth = (double)(d.width - 1) / daysInWeek;
|
||||
|
||||
// Draw a white background in the part of the calendar
|
||||
// that displays this month.
|
||||
// First figure out how much of the first week should be shaded.
|
||||
{
|
||||
g.setColor(Color.white);
|
||||
dateToCell(1, cellPos);
|
||||
int width = (int)(cellPos.x*cellWidth); // Width of unshaded area
|
||||
|
||||
if (leftToRight) {
|
||||
g.fillRect((int)(width), labelHeight ,
|
||||
d.width - width, (int)cellHeight);
|
||||
} else {
|
||||
g.fillRect(0, labelHeight ,
|
||||
d.width - width, (int)cellHeight);
|
||||
}
|
||||
|
||||
// All of the intermediate weeks get shaded completely
|
||||
g.fillRect(0, (int)(labelHeight + cellHeight),
|
||||
d.width, (int)(cellHeight * (numWeeks - 2)));
|
||||
|
||||
// Now figure out the last week.
|
||||
dateToCell(daysInMonth, cellPos);
|
||||
width = (int)((cellPos.x+1)*cellWidth); // Width of shaded area
|
||||
|
||||
if (leftToRight) {
|
||||
g.fillRect(0, (int)(labelHeight + (numWeeks-1) * cellHeight),
|
||||
width, (int)cellHeight);
|
||||
} else {
|
||||
g.fillRect(d.width - width, (int)(labelHeight + (numWeeks-1) * cellHeight),
|
||||
width, (int)cellHeight);
|
||||
}
|
||||
|
||||
}
|
||||
// Draw the X/Y grid lines
|
||||
g.setColor(Color.black);
|
||||
for (int i = 0; i <= numWeeks; i++) {
|
||||
int y = (int)(labelHeight + i * cellHeight);
|
||||
g.drawLine(0, y, d.width - 1, y);
|
||||
}
|
||||
for (int i = 0; i <= daysInWeek; i++) {
|
||||
int x = (int)(i * cellWidth);
|
||||
g.drawLine(x, labelHeight, x, d.height - 1);
|
||||
}
|
||||
|
||||
// Now loop through all of the days in the month, figure out where
|
||||
// they go in the grid, and draw the day # for each one
|
||||
|
||||
// Figure out the date of the first cell in the calendar display
|
||||
int cell = (1 + firstDayInMonth - firstDayOfWeek - minDay);
|
||||
if (firstDayInMonth < firstDayOfWeek) {
|
||||
cell += daysInWeek;
|
||||
}
|
||||
|
||||
Calendar c = (Calendar)fCalendar[0].clone();
|
||||
c.setTime(fStartOfMonth);
|
||||
c.add(Calendar.DATE, -cell);
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
for (int row = 0; row < numWeeks; row++) {
|
||||
for (int col = 0; col < daysInWeek; col++) {
|
||||
|
||||
g.setFont(DemoUtility.numberFont);
|
||||
g.setColor(Color.black);
|
||||
fm = g.getFontMetrics();
|
||||
|
||||
int cellx;
|
||||
if (leftToRight) {
|
||||
cellx = (int)((col) * cellWidth);
|
||||
} else {
|
||||
cellx = (int)((daysInWeek - col - 1) * cellWidth);
|
||||
}
|
||||
|
||||
int celly = (int)(row * cellHeight + labelHeight);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
fCalendar[i].setTime(c.getTime());
|
||||
|
||||
int date = fCalendar[i].get(Calendar.DATE);
|
||||
buffer.setLength(0);
|
||||
buffer.append(date);
|
||||
String dayNum = buffer.toString();
|
||||
|
||||
int x;
|
||||
|
||||
if (leftToRight) {
|
||||
x = cellx + (int)cellWidth - XINSET - fm.stringWidth(dayNum);
|
||||
} else {
|
||||
x = cellx + XINSET;
|
||||
}
|
||||
int y = celly + + fm.getAscent() + YINSET + i * fm.getHeight();
|
||||
|
||||
if (fColor[i] != null) {
|
||||
g.setColor(fColor[i]);
|
||||
}
|
||||
g.drawString(dayNum, x, y);
|
||||
|
||||
if (date == 1 || row == 0 && col == 0) {
|
||||
g.setFont(DemoUtility.numberFont);
|
||||
String month = fSymbols[i].getMonths()[
|
||||
fCalendar[i].get(Calendar.MONTH)];
|
||||
|
||||
if (leftToRight) {
|
||||
x = cellx + XINSET;
|
||||
} else {
|
||||
x = cellx + (int)cellWidth - XINSET - fm.stringWidth(month);
|
||||
}
|
||||
g.drawString(month, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
c.add(Calendar.DATE, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Important state variables
|
||||
private Calendar[] fCalendar = new Calendar[4];
|
||||
private Color[] fColor = new Color[4];
|
||||
|
||||
private Locale fDisplayLocale;
|
||||
private DateFormatSymbols[] fSymbols = new DateFormatSymbols[4];
|
||||
|
||||
private Date fStartOfMonth = new Date(); // 00:00:00 on first day of month
|
||||
|
||||
// Cached calculations to make drawing faster.
|
||||
private transient int minDay; // Minimum legal day #
|
||||
private transient int daysInWeek; // # of days in a week
|
||||
private transient int firstDayOfWeek; // First day to display in week
|
||||
private transient int numWeeks; // # full or partial weeks in month
|
||||
private transient int daysInMonth; // # days in this month
|
||||
private transient int firstDayInMonth; // Day of week of first day in month
|
||||
private transient boolean leftToRight;
|
||||
|
||||
private transient boolean dirty = true;
|
||||
}
|
12
demos/src/com/ibm/icu/dev/demo/calendar/package.html
Normal file
12
demos/src/com/ibm/icu/dev/demo/calendar/package.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Copyright (C) 2000-2004, International Business Machines Corporation and
|
||||
others. All Rights Reserved.
|
||||
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
Calendar demo applications including date/time arithmetic.
|
||||
</body>
|
||||
</html>
|
421
demos/src/com/ibm/icu/dev/demo/charsetdet/DetectingViewer.java
Normal file
421
demos/src/com/ibm/icu/dev/demo/charsetdet/DetectingViewer.java
Normal file
|
@ -0,0 +1,421 @@
|
|||
/*
|
||||
**************************************************************************
|
||||
* Copyright (C) 2005-2010, International Business Machines Corporation *
|
||||
* and others. All Rights Reserved. *
|
||||
**************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.charsetdet;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.AccessControlException;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import com.ibm.icu.charset.CharsetICU;
|
||||
import com.ibm.icu.dev.demo.impl.DemoApplet;
|
||||
import com.ibm.icu.text.CharsetDetector;
|
||||
import com.ibm.icu.text.CharsetMatch;
|
||||
|
||||
/**
|
||||
* This simple application demonstrates how to use the CharsetDetector API. It
|
||||
* opens a file or web page, detects the encoding, and then displays it using that
|
||||
* encoding.
|
||||
*/
|
||||
public class DetectingViewer extends JFrame implements ActionListener
|
||||
{
|
||||
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = -2307065724464747775L;
|
||||
private JTextPane text;
|
||||
private JFileChooser fileChooser;
|
||||
|
||||
/**
|
||||
* @throws java.awt.HeadlessException
|
||||
*/
|
||||
public DetectingViewer()
|
||||
{
|
||||
super();
|
||||
DemoApplet.demoFrameOpened();
|
||||
|
||||
try {
|
||||
fileChooser = new JFileChooser();
|
||||
} catch (AccessControlException ace) {
|
||||
System.err.println("no file chooser - access control exception. Continuing without file browsing. "+ace.toString());
|
||||
fileChooser = null; //
|
||||
}
|
||||
|
||||
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setSize(800, 800);
|
||||
|
||||
setJMenuBar(makeMenus());
|
||||
text = new JTextPane();
|
||||
text.setContentType("text/plain");
|
||||
text.setText("");
|
||||
text.setSize(800, 800);
|
||||
|
||||
Font font = new Font("Arial Unicode MS", Font.PLAIN, 24);
|
||||
text.setFont(font);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(text);
|
||||
|
||||
getContentPane().add(scrollPane);
|
||||
setVisible(true);
|
||||
|
||||
addWindowListener(
|
||||
new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
// setVisible(false);
|
||||
// dispose();
|
||||
|
||||
doQuit();
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent event)
|
||||
{
|
||||
String cmd = event.getActionCommand();
|
||||
|
||||
if (cmd.equals("New...")) {
|
||||
doNew();
|
||||
} else if (cmd.equals("Open File...")) {
|
||||
doOpenFile();
|
||||
} else if (cmd.equals("Open URL...")) {
|
||||
doOpenURL();
|
||||
} else if (cmd.equals("Quit")) {
|
||||
doQuit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new DetectingViewer();
|
||||
}
|
||||
|
||||
private void errorDialog(String title, String msg)
|
||||
{
|
||||
JOptionPane.showMessageDialog(this, msg, title, JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
private BufferedInputStream openFile(File file)
|
||||
{
|
||||
FileInputStream fileStream = null;
|
||||
|
||||
try {
|
||||
fileStream = new FileInputStream(file);
|
||||
} catch (Exception e) {
|
||||
errorDialog("Error Opening File", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
return new BufferedInputStream(fileStream);
|
||||
}
|
||||
|
||||
// private void openFile(String directory, String filename)
|
||||
// {
|
||||
// openFile(new File(directory, filename));
|
||||
// }
|
||||
|
||||
|
||||
private BufferedInputStream openURL(String url)
|
||||
{
|
||||
InputStream s = null;
|
||||
|
||||
try {
|
||||
URL aURL = new URL(url);
|
||||
s = aURL.openStream();
|
||||
} catch (Exception e) {
|
||||
errorDialog("Error Opening URL", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
return new BufferedInputStream(s);
|
||||
}
|
||||
|
||||
private String encodingName(CharsetMatch match)
|
||||
{
|
||||
return match.getName() + " (" + match.getLanguage() + ")";
|
||||
}
|
||||
|
||||
private void setMatchMenu(CharsetMatch[] matches)
|
||||
{
|
||||
JMenu menu = getJMenuBar().getMenu(1);
|
||||
JMenuItem menuItem;
|
||||
|
||||
menu.removeAll();
|
||||
|
||||
for (int i = 0; i < matches.length; i += 1) {
|
||||
CharsetMatch match = matches[i];
|
||||
|
||||
menuItem = new JMenuItem(encodingName(match) + " " + match.getConfidence());
|
||||
|
||||
menu.add(menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] scriptTag = {(byte) 's', (byte) 'c', (byte) 'r', (byte) 'i', (byte) 'p', (byte) 't'};
|
||||
private byte[] styleTag = {(byte) 's', (byte) 't', (byte) 'y', (byte) 'l', (byte) 'e'};
|
||||
private static int BUFFER_SIZE = 100000;
|
||||
|
||||
private boolean openTag(byte[] buffer, int offset, int length, byte[] tag)
|
||||
{
|
||||
int tagLen = tag.length;
|
||||
int bufRem = length - offset;
|
||||
int b;
|
||||
|
||||
for (b = 0; b < tagLen && b < bufRem; b += 1) {
|
||||
if (buffer[b + offset] != tag[b]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return b == tagLen;
|
||||
}
|
||||
|
||||
private boolean closedTag(byte[] buffer, int offset, int length, byte[] tag)
|
||||
{
|
||||
if (buffer[offset] != (byte) '/') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return openTag(buffer, offset + 1, length, tag);
|
||||
}
|
||||
|
||||
private byte[] filter(InputStream in)
|
||||
{
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
int bytesRemaining = BUFFER_SIZE;
|
||||
int bufLen = 0;
|
||||
|
||||
in.mark(BUFFER_SIZE);
|
||||
|
||||
try {
|
||||
while (bytesRemaining > 0) {
|
||||
int bytesRead = in.read(buffer, bufLen, bytesRemaining);
|
||||
|
||||
if (bytesRead <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
bufLen += bytesRead;
|
||||
bytesRemaining -= bytesRead;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: error handling?
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean inTag = false;
|
||||
boolean skip = false;
|
||||
int out = 0;
|
||||
|
||||
for (int i = 0; i < bufLen; i += 1) {
|
||||
byte b = buffer[i];
|
||||
|
||||
if (b == (byte) '<') {
|
||||
inTag = true;
|
||||
|
||||
if (openTag(buffer, i + 1, bufLen, scriptTag) ||
|
||||
openTag(buffer, i + 1, bufLen, styleTag)) {
|
||||
skip = true;
|
||||
} else if (closedTag(buffer, i + 1, bufLen, scriptTag) ||
|
||||
closedTag(buffer, i + 1, bufLen, styleTag)) {
|
||||
skip = false;
|
||||
}
|
||||
} else if (b == (byte) '>') {
|
||||
inTag = false;
|
||||
} else if (! (inTag || skip)) {
|
||||
buffer[out++] = b;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] filtered = new byte[out];
|
||||
|
||||
System.arraycopy(buffer, 0, filtered, 0, out);
|
||||
return filtered;
|
||||
}
|
||||
|
||||
private CharsetMatch[] detect(byte[] bytes)
|
||||
{
|
||||
CharsetDetector det = new CharsetDetector();
|
||||
|
||||
det.setText(bytes);
|
||||
|
||||
return det.detectAll();
|
||||
}
|
||||
|
||||
private CharsetMatch[] detect(BufferedInputStream inputStream)
|
||||
{
|
||||
CharsetDetector det = new CharsetDetector();
|
||||
|
||||
try {
|
||||
det.setText(inputStream);
|
||||
|
||||
return det.detectAll();
|
||||
} catch (Exception e) {
|
||||
// TODO: error message?
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void show(InputStream inputStream, CharsetMatch[] matches, String title)
|
||||
{
|
||||
InputStreamReader isr;
|
||||
char[] buffer = new char[1024];
|
||||
int bytesRead = 0;
|
||||
|
||||
if (matches == null || matches.length == 0) {
|
||||
errorDialog("Match Error", "No matches!");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String encoding = matches[0].getName();
|
||||
|
||||
inputStream.reset();
|
||||
|
||||
if (encoding.startsWith("UTF-32")) {
|
||||
byte[] bytes = new byte[1024];
|
||||
int offset = 0;
|
||||
int chBytes = 0;
|
||||
Charset utf32 = CharsetICU.forNameICU(encoding);
|
||||
|
||||
while ((bytesRead = inputStream.read(bytes, offset, 1024)) >= 0) {
|
||||
offset = bytesRead % 4;
|
||||
chBytes = bytesRead - offset;
|
||||
|
||||
sb.append(utf32.decode(ByteBuffer.wrap(bytes)).toString());
|
||||
|
||||
if (offset != 0) {
|
||||
for (int i = 0; i < offset; i += 1) {
|
||||
bytes[i] = bytes[chBytes + i];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isr = new InputStreamReader(inputStream, encoding);
|
||||
|
||||
while ((bytesRead = isr.read(buffer, 0, 1024)) >= 0) {
|
||||
sb.append(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
isr.close();
|
||||
}
|
||||
|
||||
this.setTitle(title + " - " + encodingName(matches[0]));
|
||||
|
||||
setMatchMenu(matches);
|
||||
text.setText(sb.toString());
|
||||
} catch (IOException e) {
|
||||
errorDialog("IO Error", e.getMessage());
|
||||
} catch (Exception e) {
|
||||
errorDialog("Internal Error", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void doNew()
|
||||
{
|
||||
// open a new window...
|
||||
}
|
||||
|
||||
private void doOpenFile()
|
||||
{
|
||||
int retVal = fileChooser.showOpenDialog(this);
|
||||
|
||||
if (retVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fileChooser.getSelectedFile();
|
||||
BufferedInputStream inputStream = openFile(file);
|
||||
|
||||
if (inputStream != null) {
|
||||
CharsetMatch[] matches = detect(inputStream);
|
||||
|
||||
show(inputStream, matches, file.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doOpenURL()
|
||||
{
|
||||
String url = (String) JOptionPane.showInputDialog(this, "URL to open:", "Open URL", JOptionPane.PLAIN_MESSAGE,
|
||||
null, null, null);
|
||||
|
||||
if (url != null && url.length() > 0) {
|
||||
BufferedInputStream inputStream = openURL(url);
|
||||
|
||||
if (inputStream != null) {
|
||||
byte[] filtered = filter(inputStream);
|
||||
CharsetMatch[] matches = detect(filtered);
|
||||
|
||||
show(inputStream, matches, url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doQuit()
|
||||
{
|
||||
DemoApplet.demoFrameClosed();
|
||||
this.setVisible(false);
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
private JMenuBar makeMenus()
|
||||
{
|
||||
JMenu menu = new JMenu("File");
|
||||
JMenuItem mi;
|
||||
|
||||
mi = new JMenuItem("Open File...");
|
||||
mi.setAccelerator((KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)));
|
||||
mi.addActionListener(this);
|
||||
menu.add(mi);
|
||||
if(fileChooser == null) {
|
||||
mi.setEnabled(false); // no file chooser.
|
||||
}
|
||||
|
||||
mi = new JMenuItem("Open URL...");
|
||||
mi.setAccelerator((KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK)));
|
||||
mi.addActionListener(this);
|
||||
menu.add(mi);
|
||||
|
||||
mi = new JMenuItem("Quit");
|
||||
mi.setAccelerator((KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK)));
|
||||
mi.addActionListener(this);
|
||||
menu.add(mi);
|
||||
|
||||
JMenuBar mbar = new JMenuBar();
|
||||
mbar.add(menu);
|
||||
|
||||
menu = new JMenu("Detected Encodings");
|
||||
mbar.add(menu);
|
||||
|
||||
return mbar;
|
||||
}
|
||||
}
|
552
demos/src/com/ibm/icu/dev/demo/holiday/HolidayBorderPanel.java
Normal file
552
demos/src/com/ibm/icu/dev/demo/holiday/HolidayBorderPanel.java
Normal file
|
@ -0,0 +1,552 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.holiday;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Panel;
|
||||
|
||||
/**
|
||||
* Various graphical borders. The border itself is a Panel so that it can
|
||||
* contain other Components (i.e. it borders something). You use the
|
||||
* HolidayBorderPanel like any other Panel: you set the layout that you prefer and
|
||||
* add Components to it. Beware that a null layout does not obey the insets
|
||||
* of the panel so if you use null layouts, adjust your measurements to
|
||||
* handle the border by calling insets().
|
||||
*
|
||||
* @author Andy Clark, Taligent Inc.
|
||||
* @version 1.0
|
||||
*/
|
||||
public class HolidayBorderPanel extends Panel {
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = 4669213306492461159L;
|
||||
// Constants
|
||||
|
||||
/** Solid border. */
|
||||
public final static int SOLID = 0;
|
||||
/** A raised border. */
|
||||
public final static int RAISED = 1;
|
||||
/** A lowered border. */
|
||||
public final static int LOWERED = 2;
|
||||
/** An etched in border. */
|
||||
public final static int IN = 3;
|
||||
/** An etched out border. */
|
||||
public final static int OUT = 4;
|
||||
|
||||
/** Left alignment. */
|
||||
public final static int LEFT = 0;
|
||||
/** Center alignment. */
|
||||
public final static int CENTER = 1;
|
||||
/** Right alignment. */
|
||||
public final static int RIGHT = 2;
|
||||
|
||||
/** Default style (IN). */
|
||||
public final static int DEFAULT_STYLE = IN;
|
||||
/** Default thickness (10). */
|
||||
public final static int DEFAULT_THICKNESS = 10;
|
||||
/** Default thickness for solid borders (4). */
|
||||
public final static int DEFAULT_SOLID_THICKNESS = 4;
|
||||
/** Default thickness for raised borders (2). */
|
||||
public final static int DEFAULT_RAISED_THICKNESS = 2;
|
||||
/** Default thickness for lowered borders (2). */
|
||||
public final static int DEFAULT_LOWERED_THICKNESS = 2;
|
||||
/** Default thickness for etched-in borders (10). */
|
||||
public final static int DEFAULT_IN_THICKNESS = 10;
|
||||
/** Default thickness for etched-out borders (10). */
|
||||
public final static int DEFAULT_OUT_THICKNESS = 10;
|
||||
/** Default gap between border and contained component (5). */
|
||||
public final static int DEFAULT_GAP = 5;
|
||||
/** Default color (black). Applies to SOLID and etched borders. */
|
||||
public final static Color DEFAULT_COLOR = Color.black;
|
||||
|
||||
/** Default font (TimesRoman,PLAIN,14). Only applies to etched borders. */
|
||||
public final static Font DEFAULT_FONT = new Font("TimesRoman", Font.PLAIN, 14);
|
||||
/** Default alignment (LEFT). Only applies to etched borders. */
|
||||
public final static int DEFAULT_ALIGNMENT = LEFT;
|
||||
|
||||
// Data
|
||||
private int style;
|
||||
private int thickness;
|
||||
private int gap;
|
||||
private Color color;
|
||||
|
||||
private Font font;
|
||||
private String text;
|
||||
private int alignment;
|
||||
|
||||
/**
|
||||
* Constructor. Makes default border.
|
||||
*/
|
||||
public HolidayBorderPanel() {
|
||||
|
||||
// initialize data
|
||||
style = DEFAULT_STYLE;
|
||||
thickness = DEFAULT_THICKNESS;
|
||||
gap = DEFAULT_GAP;
|
||||
color = DEFAULT_COLOR;
|
||||
|
||||
text = null;
|
||||
font = DEFAULT_FONT;
|
||||
alignment = DEFAULT_ALIGNMENT;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. Makes an etched IN border with given text caption.
|
||||
*
|
||||
* @param text Text caption
|
||||
*/
|
||||
public HolidayBorderPanel(String text) {
|
||||
this();
|
||||
|
||||
style = IN;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. Makes SOLID border with color and thickness given.
|
||||
*
|
||||
* @param color The color for the border.
|
||||
* @param thickness The thickness of the border.
|
||||
*/
|
||||
public HolidayBorderPanel(Color color, int thickness) {
|
||||
this();
|
||||
|
||||
style = SOLID;
|
||||
this.color = color;
|
||||
this.thickness = thickness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. Makes a border of the given style with the default
|
||||
* thickness for that style.
|
||||
*
|
||||
* @param style The style for this border.
|
||||
*/
|
||||
public HolidayBorderPanel(int style) {
|
||||
this();
|
||||
|
||||
// set thickness appropriate to this style
|
||||
switch (style) {
|
||||
case SOLID: thickness = DEFAULT_SOLID_THICKNESS; break;
|
||||
case RAISED: thickness = DEFAULT_RAISED_THICKNESS; break;
|
||||
case LOWERED: thickness = DEFAULT_LOWERED_THICKNESS; break;
|
||||
case IN: thickness = DEFAULT_IN_THICKNESS; break;
|
||||
case OUT: thickness = DEFAULT_OUT_THICKNESS; break;
|
||||
default:
|
||||
thickness = DEFAULT_THICKNESS;
|
||||
}
|
||||
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. Makes border with given style and thickness.
|
||||
*
|
||||
* @param style The style for this border.
|
||||
* @param thickness The thickness for this border.
|
||||
*/
|
||||
public HolidayBorderPanel(int style, int thickness) {
|
||||
this();
|
||||
|
||||
this.style = style;
|
||||
this.thickness = thickness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the insets of this panel..
|
||||
*/
|
||||
public Insets getInsets() {
|
||||
int adjustment = 0;
|
||||
|
||||
// adjust for text string
|
||||
if (style == IN || style == OUT) {
|
||||
if (text != null && text.length() > 0) {
|
||||
try {
|
||||
// set font and get info
|
||||
int height = getGraphics().getFontMetrics(font).getHeight();
|
||||
if (height > thickness)
|
||||
adjustment = height - thickness;
|
||||
}
|
||||
catch (Exception e) {
|
||||
// nothing: just in case there is no graphics context
|
||||
// at the beginning.
|
||||
System.out.print("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return appropriate insets
|
||||
int dist = thickness + gap;
|
||||
return new Insets(dist + adjustment, dist, dist, dist);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the style of the border
|
||||
*
|
||||
* @param style The new style.
|
||||
*/
|
||||
public HolidayBorderPanel setStyle(int style) {
|
||||
|
||||
// set the style and re-layout the panel
|
||||
this.style = style;
|
||||
doLayout();
|
||||
repaint();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the style of the border
|
||||
*/
|
||||
public int getStyle() {
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the thickness of the border.
|
||||
*
|
||||
* @param thickness The new thickness
|
||||
*/
|
||||
public HolidayBorderPanel setThickness(int thickness) {
|
||||
|
||||
if (thickness > 0) {
|
||||
this.thickness = thickness;
|
||||
doLayout();
|
||||
repaint();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the thickness of the border.
|
||||
*/
|
||||
public int getThickness() {
|
||||
|
||||
return thickness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the gap between the border and the contained Component.
|
||||
*
|
||||
* @param gap The new gap, in pixels.
|
||||
*/
|
||||
public HolidayBorderPanel setGap(int gap) {
|
||||
|
||||
if (gap > -1) {
|
||||
this.gap = gap;
|
||||
doLayout();
|
||||
repaint();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gap between the border and the contained Component.
|
||||
*/
|
||||
public int getGap() {
|
||||
|
||||
return gap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current color for SOLID borders and the caption text
|
||||
* color for etched borders.
|
||||
*
|
||||
* @param color The new color.
|
||||
*/
|
||||
public HolidayBorderPanel setColor(Color color) {
|
||||
|
||||
this.color = color;
|
||||
if (style == SOLID || style == IN || style == OUT)
|
||||
repaint();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current color for SOLID borders and the caption
|
||||
* text color for etched borders.
|
||||
*/
|
||||
public Color getColor() {
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the font. Only applies to etched borders.
|
||||
*/
|
||||
public HolidayBorderPanel setTextFont(Font font) {
|
||||
|
||||
// set font
|
||||
if (font != null) {
|
||||
this.font = font;
|
||||
if (style == IN || style == OUT) {
|
||||
doLayout();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the font of the text. Only applies to etched borders.
|
||||
*/
|
||||
public Font getTextFont() {
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text. Only applies to etched borders.
|
||||
*
|
||||
* @param text The new text.
|
||||
*/
|
||||
public HolidayBorderPanel setText(String text) {
|
||||
|
||||
this.text = text;
|
||||
if (style == IN || style == OUT) {
|
||||
doLayout();
|
||||
repaint();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the text. Only applies to etched borders.
|
||||
*/
|
||||
public String getText() {
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text alignment. Only applies to etched borders.
|
||||
*
|
||||
* @param alignment The new alignment.
|
||||
*/
|
||||
public HolidayBorderPanel setAlignment(int alignment) {
|
||||
|
||||
this.alignment = alignment;
|
||||
if (style == IN || style == OUT) {
|
||||
doLayout();
|
||||
repaint();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the text alignment.
|
||||
*/
|
||||
public int getAlignment() {
|
||||
|
||||
return alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repaints the border.
|
||||
*
|
||||
* @param g The graphics context.
|
||||
*/
|
||||
public void paint(Graphics g) {
|
||||
|
||||
// get current dimensions
|
||||
Dimension size = getSize();
|
||||
int width = size.width;
|
||||
int height = size.height;
|
||||
|
||||
// set colors
|
||||
Color light = getBackground().brighter().brighter().brighter();
|
||||
Color dark = getBackground().darker().darker().darker();
|
||||
|
||||
// Draw border
|
||||
switch (style) {
|
||||
case RAISED: // 3D Border (in or out)
|
||||
case LOWERED:
|
||||
Color topleft = null;
|
||||
Color bottomright = null;
|
||||
|
||||
// set colors
|
||||
if (style == RAISED) {
|
||||
topleft = light;
|
||||
bottomright = dark;
|
||||
}
|
||||
else {
|
||||
topleft = dark;
|
||||
bottomright = light;
|
||||
}
|
||||
|
||||
// draw border
|
||||
g.setColor(topleft);
|
||||
for (int i = 0; i < thickness; i++) {
|
||||
g.drawLine(i, i, width - i - 2, i);
|
||||
g.drawLine(i, i + 1, i, height - i - 1);
|
||||
}
|
||||
g.setColor(bottomright);
|
||||
for (int i = 0; i < thickness; i++) {
|
||||
g.drawLine(i + 1, height - i - 1, width - i - 1, height - i - 1);
|
||||
g.drawLine(width - i - 1, i, width - i - 1, height - i - 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case IN: // Etched Border (in or out)
|
||||
case OUT:
|
||||
int adjust1 = 0;
|
||||
int adjust2 = 0;
|
||||
|
||||
// set font and get info
|
||||
Font oldfont = g.getFont();
|
||||
g.setFont(font);
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
int ascent = fm.getAscent();
|
||||
|
||||
// set adjustment
|
||||
if (style == IN)
|
||||
adjust1 = 1;
|
||||
else
|
||||
adjust2 = 1;
|
||||
|
||||
// Calculate adjustment for text
|
||||
int adjustment = 0;
|
||||
if (text != null && text.length() > 0) {
|
||||
if (ascent > thickness)
|
||||
adjustment = (ascent - thickness) / 2;
|
||||
}
|
||||
|
||||
// The adjustment is there so that we always draw the
|
||||
// light rectangle first. Otherwise, your eye picks up
|
||||
// the discrepancy where the light rect. passes over
|
||||
// the darker rect.
|
||||
int x = thickness / 2;
|
||||
int y = thickness / 2 + adjustment;
|
||||
int w = width - thickness - 1;
|
||||
int h = height - thickness - 1 - adjustment;
|
||||
|
||||
// draw rectangles
|
||||
g.setColor(light);
|
||||
g.drawRect(x + adjust1, y + adjust1, w, h);
|
||||
g.setColor(dark);
|
||||
g.drawRect(x + adjust2, y + adjust2, w, h);
|
||||
|
||||
// draw text, if applicable
|
||||
if (text != null && text.length() > 0) {
|
||||
// calculate drawing area
|
||||
int fontheight = fm.getHeight();
|
||||
int strwidth = fm.stringWidth(text);
|
||||
|
||||
int textwidth = width - 2 * (thickness + 5);
|
||||
if (strwidth > textwidth)
|
||||
strwidth = textwidth;
|
||||
|
||||
// calculate offset for alignment
|
||||
int offset;
|
||||
switch (alignment) {
|
||||
case CENTER:
|
||||
offset = (width - strwidth) / 2;
|
||||
break;
|
||||
case RIGHT:
|
||||
offset = width - strwidth - thickness - 5;
|
||||
break;
|
||||
case LEFT:
|
||||
default: // assume left alignment if invalid
|
||||
offset = thickness + 5;
|
||||
break;
|
||||
}
|
||||
|
||||
// clear drawing area and set clipping region
|
||||
g.clearRect(offset - 5, 0, strwidth + 10, fontheight);
|
||||
g.clipRect(offset, 0, strwidth, fontheight);
|
||||
|
||||
// draw text
|
||||
g.setColor(color);
|
||||
g.drawString(text, offset, ascent);
|
||||
|
||||
// restore old clipping area
|
||||
g.clipRect(0, 0, width, height);
|
||||
}
|
||||
|
||||
g.setFont(oldfont);
|
||||
break;
|
||||
|
||||
case SOLID:
|
||||
default: // assume SOLID
|
||||
g.setColor(color);
|
||||
for (int i = 0; i < thickness; i++)
|
||||
g.drawRect(i, i, width - 2 * i - 1, height - 2 * i - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the settings of this HolidayBorderPanel instance as a string.
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer str = new StringBuffer("HolidayBorderPanel[");
|
||||
|
||||
// style
|
||||
str.append("style=");
|
||||
switch (style) {
|
||||
case SOLID: str.append("SOLID"); break;
|
||||
case RAISED: str.append("RAISED"); break;
|
||||
case LOWERED: str.append("LOWERED"); break;
|
||||
case IN: str.append("IN"); break;
|
||||
case OUT: str.append("OUT"); break;
|
||||
default: str.append("unknown");
|
||||
}
|
||||
str.append(",");
|
||||
|
||||
// thickness
|
||||
str.append("thickness=");
|
||||
str.append(thickness);
|
||||
str.append(",");
|
||||
|
||||
// gap
|
||||
str.append("gap=");
|
||||
str.append(gap);
|
||||
str.append(",");
|
||||
|
||||
// color
|
||||
str.append(color);
|
||||
str.append(",");
|
||||
|
||||
// font
|
||||
str.append(font);
|
||||
str.append(",");
|
||||
|
||||
// text
|
||||
str.append("text=");
|
||||
str.append(text);
|
||||
str.append(",");
|
||||
|
||||
// alignment
|
||||
str.append("alignment=");
|
||||
switch (alignment) {
|
||||
case LEFT: str.append("LEFT"); break;
|
||||
case CENTER: str.append("CENTER"); break;
|
||||
case RIGHT: str.append("RIGHT"); break;
|
||||
default: str.append("unknown");
|
||||
}
|
||||
|
||||
str.append("]");
|
||||
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
744
demos/src/com/ibm/icu/dev/demo/holiday/HolidayCalendarDemo.java
Normal file
744
demos/src/com/ibm/icu/dev/demo/holiday/HolidayCalendarDemo.java
Normal file
|
@ -0,0 +1,744 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.holiday;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Button;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Label;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.ibm.icu.dev.demo.impl.DemoApplet;
|
||||
import com.ibm.icu.dev.demo.impl.DemoTextBox;
|
||||
import com.ibm.icu.dev.demo.impl.DemoUtility;
|
||||
import com.ibm.icu.text.SimpleDateFormat;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.Holiday;
|
||||
import com.ibm.icu.util.SimpleTimeZone;
|
||||
|
||||
/**
|
||||
* CalendarDemo demonstrates how Calendar works.
|
||||
*/
|
||||
public class HolidayCalendarDemo extends DemoApplet
|
||||
{
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = 4546085430817359372L;
|
||||
|
||||
/**
|
||||
* The main function which defines the behavior of the CalendarDemo
|
||||
* applet when an applet is started.
|
||||
*/
|
||||
public static void main(String argv[]) {
|
||||
|
||||
new HolidayCalendarDemo().showDemo();
|
||||
}
|
||||
|
||||
/* This creates a CalendarFrame for the demo applet. */
|
||||
public Frame createDemoFrame(DemoApplet applet) {
|
||||
return new CalendarFrame(applet);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Frame is a top-level window with a title. The default layout for a frame
|
||||
* is BorderLayout. The CalendarFrame class defines the window layout of
|
||||
* CalendarDemo.
|
||||
*/
|
||||
private static class CalendarFrame extends Frame implements ActionListener,
|
||||
ItemListener
|
||||
{
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = -7023296782393042761L;
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
//private Locale curLocale = Locale.US; // unused
|
||||
|
||||
private DemoApplet applet;
|
||||
|
||||
private static final Locale[] calendars = {
|
||||
//new Locale("de","AT"),
|
||||
Locale.CANADA,
|
||||
Locale.CANADA_FRENCH,
|
||||
Locale.FRANCE,
|
||||
Locale.GERMANY,
|
||||
new Locale("iw","IL"),
|
||||
new Locale("el","GR"),
|
||||
//new Locale("es","MX"),
|
||||
Locale.UK,
|
||||
Locale.US,
|
||||
};
|
||||
private static final Locale[] displays = {
|
||||
Locale.CANADA,
|
||||
Locale.UK,
|
||||
Locale.US,
|
||||
Locale.FRANCE,
|
||||
Locale.CANADA_FRENCH,
|
||||
//new Locale("de","AT"),
|
||||
Locale.GERMAN,
|
||||
new Locale("el","GR"),
|
||||
//new Locale("iw","IL"),
|
||||
new Locale("es","MX"),
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a new CalendarFrame that is initially invisible.
|
||||
*/
|
||||
public CalendarFrame(DemoApplet applet)
|
||||
{
|
||||
super("Calendar Demo");
|
||||
this.applet = applet;
|
||||
init();
|
||||
start();
|
||||
enableEvents(WindowEvent.WINDOW_CLOSING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the applet. You never need to call this directly, it
|
||||
* is called automatically by the system once the applet is created.
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
// Get G7 locales only for demo purpose. To get all the locales
|
||||
// supported, switch to calling Calendar.getAvailableLocales().
|
||||
// commented
|
||||
locales = displays;
|
||||
|
||||
buildGUI();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
// package private
|
||||
//------------------------------------------------------------
|
||||
void addWithFont(Container container, Component foo, Font font) {
|
||||
if (font != null)
|
||||
foo.setFont(font);
|
||||
container.add(foo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to start the applet. You never need to call this method
|
||||
* directly, it is called when the applet's document is visited.
|
||||
*/
|
||||
public void start()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
private Choice localeMenu;
|
||||
private Choice displayMenu;
|
||||
private Locale[] locales;
|
||||
|
||||
private Label monthLabel;
|
||||
private Button prevYear;
|
||||
private Button prevMonth;
|
||||
private Button gotoToday;
|
||||
private Button nextMonth;
|
||||
private Button nextYear;
|
||||
private CalendarPanel calendarPanel;
|
||||
|
||||
private static final Locale kFirstLocale = Locale.US;
|
||||
|
||||
private static void add(Container container, Component component,
|
||||
GridBagLayout g, GridBagConstraints c)
|
||||
{
|
||||
g.setConstraints(component, c);
|
||||
container.add(component);
|
||||
}
|
||||
|
||||
public void buildGUI()
|
||||
{
|
||||
setBackground(DemoUtility.bgColor);
|
||||
setLayout(new BorderLayout(10,10));
|
||||
|
||||
// Label for the demo's title
|
||||
Label titleLabel = new Label("Calendar Demo", Label.CENTER);
|
||||
titleLabel.setFont(DemoUtility.titleFont);
|
||||
|
||||
// Label for the current month name
|
||||
monthLabel = new Label("", Label.LEFT);
|
||||
monthLabel.setFont(new Font(DemoUtility.titleFont.getName(),
|
||||
DemoUtility.titleFont.getStyle(),
|
||||
(DemoUtility.titleFont.getSize() * 3)/2));
|
||||
|
||||
// Make the locale popup menus
|
||||
localeMenu= new Choice();
|
||||
localeMenu.addItemListener(this);
|
||||
int selectMe = 0;
|
||||
|
||||
for (int i = 0; i < calendars.length; i++) {
|
||||
if (i > 0 &&
|
||||
calendars[i].getCountry().equals(calendars[i-1].getCountry()) ||
|
||||
i < calendars.length - 1 &&
|
||||
calendars[i].getCountry().equals(calendars[i+1].getCountry()))
|
||||
{
|
||||
localeMenu.addItem(calendars[i].getDisplayCountry() + " (" +
|
||||
calendars[i].getDisplayLanguage() + ")");
|
||||
} else {
|
||||
localeMenu.addItem( calendars[i].getDisplayCountry() );
|
||||
}
|
||||
|
||||
if (calendars[i].equals(kFirstLocale)) {
|
||||
selectMe = i;
|
||||
}
|
||||
}
|
||||
|
||||
localeMenu.setBackground(DemoUtility.choiceColor);
|
||||
localeMenu.select(selectMe);
|
||||
|
||||
displayMenu = new Choice();
|
||||
displayMenu.addItemListener(this);
|
||||
|
||||
selectMe = 0;
|
||||
for (int i = 0; i < locales.length; i++) {
|
||||
if (i > 0 &&
|
||||
locales[i].getLanguage().equals(locales[i-1].getLanguage()) ||
|
||||
i < locales.length - 1 &&
|
||||
locales[i].getLanguage().equals(locales[i+1].getLanguage()))
|
||||
{
|
||||
displayMenu.addItem( locales[i].getDisplayName() );
|
||||
} else {
|
||||
displayMenu.addItem( locales[i].getDisplayLanguage());
|
||||
}
|
||||
|
||||
if (locales[i].equals(kFirstLocale)) {
|
||||
selectMe = i;
|
||||
}
|
||||
}
|
||||
|
||||
displayMenu.setBackground(DemoUtility.choiceColor);
|
||||
displayMenu.select(selectMe);
|
||||
|
||||
// Make all the next/previous/today buttons
|
||||
prevYear = new Button("<<");
|
||||
prevYear.addActionListener(this);
|
||||
prevMonth = new Button("<");
|
||||
prevMonth.addActionListener(this);
|
||||
gotoToday = new Button("Today");
|
||||
gotoToday.addActionListener(this);
|
||||
nextMonth = new Button(">");
|
||||
nextMonth.addActionListener(this);
|
||||
nextYear = new Button(">>");
|
||||
nextYear.addActionListener(this);
|
||||
|
||||
// The month name and the control buttons are bunched together
|
||||
Panel monthPanel = new Panel();
|
||||
{
|
||||
GridBagLayout g = new GridBagLayout();
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
monthPanel.setLayout(g);
|
||||
|
||||
c.weightx = 1;
|
||||
c.weighty = 1;
|
||||
|
||||
c.gridwidth = 1;
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||
add(monthPanel, monthLabel, g, c);
|
||||
|
||||
c.gridwidth = 1;
|
||||
add(monthPanel, prevYear, g, c);
|
||||
add(monthPanel, prevMonth, g, c);
|
||||
add(monthPanel, gotoToday, g, c);
|
||||
add(monthPanel, nextMonth, g, c);
|
||||
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||
add(monthPanel, nextYear, g, c);
|
||||
}
|
||||
|
||||
// Stick the menu and buttons in a little "control panel"
|
||||
Panel menuPanel = new Panel();
|
||||
{
|
||||
GridBagLayout g = new GridBagLayout();
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
menuPanel.setLayout(g);
|
||||
|
||||
c.weightx = 1;
|
||||
c.weighty = 1;
|
||||
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
|
||||
c.gridwidth = GridBagConstraints.RELATIVE;
|
||||
Label l1 = new Label("Holidays");
|
||||
l1.setFont(DemoUtility.labelFont);
|
||||
add(menuPanel, l1, g, c);
|
||||
|
||||
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||
add(menuPanel, localeMenu, g, c);
|
||||
|
||||
c.gridwidth = GridBagConstraints.RELATIVE;
|
||||
Label l2 = new Label("Display:");
|
||||
l2.setFont(DemoUtility.labelFont);
|
||||
add(menuPanel, l2, g, c);
|
||||
|
||||
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||
add(menuPanel, displayMenu, g, c);
|
||||
}
|
||||
|
||||
// The title, buttons, etc. go in a panel at the top of the window
|
||||
Panel topPanel = new Panel();
|
||||
{
|
||||
topPanel.setLayout(new BorderLayout());
|
||||
|
||||
//topPanel.add("North", titleLabel);
|
||||
topPanel.add("Center", monthPanel);
|
||||
topPanel.add("East", menuPanel);
|
||||
}
|
||||
add("North", topPanel);
|
||||
|
||||
// The copyright notice goes at the bottom of the window
|
||||
Label copyright = new Label(DemoUtility.copyright1, Label.LEFT);
|
||||
copyright.setFont(DemoUtility.creditFont);
|
||||
add("South", copyright);
|
||||
|
||||
// Now create the big calendar panel and stick it in the middle
|
||||
calendarPanel = new CalendarPanel( kFirstLocale );
|
||||
add("Center", calendarPanel);
|
||||
|
||||
updateMonthName();
|
||||
}
|
||||
|
||||
private void updateMonthName()
|
||||
{
|
||||
SimpleDateFormat f = new SimpleDateFormat("MMMM yyyyy",
|
||||
calendarPanel.getDisplayLocale());
|
||||
f.setCalendar(calendarPanel.getCalendar());
|
||||
f.setTimeZone(new SimpleTimeZone(0, "UTC")); // JDK 1.1.2 workaround
|
||||
monthLabel.setText( f.format( calendarPanel.firstOfMonth() ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the event. Returns true if the event is handled and should not
|
||||
* be passed to the parent of this component. The default event handler
|
||||
* calls some helper methods to make life easier on the programmer.
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Object obj = e.getSource();
|
||||
|
||||
// *** Button events are handled here.
|
||||
if (obj instanceof Button) {
|
||||
if (obj == nextMonth) {
|
||||
calendarPanel.add(Calendar.MONTH, +1);
|
||||
}
|
||||
else
|
||||
if (obj == prevMonth) {
|
||||
calendarPanel.add(Calendar.MONTH, -1);
|
||||
}
|
||||
else
|
||||
if (obj == prevYear) {
|
||||
calendarPanel.add(Calendar.YEAR, -1);
|
||||
}
|
||||
else
|
||||
if (obj == nextYear) {
|
||||
calendarPanel.add(Calendar.YEAR, +1);
|
||||
}
|
||||
else
|
||||
if (obj == gotoToday) {
|
||||
calendarPanel.set( new Date() );
|
||||
}
|
||||
updateMonthName();
|
||||
}
|
||||
}
|
||||
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
Object obj = e.getSource();
|
||||
if (obj == localeMenu) {
|
||||
calendarPanel.setCalendarLocale(calendars[localeMenu.getSelectedIndex()]);
|
||||
updateMonthName();
|
||||
}
|
||||
else
|
||||
if (obj == displayMenu) {
|
||||
calendarPanel.setDisplayLocale(locales[displayMenu.getSelectedIndex()]);
|
||||
updateMonthName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out the error message while debugging this program.
|
||||
*/
|
||||
public void errorText(String s)
|
||||
{
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
||||
protected void processWindowEvent(WindowEvent e)
|
||||
{
|
||||
System.out.println("event " + e);
|
||||
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
|
||||
this.hide();
|
||||
this.dispose();
|
||||
|
||||
if (applet != null) {
|
||||
applet.demoClosed();
|
||||
} else {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class CalendarPanel extends Canvas {
|
||||
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = 1521099412250120821L;
|
||||
|
||||
public CalendarPanel( Locale locale ) {
|
||||
set(locale, locale, new Date());
|
||||
}
|
||||
|
||||
public void setCalendarLocale(Locale locale) {
|
||||
set(locale, fDisplayLocale, fCalendar.getTime());
|
||||
}
|
||||
|
||||
public void setDisplayLocale(Locale locale) {
|
||||
set(fCalendarLocale, locale, fCalendar.getTime());
|
||||
}
|
||||
|
||||
public void set(Date date) {
|
||||
set(fCalendarLocale, fDisplayLocale, date);
|
||||
}
|
||||
|
||||
public void set(Locale loc, Locale display, Date date)
|
||||
{
|
||||
if (fCalendarLocale == null || !loc.equals(fCalendarLocale)) {
|
||||
fCalendarLocale = loc;
|
||||
fCalendar = Calendar.getInstance(fCalendarLocale);
|
||||
fAllHolidays = Holiday.getHolidays(fCalendarLocale);
|
||||
}
|
||||
if (fDisplayLocale == null || !display.equals(fDisplayLocale)) {
|
||||
fDisplayLocale = display;
|
||||
fSymbols = new DateFormatSymbols(fDisplayLocale);
|
||||
}
|
||||
|
||||
fStartOfMonth = date;
|
||||
|
||||
dirty = true;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void add(int field, int delta)
|
||||
{
|
||||
synchronized(fCalendar) {
|
||||
fCalendar.setTime(fStartOfMonth);
|
||||
fCalendar.add(field, delta);
|
||||
fStartOfMonth = fCalendar.getTime();
|
||||
}
|
||||
dirty = true;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public com.ibm.icu.util.Calendar getCalendar() {
|
||||
return fCalendar;
|
||||
}
|
||||
|
||||
public Locale getCalendarLocale() {
|
||||
return fCalendarLocale;
|
||||
}
|
||||
|
||||
public Locale getDisplayLocale() {
|
||||
return fDisplayLocale;
|
||||
}
|
||||
|
||||
|
||||
public Date firstOfMonth() {
|
||||
return fStartOfMonth;
|
||||
}
|
||||
|
||||
private Date startOfMonth(Date dateInMonth)
|
||||
{
|
||||
synchronized(fCalendar) {
|
||||
fCalendar.setTime(dateInMonth); // TODO: synchronization
|
||||
|
||||
int era = fCalendar.get(Calendar.ERA);
|
||||
int year = fCalendar.get(Calendar.YEAR);
|
||||
int month = fCalendar.get(Calendar.MONTH);
|
||||
|
||||
fCalendar.clear();
|
||||
fCalendar.set(Calendar.ERA, era);
|
||||
fCalendar.set(Calendar.YEAR, year);
|
||||
fCalendar.set(Calendar.MONTH, month);
|
||||
fCalendar.set(Calendar.DATE, 1);
|
||||
|
||||
return fCalendar.getTime();
|
||||
}
|
||||
}
|
||||
|
||||
private void calculate()
|
||||
{
|
||||
//
|
||||
// As a workaround for JDK 1.1.3 and below, where Calendars and time
|
||||
// zones are a bit goofy, always set my calendar's time zone to UTC.
|
||||
// You would think I would want to do this in the "set" function above,
|
||||
// but if I do that, the program hangs when this class is loaded,
|
||||
// perhaps due to some sort of static initialization ordering problem.
|
||||
// So I do it here instead.
|
||||
//
|
||||
fCalendar.setTimeZone(new SimpleTimeZone(0, "UTC"));
|
||||
|
||||
Calendar c = (Calendar)fCalendar.clone(); // Temporary copy
|
||||
|
||||
fStartOfMonth = startOfMonth(fStartOfMonth);
|
||||
|
||||
// Stash away a few useful constants for this calendar and display
|
||||
minDay = c.getMinimum(Calendar.DAY_OF_WEEK);
|
||||
daysInWeek = c.getMaximum(Calendar.DAY_OF_WEEK) - minDay + 1;
|
||||
|
||||
firstDayOfWeek = Calendar.getInstance(fDisplayLocale).getFirstDayOfWeek();
|
||||
|
||||
// Stash away a Date for the start of this month
|
||||
|
||||
// Find the day of week of the first day in this month
|
||||
c.setTime(fStartOfMonth);
|
||||
firstDayInMonth = c.get(Calendar.DAY_OF_WEEK);
|
||||
|
||||
// Now find the # of days in the month
|
||||
c.roll(Calendar.DATE, false);
|
||||
daysInMonth = c.get(Calendar.DATE);
|
||||
|
||||
// Finally, find the end of the month, i.e. the start of the next one
|
||||
c.roll(Calendar.DATE, true);
|
||||
c.add(Calendar.MONTH, 1);
|
||||
c.getTime(); // JDK 1.1.2 bug workaround
|
||||
c.add(Calendar.SECOND, -1);
|
||||
Date endOfMonth = c.getTime();
|
||||
|
||||
//
|
||||
// Calculate the number of full or partial weeks in this month.
|
||||
// To do this I can just reuse the code that calculates which
|
||||
// calendar cell contains a given date.
|
||||
//
|
||||
numWeeks = dateToCell(daysInMonth).y - dateToCell(1).y + 1;
|
||||
|
||||
// Remember which holidays fall on which days in this month,
|
||||
// to save the trouble of having to do it later
|
||||
fHolidays.setSize(0);
|
||||
|
||||
for (int h = 0; h < fAllHolidays.length; h++)
|
||||
{
|
||||
Date d = fStartOfMonth;
|
||||
while ( (d = fAllHolidays[h].firstBetween(d, endOfMonth) ) != null)
|
||||
{
|
||||
c.setTime(d);
|
||||
fHolidays.addElement( new HolidayInfo(c.get(Calendar.DATE),
|
||||
fAllHolidays[h],
|
||||
fAllHolidays[h].getDisplayName(fDisplayLocale) ));
|
||||
|
||||
d.setTime( d.getTime() + 1000 ); // "d++"
|
||||
}
|
||||
}
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
static final int INSET = 2;
|
||||
|
||||
/*
|
||||
* Convert from the day number within a month (1-based)
|
||||
* to the cell coordinates on the calendar (0-based)
|
||||
*/
|
||||
private void dateToCell(int date, Point pos)
|
||||
{
|
||||
int cell = (date + firstDayInMonth - firstDayOfWeek - minDay);
|
||||
if (firstDayInMonth < firstDayOfWeek) {
|
||||
cell += daysInWeek;
|
||||
}
|
||||
|
||||
pos.x = cell % daysInWeek;
|
||||
pos.y = cell / daysInWeek;
|
||||
}
|
||||
private Point dateToCell(int date) {
|
||||
Point p = new Point(0,0);
|
||||
dateToCell(date, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
|
||||
if (dirty) {
|
||||
calculate();
|
||||
}
|
||||
|
||||
Point cellPos = new Point(0,0); // Temporary variable
|
||||
Dimension d = getSize();
|
||||
|
||||
g.setColor(DemoUtility.bgColor);
|
||||
g.fillRect(0,0,d.width,d.height);
|
||||
|
||||
// Draw the day names at the top
|
||||
g.setColor(Color.black);
|
||||
g.setFont(DemoUtility.labelFont);
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
int labelHeight = fm.getHeight() + INSET * 2;
|
||||
|
||||
int v = fm.getAscent() + INSET;
|
||||
for (int i = 0; i < daysInWeek; i++) {
|
||||
int dayNum = (i + minDay + firstDayOfWeek - 2) % daysInWeek + 1;
|
||||
String dayName = fSymbols.getWeekdays()[dayNum];
|
||||
|
||||
int h = (int) (d.width * (i + 0.5)) / daysInWeek;
|
||||
h -= fm.stringWidth(dayName) / 2;
|
||||
|
||||
g.drawString(dayName, h, v);
|
||||
}
|
||||
|
||||
double cellHeight = (d.height - labelHeight - 1) / numWeeks;
|
||||
double cellWidth = (double)(d.width - 1) / daysInWeek;
|
||||
|
||||
// Draw a white background in the part of the calendar
|
||||
// that displays this month.
|
||||
// First figure out how much of the first week should be shaded.
|
||||
{
|
||||
g.setColor(Color.white);
|
||||
dateToCell(1, cellPos);
|
||||
int width = (int)(cellPos.x*cellWidth); // Width of unshaded area
|
||||
|
||||
g.fillRect((int)(width), labelHeight ,
|
||||
(int)(d.width - width), (int)cellHeight);
|
||||
|
||||
// All of the intermediate weeks get shaded completely
|
||||
g.fillRect(0, (int)(labelHeight + cellHeight),
|
||||
d.width, (int)(cellHeight * (numWeeks - 2)));
|
||||
|
||||
// Now figure out the last week.
|
||||
dateToCell(daysInMonth, cellPos);
|
||||
width = (int)((cellPos.x+1)*cellWidth); // Width of shaded area
|
||||
|
||||
g.fillRect(0, (int)(labelHeight + (numWeeks-1) * cellHeight),
|
||||
width, (int)(cellHeight));
|
||||
|
||||
}
|
||||
// Draw the X/Y grid lines
|
||||
g.setColor(Color.black);
|
||||
for (int i = 0; i <= numWeeks; i++) {
|
||||
int y = (int)(labelHeight + i * cellHeight);
|
||||
g.drawLine(0, y, d.width - 1, y);
|
||||
}
|
||||
for (int i = 0; i <= daysInWeek; i++) {
|
||||
int x = (int)(i * cellWidth);
|
||||
g.drawLine(x, labelHeight, x, d.height - 1);
|
||||
}
|
||||
|
||||
// Now loop through all of the days in the month, figure out where
|
||||
// they go in the grid, and draw the day # for each one
|
||||
Font numberFont = new Font("Helvetica",Font.PLAIN,12);
|
||||
// not used Font holidayFont = DemoUtility.creditFont;
|
||||
|
||||
Calendar c = (Calendar)fCalendar.clone();
|
||||
c.setTime(fStartOfMonth);
|
||||
|
||||
for (int i = 1, h = 0; i <= daysInMonth; i++) {
|
||||
g.setFont(numberFont);
|
||||
g.setColor(Color.black);
|
||||
fm = g.getFontMetrics();
|
||||
|
||||
dateToCell(i, cellPos);
|
||||
int x = (int)((cellPos.x + 1) * cellWidth);
|
||||
int y = (int)(cellPos.y * cellHeight + labelHeight);
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(i);
|
||||
String dayNum = buffer.toString();
|
||||
|
||||
x = x - INSET - fm.stringWidth(dayNum);
|
||||
y = y + fm.getAscent() + INSET;
|
||||
|
||||
g.drawString(dayNum, x, y);
|
||||
|
||||
// See if any of the holidays land on this day....
|
||||
HolidayInfo info = null;
|
||||
int count = 0;
|
||||
|
||||
// Coordinates of lower-left corner of cell.
|
||||
x = (int)((cellPos.x) * cellWidth);
|
||||
y = (int)((cellPos.y+1) * cellHeight) + labelHeight;
|
||||
|
||||
while (h < fHolidays.size() &&
|
||||
(info = (HolidayInfo)fHolidays.elementAt(h)).date <= i)
|
||||
{
|
||||
if (info.date == i) {
|
||||
// Draw the holiday here.
|
||||
g.setFont(numberFont);
|
||||
g.setColor(Color.red);
|
||||
|
||||
DemoTextBox box = new DemoTextBox(g, info.name, (int)(cellWidth - INSET));
|
||||
box.draw(g, x + INSET, y - INSET - box.getHeight());
|
||||
|
||||
y -= (box.getHeight() + INSET);
|
||||
count++;
|
||||
}
|
||||
h++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Important state variables
|
||||
private Locale fCalendarLocale; // Whose calendar
|
||||
private Calendar fCalendar; // Calendar for calculations
|
||||
|
||||
private Locale fDisplayLocale; // How to display it
|
||||
private DateFormatSymbols fSymbols; // Symbols for drawing
|
||||
|
||||
private Date fStartOfMonth; // 00:00:00 on first day of month
|
||||
|
||||
// Cached calculations to make drawing faster.
|
||||
private transient int minDay; // Minimum legal day #
|
||||
private transient int daysInWeek; // # of days in a week
|
||||
private transient int firstDayOfWeek; // First day to display in week
|
||||
private transient int numWeeks; // # full or partial weeks in month
|
||||
private transient int daysInMonth; // # days in this month
|
||||
private transient int firstDayInMonth; // Day of week of first day in month
|
||||
|
||||
private transient Holiday[] fAllHolidays;
|
||||
private transient Vector fHolidays = new Vector(5,5);
|
||||
|
||||
private transient boolean dirty = true;
|
||||
}
|
||||
|
||||
private static class HolidayInfo {
|
||||
public HolidayInfo(int date, Holiday holiday, String name) {
|
||||
this.date = date;
|
||||
this.holiday = holiday;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Holiday holiday;
|
||||
public int date;
|
||||
public String name;
|
||||
}
|
||||
}
|
||||
|
12
demos/src/com/ibm/icu/dev/demo/holiday/package.html
Normal file
12
demos/src/com/ibm/icu/dev/demo/holiday/package.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Copyright (C) 2000-2004, International Business Machines Corporation and
|
||||
others. All Rights Reserved.
|
||||
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
Holiday demo application.
|
||||
</body>
|
||||
</html>
|
149
demos/src/com/ibm/icu/dev/demo/impl/AppletFrame.java
Normal file
149
demos/src/com/ibm/icu/dev/demo/impl/AppletFrame.java
Normal file
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.impl;
|
||||
import java.applet.Applet;
|
||||
import java.applet.AppletContext;
|
||||
import java.applet.AppletStub;
|
||||
import java.applet.AudioClip;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* <p>A Frame that runs an Applet within itself, making it possible
|
||||
* for an applet to run as an application. Usage:
|
||||
*
|
||||
* <pre>
|
||||
* public class MyApplet extends Applet {
|
||||
* public static void main(String args[]) {
|
||||
* MyApplet applet = new MyApplet();
|
||||
* new AppletFrame("My Applet Running As An App", applet, 640, 480);
|
||||
* }
|
||||
* ...
|
||||
* }
|
||||
* <pre>
|
||||
*
|
||||
* @author Alan Liu
|
||||
*/
|
||||
public class AppletFrame extends Frame implements AppletStub, AppletContext {
|
||||
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = 818828281190757725L;
|
||||
Applet applet;
|
||||
|
||||
/**
|
||||
* Construct a Frame running the given Applet with the default size
|
||||
* of 640 by 480.
|
||||
* When the Frame is closed, the applet's stop() method is called,
|
||||
* the Frame is dispose()d of, and System.exit(0) is called.
|
||||
*
|
||||
* @param name the Frame title
|
||||
* @param applet the applet to be run
|
||||
*/
|
||||
public AppletFrame(String name, Applet applet) {
|
||||
this(name, applet, 640, 480);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a Frame running the given Applet with the given size.
|
||||
* When the Frame is closed, the applet's stop() method is called,
|
||||
* the Frame is dispose()d of, and System.exit(0) is called.
|
||||
*
|
||||
* @param name the Frame title
|
||||
* @param applet the applet to be run
|
||||
* @param width width of the Frame
|
||||
* @param height height of the Frame
|
||||
*/
|
||||
public AppletFrame(String name, Applet applet, int width, int height) {
|
||||
super(name);
|
||||
this.applet = applet;
|
||||
applet.setStub(this);
|
||||
|
||||
setSize(width, height);
|
||||
add("Center", applet);
|
||||
show();
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
AppletFrame.this.applet.stop();
|
||||
dispose();
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
applet.init();
|
||||
applet.start();
|
||||
}
|
||||
|
||||
// AppletStub API
|
||||
public void appletResize(int width, int height) {
|
||||
setSize(width, height);
|
||||
}
|
||||
|
||||
public AppletContext getAppletContext() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public URL getCodeBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public URL getDocumentBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getParameter(String name) {
|
||||
return "PARAMETER";
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// AppletContext API
|
||||
public Applet getApplet(String name) {
|
||||
return applet;
|
||||
}
|
||||
|
||||
public Enumeration getApplets() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public AudioClip getAudioClip(URL url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Image getImage(URL url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void showDocument(URL url) {}
|
||||
public void showDocument(URL url, String target) {}
|
||||
|
||||
public void showStatus(String status) {
|
||||
System.out.println(status);
|
||||
}
|
||||
|
||||
public void setStream(String key, InputStream stream) throws IOException {
|
||||
}
|
||||
|
||||
public InputStream getStream(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getStreamKeys() {
|
||||
return null;
|
||||
}
|
||||
}
|
80
demos/src/com/ibm/icu/dev/demo/impl/DemoApplet.java
Normal file
80
demos/src/com/ibm/icu/dev/demo/impl/DemoApplet.java
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.impl;
|
||||
|
||||
import java.awt.Button;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public abstract class DemoApplet extends java.applet.Applet {
|
||||
private static final long serialVersionUID = -8983602961925702071L;
|
||||
private Button demoButton;
|
||||
private Frame demoFrame;
|
||||
private static int demoFrameCount = 0;
|
||||
|
||||
protected abstract Frame createDemoFrame(DemoApplet applet);
|
||||
protected Dimension getDefaultFrameSize(DemoApplet applet, Frame f) {
|
||||
return new Dimension(700, 550);
|
||||
}
|
||||
|
||||
//Create a button that will display the demo
|
||||
public void init()
|
||||
{
|
||||
setBackground(Color.white);
|
||||
demoButton = new Button("Demo");
|
||||
demoButton.setBackground(Color.yellow);
|
||||
add( demoButton );
|
||||
|
||||
demoButton.addActionListener( new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getID() == ActionEvent.ACTION_PERFORMED) {
|
||||
demoButton.setLabel("loading");
|
||||
|
||||
if (demoFrame == null) {
|
||||
demoFrame = createDemoFrame(DemoApplet.this);
|
||||
showDemo();
|
||||
}
|
||||
|
||||
demoButton.setLabel("Demo");
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public void showDemo()
|
||||
{
|
||||
demoFrame = createDemoFrame(this);
|
||||
demoFrame.doLayout();
|
||||
Dimension d = getDefaultFrameSize(this, demoFrame);
|
||||
demoFrame.setSize(d.width, d.height);
|
||||
demoFrame.show();
|
||||
demoFrameOpened();
|
||||
}
|
||||
|
||||
public void demoClosed()
|
||||
{
|
||||
demoFrame = null;
|
||||
demoFrameClosed();
|
||||
}
|
||||
|
||||
public static void demoFrameOpened() {
|
||||
demoFrameCount++;
|
||||
System.err.println("DemoFrameOpened, now at:"+demoFrameCount);
|
||||
}
|
||||
public static void demoFrameClosed() {
|
||||
if (--demoFrameCount == 0) {
|
||||
System.err.println("DemoFrameClosed, now at:"+demoFrameCount + " - quitting");
|
||||
System.exit(0);
|
||||
}
|
||||
System.err.println("DemoFrameClosed, now at:"+demoFrameCount);
|
||||
}
|
||||
}
|
||||
|
96
demos/src/com/ibm/icu/dev/demo/impl/DemoTextBox.java
Normal file
96
demos/src/com/ibm/icu/dev/demo/impl/DemoTextBox.java
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.impl;
|
||||
|
||||
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.text.BreakIterator;
|
||||
|
||||
public class DemoTextBox {
|
||||
|
||||
public DemoTextBox(Graphics g, String text, int width)
|
||||
{
|
||||
this.text = text;
|
||||
this.chars = new char[text.length()];
|
||||
text.getChars(0, text.length(), chars, 0);
|
||||
|
||||
this.width = width;
|
||||
// this.port = g;
|
||||
this.metrics = g.getFontMetrics();
|
||||
|
||||
breakText();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return (nbreaks + 1) * metrics.getHeight();
|
||||
}
|
||||
|
||||
public void draw(Graphics g, int x, int y)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
y += metrics.getAscent();
|
||||
|
||||
for (int i = 0; i < nbreaks; i++)
|
||||
{
|
||||
g.drawChars(chars, index, breakPos[i] - index, x, y);
|
||||
index = breakPos[i];
|
||||
y += metrics.getHeight();
|
||||
}
|
||||
|
||||
g.drawChars(chars, index, chars.length - index, x, y);
|
||||
}
|
||||
|
||||
|
||||
private void breakText()
|
||||
{
|
||||
if (metrics.charsWidth(chars, 0, chars.length) > width)
|
||||
{
|
||||
BreakIterator iter = BreakIterator.getWordInstance();
|
||||
iter.setText(text);
|
||||
|
||||
int start = iter.first();
|
||||
int end = start;
|
||||
int pos;
|
||||
|
||||
while ( (pos = iter.next()) != BreakIterator.DONE )
|
||||
{
|
||||
int w = metrics.charsWidth(chars, start, pos - start);
|
||||
if (w > width)
|
||||
{
|
||||
// We've gone past the maximum width, so break the line
|
||||
if (end > start) {
|
||||
// There was at least one break position before this point
|
||||
breakPos[nbreaks++] = end;
|
||||
start = end;
|
||||
end = pos;
|
||||
} else {
|
||||
// There weren't any break positions before this one, so
|
||||
// let this word overflow the margin (yuck)
|
||||
breakPos[nbreaks++] = pos;
|
||||
start = end = pos;
|
||||
}
|
||||
} else {
|
||||
// the current position still fits on the line; it's the best
|
||||
// tentative break position we have so far.
|
||||
end = pos;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String text;
|
||||
private char[] chars;
|
||||
// private Graphics port;
|
||||
private FontMetrics metrics;
|
||||
private int width;
|
||||
|
||||
private int[] breakPos = new int[10]; // TODO: get real
|
||||
private int nbreaks = 0;
|
||||
}
|
136
demos/src/com/ibm/icu/dev/demo/impl/DemoUtility.java
Normal file
136
demos/src/com/ibm/icu/dev/demo/impl/DemoUtility.java
Normal file
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.impl;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Label;
|
||||
import java.awt.Panel;
|
||||
import java.awt.TextComponent;
|
||||
import java.util.Locale;
|
||||
|
||||
public class DemoUtility
|
||||
{
|
||||
public static final Font titleFont = new Font("TimesRoman",Font.BOLD,18);
|
||||
public static final Font labelFont = new Font("TimesRoman",Font.BOLD,14);
|
||||
public static final Font choiceFont = new Font("Helvetica",Font.BOLD,12);
|
||||
public static final Font editFont = new Font("Helvetica",Font.PLAIN,14);
|
||||
public static final Font creditFont = new Font("Helvetica",Font.PLAIN,10);
|
||||
public static final Font numberFont = new Font("sansserif", Font.PLAIN, 14);
|
||||
|
||||
public static final Color bgColor = Color.lightGray;
|
||||
public static final Color choiceColor = Color.white;
|
||||
|
||||
public static final String copyright1 =
|
||||
"Copyright (C) IBM Corp and others. 1997 - 2002 All Rights Reserved";
|
||||
|
||||
/**
|
||||
Provides easy way to use basic functions of GridBagLayout, without
|
||||
the complications. After building a panel, and inserting all the
|
||||
* subcomponents, call this to lay it out in the desired number of columns.
|
||||
*/
|
||||
public static void fixGrid(Container cont, int columns) {
|
||||
GridBagLayout gridbag = new GridBagLayout();
|
||||
cont.setLayout(gridbag);
|
||||
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.VERTICAL;
|
||||
c.weightx = 1.0;
|
||||
c.insets = new Insets(2,2,2,2);
|
||||
|
||||
Component[] components = cont.getComponents();
|
||||
for (int i = 0; i < components.length; ++i) {
|
||||
// not used int colNumber = i%columns;
|
||||
c.gridwidth = 1; // default
|
||||
if ((i%columns) == columns - 1)
|
||||
c.gridwidth = GridBagConstraints.REMAINDER; // last in grid
|
||||
if (components[i] instanceof Label) {
|
||||
switch (((Label)components[i]).getAlignment()) {
|
||||
case Label.CENTER: c.anchor = GridBagConstraints.CENTER; break;
|
||||
case Label.LEFT: c.anchor = GridBagConstraints.WEST; break;
|
||||
case Label.RIGHT: c.anchor = GridBagConstraints.EAST; break;
|
||||
}
|
||||
}
|
||||
gridbag.setConstraints(components[i], c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Provides easy way to change the spacing around an object in a GridBagLayout.
|
||||
Call AFTER fixGridBag, passing in the container, the component, and the
|
||||
new insets.
|
||||
*/
|
||||
public static void setInsets(Container cont, Component comp, Insets insets) {
|
||||
GridBagLayout gbl = (GridBagLayout)cont.getLayout();
|
||||
GridBagConstraints g = gbl.getConstraints(comp);
|
||||
g.insets = insets;
|
||||
gbl.setConstraints(comp,g);
|
||||
}
|
||||
|
||||
public static Panel createSpacer() {
|
||||
Panel spacer = new Panel();
|
||||
spacer.setLayout(null);
|
||||
spacer.setSize(1000, 1);
|
||||
return spacer;
|
||||
}
|
||||
|
||||
// to avoid goofy updates and misplaced cursors
|
||||
public static void setText(TextComponent area, String newText) {
|
||||
String foo = area.getText();
|
||||
if (foo.equals(newText)) return;
|
||||
area.setText(newText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two locals. Return value is negative
|
||||
* if they're different, and more positive the more
|
||||
* fields that match.
|
||||
*/
|
||||
|
||||
public static int compareLocales(Locale l1, Locale l2)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
if (l1.getLanguage().equals(l2.getLanguage())) {
|
||||
result += 1;
|
||||
|
||||
if (l1.getCountry().equals(l2.getCountry())) {
|
||||
result += 1;
|
||||
|
||||
if (l1.getVariant().equals(l2.getVariant())) {
|
||||
result += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the G7 locale list for demos.
|
||||
*/
|
||||
public static Locale[] getG7Locales() {
|
||||
return localeList;
|
||||
}
|
||||
private static Locale[] localeList = {
|
||||
new Locale("DA", "DK", ""),
|
||||
new Locale("EN", "US", ""),
|
||||
new Locale("EN", "GB", ""),
|
||||
new Locale("EN", "CA", ""),
|
||||
new Locale("FR", "FR", ""),
|
||||
new Locale("FR", "CA", ""),
|
||||
new Locale("DE", "DE", ""),
|
||||
new Locale("IT", "IT", ""),
|
||||
//new Locale("JA", "JP", ""),
|
||||
};
|
||||
}
|
827
demos/src/com/ibm/icu/dev/demo/impl/DumbTextComponent.java
Normal file
827
demos/src/com/ibm/icu/dev/demo/impl/DumbTextComponent.java
Normal file
|
@ -0,0 +1,827 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.impl;
|
||||
import java.awt.AWTEventMulticaster;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.event.TextEvent;
|
||||
import java.awt.event.TextListener;
|
||||
import java.text.BreakIterator;
|
||||
|
||||
// LIU: Changed from final to non-final
|
||||
public class DumbTextComponent extends Canvas
|
||||
implements KeyListener, MouseListener, MouseMotionListener, FocusListener
|
||||
{
|
||||
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = 8265547730738652151L;
|
||||
|
||||
// private transient static final String copyright =
|
||||
// "Copyright \u00A9 1998, Mark Davis. All Rights Reserved.";
|
||||
private transient static boolean DEBUG = false;
|
||||
|
||||
private String contents = "";
|
||||
private Selection selection = new Selection();
|
||||
private int activeStart = -1;
|
||||
private boolean editable = true;
|
||||
|
||||
private transient Selection tempSelection = new Selection();
|
||||
private transient boolean focus;
|
||||
private transient BreakIterator lineBreaker = BreakIterator.getLineInstance();
|
||||
private transient BreakIterator wordBreaker = BreakIterator.getWordInstance();
|
||||
private transient BreakIterator charBreaker = BreakIterator.getCharacterInstance();
|
||||
private transient int lineAscent;
|
||||
private transient int lineHeight;
|
||||
private transient int lineLeading;
|
||||
private transient int lastHeight = 10;
|
||||
private transient int lastWidth = 50;
|
||||
private static final int MAX_LINES = 200; // LIU: Use symbolic name
|
||||
private transient int[] lineStarts = new int[MAX_LINES]; // LIU
|
||||
private transient int lineCount = 1;
|
||||
|
||||
private transient boolean valid = false;
|
||||
private transient FontMetrics fm;
|
||||
private transient boolean redoLines = true;
|
||||
private transient boolean doubleClick = false;
|
||||
private transient TextListener textListener;
|
||||
private transient ActionListener selectionListener;
|
||||
private transient Image cacheImage;
|
||||
private transient Dimension mySize;
|
||||
private transient int xInset = 5;
|
||||
private transient int yInset = 5;
|
||||
private transient Point startPoint = new Point();
|
||||
private transient Point endPoint = new Point();
|
||||
private transient Point caretPoint = new Point();
|
||||
private transient Point activePoint = new Point();
|
||||
|
||||
//private transient static String clipBoard;
|
||||
|
||||
private static final char CR = '\015'; // LIU
|
||||
|
||||
// ============================================
|
||||
|
||||
public DumbTextComponent() {
|
||||
addMouseListener(this);
|
||||
addMouseMotionListener(this);
|
||||
addKeyListener(this);
|
||||
addFocusListener(this);
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
|
||||
|
||||
}
|
||||
|
||||
// ================ Events ====================
|
||||
|
||||
// public boolean isFocusTraversable() { return true; }
|
||||
|
||||
public void addActionListener(ActionListener l) {
|
||||
selectionListener = AWTEventMulticaster.add(selectionListener, l);
|
||||
}
|
||||
|
||||
public void removeActionListener(ActionListener l) {
|
||||
selectionListener = AWTEventMulticaster.remove(selectionListener, l);
|
||||
}
|
||||
|
||||
public void addTextListener(TextListener l) {
|
||||
textListener = AWTEventMulticaster.add(textListener, l);
|
||||
}
|
||||
|
||||
public void removeTextListener(TextListener l) {
|
||||
textListener = AWTEventMulticaster.remove(textListener, l);
|
||||
}
|
||||
|
||||
private transient boolean pressed;
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (DEBUG) System.out.println("mousePressed");
|
||||
if (pressed) {
|
||||
select(e,false);
|
||||
} else {
|
||||
doubleClick = e.getClickCount() > 1;
|
||||
requestFocus();
|
||||
select(e, true);
|
||||
pressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
if (DEBUG) System.out.println("mouseDragged");
|
||||
select(e, false);
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (DEBUG) System.out.println("mouseReleased");
|
||||
pressed = false;
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
//if (pressed) select(e, false);
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e){
|
||||
//if (pressed) select(e, false);
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {}
|
||||
public void mouseMoved(MouseEvent e) {}
|
||||
|
||||
|
||||
public void focusGained(FocusEvent e) {
|
||||
if (DEBUG) System.out.println("focusGained");
|
||||
focus = true;
|
||||
valid = false;
|
||||
repaint(16);
|
||||
}
|
||||
public void focusLost(FocusEvent e) {
|
||||
if (DEBUG) System.out.println("focusLost");
|
||||
focus = false;
|
||||
valid = false;
|
||||
repaint(16);
|
||||
}
|
||||
|
||||
public void select(MouseEvent e, boolean first) {
|
||||
setKeyStart(-1);
|
||||
point2Offset(e.getPoint(), tempSelection);
|
||||
if (first) {
|
||||
if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
|
||||
tempSelection.anchor = tempSelection.caret;
|
||||
}
|
||||
}
|
||||
// fix words
|
||||
if (doubleClick) {
|
||||
tempSelection.expand(wordBreaker);
|
||||
}
|
||||
select(tempSelection);
|
||||
}
|
||||
|
||||
public void keyPressed(KeyEvent e) {
|
||||
int code = e.getKeyCode();
|
||||
if (DEBUG) System.out.println("keyPressed "
|
||||
+ hex((char)code) + ", " + hex((char)e.getModifiers()));
|
||||
int start = selection.getStart();
|
||||
int end = selection.getEnd();
|
||||
boolean shift = (e.getModifiers() & InputEvent.SHIFT_MASK) != 0;
|
||||
boolean ctrl = (e.getModifiers() & InputEvent.CTRL_MASK) != 0;
|
||||
|
||||
switch (code) {
|
||||
case KeyEvent.VK_Q:
|
||||
if (!ctrl || !editable) break;
|
||||
setKeyStart(-1);
|
||||
fixHex();
|
||||
break;
|
||||
case KeyEvent.VK_V:
|
||||
if (!ctrl) break;
|
||||
if (!editable) {
|
||||
this.getToolkit().beep();
|
||||
} else {
|
||||
paste();
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_C:
|
||||
if (!ctrl) break;
|
||||
copy();
|
||||
break;
|
||||
case KeyEvent.VK_X:
|
||||
if (!ctrl) break;
|
||||
if (!editable) {
|
||||
this.getToolkit().beep();
|
||||
} else {
|
||||
copy();
|
||||
insertText("");
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_A:
|
||||
if (!ctrl) break;
|
||||
setKeyStart(-1);
|
||||
select(Integer.MAX_VALUE, 0, false);
|
||||
break;
|
||||
case KeyEvent.VK_RIGHT:
|
||||
setKeyStart(-1);
|
||||
tempSelection.set(selection);
|
||||
tempSelection.nextBound(ctrl ? wordBreaker : charBreaker, +1, shift);
|
||||
select(tempSelection);
|
||||
break;
|
||||
case KeyEvent.VK_LEFT:
|
||||
setKeyStart(-1);
|
||||
tempSelection.set(selection);
|
||||
tempSelection.nextBound(ctrl ? wordBreaker : charBreaker, -1, shift);
|
||||
select(tempSelection);
|
||||
break;
|
||||
case KeyEvent.VK_UP: // LIU: Add support for up arrow
|
||||
setKeyStart(-1);
|
||||
tempSelection.set(selection);
|
||||
tempSelection.caret = lineDelta(tempSelection.caret, -1);
|
||||
if (!shift) {
|
||||
tempSelection.anchor = tempSelection.caret;
|
||||
}
|
||||
select(tempSelection);
|
||||
break;
|
||||
case KeyEvent.VK_DOWN: // LIU: Add support for down arrow
|
||||
setKeyStart(-1);
|
||||
tempSelection.set(selection);
|
||||
tempSelection.caret = lineDelta(tempSelection.caret, +1);
|
||||
if (!shift) {
|
||||
tempSelection.anchor = tempSelection.caret;
|
||||
}
|
||||
select(tempSelection);
|
||||
break;
|
||||
case KeyEvent.VK_DELETE: // LIU: Add delete key support
|
||||
if (!editable) break;
|
||||
setKeyStart(-1);
|
||||
if (contents.length() == 0) break;
|
||||
start = selection.getStart();
|
||||
end = selection.getEnd();
|
||||
if (start == end) {
|
||||
++end;
|
||||
if (end > contents.length()) {
|
||||
getToolkit().beep();
|
||||
return;
|
||||
}
|
||||
}
|
||||
replaceRange("", start, end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void copy() {
|
||||
Clipboard cb = this.getToolkit().getSystemClipboard();
|
||||
StringSelection ss = new StringSelection(
|
||||
contents.substring(selection.getStart(), selection.getEnd()));
|
||||
cb.setContents(ss, ss);
|
||||
}
|
||||
|
||||
void paste () {
|
||||
Clipboard cb = this.getToolkit().getSystemClipboard();
|
||||
Transferable t = cb.getContents(this);
|
||||
if (t == null) {
|
||||
this.getToolkit().beep();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String temp = (String) t.getTransferData(DataFlavor.stringFlavor);
|
||||
insertText(temp);
|
||||
} catch (Exception e) {
|
||||
this.getToolkit().beep();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* LIU: Given an offset into contents, moves up or down by lines,
|
||||
* according to lineStarts[].
|
||||
* @param off the offset into contents
|
||||
* @param delta how many lines to move up (< 0) or down (> 0)
|
||||
* @return the new offset into contents
|
||||
*/
|
||||
private int lineDelta(int off, int delta) {
|
||||
int line = findLine(off, false);
|
||||
int posInLine = off - lineStarts[line];
|
||||
// System.out.println("off=" + off + " at " + line + ":" + posInLine);
|
||||
line += delta;
|
||||
if (line < 0) {
|
||||
line = posInLine = 0;
|
||||
} else if (line >= lineCount) {
|
||||
return contents.length();
|
||||
}
|
||||
off = lineStarts[line] + posInLine;
|
||||
if (off >= lineStarts[line+1]) {
|
||||
off = lineStarts[line+1] - 1;
|
||||
}
|
||||
return off;
|
||||
}
|
||||
|
||||
public void keyReleased(KeyEvent e) {
|
||||
int code = e.getKeyCode();
|
||||
if (DEBUG) System.out.println("keyReleased "
|
||||
+ hex((char)code) + ", " + hex((char)e.getModifiers()));
|
||||
}
|
||||
|
||||
public void keyTyped(KeyEvent e) {
|
||||
char ch = e.getKeyChar();
|
||||
if (DEBUG) System.out.println("keyTyped "
|
||||
+ hex((char)ch) + ", " + hex((char)e.getModifiers()));
|
||||
if ((e.getModifiers() & InputEvent.CTRL_MASK) != 0) return;
|
||||
int start, end;
|
||||
switch (ch) {
|
||||
case KeyEvent.CHAR_UNDEFINED:
|
||||
break;
|
||||
case KeyEvent.VK_BACK_SPACE:
|
||||
//setKeyStart(-1);
|
||||
if (!editable) break;
|
||||
if (contents.length() == 0) break;
|
||||
start = selection.getStart();
|
||||
end = selection.getEnd();
|
||||
if (start == end) {
|
||||
--start;
|
||||
if (start < 0) {
|
||||
getToolkit().beep(); // LIU: Add audio feedback of NOP
|
||||
return;
|
||||
}
|
||||
}
|
||||
replaceRange("", start, end);
|
||||
break;
|
||||
case KeyEvent.VK_DELETE:
|
||||
//setKeyStart(-1);
|
||||
if (!editable) break;
|
||||
if (contents.length() == 0) break;
|
||||
start = selection.getStart();
|
||||
end = selection.getEnd();
|
||||
if (start == end) {
|
||||
++end;
|
||||
if (end > contents.length()) {
|
||||
getToolkit().beep(); // LIU: Add audio feedback of NOP
|
||||
return;
|
||||
}
|
||||
}
|
||||
replaceRange("", start, end);
|
||||
break;
|
||||
default:
|
||||
if (!editable) break;
|
||||
// LIU: Dispatch to subclass API
|
||||
handleKeyTyped(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// LIU: Subclass API for handling of key typing
|
||||
protected void handleKeyTyped(KeyEvent e) {
|
||||
insertText(String.valueOf(e.getKeyChar()));
|
||||
}
|
||||
|
||||
protected void setKeyStart(int keyStart) {
|
||||
if (activeStart != keyStart) {
|
||||
activeStart = keyStart;
|
||||
repaint(10);
|
||||
}
|
||||
}
|
||||
|
||||
protected void validateKeyStart() {
|
||||
if (activeStart > selection.getStart()) {
|
||||
activeStart = selection.getStart();
|
||||
repaint(10);
|
||||
}
|
||||
}
|
||||
|
||||
protected int getKeyStart() {
|
||||
return activeStart;
|
||||
}
|
||||
|
||||
// ===================== Control ======================
|
||||
|
||||
public synchronized void setEditable(boolean b) {
|
||||
editable = b;
|
||||
}
|
||||
|
||||
public boolean isEditable() {
|
||||
return editable;
|
||||
}
|
||||
|
||||
public void select(Selection newSelection) {
|
||||
newSelection.pin(contents);
|
||||
if (!selection.equals(newSelection)) {
|
||||
selection.set(newSelection);
|
||||
if (selectionListener != null) {
|
||||
selectionListener.actionPerformed(
|
||||
new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
|
||||
"Selection Changed", 0));
|
||||
}
|
||||
repaint(10);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void select(int start, int end) {
|
||||
select(start, end, false);
|
||||
}
|
||||
|
||||
public void select(int start, int end, boolean clickAfter) {
|
||||
tempSelection.set(start, end, clickAfter);
|
||||
select(tempSelection);
|
||||
}
|
||||
|
||||
public int getSelectionStart() {
|
||||
return selection.getStart();
|
||||
}
|
||||
|
||||
public int getSelectionEnd() {
|
||||
return selection.getEnd();
|
||||
}
|
||||
|
||||
public void setBounds(int x, int y, int w, int h) {
|
||||
super.setBounds(x,y,w,h);
|
||||
redoLines = true;
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(lastWidth,lastHeight);
|
||||
}
|
||||
|
||||
public Dimension getMaximumSize() {
|
||||
return new Dimension(lastWidth,lastHeight);
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
return new Dimension(lastHeight,lastHeight);
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
setText2(text);
|
||||
select(tempSelection.set(selection).pin(contents));
|
||||
}
|
||||
|
||||
public void setText2(String text) {
|
||||
contents = text;
|
||||
charBreaker.setText(text);
|
||||
wordBreaker.setText(text);
|
||||
lineBreaker.setText(text);
|
||||
redoLines = true;
|
||||
if (textListener != null)
|
||||
textListener.textValueChanged(
|
||||
new TextEvent(this, TextEvent.TEXT_VALUE_CHANGED));
|
||||
repaint(16);
|
||||
}
|
||||
|
||||
public void insertText(String text) {
|
||||
if (activeStart == -1) activeStart = selection.getStart();
|
||||
replaceRange(text, selection.getStart(), selection.getEnd());
|
||||
}
|
||||
|
||||
public void replaceRange(String s, int start, int end) {
|
||||
setText2(contents.substring(0,start) + s
|
||||
+ contents.substring(end));
|
||||
select(tempSelection.set(selection).
|
||||
fixAfterReplace(start, end, s.length()));
|
||||
validateKeyStart();
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
public void setFont(Font font) {
|
||||
super.setFont(font);
|
||||
redoLines = true;
|
||||
repaint(16);
|
||||
}
|
||||
|
||||
// ================== Graphics ======================
|
||||
|
||||
public void update(Graphics g) {
|
||||
if (DEBUG) System.out.println("update");
|
||||
paint(g);
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
mySize = getSize();
|
||||
if (cacheImage == null
|
||||
|| cacheImage.getHeight(this) != mySize.height
|
||||
|| cacheImage.getWidth(this) != mySize.width) {
|
||||
cacheImage = createImage(mySize.width, mySize.height);
|
||||
valid = false;
|
||||
}
|
||||
if (!valid || redoLines) {
|
||||
if (DEBUG) System.out.println("painting");
|
||||
paint2(cacheImage.getGraphics());
|
||||
valid = true;
|
||||
}
|
||||
//getToolkit().sync();
|
||||
if (DEBUG) System.out.println("copying");
|
||||
g.drawImage(cacheImage,
|
||||
0, 0, mySize.width, mySize.height,
|
||||
0, 0, mySize.width, mySize.height,
|
||||
this);
|
||||
}
|
||||
|
||||
public void paint2(Graphics g) {
|
||||
g.clearRect(0, 0, mySize.width, mySize.height);
|
||||
if (DEBUG) System.out.println("print");
|
||||
if (focus) g.setColor(Color.black);
|
||||
else g.setColor(Color.gray);
|
||||
g.drawRect(0,0,mySize.width-1,mySize.height-1);
|
||||
g.setClip(1,1,
|
||||
mySize.width-2,mySize.height-2);
|
||||
g.setColor(Color.black);
|
||||
g.setFont(getFont());
|
||||
fm = g.getFontMetrics();
|
||||
lineAscent = fm.getAscent();
|
||||
lineLeading = fm.getLeading();
|
||||
lineHeight = lineAscent + fm.getDescent() + lineLeading;
|
||||
int y = yInset + lineAscent;
|
||||
String lastSubstring = "";
|
||||
if (redoLines) fixLineStarts(mySize.width-xInset-xInset);
|
||||
for (int i = 0; i < lineCount; y += lineHeight, ++i) {
|
||||
// LIU: Don't display terminating ^M characters
|
||||
int lim = lineStarts[i+1];
|
||||
if (lim > 0 && contents.length() > 0 &&
|
||||
contents.charAt(lim-1) == CR) --lim;
|
||||
lastSubstring = contents.substring(lineStarts[i],lim);
|
||||
g.drawString(lastSubstring, xInset, y);
|
||||
}
|
||||
drawSelection(g, lastSubstring);
|
||||
lastHeight = y + yInset - lineHeight + yInset;
|
||||
lastWidth = mySize.width-xInset-xInset;
|
||||
}
|
||||
|
||||
void paintRect(Graphics g, int x, int y, int w, int h) {
|
||||
if (focus) {
|
||||
g.fillRect(x, y, w, h);
|
||||
} else {
|
||||
g.drawRect(x, y, w-1, h-1);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawSelection(Graphics g, String lastSubstring) {
|
||||
g.setXORMode(Color.black);
|
||||
if (activeStart != -1) {
|
||||
offset2Point(activeStart, false, activePoint);
|
||||
g.setColor(Color.magenta);
|
||||
int line = activePoint.x - 1;
|
||||
g.fillRect(line, activePoint.y, 1, lineHeight);
|
||||
}
|
||||
if (selection.isCaret()) {
|
||||
offset2Point(selection.caret, selection.clickAfter, caretPoint);
|
||||
} else {
|
||||
if (focus) g.setColor(Color.blue);
|
||||
else g.setColor(Color.yellow);
|
||||
offset2Point(selection.getStart(), true, startPoint);
|
||||
offset2Point(selection.getEnd(), false, endPoint);
|
||||
if (selection.getStart() == selection.caret)
|
||||
caretPoint.setLocation(startPoint);
|
||||
else caretPoint.setLocation(endPoint);
|
||||
if (startPoint.y == endPoint.y) {
|
||||
paintRect(g, startPoint.x, startPoint.y,
|
||||
Math.max(1,endPoint.x-startPoint.x), lineHeight);
|
||||
} else {
|
||||
paintRect(g, startPoint.x, startPoint.y,
|
||||
(mySize.width-xInset)-startPoint.x, lineHeight);
|
||||
if (startPoint.y + lineHeight < endPoint.y)
|
||||
paintRect(g, xInset, startPoint.y + lineHeight,
|
||||
(mySize.width-xInset)-xInset, endPoint.y - startPoint.y - lineHeight);
|
||||
paintRect(g, xInset, endPoint.y, endPoint.x-xInset, lineHeight);
|
||||
}
|
||||
}
|
||||
if (focus || selection.isCaret()) {
|
||||
if (focus) g.setColor(Color.green);
|
||||
else g.setColor(Color.red);
|
||||
int line = caretPoint.x - (selection.clickAfter ? 0 : 1);
|
||||
g.fillRect(line, caretPoint.y, 1, lineHeight);
|
||||
int w = lineHeight/12 + 1;
|
||||
int braces = line - (selection.clickAfter ? -1 : w);
|
||||
g.fillRect(braces, caretPoint.y, w, 1);
|
||||
g.fillRect(braces, caretPoint.y + lineHeight - 1, w, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public Point offset2Point(int off, boolean start, Point p) {
|
||||
int line = findLine(off, start);
|
||||
int width = 0;
|
||||
try {
|
||||
width = fm.stringWidth(
|
||||
contents.substring(lineStarts[line], off));
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
p.x = width + xInset;
|
||||
if (p.x > mySize.width - xInset)
|
||||
p.x = mySize.width - xInset;
|
||||
p.y = lineHeight * line + yInset;
|
||||
return p;
|
||||
}
|
||||
|
||||
private int findLine(int off, boolean start) {
|
||||
// if it is start, then go to the next line!
|
||||
if (start) ++off;
|
||||
for (int i = 1; i < lineCount; ++i) {
|
||||
// LIU: This was <= ; changed to < to make caret after
|
||||
// final CR in line appear at START of next line.
|
||||
if (off < lineStarts[i]) return i-1;
|
||||
}
|
||||
// LIU: Check for special case; after CR at end of the last line
|
||||
if (off == lineStarts[lineCount] &&
|
||||
off > 0 && contents.length() > 0 && contents.charAt(off-1) == CR) {
|
||||
return lineCount;
|
||||
}
|
||||
return lineCount-1;
|
||||
}
|
||||
|
||||
// offsets on any line will go from start,true to end,false
|
||||
// excluding start,false and end,true
|
||||
public Selection point2Offset(Point p, Selection o) {
|
||||
if (p.y < yInset) {
|
||||
o.caret = 0;
|
||||
o.clickAfter = true;
|
||||
return o;
|
||||
}
|
||||
int line = (p.y - yInset)/lineHeight;
|
||||
if (line >= lineCount) {
|
||||
o.caret = contents.length();
|
||||
o.clickAfter = false;
|
||||
return o;
|
||||
}
|
||||
int target = p.x - xInset;
|
||||
if (target <= 0) {
|
||||
o.caret = lineStarts[line];
|
||||
o.clickAfter = true;
|
||||
return o;
|
||||
}
|
||||
int lowGuess = lineStarts[line];
|
||||
int lowWidth = 0;
|
||||
int highGuess = lineStarts[line+1];
|
||||
int highWidth = fm.stringWidth(contents.substring(lineStarts[line],highGuess));
|
||||
if (target >= highWidth) {
|
||||
o.caret = lineStarts[line+1];
|
||||
o.clickAfter = false;
|
||||
return o;
|
||||
}
|
||||
while (lowGuess < highGuess - 1) {
|
||||
int guess = (lowGuess + highGuess)/2;
|
||||
int width = fm.stringWidth(contents.substring(lineStarts[line],guess));
|
||||
if (width <= target) {
|
||||
lowGuess = guess;
|
||||
lowWidth = width;
|
||||
if (width == target) break;
|
||||
} else {
|
||||
highGuess = guess;
|
||||
highWidth = width;
|
||||
}
|
||||
}
|
||||
// at end, either lowWidth < target < width(low+1), or lowWidth = target
|
||||
int highBound = charBreaker.following(lowGuess);
|
||||
int lowBound = charBreaker.previous();
|
||||
// we are now at character boundaries
|
||||
if (lowBound != lowGuess)
|
||||
lowWidth = fm.stringWidth(contents.substring(lineStarts[line],lowBound));
|
||||
if (highBound != highGuess)
|
||||
highWidth = fm.stringWidth(contents.substring(lineStarts[line],highBound));
|
||||
// we now have the right widths
|
||||
if (target - lowWidth < highWidth - target) {
|
||||
o.caret = lowBound;
|
||||
o.clickAfter = true;
|
||||
} else {
|
||||
o.caret = highBound;
|
||||
o.clickAfter = false;
|
||||
}
|
||||
// we now have the closest!
|
||||
return o;
|
||||
}
|
||||
|
||||
private void fixLineStarts(int width) {
|
||||
lineCount = 1;
|
||||
lineStarts[0] = 0;
|
||||
if (contents.length() == 0) {
|
||||
lineStarts[1] = 0;
|
||||
return;
|
||||
}
|
||||
int end = 0;
|
||||
// LIU: Add check for MAX_LINES
|
||||
for (int start = 0; start < contents.length() && lineCount < MAX_LINES;
|
||||
start = end) {
|
||||
end = nextLine(fm, start, width);
|
||||
lineStarts[lineCount++] = end;
|
||||
if (end == start) { // LIU: Assertion
|
||||
throw new RuntimeException("nextLine broken");
|
||||
}
|
||||
}
|
||||
--lineCount;
|
||||
redoLines = false;
|
||||
}
|
||||
|
||||
// LIU: Enhanced to wrap long lines. Bug with return of start fixed.
|
||||
public int nextLine(FontMetrics fMtr, int start, int width) {
|
||||
int len = contents.length();
|
||||
for (int i = start; i < len; ++i) {
|
||||
// check for line separator
|
||||
char ch = (contents.charAt(i));
|
||||
if (ch >= 0x000A && ch <= 0x000D || ch == 0x2028 || ch == 0x2029) {
|
||||
len = i + 1;
|
||||
if (ch == 0x000D && i+1 < len && contents.charAt(i+1) == 0x000A) // crlf
|
||||
++len; // grab extra char
|
||||
break;
|
||||
}
|
||||
}
|
||||
String subject = contents.substring(start,len);
|
||||
if (visibleWidth(fMtr, subject) <= width)
|
||||
return len;
|
||||
|
||||
// LIU: Remainder of this method rewritten to accomodate lines
|
||||
// longer than the component width by first trying to break
|
||||
// into lines; then words; finally chars.
|
||||
int n = findFittingBreak(fMtr, subject, width, lineBreaker);
|
||||
if (n == 0) {
|
||||
n = findFittingBreak(fMtr, subject, width, wordBreaker);
|
||||
}
|
||||
if (n == 0) {
|
||||
n = findFittingBreak(fMtr, subject, width, charBreaker);
|
||||
}
|
||||
return n > 0 ? start + n : len;
|
||||
}
|
||||
|
||||
/**
|
||||
* LIU: Finds the longest substring that fits a given width
|
||||
* composed of subunits returned by a BreakIterator. If the smallest
|
||||
* subunit is too long, returns 0.
|
||||
* @param fMtr metrics to use
|
||||
* @param line the string to be fix into width
|
||||
* @param width line.substring(0, result) must be <= width
|
||||
* @param breaker the BreakIterator that will be used to find subunits
|
||||
* @return maximum characters, at boundaries returned by breaker,
|
||||
* that fit into width, or zero on failure
|
||||
*/
|
||||
private int findFittingBreak(FontMetrics fMtr, String line, int width,
|
||||
BreakIterator breaker) {
|
||||
breaker.setText(line);
|
||||
int last = breaker.first();
|
||||
int end = breaker.next();
|
||||
while (end != BreakIterator.DONE &&
|
||||
visibleWidth(fMtr, line.substring(0, end)) <= width) {
|
||||
last = end;
|
||||
end = breaker.next();
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
public int visibleWidth(FontMetrics fMtr, String s) {
|
||||
int i;
|
||||
for (i = s.length()-1; i >= 0; --i) {
|
||||
char ch = s.charAt(i);
|
||||
if (!(ch == ' ' || ch >= 0x000A && ch <= 0x000D || ch == 0x2028 || ch == 0x2029))
|
||||
return fMtr.stringWidth(s.substring(0,i+1));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// =============== Utility ====================
|
||||
|
||||
private void fixHex() {
|
||||
if (selection.getEnd() == 0) return;
|
||||
int store = 0;
|
||||
int places = 1;
|
||||
int count = 0;
|
||||
int min = Math.min(8,selection.getEnd());
|
||||
for (int i = 0; i < min; ++i) {
|
||||
char ch = contents.charAt(selection.getEnd()-1-i);
|
||||
int value = Character.getNumericValue(ch);
|
||||
if (value < 0 || value > 15) break;
|
||||
store += places * value;
|
||||
++count;
|
||||
places *= 16;
|
||||
}
|
||||
String add = "";
|
||||
int bottom = store & 0xFFFF;
|
||||
if (store >= 0xD8000000 && store < 0xDC000000
|
||||
&& bottom >= 0xDC00 && bottom < 0xE000) { // surrogates
|
||||
add = "" + (char)(store >> 16) + (char)bottom;
|
||||
} else if (store > 0xFFFF && store <= 0x10FFFF) {
|
||||
store -= 0x10000;
|
||||
add = "" + (char)(((store >> 10) & 0x3FF) + 0xD800)
|
||||
+ (char)((store & 0x3FF) + 0xDC00);
|
||||
|
||||
} else if (count >= 4) {
|
||||
count = 4;
|
||||
add = ""+(char)(store & 0xFFFF);
|
||||
} else {
|
||||
count = 1;
|
||||
char ch = contents.charAt(selection.getEnd()-1);
|
||||
add = hex(ch);
|
||||
if (ch >= 0xDC00 && ch <= 0xDFFF && selection.getEnd() > 1) {
|
||||
ch = contents.charAt(selection.getEnd()-2);
|
||||
if (ch >= 0xD800 && ch <= 0xDBFF) {
|
||||
count = 2;
|
||||
add = hex(ch) + add;
|
||||
}
|
||||
}
|
||||
}
|
||||
replaceRange(add, selection.getEnd()-count, selection.getEnd());
|
||||
}
|
||||
|
||||
public static String hex(char ch) {
|
||||
String result = Integer.toString(ch,16).toUpperCase();
|
||||
result = "0000".substring(result.length(),4) + result;
|
||||
return result;
|
||||
}
|
||||
}
|
161
demos/src/com/ibm/icu/dev/demo/impl/Selection.java
Normal file
161
demos/src/com/ibm/icu/dev/demo/impl/Selection.java
Normal file
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.impl;
|
||||
import java.text.BreakIterator;
|
||||
|
||||
public final class Selection {
|
||||
|
||||
public int anchor;
|
||||
public int caret;
|
||||
public boolean clickAfter;
|
||||
|
||||
public int getStart() {
|
||||
return anchor < caret ? anchor : caret;
|
||||
}
|
||||
|
||||
public int getEnd() {
|
||||
return anchor > caret ? anchor : caret;
|
||||
}
|
||||
|
||||
public boolean isCaret() {
|
||||
return anchor == caret;
|
||||
}
|
||||
|
||||
public Selection set(Selection other) {
|
||||
anchor = other.anchor;
|
||||
caret = other.caret;
|
||||
clickAfter = other.clickAfter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Selection set(int anchor, int caret, boolean clickAfter) {
|
||||
this.anchor = anchor;
|
||||
this.caret = caret;
|
||||
this.clickAfter = clickAfter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
Selection other2 = (Selection)other;
|
||||
return anchor == other2.anchor
|
||||
&& caret == other2.caret
|
||||
&& clickAfter == other2.clickAfter;
|
||||
}
|
||||
|
||||
public boolean isLessThan(Selection other) {
|
||||
return getStart() < other.getEnd();
|
||||
}
|
||||
|
||||
public Selection pin(String text) {
|
||||
if (anchor > text.length()) {
|
||||
anchor = text.length();
|
||||
} else if (anchor < 0) {
|
||||
anchor = 0;
|
||||
}
|
||||
if (caret > text.length()) {
|
||||
caret = text.length();
|
||||
clickAfter = true;
|
||||
} else if (caret < 0) {
|
||||
caret = 0;
|
||||
clickAfter = false;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Selection swap(Selection after) {
|
||||
int temp = anchor;
|
||||
anchor = after.anchor;
|
||||
after.anchor = temp;
|
||||
temp = caret;
|
||||
caret = after.caret;
|
||||
after.caret = temp;
|
||||
boolean b = clickAfter;
|
||||
clickAfter = after.clickAfter;
|
||||
after.clickAfter = b;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Selection fixAfterReplace(int start, int end, int len) {
|
||||
if (anchor >= start) {
|
||||
if (anchor < end) anchor = end;
|
||||
anchor = start + len + anchor - end;
|
||||
}
|
||||
if (caret >= start) {
|
||||
if (caret < end) caret = end;
|
||||
caret = start + len + caret - end;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// Mac & Windows considerably different
|
||||
// Mac: end++. If start!=end, start=end
|
||||
// SHIFT: move end right
|
||||
// CTL: no different
|
||||
// Windows:
|
||||
// UNSHIFTED: if start!=end, start = end, else start=end=end+1;
|
||||
// anchor = tip = start
|
||||
// SHIFT: tip++
|
||||
// CTL: if start!=end, start = end = nextbound(end-1),
|
||||
// else start=end=nextbound(end)
|
||||
// anchor = tip = start
|
||||
// CTL/SHIFT: tip = nextbound(tip)
|
||||
|
||||
public Selection nextBound(BreakIterator breaker,
|
||||
int direction, boolean extend) {
|
||||
if (!extend && anchor != caret) caret -= direction;
|
||||
caret = next(caret, breaker, direction, true);
|
||||
if (!extend) anchor = caret;
|
||||
clickAfter = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
// expand start and end to word breaks--if they are not already on one
|
||||
public void expand(BreakIterator breaker) {
|
||||
if (anchor <= caret) {
|
||||
anchor = next(anchor,breaker,-1,false);
|
||||
caret = next(caret,breaker,1,false);
|
||||
/*
|
||||
try {
|
||||
breaker.following(anchor);
|
||||
anchor = breaker.previous();
|
||||
} catch (Exception e) {}
|
||||
try {
|
||||
caret = breaker.following(caret-1);
|
||||
} catch (Exception e) {}
|
||||
*/
|
||||
} else {
|
||||
anchor = next(anchor,breaker,1,false);
|
||||
caret = next(caret,breaker,-1,false);
|
||||
/*
|
||||
try {
|
||||
breaker.following(caret);
|
||||
caret = breaker.previous();
|
||||
} catch (Exception e) {}
|
||||
try {
|
||||
anchor = breaker.following(anchor-1);
|
||||
} catch (Exception e) {}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
// different = false - move to next boundary, unless on one
|
||||
// true - move to next boundary, even if on one
|
||||
public static int next(int position, BreakIterator breaker,
|
||||
int direction, boolean different) {
|
||||
if (!different) position -= direction;
|
||||
try {
|
||||
if (direction > 0) {
|
||||
position = breaker.following(position);
|
||||
} else {
|
||||
breaker.following(position-1);
|
||||
position = breaker.previous();
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
12
demos/src/com/ibm/icu/dev/demo/impl/package.html
Normal file
12
demos/src/com/ibm/icu/dev/demo/impl/package.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Copyright (C) 2000-2004, International Business Machines Corporation and
|
||||
others. All Rights Reserved.
|
||||
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
Shared utilities for demo applications and Applets.
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* created on: 2010aug21
|
||||
* created by: Markus W. Scherer
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.messagepattern;
|
||||
|
||||
import com.ibm.icu.text.MessagePattern;
|
||||
|
||||
/**
|
||||
* Demo code for MessagePattern class.
|
||||
* Pretty-prints the list of MessagePattern Parts and uses the MiniMessageFormatter
|
||||
* with a few patterns.
|
||||
* @author Markus Scherer
|
||||
* @since 2010-aug-21
|
||||
*/
|
||||
public final class MessagePatternDemo {
|
||||
private static final String manySpaces=" ";
|
||||
|
||||
private static final void printParts(MessagePattern msg) {
|
||||
String autoQA=msg.autoQuoteApostropheDeep();
|
||||
if(!autoQA.equals(msg.getPatternString())) {
|
||||
System.out.println("autoQA: "+autoQA);
|
||||
}
|
||||
String indent="";
|
||||
StringBuilder explanation=new StringBuilder();
|
||||
MessagePattern.Part prevPart=null;
|
||||
int count=msg.countParts();
|
||||
for(int i=0; i<count; ++i) {
|
||||
explanation.delete(0, 0x7fffffff);
|
||||
MessagePattern.Part part=msg.getPart(i);
|
||||
assert prevPart==null || prevPart.getLimit()<=part.getIndex();
|
||||
String partString=part.toString();
|
||||
MessagePattern.Part.Type type=part.getType();
|
||||
if(type==MessagePattern.Part.Type.MSG_START) {
|
||||
indent=manySpaces.substring(0, part.getValue()*2);
|
||||
}
|
||||
if(part.getLength()>0) {
|
||||
explanation.append("=\"").append(msg.getSubstring(part)).append('"');
|
||||
}
|
||||
if(type.hasNumericValue()) {
|
||||
explanation.append('=').append(msg.getNumericValue(part));
|
||||
}
|
||||
System.out.format("%2d: %s%s%s\n", i, indent, partString, explanation);
|
||||
if(type==MessagePattern.Part.Type.MSG_LIMIT) {
|
||||
int nestingLevel=part.getValue();
|
||||
if(nestingLevel>1) {
|
||||
indent=manySpaces.substring(0, (nestingLevel-1)*2); // outdent
|
||||
} else {
|
||||
indent="";
|
||||
}
|
||||
}
|
||||
prevPart=part;
|
||||
}
|
||||
}
|
||||
|
||||
private static final MessagePattern print(String s) {
|
||||
System.out.println("message: "+s);
|
||||
try {
|
||||
MessagePattern msg=new MessagePattern(s);
|
||||
printParts(msg);
|
||||
return msg;
|
||||
} catch(Exception e) {
|
||||
System.out.println("Exception: "+e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static final void printFormat(String s, Object... args) {
|
||||
MessagePattern msg=print(s);
|
||||
if(msg!=null) {
|
||||
System.out.println(new MiniMessageFormatter(msg).format(new StringBuilder(), args));
|
||||
}
|
||||
}
|
||||
|
||||
private static final void printFormatWithNamedArgs(String s, Object... args) {
|
||||
MessagePattern msg=print(s);
|
||||
if(msg!=null) {
|
||||
System.out.println(new MiniMessageFormatter(msg).format(
|
||||
new StringBuilder(), MiniMessageFormatter.mapFromNameValuePairs(args)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] argv) {
|
||||
print("Hello!");
|
||||
print("Hel'lo!");
|
||||
print("Hel'{o");
|
||||
print("Hel'{'o");
|
||||
// double apostrophe inside quoted literal text still encodes a single apostrophe
|
||||
printFormat("a'{bc''de'f");
|
||||
print("a'{bc''de'f{0,number,g'hi''jk'l#}");
|
||||
print("abc{0}def");
|
||||
print("abc{ arg }def");
|
||||
print("abc{1}def{arg}ghi");
|
||||
print("abc{2, number}ghi{3, select, xx {xxx} other {ooo}} xyz");
|
||||
print("abc{gender,select,"+
|
||||
"other{His name is {person,XML,<entry name=\"PERSON\">{$PERSON}</entry>}.}}xyz");
|
||||
print("abc{num_people, plural, offset:17 few{fff} other {oooo}}xyz");
|
||||
print("abc{ num , plural , offset: 2 =1 {1} =-1 {-1} =3.14 {3.14} other {oo} }xyz");
|
||||
print("I don't {a,plural,other{w'{'on't #'#'}} and "+
|
||||
"{b,select,other{shan't'}'}} '{'''know'''}' and "+
|
||||
"{c,choice,0#can't'|'}"+
|
||||
"{z,number,#'#'###.00'}'}.");
|
||||
print("a_{0,choice,-∞ #-inf| 5≤ five | 99 # ninety'|'nine }_z");
|
||||
print("a_{0,plural,other{num=#'#'=#'#'={1,number,##}!}}_z");
|
||||
print("}}}{0}}"); // yes, unmatched '}' are ok in ICU MessageFormat
|
||||
printFormat("Hello {0}!", "Alice");
|
||||
String msg="++{0, select, female{{1} calls you her friend}"+
|
||||
"other{{1} calls you '{their}' friend}"+
|
||||
"male{{1} calls you his friend}}--";
|
||||
printFormat(msg, "female", "Alice");
|
||||
printFormat(msg, "male", "Bob");
|
||||
printFormat(msg, "unknown", "sushifan3");
|
||||
msg="_'__{gender, select, female{Her n'ame is {person_name}.}"+
|
||||
"other{His n'ame is {person_name}.}}__'_";
|
||||
printFormatWithNamedArgs(msg, "gender", "female", "person_name", "Alice");
|
||||
printFormatWithNamedArgs(msg, "gender", "male", "person_name", "Bob");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* created on: 2010aug21
|
||||
* created by: Markus W. Scherer
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.messagepattern;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.text.MessagePattern;
|
||||
import com.ibm.icu.text.MessagePattern.ArgType;
|
||||
import com.ibm.icu.text.MessagePattern.Part;
|
||||
import com.ibm.icu.util.Freezable;
|
||||
|
||||
/**
|
||||
* Mini message formatter for a small subset of the ICU MessageFormat syntax.
|
||||
* Supports only string substitution and select formatting.
|
||||
* @author Markus Scherer
|
||||
* @since 2010-aug-21
|
||||
*/
|
||||
public final class MiniMessageFormatter implements Freezable<MiniMessageFormatter> {
|
||||
public MiniMessageFormatter() {
|
||||
this.msg=new MessagePattern();
|
||||
}
|
||||
|
||||
public MiniMessageFormatter(MessagePattern msg) {
|
||||
this.msg=(MessagePattern)msg.clone();
|
||||
}
|
||||
|
||||
public MiniMessageFormatter(String msg) {
|
||||
this.msg=new MessagePattern(msg);
|
||||
}
|
||||
|
||||
public MiniMessageFormatter applyPattern(String msg) {
|
||||
this.msg.parse(msg);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPatternString() {
|
||||
return msg.getPatternString();
|
||||
}
|
||||
|
||||
public boolean hasNamedArguments() {
|
||||
return msg.hasNamedArguments();
|
||||
}
|
||||
|
||||
public boolean hasNumberedArguments() {
|
||||
return msg.hasNumberedArguments();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the parsed message with positional arguments.
|
||||
* Supports only string substitution (e.g., {3}) and select format.
|
||||
* @param dest gets the formatted message appended
|
||||
* @param args positional arguments
|
||||
* @return dest
|
||||
*/
|
||||
public Appendable format(Appendable dest, Object... args) {
|
||||
if(msg.hasNamedArguments()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Formatting message with named arguments using positional argument values.");
|
||||
}
|
||||
format(0, dest, args, null);
|
||||
return dest;
|
||||
}
|
||||
|
||||
public static final String format(String msg, Object... args) {
|
||||
return new MiniMessageFormatter(msg).format(new StringBuilder(2*msg.length()), args).toString();
|
||||
}
|
||||
|
||||
public Appendable format(Appendable dest, Map<String, Object> argsMap) {
|
||||
if(msg.hasNumberedArguments()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Formatting message with numbered arguments using named argument values.");
|
||||
}
|
||||
format(0, dest, null, argsMap);
|
||||
return dest;
|
||||
}
|
||||
|
||||
public static final String format(String msg, Map<String, Object> argsMap) {
|
||||
return new MiniMessageFormatter(msg).format(new StringBuilder(2*msg.length()), argsMap).toString();
|
||||
}
|
||||
|
||||
private int format(int msgStart, Appendable dest, Object[] args, Map<String, Object> argsMap) {
|
||||
try {
|
||||
String msgString=msg.getPatternString();
|
||||
int prevIndex=msg.getPart(msgStart).getLimit();
|
||||
for(int i=msgStart+1;; ++i) {
|
||||
Part part=msg.getPart(i);
|
||||
Part.Type type=part.getType();
|
||||
int index=part.getIndex();
|
||||
dest.append(msgString, prevIndex, index);
|
||||
if(type==Part.Type.MSG_LIMIT) {
|
||||
return i;
|
||||
}
|
||||
if(type==Part.Type.SKIP_SYNTAX || type==Part.Type.INSERT_CHAR) {
|
||||
prevIndex=part.getLimit();
|
||||
continue;
|
||||
}
|
||||
assert type==Part.Type.ARG_START : "Unexpected Part "+part+" in parsed message.";
|
||||
int argLimit=msg.getLimitPartIndex(i);
|
||||
ArgType argType=part.getArgType();
|
||||
part=msg.getPart(++i);
|
||||
Object arg;
|
||||
if(args!=null) {
|
||||
try {
|
||||
arg=args[part.getValue()]; // args[ARG_NUMBER]
|
||||
} catch(IndexOutOfBoundsException e) {
|
||||
throw new IndexOutOfBoundsException(
|
||||
"No argument at index "+part.getValue());
|
||||
}
|
||||
} else {
|
||||
arg=argsMap.get(msg.getSubstring(part)); // args[ARG_NAME]
|
||||
if(arg==null) {
|
||||
throw new IndexOutOfBoundsException(
|
||||
"No argument for name "+msg.getSubstring(part));
|
||||
}
|
||||
}
|
||||
String argValue=arg.toString();
|
||||
++i;
|
||||
if(argType==ArgType.NONE) {
|
||||
dest.append(argValue);
|
||||
} else if(argType==ArgType.SELECT) {
|
||||
// Similar to SelectFormat.findSubMessage().
|
||||
int subMsgStart=0;
|
||||
for(;; ++i) { // (ARG_SELECTOR, message) pairs until ARG_LIMIT
|
||||
part=msg.getPart(i++);
|
||||
if(part.getType()==Part.Type.ARG_LIMIT) {
|
||||
assert subMsgStart!=0; // The parser made sure this is the case.
|
||||
break;
|
||||
// else: part is an ARG_SELECTOR followed by a message
|
||||
} else if(msg.partSubstringMatches(part, argValue)) {
|
||||
// keyword matches
|
||||
subMsgStart=i;
|
||||
break;
|
||||
} else if(subMsgStart==0 && msg.partSubstringMatches(part, "other")) {
|
||||
subMsgStart=i;
|
||||
}
|
||||
i=msg.getLimitPartIndex(i);
|
||||
}
|
||||
format(subMsgStart, dest, args, argsMap);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Unsupported argument type "+argType);
|
||||
}
|
||||
prevIndex=msg.getPart(argLimit).getLimit();
|
||||
i=argLimit;
|
||||
}
|
||||
} catch(IOException e) { // Appendable throws IOException
|
||||
throw new RuntimeException(e); // We do not want a throws clause.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Presents an array of (String, Object) pairs as a Map.
|
||||
* Only for temporary use for formatting with named arguments.
|
||||
*/
|
||||
public static Map<String, Object> mapFromNameValuePairs(Object[] args) {
|
||||
HashMap<String, Object> argsMap = new HashMap<String, Object>();
|
||||
for(int i=0; i<args.length; i+=2) {
|
||||
argsMap.put((String)args[i], args[i+1]);
|
||||
}
|
||||
return argsMap;
|
||||
}
|
||||
|
||||
public MiniMessageFormatter cloneAsThawed() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public MiniMessageFormatter freeze() {
|
||||
msg.freeze();
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFrozen() {
|
||||
return msg.isFrozen();
|
||||
}
|
||||
|
||||
private final MessagePattern msg;
|
||||
}
|
114
demos/src/com/ibm/icu/dev/demo/number/CurrencyDemo.java
Normal file
114
demos/src/com/ibm/icu/dev/demo/number/CurrencyDemo.java
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2003-2010, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Author: Mark Davis
|
||||
* Created: May 22 2003
|
||||
* Since: ICU 2.6
|
||||
**********************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.number;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.text.DecimalFormat;
|
||||
import com.ibm.icu.text.DecimalFormatSymbols;
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.util.Currency;
|
||||
|
||||
/**
|
||||
* Demonstration code to illustrate how to obtain ICU 2.6-like currency
|
||||
* behavior using pre-ICU 2.6 ICU4J.
|
||||
* @author Mark Davis
|
||||
*/
|
||||
public class CurrencyDemo {
|
||||
|
||||
public static void main(String[] args) {
|
||||
testFormatHack(true);
|
||||
}
|
||||
|
||||
static NumberFormat getCurrencyFormat(Currency currency,
|
||||
Locale displayLocale,
|
||||
boolean ICU26) {
|
||||
// code for ICU 2.6
|
||||
if (ICU26) {
|
||||
NumberFormat result = NumberFormat.getCurrencyInstance(displayLocale);
|
||||
result.setCurrency(currency);
|
||||
return result;
|
||||
}
|
||||
|
||||
// ugly work-around for 2.4
|
||||
DecimalFormat result = (DecimalFormat)NumberFormat.getCurrencyInstance(displayLocale);
|
||||
HackCurrencyInfo hack = (HackCurrencyInfo)(hackData.get(currency.getCurrencyCode()));
|
||||
result.setMinimumFractionDigits(hack.decimals);
|
||||
result.setMaximumFractionDigits(hack.decimals);
|
||||
result.setRoundingIncrement(hack.rounding);
|
||||
DecimalFormatSymbols symbols = result.getDecimalFormatSymbols();
|
||||
symbols.setCurrencySymbol(hack.symbol);
|
||||
result.setDecimalFormatSymbols(symbols);
|
||||
return result;
|
||||
}
|
||||
|
||||
static Map hackData = new HashMap();
|
||||
static class HackCurrencyInfo {
|
||||
int decimals;
|
||||
double rounding;
|
||||
String symbol;
|
||||
HackCurrencyInfo(int decimals, double rounding, String symbol) {
|
||||
this.decimals = decimals;
|
||||
this.rounding = rounding;
|
||||
this.symbol = symbol;
|
||||
}
|
||||
}
|
||||
static {
|
||||
hackData.put("USD", new HackCurrencyInfo(2, 0, "$"));
|
||||
hackData.put("GBP", new HackCurrencyInfo(2, 0, "\u00A3"));
|
||||
hackData.put("JPY", new HackCurrencyInfo(0, 0, "\u00A5"));
|
||||
hackData.put("EUR", new HackCurrencyInfo(2, 0, "\u20AC"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Walk through all locales and compare the output of the ICU26
|
||||
* currency format with the "hacked" currency format.
|
||||
* @param quiet if true, only display discrepancies. Otherwise,
|
||||
* display all results.
|
||||
*/
|
||||
static void testFormatHack(boolean quiet) {
|
||||
String[] testCurrencies = {"USD","GBP","JPY","EUR"};
|
||||
Locale[] testLocales = NumberFormat.getAvailableLocales();
|
||||
for (int i = 0; i < testLocales.length; ++i) {
|
||||
// since none of this should vary by country, we'll just do by language
|
||||
if (!testLocales[i].getCountry().equals("")) continue;
|
||||
boolean noOutput = true;
|
||||
if (!quiet) {
|
||||
System.out.println(testLocales[i].getDisplayName());
|
||||
noOutput = false;
|
||||
}
|
||||
for (int j = 0; j < testCurrencies.length; ++j) {
|
||||
NumberFormat nf26 = getCurrencyFormat(Currency.getInstance(testCurrencies[j]), testLocales[i], true);
|
||||
String str26 = nf26.format(1234.567);
|
||||
if (!quiet) {
|
||||
System.out.print("\t" + Utility.escape(str26));
|
||||
}
|
||||
NumberFormat nf24 = getCurrencyFormat(Currency.getInstance(testCurrencies[j]), testLocales[i], false);
|
||||
String str24 = nf24.format(1234.567);
|
||||
if (!str24.equals(str26)) {
|
||||
if (noOutput) {
|
||||
System.out.println(testLocales[i].getDisplayName());
|
||||
noOutput = false;
|
||||
}
|
||||
if (quiet) {
|
||||
System.out.print("\t" + Utility.escape(str26));
|
||||
}
|
||||
System.out.print(" (" + Utility.escape(str24) + ")");
|
||||
}
|
||||
}
|
||||
if (!noOutput) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
580
demos/src/com/ibm/icu/dev/demo/rbnf/RbnfDemo.java
Normal file
580
demos/src/com/ibm/icu/dev/demo/rbnf/RbnfDemo.java
Normal file
|
@ -0,0 +1,580 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.rbnf;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Button;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Checkbox;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Panel;
|
||||
import java.awt.ScrollPane;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.TextComponent;
|
||||
import java.awt.TextField;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.TextEvent;
|
||||
import java.awt.event.TextListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.text.BreakIterator;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.dev.demo.impl.DemoApplet;
|
||||
import com.ibm.icu.text.RuleBasedNumberFormat;
|
||||
|
||||
public class RbnfDemo extends DemoApplet {
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = -9119861296873763536L;
|
||||
|
||||
/**
|
||||
* Puts a copyright in the .class file
|
||||
*/
|
||||
// private static final String copyrightNotice
|
||||
// = "Copyright \u00a91997-1998 IBM Corp. All rights reserved.";
|
||||
|
||||
/*
|
||||
* code to run the demo as an application
|
||||
*/
|
||||
public static void main(String[] argv) {
|
||||
new RbnfDemo().showDemo();
|
||||
}
|
||||
|
||||
protected Dimension getDefaultFrameSize(DemoApplet applet, Frame f) {
|
||||
return new Dimension(430,270);
|
||||
}
|
||||
|
||||
protected Frame createDemoFrame(DemoApplet applet) {
|
||||
final Frame window = new Frame("Number Spellout Demo");
|
||||
window.setSize(800, 600);
|
||||
window.setLayout(new BorderLayout());
|
||||
|
||||
Panel mainPanel = new Panel();
|
||||
mainPanel.setLayout(new GridLayout(1,2));
|
||||
|
||||
commentaryField = new TextArea("", 0, 0, TextArea.SCROLLBARS_VERTICAL_ONLY);
|
||||
commentaryField.setSize(800, 50);
|
||||
commentaryField.setText(RbnfSampleRuleSets.sampleRuleSetCommentary[0]);
|
||||
commentaryField.setEditable(false);
|
||||
commentaryField.setFont(new Font("Helvetica", Font.PLAIN, 14));
|
||||
|
||||
spelloutFormatter = new RuleBasedNumberFormat(RbnfSampleRuleSets.usEnglish, Locale.US);
|
||||
spelloutFormatter.setLenientParseMode(lenientParse);
|
||||
populateRuleSetMenu();
|
||||
numberFormatter = new DecimalFormat("#,##0.##########");
|
||||
parsePosition = new ParsePosition(0);
|
||||
theNumber = 0;
|
||||
|
||||
numberField = new TextField();
|
||||
numberField.setFont(new Font("Serif", Font.PLAIN, 24));
|
||||
textField = new DemoTextFieldHolder();
|
||||
textField.setFont(new Font("Serif", Font.PLAIN, 24));
|
||||
rulesField = new DemoTextFieldHolder();
|
||||
rulesField.setFont(new Font("Serif", Font.PLAIN, 14));
|
||||
lenientParseButton = new Checkbox("Lenient parse", lenientParse);
|
||||
|
||||
numberField.addTextListener(new TextListener() {
|
||||
public void textValueChanged(TextEvent e) {
|
||||
if (!numberFieldHasFocus)
|
||||
return;
|
||||
|
||||
String fieldText = ((TextComponent)(e.getSource())).getText();
|
||||
parsePosition.setIndex(0);
|
||||
Number temp = numberFormatter.parse(fieldText, parsePosition);
|
||||
if (temp == null || parsePosition.getIndex() == 0) {
|
||||
theNumber = 0;
|
||||
textField.setText("PARSE ERROR");
|
||||
}
|
||||
else {
|
||||
theNumber = temp.doubleValue();
|
||||
textField.setText(spelloutFormatter.format(theNumber, ruleSetName));
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
numberField.addFocusListener(new FocusAdapter() {
|
||||
public void focusLost(FocusEvent e) {
|
||||
numberFieldHasFocus = false;
|
||||
numberField.setText(numberFormatter.format(theNumber));
|
||||
}
|
||||
|
||||
public void focusGained(FocusEvent e) {
|
||||
numberFieldHasFocus = true;
|
||||
numberField.selectAll();
|
||||
}
|
||||
} );
|
||||
|
||||
textField.addKeyListener(new KeyAdapter() {
|
||||
public void keyTyped(KeyEvent e) {
|
||||
if (e.getKeyChar() == '\t') {
|
||||
String fieldText = ((TextComponent)(e.getSource())).getText();
|
||||
parsePosition.setIndex(0);
|
||||
theNumber = spelloutFormatter.parse(fieldText, parsePosition)
|
||||
.doubleValue();
|
||||
if (parsePosition.getIndex() == 0) {
|
||||
theNumber = 0;
|
||||
numberField.setText("PARSE ERROR");
|
||||
textField.selectAll();
|
||||
}
|
||||
else if (parsePosition.getIndex() < fieldText.length()) {
|
||||
textField.select(parsePosition.getIndex(), fieldText.length());
|
||||
numberField.setText(numberFormatter.format(theNumber));
|
||||
}
|
||||
else {
|
||||
textField.selectAll();
|
||||
numberField.setText(numberFormatter.format(theNumber));
|
||||
}
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
textField.addFocusListener(new FocusAdapter() {
|
||||
public void focusLost(FocusEvent e) {
|
||||
String fieldText = ((TextComponent)(e.getSource())).getText();
|
||||
parsePosition.setIndex(0);
|
||||
theNumber = spelloutFormatter.parse(fieldText, parsePosition)
|
||||
.doubleValue();
|
||||
if (parsePosition.getIndex() == 0)
|
||||
numberField.setText("PARSE ERROR");
|
||||
else
|
||||
numberField.setText(numberFormatter.format(theNumber));
|
||||
textField.setText(textField.getText()); // textField.repaint() didn't work right
|
||||
}
|
||||
|
||||
public void focusGained(FocusEvent e) {
|
||||
textField.selectAll();
|
||||
}
|
||||
} );
|
||||
|
||||
rulesField.addKeyListener(new KeyAdapter() {
|
||||
public void keyTyped(KeyEvent e) {
|
||||
if (e.getKeyChar() == '\t') {
|
||||
String fieldText = ((TextComponent)(e.getSource())).getText();
|
||||
if (formatterMenu.getSelectedItem().equals("Custom") || !fieldText.equals(
|
||||
RbnfSampleRuleSets.sampleRuleSets[formatterMenu.getSelectedIndex()])) {
|
||||
try {
|
||||
RuleBasedNumberFormat temp = new RuleBasedNumberFormat(fieldText);
|
||||
temp.setLenientParseMode(lenientParse);
|
||||
populateRuleSetMenu();
|
||||
spelloutFormatter = temp;
|
||||
customRuleSet = fieldText;
|
||||
formatterMenu.select("Custom");
|
||||
commentaryField.setText(RbnfSampleRuleSets.
|
||||
sampleRuleSetCommentary[RbnfSampleRuleSets.
|
||||
sampleRuleSetCommentary.length - 1]);
|
||||
redisplay();
|
||||
}
|
||||
catch (Exception x) {
|
||||
textField.setText(x.toString());
|
||||
}
|
||||
}
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
rulesField.addFocusListener(new FocusAdapter() {
|
||||
public void focusLost(FocusEvent e) {
|
||||
String fieldText = ((TextComponent)(e.getSource())).getText();
|
||||
if (formatterMenu.getSelectedItem().equals("Custom") || !fieldText.equals(
|
||||
RbnfSampleRuleSets.sampleRuleSets[formatterMenu.getSelectedIndex()])) {
|
||||
try {
|
||||
RuleBasedNumberFormat temp = new RuleBasedNumberFormat(fieldText);
|
||||
temp.setLenientParseMode(lenientParse);
|
||||
populateRuleSetMenu();
|
||||
spelloutFormatter = temp;
|
||||
customRuleSet = fieldText;
|
||||
formatterMenu.select("Custom");
|
||||
redisplay();
|
||||
}
|
||||
catch (Exception x) {
|
||||
textField.setText(x.toString());
|
||||
}
|
||||
}
|
||||
rulesField.setText(rulesField.getText()); // rulesField.repaint() didn't work right
|
||||
}
|
||||
} );
|
||||
|
||||
lenientParseButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
lenientParse = lenientParseButton.getState();
|
||||
spelloutFormatter.setLenientParseMode(lenientParse);
|
||||
}
|
||||
} );
|
||||
|
||||
numberField.setText(numberFormatter.format(theNumber));
|
||||
numberField.selectAll();
|
||||
textField.setText(spelloutFormatter.format(theNumber, ruleSetName));
|
||||
|
||||
Panel leftPanel = new Panel();
|
||||
leftPanel.setLayout(new BorderLayout());
|
||||
Panel panel = new Panel();
|
||||
panel.setLayout(new BorderLayout());
|
||||
Panel panel1 = new Panel();
|
||||
panel1.setLayout(new GridLayout(3, 1));
|
||||
panel1.add(new Panel());
|
||||
panel1.add(numberField, "Center");
|
||||
panel1.add(lenientParseButton);
|
||||
panel.add(panel1, "Center");
|
||||
Panel panel2 = new Panel();
|
||||
panel2.setLayout(new GridLayout(3, 3));
|
||||
Button button = new Button("+100");
|
||||
button.addActionListener( new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
roll(100);
|
||||
}
|
||||
} );
|
||||
panel2.add(button);
|
||||
button = new Button("+10");
|
||||
button.addActionListener( new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
roll(10);
|
||||
}
|
||||
} );
|
||||
panel2.add(button);
|
||||
button = new Button("+1");
|
||||
button.addActionListener( new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
roll(1);
|
||||
}
|
||||
} );
|
||||
panel2.add(button);
|
||||
button = new Button("<");
|
||||
button.addActionListener( new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
theNumber *= 10;
|
||||
redisplay();
|
||||
}
|
||||
} );
|
||||
panel2.add(button);
|
||||
panel2.add(new Panel());
|
||||
button = new Button(">");
|
||||
button.addActionListener( new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
theNumber /= 10;
|
||||
redisplay();
|
||||
}
|
||||
} );
|
||||
panel2.add(button);
|
||||
button = new Button("-100");
|
||||
button.addActionListener( new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
roll(-100);
|
||||
}
|
||||
} );
|
||||
panel2.add(button);
|
||||
button = new Button("-10");
|
||||
button.addActionListener( new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
roll(-10);
|
||||
}
|
||||
} );
|
||||
panel2.add(button);
|
||||
button = new Button("-1");
|
||||
button.addActionListener( new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
roll(-1);
|
||||
}
|
||||
} );
|
||||
panel2.add(button);
|
||||
panel.add(panel2, "East");
|
||||
leftPanel.add(panel, "North");
|
||||
leftPanel.add(textField, "Center");
|
||||
|
||||
Panel rightPanel = new Panel();
|
||||
rightPanel.setLayout(new BorderLayout());
|
||||
formatterMenu = new Choice();
|
||||
for (int i = 0; i < RbnfSampleRuleSets.sampleRuleSetNames.length; i++)
|
||||
formatterMenu.addItem(RbnfSampleRuleSets.sampleRuleSetNames[i]);
|
||||
formatterMenu.addItem("Custom");
|
||||
formatterMenu.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
Choice source = (Choice)(e.getSource());
|
||||
int item = source.getSelectedIndex();
|
||||
Locale locale = RbnfSampleRuleSets.sampleRuleSetLocales[item];
|
||||
|
||||
commentaryField.setText(RbnfSampleRuleSets.
|
||||
sampleRuleSetCommentary[item]);
|
||||
|
||||
if (locale != null && (locale.getLanguage().equals("iw")
|
||||
|| locale.getLanguage().equals("ru") || locale.getLanguage().equals("ja")
|
||||
|| locale.getLanguage().equals("el")
|
||||
|| locale.getLanguage().equals("zh"))) {
|
||||
textField.togglePanes(false);
|
||||
rulesField.togglePanes(false);
|
||||
}
|
||||
else {
|
||||
textField.togglePanes(true);
|
||||
rulesField.togglePanes(true);
|
||||
}
|
||||
|
||||
makeNewSpelloutFormatter();
|
||||
redisplay();
|
||||
}
|
||||
} );
|
||||
|
||||
ruleSetMenu = new Choice();
|
||||
populateRuleSetMenu();
|
||||
|
||||
ruleSetMenu.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
ruleSetName = ruleSetMenu.getSelectedItem();
|
||||
redisplay();
|
||||
}
|
||||
} );
|
||||
|
||||
Panel menuPanel = new Panel();
|
||||
menuPanel.setLayout(new GridLayout(1, 2));
|
||||
menuPanel.add(formatterMenu);
|
||||
menuPanel.add(ruleSetMenu);
|
||||
rightPanel.add(menuPanel, "North");
|
||||
|
||||
rulesField.setText(RbnfSampleRuleSets.sampleRuleSets[formatterMenu.getSelectedIndex()]);
|
||||
rightPanel.add(rulesField, "Center");
|
||||
|
||||
mainPanel.add(leftPanel);
|
||||
mainPanel.add(rightPanel);
|
||||
|
||||
window.add(mainPanel, "Center");
|
||||
window.add(commentaryField, "South");
|
||||
|
||||
window.doLayout();
|
||||
window.show();
|
||||
final DemoApplet theApplet = applet;
|
||||
window.addWindowListener(
|
||||
new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
setVisible(false);
|
||||
window.dispose();
|
||||
|
||||
if (theApplet != null) {
|
||||
theApplet.demoClosed();
|
||||
} else System.exit(0);
|
||||
}
|
||||
} );
|
||||
return window;
|
||||
}
|
||||
|
||||
void roll(int delta) {
|
||||
theNumber += delta;
|
||||
redisplay();
|
||||
}
|
||||
|
||||
void redisplay() {
|
||||
numberField.setText(numberFormatter.format(theNumber));
|
||||
textField.setText(spelloutFormatter.format(theNumber, ruleSetName));
|
||||
}
|
||||
|
||||
void makeNewSpelloutFormatter() {
|
||||
int item = formatterMenu.getSelectedIndex();
|
||||
String formatterMenuItem = formatterMenu.getSelectedItem();
|
||||
|
||||
if (formatterMenuItem.equals("Custom")) {
|
||||
rulesField.setText(customRuleSet);
|
||||
spelloutFormatter = new RuleBasedNumberFormat(customRuleSet);
|
||||
}
|
||||
else {
|
||||
rulesField.setText(RbnfSampleRuleSets.sampleRuleSets[item]);
|
||||
|
||||
Locale locale = RbnfSampleRuleSets.sampleRuleSetLocales[item];
|
||||
if (locale == null)
|
||||
locale = Locale.getDefault();
|
||||
|
||||
spelloutFormatter = new RuleBasedNumberFormat(RbnfSampleRuleSets.
|
||||
sampleRuleSets[item], locale);
|
||||
}
|
||||
spelloutFormatter.setLenientParseMode(lenientParse);
|
||||
populateRuleSetMenu();
|
||||
}
|
||||
|
||||
void populateRuleSetMenu() {
|
||||
String[] ruleSetNames = spelloutFormatter.getRuleSetNames();
|
||||
|
||||
if (ruleSetMenu != null) {
|
||||
ruleSetMenu.removeAll();
|
||||
for (int i = 0; i < ruleSetNames.length; i++)
|
||||
ruleSetMenu.addItem(ruleSetNames[i]);
|
||||
|
||||
ruleSetName = ruleSetMenu.getSelectedItem();
|
||||
}
|
||||
else
|
||||
ruleSetName = ruleSetNames[0];
|
||||
}
|
||||
|
||||
// private Frame demoWindow = null;
|
||||
|
||||
private TextComponent numberField;
|
||||
private DemoTextFieldHolder textField;
|
||||
private DemoTextFieldHolder rulesField;
|
||||
private TextComponent commentaryField;
|
||||
private Checkbox lenientParseButton;
|
||||
|
||||
private boolean numberFieldHasFocus = true;
|
||||
|
||||
private RuleBasedNumberFormat spelloutFormatter;
|
||||
private DecimalFormat numberFormatter;
|
||||
private ParsePosition parsePosition;
|
||||
|
||||
private boolean lenientParse = true;
|
||||
|
||||
private double theNumber = 0;
|
||||
// private boolean canEdit = true;
|
||||
|
||||
private Choice formatterMenu;
|
||||
private Choice ruleSetMenu;
|
||||
private String ruleSetName;
|
||||
|
||||
private String customRuleSet = "NO RULES!";
|
||||
}
|
||||
|
||||
class DemoTextField extends Component {
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = -7947090021239472658L;
|
||||
public DemoTextField() {
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
Font font = getFont();
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
g.setFont(font);
|
||||
String txt = getText();
|
||||
BreakIterator bi = BreakIterator.getLineInstance();
|
||||
bi.setText(txt);
|
||||
int lineHeight = fm.getHeight();
|
||||
int width = getSize().width;
|
||||
int penY = fm.getAscent();
|
||||
int lineStart = 0;
|
||||
int tempLineEnd = bi.first();
|
||||
int lineEnd = 0;
|
||||
int maxLineEnd = 0;
|
||||
totalHeight = 0;
|
||||
|
||||
while (lineStart < txt.length()) {
|
||||
maxLineEnd = txt.indexOf('\n', lineStart);
|
||||
if (maxLineEnd == -1)
|
||||
maxLineEnd = Integer.MAX_VALUE;
|
||||
while (tempLineEnd != BreakIterator.DONE && fm.stringWidth(txt.substring(
|
||||
lineStart, tempLineEnd)) < width) {
|
||||
lineEnd = tempLineEnd;
|
||||
tempLineEnd = bi.next();
|
||||
}
|
||||
if (lineStart >= lineEnd) {
|
||||
if (tempLineEnd == BreakIterator.DONE)
|
||||
lineEnd = txt.length();
|
||||
else
|
||||
lineEnd = tempLineEnd;
|
||||
}
|
||||
if (lineEnd > maxLineEnd)
|
||||
lineEnd = maxLineEnd;
|
||||
g.drawString(txt.substring(lineStart, lineEnd), 0, penY);
|
||||
penY += lineHeight;
|
||||
totalHeight += lineHeight;
|
||||
lineStart = lineEnd;
|
||||
if (lineStart < txt.length() && txt.charAt(lineStart) == '\n')
|
||||
++lineStart;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension size = getParent().getSize();
|
||||
return new Dimension(size.width, totalHeight);
|
||||
}
|
||||
*/
|
||||
|
||||
private String text;
|
||||
private int totalHeight;
|
||||
}
|
||||
|
||||
class DemoTextFieldHolder extends Panel {
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = 7514498764062569858L;
|
||||
public DemoTextFieldHolder() {
|
||||
tf1 = new TextArea("", 0, 0, TextArea.SCROLLBARS_VERTICAL_ONLY);
|
||||
tf2 = new DemoTextField();
|
||||
sp = new ScrollPane();
|
||||
|
||||
setLayout(new CardLayout());
|
||||
|
||||
sp.add(tf2, "TextField1");
|
||||
sp.setVisible(false);
|
||||
add(tf1, "TestField2");
|
||||
add(sp, "ScrollPane");
|
||||
}
|
||||
|
||||
public void addFocusListener(FocusListener l) {
|
||||
tf1.addFocusListener(l);
|
||||
}
|
||||
|
||||
public void addKeyListener(KeyListener l) {
|
||||
tf1.addKeyListener(l);
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
tf1.setText(text);
|
||||
tf2.setText(text);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return tf1.getText();
|
||||
}
|
||||
|
||||
public void select(int start, int end) {
|
||||
tf1.select(start, end);
|
||||
}
|
||||
|
||||
public void selectAll() {
|
||||
tf1.selectAll();
|
||||
}
|
||||
|
||||
public void togglePanes(boolean canShowRealTextField) {
|
||||
if (canShowRealTextField != showingRealTextField) {
|
||||
CardLayout layout = (CardLayout)(getLayout());
|
||||
layout.next(this);
|
||||
showingRealTextField = canShowRealTextField;
|
||||
}
|
||||
}
|
||||
|
||||
private TextArea tf1 = null;
|
||||
private DemoTextField tf2 = null;
|
||||
private ScrollPane sp = null;
|
||||
private boolean showingRealTextField = true;
|
||||
}
|
1941
demos/src/com/ibm/icu/dev/demo/rbnf/RbnfSampleRuleSets.java
Normal file
1941
demos/src/com/ibm/icu/dev/demo/rbnf/RbnfSampleRuleSets.java
Normal file
File diff suppressed because it is too large
Load diff
12
demos/src/com/ibm/icu/dev/demo/rbnf/package.html
Normal file
12
demos/src/com/ibm/icu/dev/demo/rbnf/package.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Copyright (C) 2000-2004, International Business Machines Corporation and
|
||||
others. All Rights Reserved.
|
||||
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
RuleBasedNumberFormat demo appliation.
|
||||
</body>
|
||||
</html>
|
78
demos/src/com/ibm/icu/dev/demo/timescale/PivotDemo.java
Normal file
78
demos/src/com/ibm/icu/dev/demo/timescale/PivotDemo.java
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.timescale;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.SimpleTimeZone;
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
import com.ibm.icu.util.UniversalTimeScale;
|
||||
|
||||
/**
|
||||
* This class demonstrates how to use <code>UniversalTimeScale</code> to
|
||||
* convert from one local time scale to another.
|
||||
*
|
||||
* @see UniversalTimeScale
|
||||
*/
|
||||
public class PivotDemo {
|
||||
|
||||
/**
|
||||
* The default constructor.
|
||||
*/
|
||||
public PivotDemo()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>main()</code> method uses <code>UniversalTimeScale</code> to
|
||||
* convert from the Java and Unix time scales to the ICU time scale. It uses
|
||||
* a <code>Calendar</code> object to display the ICU time values.
|
||||
*
|
||||
* @param args the command line arguments.
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
TimeZone utc = new SimpleTimeZone(0, "UTC");
|
||||
Calendar cal = Calendar.getInstance(utc, Locale.ENGLISH);
|
||||
MessageFormat fmt = new MessageFormat("{1} = {0, date, full} {0, time, full}");
|
||||
Object arguments[] = {cal, null};
|
||||
|
||||
arguments[0] = cal;
|
||||
|
||||
System.out.println("\nJava test:");
|
||||
cal.setTimeInMillis(UniversalTimeScale.toLong(UniversalTimeScale.from(0, UniversalTimeScale.JAVA_TIME), UniversalTimeScale.ICU4C_TIME));
|
||||
arguments[1] = " 000000000000000";
|
||||
System.out.println(fmt.format(arguments));
|
||||
|
||||
cal.setTimeInMillis(UniversalTimeScale.toLong(UniversalTimeScale.from(-62164684800000L, UniversalTimeScale.JAVA_TIME), UniversalTimeScale.ICU4C_TIME));
|
||||
arguments[1] = "-62164684800000L";
|
||||
System.out.println(fmt.format(arguments));
|
||||
|
||||
cal.setTimeInMillis(UniversalTimeScale.toLong(UniversalTimeScale.from(-62135769600000L, UniversalTimeScale.JAVA_TIME), UniversalTimeScale.ICU4C_TIME));
|
||||
arguments[1] = "-62135769600000L";
|
||||
System.out.println(fmt.format(arguments));
|
||||
|
||||
System.out.println("\nUnix test:");
|
||||
|
||||
cal.setTimeInMillis(UniversalTimeScale.toLong(UniversalTimeScale.from(0x80000000, UniversalTimeScale.UNIX_TIME), UniversalTimeScale.ICU4C_TIME));
|
||||
arguments[1] = "0x80000000";
|
||||
System.out.println(fmt.format(arguments));
|
||||
|
||||
cal.setTimeInMillis(UniversalTimeScale.toLong(UniversalTimeScale.from(0, UniversalTimeScale.UNIX_TIME), UniversalTimeScale.ICU4C_TIME));
|
||||
arguments[1] = "0x00000000";
|
||||
System.out.println(fmt.format(arguments));
|
||||
|
||||
cal.setTimeInMillis(UniversalTimeScale.toLong(UniversalTimeScale.from(0x7FFFFFFF, UniversalTimeScale.UNIX_TIME), UniversalTimeScale.ICU4C_TIME));
|
||||
arguments[1] = "0x7FFFFFFF";
|
||||
System.out.println(fmt.format(arguments));
|
||||
|
||||
}
|
||||
}
|
308
demos/src/com/ibm/icu/dev/demo/translit/AnyTransliterator.java
Normal file
308
demos/src/com/ibm/icu/dev/demo/translit/AnyTransliterator.java
Normal file
|
@ -0,0 +1,308 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.translit;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.ibm.icu.lang.UScript;
|
||||
import com.ibm.icu.text.Replaceable;
|
||||
import com.ibm.icu.text.Transliterator;
|
||||
import com.ibm.icu.text.UTF16;
|
||||
import com.ibm.icu.text.UnicodeFilter;
|
||||
|
||||
public class AnyTransliterator extends Transliterator {
|
||||
|
||||
static final boolean DEBUG = false;
|
||||
private String targetName;
|
||||
private RunIterator it;
|
||||
private Position run;
|
||||
|
||||
|
||||
public AnyTransliterator(String targetName, UnicodeFilter filter, RunIterator it){
|
||||
super("Any-" + targetName, filter);
|
||||
this.targetName = targetName;
|
||||
this.it = it;
|
||||
run = new Position();
|
||||
}
|
||||
|
||||
public AnyTransliterator(String targetName, UnicodeFilter filter){
|
||||
this(targetName, filter, new ScriptRunIterator());
|
||||
}
|
||||
|
||||
static private Transliterator hex = Transliterator.getInstance("[^\\u0020-\\u007E] hex");
|
||||
|
||||
protected void handleTransliterate(Replaceable text,
|
||||
Position offsets, boolean isIncremental) {
|
||||
if (DEBUG) {
|
||||
System.out.println("- handleTransliterate " + hex.transliterate(text.toString())
|
||||
+ ", " + toString(offsets));
|
||||
}
|
||||
it.reset(text, offsets);
|
||||
|
||||
while (it.next(run)) {
|
||||
if (targetName.equalsIgnoreCase(it.getName())) {
|
||||
if (DEBUG) System.out.println("Skipping identical: " + targetName);
|
||||
run.start = run.limit; // show we processed
|
||||
continue; // skip if same
|
||||
}
|
||||
|
||||
Transliterator t;
|
||||
String id = it.getName() + '-' + targetName;
|
||||
try {
|
||||
t = Transliterator.getInstance(id);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
if (DEBUG) System.out.println("Couldn't find: " + id + ", Trying Latin as Pivot");
|
||||
id = it.getName() + "-Latin; Latin-" + targetName;
|
||||
try {
|
||||
t = Transliterator.getInstance(id);
|
||||
} catch (IllegalArgumentException ex2) {
|
||||
if (DEBUG) System.out.println("Couldn't find: " + id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// TODO catch error later!!
|
||||
|
||||
if (DEBUG) {
|
||||
System.out.println(t.getID());
|
||||
System.out.println("input: " + hex.transliterate(text.toString())
|
||||
+ ", " + toString(run));
|
||||
}
|
||||
|
||||
if (isIncremental && it.atEnd()) {
|
||||
t.transliterate(text, run);
|
||||
} else {
|
||||
t.finishTransliteration(text, run);
|
||||
}
|
||||
// adjust the offsets in line with the changes
|
||||
it.adjust(run.limit);
|
||||
|
||||
if (DEBUG) {
|
||||
System.out.println("output: " + hex.transliterate(text.toString())
|
||||
+ ", " + toString(run));
|
||||
}
|
||||
}
|
||||
|
||||
// show how far we got!
|
||||
it.getExpanse(offsets);
|
||||
if (run.start == run.limit) offsets.start = offsets.limit;
|
||||
else offsets.start = run.start;
|
||||
if (DEBUG) {
|
||||
System.out.println("+ handleTransliterate: " + ", " + toString(offsets));
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
// should be method on Position
|
||||
public static String toString(Position offsets) {
|
||||
return "[cs: " + offsets.contextStart
|
||||
+ ", s: " + offsets.start
|
||||
+ ", l: " + offsets.limit
|
||||
+ ", cl: " + offsets.contextLimit
|
||||
+ "]";
|
||||
}
|
||||
|
||||
public interface RunIterator {
|
||||
public void reset(Replaceable text, Position expanse);
|
||||
public void getExpanse(Position run);
|
||||
public void reset();
|
||||
public boolean next(Position run);
|
||||
public void getCurrent(Position run);
|
||||
public String getName();
|
||||
public void adjust(int newCurrentLimit);
|
||||
public boolean atEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a series of ranges corresponding to scripts. They will be of the form:
|
||||
* ccccSScSSccccTTcTcccc - where c is common, S is the first script and T is the second
|
||||
*| | - first run
|
||||
* | | - second run
|
||||
* That is, the runs will overlap. The reason for this is so that a transliterator can
|
||||
* consider common characters both before and after the scripts.
|
||||
* The only time that contextStart != start is for the first run
|
||||
* (the context is the start context of the entire expanse)
|
||||
* The only time that contextLimit != limit is for the last run
|
||||
* (the context is the end context of the entire expanse)
|
||||
*/
|
||||
public static class ScriptRunIterator implements RunIterator {
|
||||
private Replaceable text;
|
||||
private Position expanse = new Position();
|
||||
private Position current = new Position();
|
||||
private int script;
|
||||
private boolean done = true;
|
||||
|
||||
|
||||
public void reset(Replaceable repText, Position expansePos) {
|
||||
set(this.expanse, expansePos);
|
||||
this.text = repText;
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
done = false;
|
||||
//this.expanse = expanse;
|
||||
script = UScript.INVALID_CODE;
|
||||
// set up first range to be empty, at beginning
|
||||
current.contextStart = expanse.contextStart;
|
||||
current.start = current.limit = current.contextLimit = expanse.start;
|
||||
}
|
||||
|
||||
public boolean next(Position run) {
|
||||
if (done) return false;
|
||||
if (DEBUG) {
|
||||
System.out.println("+cs: " + current.contextStart
|
||||
+ ", s: " + current.start
|
||||
+ ", l: " + current.limit
|
||||
+ ", cl: " + current.contextLimit);
|
||||
}
|
||||
// reset start context run to the last end
|
||||
current.start = current.limit;
|
||||
|
||||
// Phase 1. Backup the START value through COMMON until we get to expanse.start or a real script.
|
||||
int i, cp;
|
||||
int limit = expanse.start;
|
||||
for (i = current.start; i > limit; i -= UTF16.getCharCount(cp)) {
|
||||
cp = text.char32At(i);
|
||||
int scrpt = UScript.getScript(cp);
|
||||
if (scrpt != UScript.COMMON && scrpt != UScript.INHERITED) break;
|
||||
}
|
||||
current.start = i;
|
||||
current.contextStart = (i == limit) ? expanse.contextStart : i; // extend at start
|
||||
|
||||
// PHASE 2. Move up the LIMIT value through COMMON or single script until we get to expanse.limit
|
||||
int lastScript = UScript.COMMON;
|
||||
//int veryLastScript = UScript.COMMON;
|
||||
limit = expanse.limit;
|
||||
for (i = current.limit; i < limit; i += UTF16.getCharCount(cp)) {
|
||||
cp = text.char32At(i);
|
||||
int scrpt = UScript.getScript(cp);
|
||||
if (scrpt == UScript.INHERITED) scrpt = UScript.COMMON;
|
||||
if (scrpt != UScript.COMMON) {
|
||||
// if we find a real script:
|
||||
// if we already had a script, bail
|
||||
// otherwise set our script
|
||||
if (lastScript == UScript.COMMON) lastScript = scrpt;
|
||||
else if (lastScript != scrpt) break;
|
||||
}
|
||||
}
|
||||
current.limit = i;
|
||||
current.contextLimit = (i == limit) ? expanse.contextLimit : i; // extend at end
|
||||
done = (i == limit);
|
||||
script = lastScript;
|
||||
|
||||
if (DEBUG) {
|
||||
System.out.println("-cs: " + current.contextStart
|
||||
+ ", s: " + current.start
|
||||
+ ", l: " + current.limit
|
||||
+ ", cl: " + current.contextLimit);
|
||||
}
|
||||
|
||||
set(run, current);
|
||||
return true;
|
||||
}
|
||||
|
||||
// SHOULD BE METHOD ON POSITION
|
||||
public static void set(Position run, Position current) {
|
||||
run.contextStart = current.contextStart;
|
||||
run.start = current.start;
|
||||
run.limit = current.limit;
|
||||
run.contextLimit = current.contextLimit;
|
||||
}
|
||||
|
||||
public boolean atEnd() {
|
||||
return current.limit == expanse.limit;
|
||||
}
|
||||
|
||||
public void getCurrent(Position run) {
|
||||
set(run, current);
|
||||
}
|
||||
|
||||
public void getExpanse(Position run) {
|
||||
set(run, expanse);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return UScript.getName(script);
|
||||
}
|
||||
|
||||
public void adjust(int newCurrentLimit) {
|
||||
if (expanse == null) {
|
||||
throw new IllegalArgumentException("Must reset() before calling");
|
||||
}
|
||||
int delta = newCurrentLimit - current.limit;
|
||||
current.limit += delta;
|
||||
current.contextLimit += delta;
|
||||
expanse.limit += delta;
|
||||
expanse.contextLimit += delta;
|
||||
}
|
||||
|
||||
// register Any-Script for every script.
|
||||
|
||||
private static Set scriptList = new HashSet();
|
||||
|
||||
public static void registerAnyToScript() {
|
||||
synchronized (scriptList) {
|
||||
Enumeration sources = Transliterator.getAvailableSources();
|
||||
while(sources.hasMoreElements()) {
|
||||
String source = (String) sources.nextElement();
|
||||
if (source.equals("Any")) continue; // to keep from looping
|
||||
|
||||
Enumeration targets = Transliterator.getAvailableTargets(source);
|
||||
while(targets.hasMoreElements()) {
|
||||
String target = (String) targets.nextElement();
|
||||
if (UScript.getCode(target) == null) continue; // SKIP unless we have a script (or locale)
|
||||
if (scriptList.contains(target)) continue; // already encountered
|
||||
scriptList.add(target); // otherwise add for later testing
|
||||
|
||||
Set variantSet = add(new TreeSet(), Transliterator.getAvailableVariants(source, target));
|
||||
if (variantSet.size() < 2) {
|
||||
AnyTransliterator at = new AnyTransliterator(target, null);
|
||||
DummyFactory.add(at.getID(), at);
|
||||
} else {
|
||||
Iterator variants = variantSet.iterator();
|
||||
while(variants.hasNext()) {
|
||||
String variant = (String) variants.next();
|
||||
AnyTransliterator at = new AnyTransliterator(
|
||||
(variant.length() > 0) ? target + "/" + variant : target, null);
|
||||
DummyFactory.add(at.getID(), at);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class DummyFactory implements Transliterator.Factory {
|
||||
static DummyFactory singleton = new DummyFactory();
|
||||
static HashMap m = new HashMap();
|
||||
|
||||
// Since Transliterators are immutable, we don't have to clone on set & get
|
||||
static void add(String ID, Transliterator t) {
|
||||
m.put(ID, t);
|
||||
System.out.println("Registering: " + ID + ", " + t.toRules(true));
|
||||
Transliterator.registerFactory(ID, singleton);
|
||||
}
|
||||
public Transliterator getInstance(String ID) {
|
||||
return (Transliterator) m.get(ID);
|
||||
}
|
||||
}
|
||||
|
||||
// Nice little Utility for converting Enumeration to collection
|
||||
static Set add(Set s, Enumeration enumeration) {
|
||||
while(enumeration.hasMoreElements()) {
|
||||
s.add(enumeration.nextElement());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
560
demos/src/com/ibm/icu/dev/demo/translit/CaseIterator.java
Normal file
560
demos/src/com/ibm/icu/dev/demo/translit/CaseIterator.java
Normal file
|
@ -0,0 +1,560 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.translit;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.ibm.icu.lang.UCharacter;
|
||||
import com.ibm.icu.text.Transliterator;
|
||||
import com.ibm.icu.text.UTF16;
|
||||
import com.ibm.icu.text.UnicodeSet;
|
||||
|
||||
/**
|
||||
* Incrementally returns the set of all strings that case-fold to the same value.
|
||||
*/
|
||||
public class CaseIterator {
|
||||
|
||||
// testing stuff
|
||||
static Transliterator toName = Transliterator.getInstance("[:^ascii:] Any-Name");
|
||||
static Transliterator toHex = Transliterator.getInstance("[:^ascii:] Any-Hex");
|
||||
static Transliterator toHex2 = Transliterator.getInstance("[[^\u0021-\u007F]-[,]] Any-Hex");
|
||||
|
||||
// global tables (could be precompiled)
|
||||
private static Map fromCaseFold = new HashMap();
|
||||
private static Map toCaseFold = new HashMap();
|
||||
private static int maxLength = 0;
|
||||
|
||||
// This exception list is generated on the console by turning on the GENERATED flag,
|
||||
// which MUST be false for normal operation.
|
||||
// Once the list is generated, it is pasted in here.
|
||||
// A bit of a cludge, but this bootstrapping is the easiest way
|
||||
// to get around certain complications in the data.
|
||||
|
||||
private static final boolean GENERATE = false;
|
||||
|
||||
private static final boolean DUMP = false;
|
||||
|
||||
private static String[][] exceptionList = {
|
||||
// a\N{MODIFIER LETTER RIGHT HALF RING}
|
||||
{"a\u02BE","A\u02BE","a\u02BE",},
|
||||
// ff
|
||||
{"ff","FF","Ff","fF","ff",},
|
||||
// ffi
|
||||
{"ffi","FFI","FFi","FfI","Ffi","F\uFB01","fFI","fFi","ffI","ffi","f\uFB01","\uFB00I","\uFB00i",},
|
||||
// ffl
|
||||
{"ffl","FFL","FFl","FfL","Ffl","F\uFB02","fFL","fFl","ffL","ffl","f\uFB02","\uFB00L","\uFB00l",},
|
||||
// fi
|
||||
{"fi","FI","Fi","fI","fi",},
|
||||
// fl
|
||||
{"fl","FL","Fl","fL","fl",},
|
||||
// h\N{COMBINING MACRON BELOW}
|
||||
{"h\u0331","H\u0331","h\u0331",},
|
||||
// i\N{COMBINING DOT ABOVE}
|
||||
{"i\u0307","I\u0307","i\u0307",},
|
||||
// j\N{COMBINING CARON}
|
||||
{"j\u030C","J\u030C","j\u030C",},
|
||||
// ss
|
||||
{"ss","SS","Ss","S\u017F","sS","ss","s\u017F","\u017FS","\u017Fs","\u017F\u017F",},
|
||||
// st
|
||||
{"st","ST","St","sT","st","\u017FT","\u017Ft",},
|
||||
// t\N{COMBINING DIAERESIS}
|
||||
{"t\u0308","T\u0308","t\u0308",},
|
||||
// w\N{COMBINING RING ABOVE}
|
||||
{"w\u030A","W\u030A","w\u030A",},
|
||||
// y\N{COMBINING RING ABOVE}
|
||||
{"y\u030A","Y\u030A","y\u030A",},
|
||||
// \N{MODIFIER LETTER APOSTROPHE}n
|
||||
{"\u02BCn","\u02BCN","\u02BCn",},
|
||||
// \N{GREEK SMALL LETTER ALPHA WITH TONOS}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u03AC\u03B9","\u0386\u0345","\u0386\u0399","\u0386\u03B9","\u0386\u1FBE","\u03AC\u0345","\u03AC\u0399","\u03AC\u03B9","\u03AC\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA WITH TONOS}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u03AE\u03B9","\u0389\u0345","\u0389\u0399","\u0389\u03B9","\u0389\u1FBE","\u03AE\u0345","\u03AE\u0399","\u03AE\u03B9","\u03AE\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ALPHA}\N{COMBINING GREEK PERISPOMENI}
|
||||
{"\u03B1\u0342","\u0391\u0342","\u03B1\u0342",},
|
||||
// \N{GREEK SMALL LETTER ALPHA}\N{COMBINING GREEK PERISPOMENI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u03B1\u0342\u03B9","\u0391\u0342\u0345","\u0391\u0342\u0399","\u0391\u0342\u03B9","\u0391\u0342\u1FBE",
|
||||
"\u03B1\u0342\u0345","\u03B1\u0342\u0399","\u03B1\u0342\u03B9","\u03B1\u0342\u1FBE","\u1FB6\u0345",
|
||||
"\u1FB6\u0399","\u1FB6\u03B9","\u1FB6\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ALPHA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u03B1\u03B9","\u0391\u0345","\u0391\u0399","\u0391\u03B9","\u0391\u1FBE","\u03B1\u0345","\u03B1\u0399","\u03B1\u03B9","\u03B1\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA}\N{COMBINING GREEK PERISPOMENI}
|
||||
{"\u03B7\u0342","\u0397\u0342","\u03B7\u0342",},
|
||||
// \N{GREEK SMALL LETTER ETA}\N{COMBINING GREEK PERISPOMENI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u03B7\u0342\u03B9","\u0397\u0342\u0345","\u0397\u0342\u0399","\u0397\u0342\u03B9","\u0397\u0342\u1FBE",
|
||||
"\u03B7\u0342\u0345","\u03B7\u0342\u0399","\u03B7\u0342\u03B9","\u03B7\u0342\u1FBE","\u1FC6\u0345","\u1FC6\u0399",
|
||||
"\u1FC6\u03B9","\u1FC6\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u03B7\u03B9","\u0397\u0345","\u0397\u0399","\u0397\u03B9","\u0397\u1FBE","\u03B7\u0345","\u03B7\u0399","\u03B7\u03B9","\u03B7\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER IOTA}\N{COMBINING DIAERESIS}\N{COMBINING GRAVE ACCENT}
|
||||
{"\u03B9\u0308\u0300","\u0345\u0308\u0300","\u0399\u0308\u0300","\u03B9\u0308\u0300","\u1FBE\u0308\u0300",},
|
||||
// \N{GREEK SMALL LETTER IOTA}\N{COMBINING DIAERESIS}\N{COMBINING ACUTE ACCENT}
|
||||
{"\u03B9\u0308\u0301","\u0345\u0308\u0301","\u0399\u0308\u0301","\u03B9\u0308\u0301","\u1FBE\u0308\u0301",},
|
||||
// \N{GREEK SMALL LETTER IOTA}\N{COMBINING DIAERESIS}\N{COMBINING GREEK PERISPOMENI}
|
||||
{"\u03B9\u0308\u0342","\u0345\u0308\u0342","\u0399\u0308\u0342","\u03B9\u0308\u0342","\u1FBE\u0308\u0342",},
|
||||
// \N{GREEK SMALL LETTER IOTA}\N{COMBINING GREEK PERISPOMENI}
|
||||
{"\u03B9\u0342","\u0345\u0342","\u0399\u0342","\u03B9\u0342","\u1FBE\u0342",},
|
||||
// \N{GREEK SMALL LETTER RHO}\N{COMBINING COMMA ABOVE}
|
||||
{"\u03C1\u0313","\u03A1\u0313","\u03C1\u0313","\u03F1\u0313",},
|
||||
// \N{GREEK SMALL LETTER UPSILON}\N{COMBINING DIAERESIS}\N{COMBINING GRAVE ACCENT}
|
||||
{"\u03C5\u0308\u0300","\u03A5\u0308\u0300","\u03C5\u0308\u0300",},
|
||||
// \N{GREEK SMALL LETTER UPSILON}\N{COMBINING DIAERESIS}\N{COMBINING ACUTE ACCENT}
|
||||
{"\u03C5\u0308\u0301","\u03A5\u0308\u0301","\u03C5\u0308\u0301",},
|
||||
// \N{GREEK SMALL LETTER UPSILON}\N{COMBINING DIAERESIS}\N{COMBINING GREEK PERISPOMENI}
|
||||
{"\u03C5\u0308\u0342","\u03A5\u0308\u0342","\u03C5\u0308\u0342",},
|
||||
// \N{GREEK SMALL LETTER UPSILON}\N{COMBINING COMMA ABOVE}
|
||||
{"\u03C5\u0313","\u03A5\u0313","\u03C5\u0313",},
|
||||
// \N{GREEK SMALL LETTER UPSILON}\N{COMBINING COMMA ABOVE}\N{COMBINING GRAVE ACCENT}
|
||||
{"\u03C5\u0313\u0300","\u03A5\u0313\u0300","\u03C5\u0313\u0300","\u1F50\u0300",},
|
||||
// \N{GREEK SMALL LETTER UPSILON}\N{COMBINING COMMA ABOVE}\N{COMBINING ACUTE ACCENT}
|
||||
{"\u03C5\u0313\u0301","\u03A5\u0313\u0301","\u03C5\u0313\u0301","\u1F50\u0301",},
|
||||
// \N{GREEK SMALL LETTER UPSILON}\N{COMBINING COMMA ABOVE}\N{COMBINING GREEK PERISPOMENI}
|
||||
{"\u03C5\u0313\u0342","\u03A5\u0313\u0342","\u03C5\u0313\u0342","\u1F50\u0342",},
|
||||
// \N{GREEK SMALL LETTER UPSILON}\N{COMBINING GREEK PERISPOMENI}
|
||||
{"\u03C5\u0342","\u03A5\u0342","\u03C5\u0342",},
|
||||
// \N{GREEK SMALL LETTER OMEGA}\N{COMBINING GREEK PERISPOMENI}
|
||||
{"\u03C9\u0342","\u03A9\u0342","\u03C9\u0342","\u2126\u0342",},
|
||||
// \N{GREEK SMALL LETTER OMEGA}\N{COMBINING GREEK PERISPOMENI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u03C9\u0342\u03B9","\u03A9\u0342\u0345","\u03A9\u0342\u0399","\u03A9\u0342\u03B9","\u03A9\u0342\u1FBE","\u03C9\u0342\u0345","\u03C9\u0342\u0399","\u03C9\u0342\u03B9","\u03C9\u0342\u1FBE","\u1FF6\u0345",
|
||||
"\u1FF6\u0399","\u1FF6\u03B9","\u1FF6\u1FBE","\u2126\u0342\u0345","\u2126\u0342\u0399","\u2126\u0342\u03B9","\u2126\u0342\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER OMEGA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u03C9\u03B9","\u03A9\u0345","\u03A9\u0399","\u03A9\u03B9","\u03A9\u1FBE","\u03C9\u0345","\u03C9\u0399","\u03C9\u03B9","\u03C9\u1FBE","\u2126\u0345","\u2126\u0399","\u2126\u03B9","\u2126\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER OMEGA WITH TONOS}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u03CE\u03B9","\u038F\u0345","\u038F\u0399","\u038F\u03B9","\u038F\u1FBE","\u03CE\u0345","\u03CE\u0399","\u03CE\u03B9","\u03CE\u1FBE",},
|
||||
// \N{ARMENIAN SMALL LETTER ECH}\N{ARMENIAN SMALL LETTER YIWN}
|
||||
{"\u0565\u0582","\u0535\u0552","\u0535\u0582","\u0565\u0552","\u0565\u0582",},
|
||||
// \N{ARMENIAN SMALL LETTER MEN}\N{ARMENIAN SMALL LETTER ECH}
|
||||
{"\u0574\u0565","\u0544\u0535","\u0544\u0565","\u0574\u0535","\u0574\u0565",},
|
||||
// \N{ARMENIAN SMALL LETTER MEN}\N{ARMENIAN SMALL LETTER INI}
|
||||
{"\u0574\u056B","\u0544\u053B","\u0544\u056B","\u0574\u053B","\u0574\u056B",},
|
||||
// \N{ARMENIAN SMALL LETTER MEN}\N{ARMENIAN SMALL LETTER XEH}
|
||||
{"\u0574\u056D","\u0544\u053D","\u0544\u056D","\u0574\u053D","\u0574\u056D",},
|
||||
// \N{ARMENIAN SMALL LETTER MEN}\N{ARMENIAN SMALL LETTER NOW}
|
||||
{"\u0574\u0576","\u0544\u0546","\u0544\u0576","\u0574\u0546","\u0574\u0576",},
|
||||
// \N{ARMENIAN SMALL LETTER VEW}\N{ARMENIAN SMALL LETTER NOW}
|
||||
{"\u057E\u0576","\u054E\u0546","\u054E\u0576","\u057E\u0546","\u057E\u0576",},
|
||||
// \N{GREEK SMALL LETTER ALPHA WITH PSILI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F00\u03B9","\u1F00\u0345","\u1F00\u0399","\u1F00\u03B9","\u1F00\u1FBE","\u1F08\u0345","\u1F08\u0399","\u1F08\u03B9","\u1F08\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ALPHA WITH DASIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F01\u03B9","\u1F01\u0345","\u1F01\u0399","\u1F01\u03B9","\u1F01\u1FBE","\u1F09\u0345","\u1F09\u0399","\u1F09\u03B9","\u1F09\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ALPHA WITH PSILI AND VARIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F02\u03B9","\u1F02\u0345","\u1F02\u0399","\u1F02\u03B9","\u1F02\u1FBE","\u1F0A\u0345","\u1F0A\u0399","\u1F0A\u03B9","\u1F0A\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ALPHA WITH DASIA AND VARIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F03\u03B9","\u1F03\u0345","\u1F03\u0399","\u1F03\u03B9","\u1F03\u1FBE","\u1F0B\u0345","\u1F0B\u0399","\u1F0B\u03B9","\u1F0B\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ALPHA WITH PSILI AND OXIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F04\u03B9","\u1F04\u0345","\u1F04\u0399","\u1F04\u03B9","\u1F04\u1FBE","\u1F0C\u0345","\u1F0C\u0399","\u1F0C\u03B9","\u1F0C\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ALPHA WITH DASIA AND OXIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F05\u03B9","\u1F05\u0345","\u1F05\u0399","\u1F05\u03B9","\u1F05\u1FBE","\u1F0D\u0345","\u1F0D\u0399","\u1F0D\u03B9","\u1F0D\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F06\u03B9","\u1F06\u0345","\u1F06\u0399","\u1F06\u03B9","\u1F06\u1FBE","\u1F0E\u0345","\u1F0E\u0399","\u1F0E\u03B9","\u1F0E\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ALPHA WITH DASIA AND PERISPOMENI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F07\u03B9","\u1F07\u0345","\u1F07\u0399","\u1F07\u03B9","\u1F07\u1FBE","\u1F0F\u0345","\u1F0F\u0399","\u1F0F\u03B9","\u1F0F\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA WITH PSILI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F20\u03B9","\u1F20\u0345","\u1F20\u0399","\u1F20\u03B9","\u1F20\u1FBE","\u1F28\u0345","\u1F28\u0399","\u1F28\u03B9","\u1F28\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA WITH DASIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F21\u03B9","\u1F21\u0345","\u1F21\u0399","\u1F21\u03B9","\u1F21\u1FBE","\u1F29\u0345","\u1F29\u0399","\u1F29\u03B9","\u1F29\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA WITH PSILI AND VARIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F22\u03B9","\u1F22\u0345","\u1F22\u0399","\u1F22\u03B9","\u1F22\u1FBE","\u1F2A\u0345","\u1F2A\u0399","\u1F2A\u03B9","\u1F2A\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA WITH DASIA AND VARIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F23\u03B9","\u1F23\u0345","\u1F23\u0399","\u1F23\u03B9","\u1F23\u1FBE","\u1F2B\u0345","\u1F2B\u0399","\u1F2B\u03B9","\u1F2B\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA WITH PSILI AND OXIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F24\u03B9","\u1F24\u0345","\u1F24\u0399","\u1F24\u03B9","\u1F24\u1FBE","\u1F2C\u0345","\u1F2C\u0399","\u1F2C\u03B9","\u1F2C\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA WITH DASIA AND OXIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F25\u03B9","\u1F25\u0345","\u1F25\u0399","\u1F25\u03B9","\u1F25\u1FBE","\u1F2D\u0345","\u1F2D\u0399","\u1F2D\u03B9","\u1F2D\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA WITH PSILI AND PERISPOMENI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F26\u03B9","\u1F26\u0345","\u1F26\u0399","\u1F26\u03B9","\u1F26\u1FBE","\u1F2E\u0345","\u1F2E\u0399","\u1F2E\u03B9","\u1F2E\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA WITH DASIA AND PERISPOMENI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F27\u03B9","\u1F27\u0345","\u1F27\u0399","\u1F27\u03B9","\u1F27\u1FBE","\u1F2F\u0345","\u1F2F\u0399","\u1F2F\u03B9","\u1F2F\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER OMEGA WITH PSILI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F60\u03B9","\u1F60\u0345","\u1F60\u0399","\u1F60\u03B9","\u1F60\u1FBE","\u1F68\u0345","\u1F68\u0399","\u1F68\u03B9","\u1F68\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER OMEGA WITH DASIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F61\u03B9","\u1F61\u0345","\u1F61\u0399","\u1F61\u03B9","\u1F61\u1FBE","\u1F69\u0345","\u1F69\u0399","\u1F69\u03B9","\u1F69\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER OMEGA WITH PSILI AND VARIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F62\u03B9","\u1F62\u0345","\u1F62\u0399","\u1F62\u03B9","\u1F62\u1FBE","\u1F6A\u0345","\u1F6A\u0399","\u1F6A\u03B9","\u1F6A\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER OMEGA WITH DASIA AND VARIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F63\u03B9","\u1F63\u0345","\u1F63\u0399","\u1F63\u03B9","\u1F63\u1FBE","\u1F6B\u0345","\u1F6B\u0399","\u1F6B\u03B9","\u1F6B\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER OMEGA WITH PSILI AND OXIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F64\u03B9","\u1F64\u0345","\u1F64\u0399","\u1F64\u03B9","\u1F64\u1FBE","\u1F6C\u0345","\u1F6C\u0399","\u1F6C\u03B9","\u1F6C\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER OMEGA WITH DASIA AND OXIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F65\u03B9","\u1F65\u0345","\u1F65\u0399","\u1F65\u03B9","\u1F65\u1FBE","\u1F6D\u0345","\u1F6D\u0399","\u1F6D\u03B9","\u1F6D\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER OMEGA WITH PSILI AND PERISPOMENI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F66\u03B9","\u1F66\u0345","\u1F66\u0399","\u1F66\u03B9","\u1F66\u1FBE","\u1F6E\u0345","\u1F6E\u0399","\u1F6E\u03B9","\u1F6E\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER OMEGA WITH DASIA AND PERISPOMENI}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F67\u03B9","\u1F67\u0345","\u1F67\u0399","\u1F67\u03B9","\u1F67\u1FBE","\u1F6F\u0345","\u1F6F\u0399","\u1F6F\u03B9","\u1F6F\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ALPHA WITH VARIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F70\u03B9","\u1F70\u0345","\u1F70\u0399","\u1F70\u03B9","\u1F70\u1FBE","\u1FBA\u0345","\u1FBA\u0399","\u1FBA\u03B9","\u1FBA\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER ETA WITH VARIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F74\u03B9","\u1F74\u0345","\u1F74\u0399","\u1F74\u03B9","\u1F74\u1FBE","\u1FCA\u0345","\u1FCA\u0399","\u1FCA\u03B9","\u1FCA\u1FBE",},
|
||||
// \N{GREEK SMALL LETTER OMEGA WITH VARIA}\N{GREEK SMALL LETTER IOTA}
|
||||
{"\u1F7C\u03B9","\u1F7C\u0345","\u1F7C\u0399","\u1F7C\u03B9","\u1F7C\u1FBE","\u1FFA\u0345","\u1FFA\u0399","\u1FFA\u03B9","\u1FFA\u1FBE",},
|
||||
};
|
||||
|
||||
// this initializes the data used to generated the case-equivalents
|
||||
|
||||
static {
|
||||
|
||||
// Gather up the exceptions in a form we can use
|
||||
|
||||
if (!GENERATE) {
|
||||
for (int i = 0; i < exceptionList.length; ++i) {
|
||||
String[] exception = exceptionList[i];
|
||||
Set s = new HashSet();
|
||||
// there has to be some method to do the following, but I can't find it in the collections
|
||||
for (int j = 0; j < exception.length; ++j) {
|
||||
s.add(exception[j]);
|
||||
}
|
||||
fromCaseFold.put(exception[0], s);
|
||||
}
|
||||
}
|
||||
|
||||
// walk through all the characters, and at every case fold result,
|
||||
// put a set of all the characters that map to that result
|
||||
|
||||
boolean defaultmapping = true; // false for turkish
|
||||
for (int i = 0; i <= 0x10FFFF; ++i) {
|
||||
int cat = UCharacter.getType(i);
|
||||
if (cat == Character.UNASSIGNED || cat == Character.PRIVATE_USE) continue;
|
||||
|
||||
String cp = UTF16.valueOf(i);
|
||||
String mapped = UCharacter.foldCase(cp, defaultmapping);
|
||||
if (mapped.equals(cp)) continue;
|
||||
|
||||
if (maxLength < mapped.length()) maxLength = mapped.length();
|
||||
|
||||
// at this point, have different case folding
|
||||
|
||||
Set s = (Set) fromCaseFold.get(mapped);
|
||||
if (s == null) {
|
||||
s = new HashSet();
|
||||
s.add(mapped); // add the case fold result itself
|
||||
fromCaseFold.put(mapped, s);
|
||||
}
|
||||
s.add(cp);
|
||||
toCaseFold.put(cp, mapped);
|
||||
toCaseFold.put(mapped, mapped); // add mapping to self
|
||||
}
|
||||
|
||||
// Emit the final data
|
||||
|
||||
if (DUMP) {
|
||||
System.out.println("maxLength = " + maxLength);
|
||||
|
||||
System.out.println("\nfromCaseFold:");
|
||||
Iterator it = fromCaseFold.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Object key = it.next();
|
||||
System.out.print(" " + toHex2.transliterate((String)key) + ": ");
|
||||
Set s = (Set) fromCaseFold.get(key);
|
||||
Iterator it2 = s.iterator();
|
||||
boolean first = true;
|
||||
while (it2.hasNext()) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
System.out.print(", ");
|
||||
}
|
||||
System.out.print(toHex2.transliterate((String)it2.next()));
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
System.out.println("\ntoCaseFold:");
|
||||
it = toCaseFold.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
String value = (String) toCaseFold.get(key);
|
||||
System.out.println(" " + toHex2.transliterate(key) + ": " + toHex2.transliterate(value));
|
||||
}
|
||||
}
|
||||
|
||||
// Now convert all those sets into linear arrays
|
||||
// We can't do this in place in Java, so make a temporary target array
|
||||
|
||||
// Note: This could be transformed into a single array, with offsets into it.
|
||||
// Might be best choice in C.
|
||||
|
||||
|
||||
Map fromCaseFold2 = new HashMap();
|
||||
Iterator it = fromCaseFold.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Object key = it.next();
|
||||
Set s = (Set) fromCaseFold.get(key);
|
||||
String[] temp = new String[s.size()];
|
||||
s.toArray(temp);
|
||||
fromCaseFold2.put(key, temp);
|
||||
}
|
||||
fromCaseFold = fromCaseFold2;
|
||||
|
||||
// We have processed everything, so the iterator will now work
|
||||
// The following is normally OFF.
|
||||
// It is here to generate (under the GENERATE flag) the static exception list.
|
||||
// It must be at the very end of initialization, so that the iterator is functional.
|
||||
// (easiest to do it that way)
|
||||
|
||||
if (GENERATE) {
|
||||
|
||||
// first get small set of items that have multiple characters
|
||||
|
||||
Set multichars = new TreeSet();
|
||||
it = fromCaseFold.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
if (UTF16.countCodePoint(key) < 2) continue;
|
||||
multichars.add(key);
|
||||
}
|
||||
|
||||
// now we will go through each of them.
|
||||
|
||||
CaseIterator ci = new CaseIterator();
|
||||
it = multichars.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
|
||||
// here is a nasty complication. Take 'ffi' ligature. We
|
||||
// can't just close it, since we would miss the combination
|
||||
// that includes the 'fi' => "fi" ligature
|
||||
// so first do a pass through, and add substring combinations
|
||||
// we call this a 'partial closure'
|
||||
|
||||
Set partialClosure = new TreeSet();
|
||||
partialClosure.add(key);
|
||||
|
||||
if (UTF16.countCodePoint(key) > 2) {
|
||||
Iterator multiIt2 = multichars.iterator();
|
||||
while (multiIt2.hasNext()) {
|
||||
String otherKey = (String) multiIt2.next();
|
||||
if (otherKey.length() >= key.length()) continue;
|
||||
int pos = -1;
|
||||
while (true) {
|
||||
// The following is not completely general
|
||||
// but works for the actual cased stuff,
|
||||
// and should work for future characters, since we won't have
|
||||
// more ligatures & other oddities.
|
||||
pos = key.indexOf(otherKey, pos+1);
|
||||
if (pos < 0) break;
|
||||
int endPos = pos + otherKey.length();
|
||||
// we know we have a proper substring,
|
||||
// so get the combinations
|
||||
String[] choices = (String[]) fromCaseFold.get(otherKey);
|
||||
for (int ii = 0; ii < choices.length; ++ii) {
|
||||
String patchwork = key.substring(0, pos)
|
||||
+ choices[ii]
|
||||
+ key.substring(endPos);
|
||||
partialClosure.add(patchwork);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now, for each thing in the partial closure, get its
|
||||
// case closure and add it to the final result.
|
||||
|
||||
Set closure = new TreeSet(); // this will be the real closure
|
||||
Iterator partialIt = partialClosure.iterator();
|
||||
while (partialIt.hasNext()) {
|
||||
String key2 = (String) partialIt.next();
|
||||
ci.reset(key2);
|
||||
for (String temp = ci.next(); temp != null; temp = ci.next()) {
|
||||
closure.add(temp);
|
||||
}
|
||||
// form closure
|
||||
/*String[] choices = (String[]) fromCaseFold.get(key2);
|
||||
for (int i = 0; i < choices.length; ++i) {
|
||||
ci.reset(choices[i]);
|
||||
String temp;
|
||||
while (null != (temp = ci.next())) {
|
||||
closure.add(temp);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// print it out, so that it can be cut and pasted back into this document.
|
||||
|
||||
Iterator it2 = closure.iterator();
|
||||
System.out.println("\t// " + toName.transliterate(key));
|
||||
System.out.print("\t{\"" + toHex.transliterate(key) + "\",");
|
||||
while (it2.hasNext()) {
|
||||
String item = (String)it2.next();
|
||||
System.out.print("\"" + toHex.transliterate(item) + "\",");
|
||||
}
|
||||
System.out.println("},");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============ PRIVATE CLASS DATA ============
|
||||
|
||||
// pieces that we will put together
|
||||
// is not changed during iteration
|
||||
private int count = 0;
|
||||
private String[][] variants;
|
||||
|
||||
// state information, changes during iteration
|
||||
private boolean done = false;
|
||||
private int[] counts;
|
||||
|
||||
// internal buffer for efficiency
|
||||
private StringBuffer nextBuffer = new StringBuffer();
|
||||
|
||||
// ========================
|
||||
|
||||
/**
|
||||
* Reset to different source. Once reset, the iteration starts from the beginning.
|
||||
* @param source The string to get case variants for
|
||||
*/
|
||||
public void reset(String source) {
|
||||
|
||||
// allocate arrays to store pieces
|
||||
// using length might be slightly too long, but we don't care much
|
||||
|
||||
counts = new int[source.length()];
|
||||
variants = new String[source.length()][];
|
||||
|
||||
// walk through the source, and break up into pieces
|
||||
// each piece becomes an array of equivalent values
|
||||
// TODO: could optimized this later to coalesce all single string pieces
|
||||
|
||||
String piece = null;
|
||||
count = 0;
|
||||
for (int i = 0; i < source.length(); i += piece.length()) {
|
||||
|
||||
// find *longest* matching piece
|
||||
String caseFold = null;
|
||||
|
||||
if (GENERATE) {
|
||||
// do exactly one CP
|
||||
piece = UTF16.valueOf(source, i);
|
||||
caseFold = (String) toCaseFold.get(piece);
|
||||
} else {
|
||||
int max = i + maxLength;
|
||||
if (max > source.length()) max = source.length();
|
||||
for (int j = max; j > i; --j) {
|
||||
piece = source.substring(i, j);
|
||||
caseFold = (String) toCaseFold.get(piece);
|
||||
if (caseFold != null) break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we fail, pick one code point
|
||||
if (caseFold == null) {
|
||||
piece = UTF16.valueOf(source, i);
|
||||
variants[count++] = new String[] {piece}; // single item string
|
||||
} else {
|
||||
variants[count++] = (String[])fromCaseFold.get(caseFold);
|
||||
}
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restart the iteration from the beginning, but with same source
|
||||
*/
|
||||
public void reset() {
|
||||
done = false;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
counts[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through the case variants.
|
||||
* @return next case variant. Each variant will case-fold to the same value as the source will.
|
||||
* When the iteration is done, null is returned.
|
||||
*/
|
||||
public String next() {
|
||||
|
||||
if (done) return null;
|
||||
int i;
|
||||
|
||||
// TODO Optimize so we keep the piece before and after the current position
|
||||
// so we don't have so much concatenation
|
||||
|
||||
// get the result, a concatenation
|
||||
|
||||
nextBuffer.setLength(0);
|
||||
for (i = 0; i < count; ++i) {
|
||||
nextBuffer.append(variants[i][counts[i]]);
|
||||
}
|
||||
|
||||
// find the next right set of pieces to concatenate
|
||||
|
||||
for (i = count-1; i >= 0; --i) {
|
||||
counts[i]++;
|
||||
if (counts[i] < variants[i].length) break;
|
||||
counts[i] = 0;
|
||||
}
|
||||
|
||||
// if we go too far, bail
|
||||
|
||||
if (i < 0) {
|
||||
done = true;
|
||||
}
|
||||
|
||||
return nextBuffer.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Temporary test, just to see how the stuff works.
|
||||
*/
|
||||
static public void main(String[] args) {
|
||||
String[] testCases = {"fiss", "h\u03a3"};
|
||||
CaseIterator ci = new CaseIterator();
|
||||
|
||||
for (int i = 0; i < testCases.length; ++i) {
|
||||
String item = testCases[i];
|
||||
System.out.println();
|
||||
System.out.println("Testing: " + toName.transliterate(item));
|
||||
System.out.println();
|
||||
ci.reset(item);
|
||||
int count = 0;
|
||||
for (String temp = ci.next(); temp != null; temp = ci.next()) {
|
||||
System.out.println(toName.transliterate(temp));
|
||||
count++;
|
||||
}
|
||||
System.out.println("Total: " + count);
|
||||
}
|
||||
|
||||
// generate a list of all caseless characters -- characters whose
|
||||
// case closure is themselves.
|
||||
|
||||
UnicodeSet caseless = new UnicodeSet();
|
||||
|
||||
for (int i = 0; i <= 0x10FFFF; ++i) {
|
||||
String cp = UTF16.valueOf(i);
|
||||
ci.reset(cp);
|
||||
int count = 0;
|
||||
String fold = null;
|
||||
for (String temp = ci.next(); temp != null; temp = ci.next()) {
|
||||
fold = temp;
|
||||
if (++count > 1) break;
|
||||
}
|
||||
if (count==1 && fold.equals(cp)) {
|
||||
caseless.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("caseless = " + caseless.toPattern(true));
|
||||
|
||||
UnicodeSet not_lc = new UnicodeSet("[:^lc:]");
|
||||
|
||||
UnicodeSet a = new UnicodeSet();
|
||||
a.set(not_lc);
|
||||
a.removeAll(caseless);
|
||||
System.out.println("[:^lc:] - caseless = " + a.toPattern(true));
|
||||
|
||||
a.set(caseless);
|
||||
a.removeAll(not_lc);
|
||||
System.out.println("caseless - [:^lc:] = " + a.toPattern(true));
|
||||
}
|
||||
}
|
1417
demos/src/com/ibm/icu/dev/demo/translit/Demo.java
Normal file
1417
demos/src/com/ibm/icu/dev/demo/translit/Demo.java
Normal file
File diff suppressed because it is too large
Load diff
73
demos/src/com/ibm/icu/dev/demo/translit/DemoApplet.java
Normal file
73
demos/src/com/ibm/icu/dev/demo/translit/DemoApplet.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.translit;
|
||||
import java.applet.Applet;
|
||||
import java.awt.Button;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
import com.ibm.icu.dev.demo.impl.AppletFrame;
|
||||
|
||||
/**
|
||||
* A simple Applet that shows a button. When pressed, the button
|
||||
* shows the DemoAppletFrame. This Applet is meant to be embedded
|
||||
* in a web page.
|
||||
*
|
||||
* <p>Copyright (c) IBM Corporation 1999. All rights reserved.
|
||||
*
|
||||
* @author Alan Liu
|
||||
*/
|
||||
public class DemoApplet extends Applet {
|
||||
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = 8214879807740061678L;
|
||||
Demo frame = null;
|
||||
|
||||
public static void main(String args[]) {
|
||||
final DemoApplet applet = new DemoApplet();
|
||||
new AppletFrame("Transliteration Demo", applet, 640, 480);
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
||||
Button button = new Button("Transliteration Demo");
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (frame == null) {
|
||||
frame = new Demo(600, 200);
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent we) {
|
||||
frame = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
frame.setVisible(true);
|
||||
frame.toFront();
|
||||
}
|
||||
});
|
||||
|
||||
add(button);
|
||||
|
||||
Dimension size = button.getPreferredSize();
|
||||
size.width += 10;
|
||||
size.height += 10;
|
||||
|
||||
resize(size);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
frame = null;
|
||||
}
|
||||
}
|
66
demos/src/com/ibm/icu/dev/demo/translit/InfoDialog.java
Normal file
66
demos/src/com/ibm/icu/dev/demo/translit/InfoDialog.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.translit;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Button;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Label;
|
||||
import java.awt.Panel;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
public class InfoDialog extends Dialog {
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = -3086665546137919018L;
|
||||
protected Button button;
|
||||
protected TextArea area;
|
||||
protected Dialog me;
|
||||
protected Panel bottom;
|
||||
|
||||
public TextArea getArea() {
|
||||
return area;
|
||||
}
|
||||
|
||||
public Panel getBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
InfoDialog(Frame parent, String title, String label, String message) {
|
||||
super(parent, title, false);
|
||||
me = this;
|
||||
this.setLayout(new BorderLayout());
|
||||
if (label.length() != 0) {
|
||||
this.add("North", new Label(label));
|
||||
}
|
||||
|
||||
area = new TextArea(message, 8, 80, TextArea.SCROLLBARS_VERTICAL_ONLY);
|
||||
this.add("Center", area);
|
||||
|
||||
button = new Button("Hide");
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
me.hide();
|
||||
}
|
||||
});
|
||||
bottom = new Panel();
|
||||
bottom.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
|
||||
bottom.add(button);
|
||||
this.add("South", bottom);
|
||||
this.pack();
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
me.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#--------------------------------------------------------------------
|
||||
# Copyright (c) 1999-2004, International Business Machines
|
||||
# Corporation and others. All Rights Reserved.
|
||||
#--------------------------------------------------------------------
|
||||
@UPPERFILTER@
|
||||
ما هي الشفرة الموحدة "يونِكود" ؟
|
||||
|
||||
أساسًا، تتعامل الحواسيب فقط مع الأرقام، وتقوم بتخزين الأحرف والمحارف الأخرى بعد أن تُعطي رقما معينا لكل واحد منها. وقبل اختراع "يونِكود"، كان هناك مئات الأنظمة للتشفير وتخصيص هذه الأرقام للمحارف، ولم يوجد نظام تشفير واحد يحتوي على جميع المحارف الضرورية. وعلى سبيل المثال، فإن الاتحاد الأوروبي لوحده، احتوى العديد من الشفرات المختلفة ليغطي جميع اللغات المستخدمة في الاتحاد. وحتى لو اعتبرنا لغة واحدة، كاللغة الإنجليزية، فإن جدول شفرة واحد لم يكف لاستيعاب جميع الأحرف وعلامات الترقيم والرموز الفنية والعلمية الشائعة الاستعمال.
|
||||
|
||||
|
||||
|
||||
وتجدر الملاحظة أن أنظمة التشفير المختلفة تتعارض مع بعضها البعض. وبعبارة أخرى، يمكن أن يستخدِم جدولي شفرة نفس الرقم لتمثيل محرفين مختلفين، أو رقمين مختلفين لتمثيل نفس المحرف. ولو أخذنا أي جهاز حاسوب، وبخاصة جهاز النادل (server)، فيجب أن تكون لديه القدرة على التعامل مع عدد كبير من الشفرات المختلفة، ويتم تصميمه على هذا الأساس. ومع ذلك، فعندما تمر البيانات عبر أنظمة مختلفة، توجد هناك خطورة لضياع أو تحريف بعض هذه البيانات.
|
||||
|
||||
|
||||
|
||||
"يونِكود" تغير هذا كليا !
|
||||
|
||||
تخصص الشفرة الموحدة "يونِكود" رقما وحيدا لكل محرف في جميع اللغات العالمية، وذلك بغض النظر عن نوع الحاسوب أو البرامج المستخدمة. وقد تم تبني مواصفة "يونِكود" من قبل قادة الصانعين لأنظمة الحواسيب في العالم، مثل شركات آي.بي.إم. (IBM)، أبل (APPLE)، هِيْولِت باكرد (Hewlett-Packard) ، مايكروسوفت (Microsoft)، أوراكِل (Oracle) ، صن (Sun) وغيرها. كما أن المواصفات والمقاييس الحديثة (مثل لغة البرمجة "جافا" "JAVA" ولغة "إكس إم إل" "XML" التي تستخدم لبرمجة الانترنيت) تتطلب استخدام "يونِكود". علاوة على ذلك ، فإن "يونِكود" هي الطريقة الرسمية لتطبيق المقياس العالمي إيزو ١٠٦٤٦ (ISO 10646) .
|
||||
|
||||
|
||||
|
||||
إن بزوغ مواصفة "يونِكود" وتوفُّر الأنظمة التي تستخدمه وتدعمه، يعتبر من أهم الاختراعات الحديثة في عولمة البرمجيات لجميع اللغات في العالم. وإن استخدام "يونِكود" في عالم الانترنيت سيؤدي إلى توفير كبير مقارنة مع استخدام المجموعات التقليدية للمحارف المشفرة. كما أن استخدام "يونِكود" سيُمكِّن المبرمج من كتابة البرنامج مرة واحدة، واستخدامه على أي نوع من الأجهزة أو الأنظمة، ولأي لغة أو دولة في العالم أينما كانت، دون الحاجة لإعادة البرمجة أو إجراء أي تعديل. وأخيرا، فإن استخدام "يونِكود" سيمكن البيانات من الانتقال عبر الأنظمة والأجهزة المختلفة دون أي خطورة لتحريفها، مهما تعددت الشركات الصانعة للأنظمة واللغات، والدول التي تمر من خلالها هذه البيانات.
|
||||
|
||||
@SET [[[:Arabic:] & [\u0600-\u06FF]] [\u060C\u061B\u061F\u0640\u064B-\u0655\u0660-\u066C\u06F0-\u06F9]]
|
73
demos/src/com/ibm/icu/dev/demo/translit/Test_Greek-Latin.txt
Normal file
73
demos/src/com/ibm/icu/dev/demo/translit/Test_Greek-Latin.txt
Normal file
|
@ -0,0 +1,73 @@
|
|||
#--------------------------------------------------------------------
|
||||
# Copyright (c) 1999-2004, International Business Machines
|
||||
# Corporation and others. All Rights Reserved.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
Τι είναι το Unicode?
|
||||
|
||||
Η κωδικοσελίδα Unicode προτείνει έναν και μοναδικό αριθμό για κάθε χαρακτήρα, ανεξάρτητα από το λειτουργικό σύστημα, ανεξάρτητα από το λογισμικό, ανεξάρτητα από την γλώσσα.
|
||||
|
||||
Οι ηλεκτρονικοί υπολογιστές, σε τελική ανάλυση, χειρίζονται απλώς αριθμούς. Αποθηκεύουν γράμματα και άλλους χαρακτήρες αντιστοιχώντας στο καθένα τους από έναν αριθμό (ονομάζουμε μία τέτοια αντιστοιχία κωδικοσελίδα). Πριν την εφεύρεση του Unicode, υπήρχαν εκατοντάδες διαφορετικές κωδικοσελίδες. Λόγω περιορισμών μεγέθους όμως, σε καμία κωδικοσελίδα δεν χωρούσαν αρκετοί χαρακτήρες: λόγου χάριν, η Ευρωπαϊκή Ένωση χρειαζόταν πλήθος διαφορετικών κωδικοσελίδων για να καλύψει όλες τις γλώσσες των χωρών-μελών της. Ακόμα και για μία και μόνη γλώσσα, όπως π.χ. τα Αγγλικά, μία κωδικοσελίδα δεν επαρκούσε για να καλύψει όλα τα γράμματα, σημεία στίξης και τεχνικά σύμβολα ευρείας χρήσης.
|
||||
|
||||
Εκτός αυτού, οι κωδικοσελίδες αυτές διαφωνούσαν μεταξύ τους. Έτσι, δύο κωδικοσελίδες μπορούσαν κάλλιστα να χρησιμοποιούν τον ίδιο αριθμό για δύο διαφορετικούς χαρακτήρες, ή να χρησιμοποιούν διαφορετικούς αριθμούς για τον ίδιο χαρακτήρα. Κάθε υπολογιστής (και ιδίως εάν ήταν διακομιστής) έπρεπε να υποστηρίζει πλήθος διαφορετικών κωδικοσελίδων· ταυτόχρονα κάθε φορά που δεδομένα μεταφέρονταν μεταξύ διαφορετικών κωδικοσελίδων ή λειτουργικών συστημάτων, τα δεδομένα αυτά κινδύνευαν να αλλοιωθούν.
|
||||
|
||||
Το Unicode αλλάζει αυτή την κατάσταση!
|
||||
Το Unicode προτείνει έναν μοναδικό αριθμό για κάθε χαρακτήρα, ανεξάρτητα από το λειτουργικό σύστημα, ανεξάρτητα από το λογισμικό, ανεξάρτητα από την γλώσσα. Την κωδικοσελίδα Unicode έχουν ασπασθεί κορυφαίοι παράγοντες του χώρου των λογισμικών όπως οι: Apple, HP, IBM, JustSystem, Microsoft, Oracle, SAP, Sun, Sybase, Unisys και πολλοί άλλοι. Το Unicode απαιτούν πολλές σύγχρονες τυποποιήσεις όπως οι: XML, Java, ECMAScript (JavaScript), LDAP, CORBA 3.0, WML, κ.λπ., και είναι η επίσημη μέθοδος εφαρμογής της τυποποίησης ISO/IEC 10646. Υποστηρίζεται από πολλά λειτουργικά συστήματα, όλους τους σύχρονους περιηγητές Διαδικτύου, και πολλά άλλα προϊόντα. Η εμφάνιση της κωδικοσελίδας Unicode, και η διαθεσιμότητα εργαλείων που να την υποστηρίζουν είναι από τις σημαντικότερες εξελίξεις της πρόσφατης τεχνολογίας λογισμικών.
|
||||
|
||||
Η ενσωμάτωση του Unicode σε εφαρμογές πελάτη-διακομιστή ή "multi-tiered" προσφέρει σημαντικές οικονομίες σε σχέση με τις ως τώρα υπάρχουσες κωδικοσελίδες. Χάρις στο Unicode ένα και μόνο προϊόν ή μία και μόνη τοποθεσία Διαδικτύου μπορεί να επικοινωνεί με διάφορα λειτουργικά συστήματα, σε διάφορες γλώσσες και χώρες, χωρίς την ανάγκη επαναπρογραμματισμού. Γίνεται έτσι δυνατή η μεταφορά δεδομένων ανάμεσα σε πλήθος διαφορετικών συστημάτων δίχως κίνδυνο αλλοίωσης.
|
||||
|
||||
Σχετικά με το Κονσόρτιουμ Unicode
|
||||
Tο Κονσόρτιουμ Unicode είναι ένας κοινωφελής οργανισμός· ιδρύθηκε για να αναπτύξει, να επεκτείνει και να μεταδώσει την χρήση της κωδικοσελίδας Unicode που καθορίζει την αναπαράσταση κειμένου σε σύγχρονα λογισμικά προϊόντα και τυποποιήσεις. Μεγάλος αριθμός εταιρειών και οργανισμών της διεθνούς βιομηχανίας υπολογιστών και λογισμικών είναι μέλη του Κονσόρτιουμ Unicode. Το Κονσόρτιουμ χρηματοδοτείται μόνο από τις συνδρομές των μελών του. Μέλος του κονσόρτιουμ Unicode μπορεί να γίνει οιοσδήποτε (οργανισμός, εταιρεία ή ιδιώτης, οπουδήποτε στον κόσμο) που να υποστηρίζει την κωδικοσελίδα Unicode και να επιθυμεί να συνδράμει στην επέκταση και στην εφαρμογή της.
|
||||
|
||||
Για περαιτέρω πληροφορίες, βλέπε τις εξής ιστοσελίδες: Γλωσσάρι, Δείγματα προϊόντων συμβατών με το Unicode, Τεχνική Εισαγωγή και Χρήσιμες πηγές πληροφοριών.
|
||||
|
||||
(ANCIENT)
|
||||
|
||||
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
|
||||
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν:
|
||||
πολλῶν δ’ ἀνθρώπων ἴδεν ἄστεα καὶ νόον ἔγνω,
|
||||
πολλὰ δ’ ὅ γ’ ἐν πόντῳ πάθεν ἄλγεα ὃν κατὰ θυμόν,
|
||||
ἀρνύμενος ἥν τε ψυχὴν καὶ νόστον ἑταίρων.
|
||||
ἀλλ’ οὐδ’ ὣς ἑτάρους ἐρρύσατο, ἱέμενός περ:
|
||||
αὐτῶν γὰρ σφετέρῃσιν ἀτασθαλίῃσιν ὄλοντο,
|
||||
νήπιοι, οἳ κατὰ βοῦς Ὑπερίονος Ἠελίοιο
|
||||
ἤσθιον: αὐτὰρ ὁ τοῖσιν ἀφείλετο νόστιμον ἦμαρ.
|
||||
τῶν ἁμόθεν γε, θεά, θύγατερ Διός, εἰπὲ καὶ ἡμῖν.
|
||||
*
|
||||
ἔνθ’ ἄλλοι μὲν πάντες, ὅσοι φύγον αἰπὺν ὄλεθρον,
|
||||
οἴκοι ἔσαν, πόλεμόν τε πεφευγότες ἠδὲ θάλασσαν:
|
||||
τὸν δ’ οἶον νόστου κεχρημένον ἠδὲ γυναικὸς
|
||||
νύμφη πότνι’ ἔρυκε Καλυψὼ δῖα θεάων
|
||||
ἐν σπέσσι γλαφυροῖσι, λιλαιομένη πόσιν εἶναι.
|
||||
ἀλλ’ ὅτε δὴ ἔτος ἦλθε περιπλομένων ἐνιαυτῶν,
|
||||
τῷ οἱ ἐπεκλώσαντο θεοὶ οἶκόνδε νέεσθαι
|
||||
εἰς Ἰθάκην, οὐδ’ ἔνθα πεφυγμένος ἦεν ἀέθλων
|
||||
καὶ μετὰ οἷσι φίλοισι. θεοὶ δ’ ἐλέαιρον ἅπαντες
|
||||
νόσφι Ποσειδάωνος: ὁ δ’ ἀσπερχὲς μενέαινεν
|
||||
ἀντιθέῳ Ὀδυσῆι πάρος ἣν γαῖαν ἱκέσθαι.
|
||||
*
|
||||
ἀλλ’ ὁ μὲν Αἰθίοπας μετεκίαθε τηλόθ’ ἐόντας,
|
||||
Αἰθίοπας τοὶ διχθὰ δεδαίαται, ἔσχατοι ἀνδρῶν,
|
||||
οἱ μὲν δυσομένου Ὑπερίονος οἱ δ’ ἀνιόντος,
|
||||
ἀντιόων ταύρων τε καὶ ἀρνειῶν ἑκατόμβης.
|
||||
ἔνθ’ ὅ γ’ ἐτέρπετο δαιτὶ παρήμενος: οἱ δὲ δὴ ἄλλοι
|
||||
Ζηνὸς ἐνὶ μεγάροισιν Ὀλυμπίου ἁθρόοι ἦσαν.
|
||||
τοῖσι δὲ μύθων ἦρχε πατὴρ ἀνδρῶν τε θεῶν τε:
|
||||
μνήσατο γὰρ κατὰ θυμὸν ἀμύμονος Αἰγίσθοιο,
|
||||
τόν ῥ’ Ἀγαμεμνονίδης τηλεκλυτὸς ἔκταν’ Ὀρέστης:
|
||||
τοῦ ὅ γ’ ἐπιμνησθεὶς ἔπε’ ἀθανάτοισι μετηύδα:
|
||||
*
|
||||
“ὢ πόποι, οἷον δή νυ θεοὺς βροτοὶ αἰτιόωνται:
|
||||
ἐξ ἡμέων γάρ φασι κάκ’ ἔμμεναι, οἱ δὲ καὶ αὐτοὶ
|
||||
σφῇσιν ἀτασθαλίῃσιν ὑπὲρ μόρον ἄλγε’ ἔχουσιν,
|
||||
ὡς καὶ νῦν Αἴγισθος ὑπὲρ μόρον Ἀτρεί̈δαο
|
||||
γῆμ’ ἄλοχον μνηστήν, τὸν δ’ ἔκτανε νοστήσαντα,
|
||||
εἰδὼς αἰπὺν ὄλεθρον, ἐπεὶ πρό οἱ εἴπομεν ἡμεῖς,
|
||||
Ἑρμείαν πέμψαντες, ἐύσκοπον ἀργεϊφόντην,
|
||||
μήτ’ αὐτὸν κτείνειν μήτε μνάασθαι ἄκοιτιν:
|
||||
ἐκ γὰρ Ὀρέσταο τίσις ἔσσεται Ἀτρεί̈δαο,
|
||||
ὁππότ’ ἂν ἡβήσῃ τε καὶ ἧς ἱμείρεται αἴης.
|
||||
ὣς ἔφαθ’ Ἑρμείας, ἀλλ’ οὐ φρένας Αἰγίσθοιο
|
||||
πεῖθ’ ἀγαθὰ φρονέων: νῦν δ’ ἁθρόα πάντ’ ἀπέτισεν.”
|
||||
|
||||
@SET [[[:Greek:]&[\u0370-\u03E1 \u03F0-\u03FF]] [\:-;?\u00B7\u037E\u0387]]
|
26
demos/src/com/ibm/icu/dev/demo/translit/Test_Han-Latin.txt
Normal file
26
demos/src/com/ibm/icu/dev/demo/translit/Test_Han-Latin.txt
Normal file
|
@ -0,0 +1,26 @@
|
|||
#--------------------------------------------------------------------
|
||||
# Copyright (c) 1999-2004, International Business Machines
|
||||
# Corporation and others. All Rights Reserved.
|
||||
#--------------------------------------------------------------------
|
||||
@UPPERFILTER@
|
||||
什么是Unicode(统一码)?
|
||||
Unicode给每个字符提供了一个唯一的数字,
|
||||
不论是什么平台,
|
||||
不论是什么程序,
|
||||
不论是什么语言。
|
||||
|
||||
基本上,计算机只是处理数字。它们指定一个数字,来储存字母或其他字符。在创造Unicode之前,有数百种指定这些数字的编码系统。没有一个编码可以包含足够的字符:例如,单单欧州共同体就需要好几种不同的编码来包括所有的语言。即使是单一种语言,例如英语,也没有哪一个编码可以适用于所有的字母,标点符号,和常用的技术符号。
|
||||
|
||||
这些编码系统也会互相冲突。也就是说,两种编码可能使用相同的数字代表两个不同的字符,或使用不同的数字代表相同的字符。任何一台特定的计算机(特别是服务器)都需要支持许多不同的编码,但是,不论什么时候数据通过不同的编码或平台之间,那些数据总会有损坏的危险。
|
||||
|
||||
Unicode正在改变所有这一切!
|
||||
Unicode给每个字符提供了一个唯一的数字,不论是什么平台,不论是什么程序,不论什么语言。Unicode标准已经被这些工业界的领导们所采用,例如:Apple, HP, IBM, JustSystem, Microsoft, Oracle, SAP, Sun, Sybase, Unisys和其它许多公司。最新的标准都需要Unicode,例如XML, Java, ECMAScript (JavaScript), LDAP, CORBA 3.0, WML等等,并且,Unicode是实现ISO/IEC 10646的正规方式。许多操作系统,所有最新的浏览器和许多其他产品都支持它。Unicode标准的出现和支持它工具的存在,是近来全球软件技术最重要的发展趋势。
|
||||
|
||||
将Unicode与客户服务器或多层应用程序和网站结合,比使用传统字符集节省费用。Unicode使单一软件产品或单一网站能够贯穿多个平台,语言和国家,而不需要重建。它可将数据传输到许多不同的系统,而无损坏。
|
||||
|
||||
关于Unicode学术学会
|
||||
Unicode学术学会是一个非盈利的组织,是为发展,扩展和推广使用Unicode标准而建立的,Unicode学术学会设立了现代软件产品和标准文本的表示法。学术学会的会员代表了广泛领域的计算机和资讯工业的公司和组织。学术学会只由会员提供资金。Unicode学术学会的会员资格开放给世界上任何支持Unicode标准和希望协助其扩展和执行的组织及个人。
|
||||
|
||||
欲知更多信息,请参阅术语词汇表,Unicode产品样本,技术简介和参考资料。
|
||||
|
||||
Chinese translation by 黎國珍, Xerox
|
|
@ -0,0 +1,26 @@
|
|||
#--------------------------------------------------------------------
|
||||
# Copyright (c) 1999-2004, International Business Machines
|
||||
# Corporation and others. All Rights Reserved.
|
||||
#--------------------------------------------------------------------
|
||||
@UPPERFILTER@
|
||||
מה זה יוניקוד (Unicode)?
|
||||
יוניקוד מקצה מספר ייחודי לכל תו,
|
||||
לא משנה על איזו פלטפורמה,
|
||||
לא משנה באיזו תוכנית,
|
||||
ולא משנה באיזו שפה.
|
||||
|
||||
באופן בסיסי, מחשבים עוסקים רק במספרים. הם מאחסנים אותיות ותווים אחרים על-ידי הקצאת מספר לכל אחד מהם. בטרם הומצא היוניקוד, היו מאות מערכות קידוד שונות להקצאת המספרים הללו. אף לא אחת מהן יכלה להכיל כמות תווים מספקת. לדוגמא: רק לאיחוד האירופאי נדרשים כמה סוגי קידודים שונים על מנת לכסות את כל השפות המדוברות בו. יתירה מזאת אף לשפה בודדת, כמו אנגלית למשל, לא היה די במערכת קידוד אחת בעבור כל האותיות, סימני הפיסוק והסמלים הטכניים שבשימוש שוטף.
|
||||
|
||||
מערכות קידוד אלו אף סותרות זו את זו. כלומר, שני קידודים יכולים להשתמש באותו מספר לשני תוים נבדלים, או להשתמש במספרים שונים לאותו תו. על כל מחשב (ובמיוחד שרתים) לתמוך במספר רב של מערכות קידוד שונות; אולם כל אימת שנתונים עוברים בין מערכות קידוד או פלטפורמות שונות קיים הסיכון שייפגמו.
|
||||
|
||||
יוניקוד משנה את כל זה!
|
||||
יוניקוד מקצה מספר ייחודי לכל תו, ללא תלות בפלטפורמה, בתוכנית, או בשפה. תקן היוניקוד אומץ על-ידי המובילים בתעשייה כמו Apple, HP, IBM, JustSystem, Microsoft, Oracle, SAP, Sun, Sybase, Unisys ורבים אחרים. יוניקוד נדרש על-ידי תקנים מודרניים כמו XML, Java, ECMAScript (JavaScript), LDAP, CORBA 3.0, WML וכדומה, ומהווה למעשה את היישום הרשמי של תקן ISO/IEC 10646. הוא נתמך על ידי מערכות הפעלה רבות, כל הדפדפנים החדישים, ומוצרים רבים אחרים. הופעת תקן היוניקוד וזמינות הכלים התומכים בו נמנות עם המגמות הכלל-עולמיות החשובות ביותר, אשר מסתמנות לאחרונה בטכנולוגיית התוכנה.
|
||||
|
||||
שילוב יוניקוד ביישומי שרת-לקוח או ביישומים רבי-שכבות ובאתרי אינטרנט מאפשר חיסכון ניכר בעלויות לעומת השימוש בסדרות התווים המסורתיות. הודות ליוניקוד, מוצר תוכנה אחד או אתר יחיד ברשת יכול להרחיב את יעדיו למגוון פלטפורמות, ארצות ושפות ללא צורך בשינויים מרחיקים. יוניקוד מאפשר מעבר נתונים דרך מערכות רבות ושונות מבלי שייפגמו.
|
||||
|
||||
פרטים אודות הקונסורציום של יוניקוד (Unicode Consortium)
|
||||
הקונסורציום של יוניקוד הוא ארגון ללא מטרת רווח שנוסד כדי לפתח, להרחיב ולקדם את השימוש בתקן יוניקוד, אשר מגדיר את ייצוג הטקסט במוצרי תוכנה ותקנים מודרניים. חברים בקונסורציום מגוון רחב של תאגידים וארגונים בתעשיית המחשבים ועיבוד המידע. הקונסורציום ממומן על-ידי דמי-חבר בלבד. החברות בקונסורציום יוניקוד פתוחה לארגונים ולאנשים פרטיים, בכל רחבי העולם, אשר תומכים בתקן יוניקוד ומעוניינים לסייע בהתפתחותו והטמעתו.
|
||||
|
||||
למידע נוסף, ראה מילון מונחים, רשימה חלקית של מוצרים מותאמים ליוניקוד, מבוא טכני ו- חומרי עזר [קישורים באנגלית].
|
||||
|
||||
@SET [[:Hebrew:] [\u05B0-\u05B9\u05BB-\u05BC\u05C1-\u05C2\u2135-\u2138]]
|
154
demos/src/com/ibm/icu/dev/demo/translit/Test_Instructions.html
Normal file
154
demos/src/com/ibm/icu/dev/demo/translit/Test_Instructions.html
Normal file
|
@ -0,0 +1,154 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<meta name="COPYRIGHT" content="Copyright 2006-2007, International Business Machines Corporation and others. All Rights Reserved.">
|
||||
<title>New Transliteration Test Files</title>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#FFFFFF">
|
||||
|
||||
<h2>New Transliteration Test Files</h2>
|
||||
<p>The Test_*.html files show the transliteration of characters for given
|
||||
languages. The sample for each language consists of "What Is Unicode"
|
||||
in Thai, followed by other available text. The text is broken apart into
|
||||
sentences for ease of viewing (note: we know of some problems with the sentence
|
||||
rules for Japanese and Chinese). The left column is the original, and the right
|
||||
is the romanization. The program also converts back to the original script. If
|
||||
there is a discrepancy between the source and the reverse transformation, that
|
||||
is indicated by making the background <font color="#FF0000"><b>red</b></font>
|
||||
from that point on.</p>
|
||||
<blockquote>
|
||||
<p><i><b>Note: </b>If you have some more text that you would like added to the
|
||||
sample, just let me know. I am particularly interested in name lists, since
|
||||
they are the typical source.</i></p>
|
||||
</blockquote>
|
||||
<h3>Standards</h3>
|
||||
<p>The goal is to follow a given standard, such as ISO* or UNGEGN wherever
|
||||
possible. We also need to round-trip, so in some cases, that means adding some
|
||||
additional accent marks to disambiguate characters. And often the source
|
||||
standards are missing some characters, such as characters with combining Hamzas
|
||||
in Arabic. Remember that the goal for these is transliteration (unambiguously
|
||||
representing all the letters in the original), not transcription (representing
|
||||
the best pronunciation).</p>
|
||||
<ul>
|
||||
<li><b><a href="Test_Thai-Latin.html">Thai</a>:</b> ISO 11940 < <a href="http://homepage.mac.com/sirbinks/pdf/Thai.r2.pdf">http://homepage.mac.com/sirbinks/pdf/Thai.r2.pdf</a>
|
||||
> plus a few items:
|
||||
<ul>
|
||||
<li>Accents may be added to the Latin for disambiguation.</li>
|
||||
<li>In the next release, we'd like to do the UNGEGN version < <a href="http://www.eki.ee/wgrs/rom1_th.pdf">http://www.eki.ee/wgrs/rom1_th.pdf</a>
|
||||
> which is probably more useful (and readable), and follows more
|
||||
closely the Thai standard.</li>
|
||||
<li>Spaces are provided at word-breaks, using the Thai BreakIterator.</li>
|
||||
<li>An inherent vowel (ọ) is added, as in UNGEGN. The dot is for
|
||||
disambiguation.
|
||||
<ul>
|
||||
<li><i>Note: if the inherent vowel positions cannot be algorithmically
|
||||
determined, let me know and I will remove them.</i></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><b><a href="Test_Arabic-Latin.html">Arabic</a>: </b>Generally follows
|
||||
UNGEGN < <a href="http://www.eki.ee/wgrs/rom1_ar.pdf">http://www.eki.ee/wgrs/rom1_ar.pdf</a>
|
||||
>
|
||||
<ul>
|
||||
<li>Accents may be added to the Latin for disambiguation.</li>
|
||||
<li>Occasionally deviates in the direction of ISO 233 < <a href="http://homepage.mac.com/sirbinks/pdf/Arabic.pdf">http://homepage.mac.com/sirbinks/pdf/Arabic.pdf</a>
|
||||
>
|
||||
<ul>
|
||||
<li>with underdot instead of cedilla for letter like SAD, since those
|
||||
are explicitly in Unicode for transliteration of Arabic</li>
|
||||
<li>adding extra non-Arabic-language letters, like PEH. Note: not all
|
||||
extended Arabic characters are handled yet.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Does <i>not</i> do assimilation of "al", nor hyphenation of
|
||||
it.
|
||||
<ul>
|
||||
<li>While it could be done, we need to determine whether a prefix
|
||||
"al" could occur other than as the definite article (since
|
||||
no space is used).</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>This is transliteration. For <i>transcription</i> one would want an
|
||||
engine that added points appropriately to the Hebrew.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><b><a href="Test_Hebrew-Latin.html">Hebrew</a></b><b>: </b>Generally
|
||||
follows UNGEGN < <a href="http://www.eki.ee/wgrs/rom1_he.pdf">http://www.eki.ee/wgrs/rom1_he.pdf</a>
|
||||
>, with some exceptions:
|
||||
<ul>
|
||||
<li>Accents may be added to the Latin for disambiguation.</li>
|
||||
<li>Combinations of dagesh, shin/sin dot that would produce different
|
||||
letters are not yet called out.</li>
|
||||
<li>Note that the final forms are not preserved. Thus, when going from
|
||||
Latin to Hebrew, a character is given final form depending on its
|
||||
position.
|
||||
<ul>
|
||||
<li>E.g. מםמם => mmmm =>
|
||||
מממם</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>This is transliteration. For <i>transcription</i> one would want an
|
||||
engine that added points appropriately to the Hebrew.</li>
|
||||
<li>See also < <a href="http://homepage.mac.com/sirbinks/pdf/Hebrew.r1.pdf">http://homepage.mac.com/sirbinks/pdf/Hebrew.r1.pdf</a>
|
||||
> for the ISO version. The Chicago Manual of Style has a clear table
|
||||
of mappings for the vowel marks.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><b><a href="Test_Han-Latin.html">Han</a>:</b> Uses the <a href="http://www.mandarintools.com/cedict.html">CEDICT</a>
|
||||
data plus Unicode Unihan <i>kMandarin</i> values for pinyin. Doesn't
|
||||
roundtrip!
|
||||
<ul>
|
||||
<li><i>Note: </i>the Chinese pronunciation of Han characters varies by
|
||||
context and grammar, though nowhere near as much a Japanese.
|
||||
<ul>
|
||||
<li>Ideally we'd have an underlying engine for this. In 2.4 we will
|
||||
have a plug-in interface so that people could add one, such as the
|
||||
IBM engine.</li>
|
||||
<li>The data from CEDICT and Unihan don't list the most frequent
|
||||
choice first, so we will be updating that.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="Test_Greek-Latin_UNGEGN.html"><b>Greek/UNGEGN</b></a>: Uses a
|
||||
modern Greek transliteration, based on the UNGEGN rules at < <a href="http://www.eki.ee/wgrs/rom1_el.pdf">http://www.eki.ee/wgrs/rom1_el.pdf</a>
|
||||
>. This version will not roundtrip ancient Greek.</li>
|
||||
<li><a href="Test_Greek-Latin.html"><b>Greek</b></a>: Uses a classic Greek
|
||||
transliteration. This version will not roundtrip modern Greek.</li>
|
||||
</ul>
|
||||
<h3><b>Notes</b></h3>
|
||||
<ol>
|
||||
<li>For readability, the files have a few other things besides just the
|
||||
transliteration:
|
||||
<ul>
|
||||
<li>The first word of the sentences are titlecased, as are names (where we
|
||||
have a name-list, such as in Thai).</li>
|
||||
<li>The Latin in the original is mapped to the private-use zone before
|
||||
conversion, and then again after conversion. This does have the downside
|
||||
that any rules (such as in Han) that need to know the context (e.g. for
|
||||
inserting spaces or capitalization) will gum up a little bit. This is
|
||||
just an artifact of the test display.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>I don't think that ISO 11940 is a particularly good way to romanize, but
|
||||
it is at least complete and a standard. So what I am interested in just for
|
||||
now is whether the samples in the file follow it (with the above
|
||||
exceptions).</li>
|
||||
<li>Some of the files also have a set of characters at the end, one character
|
||||
per row, with a following row listing the hex and name.</li>
|
||||
<li>The source rules for all of these is in the following URL. So if you want
|
||||
to know the details of how the characters are handled, that is the place to
|
||||
look.
|
||||
<ul>
|
||||
<li><a href="http://source.icu-project.org/repos/icu/icu/trunk/source/data/translit/">http://source.icu-project.org/repos/icu/icu/trunk/source/data/translit/</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
69
demos/src/com/ibm/icu/dev/demo/translit/Test_Thai-Latin.txt
Normal file
69
demos/src/com/ibm/icu/dev/demo/translit/Test_Thai-Latin.txt
Normal file
|
@ -0,0 +1,69 @@
|
|||
#--------------------------------------------------------------------
|
||||
# Copyright (c) 1999-2004, International Business Machines
|
||||
# Corporation and others. All Rights Reserved.
|
||||
#--------------------------------------------------------------------
|
||||
@UPPERFILTER@
|
||||
Unicode คืออะไร?
|
||||
Unicode กำหนดหมายเลขเฉพาะสำหรับทุกอักขระ
|
||||
โดยไม่สนใจว่าเป็นแพล็ตฟอร์มใด
|
||||
ไม่ขึ้นกับว่าจะเป็นโปรแกรมใด
|
||||
และไม่ว่าจะเป็นภาษาใด
|
||||
|
||||
โดยพื้นฐานแล้ว, คอมพิวเตอร์จะเกี่ยวข้องกับเรื่องของตัวเลข. คอมพิวเตอร์จัดเก็บตัวอักษรและอักขระอื่นๆ โดยการกำหนดหมายเลขให้สำหรับแต่ละตัว. ก่อนหน้าที่๊ Unicode จะถูกสร้างขึ้น, ได้มีระบบ encoding อยู่หลายร้อยระบบสำหรับการกำหนดหมายเลขเหล่านี้. ไม่มี encoding ใดที่มีจำนวนตัวอักขระมากเพียงพอ: ยกตัวอย่างเช่น, เฉพาะในกลุ่มสหภาพยุโรปเพียงแห่งเดียว ก็ต้องการหลาย encoding ในการครอบคลุมทุกภาษาในกลุ่ม. หรือแม้แต่ในภาษาเดี่ยว เช่น ภาษาอังกฤษ ก็ไม่มี encoding ใดที่เพียงพอสำหรับทุกตัวอักษร, เครื่องหมายวรรคตอน และสัญลักษณ์ทางเทคนิคที่ใช้กันอยู่ทั่วไป.
|
||||
|
||||
ระบบ encoding เหล่านี้ยังขัดแย้งซึ่งกันและกัน. นั่นก็คือ, ในสอง encoding สามารถใช้หมายเลขเดียวกันสำหรับตัวอักขระสองตัวที่แตกต่างกัน,หรือใช้หมายเลขต่างกันสำหรับอักขระตัวเดียวกัน. ในระบบคอมพิวเตอร์ (โดยเฉพาะเซิร์ฟเวอร์) ต้องมีการสนับสนุนหลาย encoding; และเมื่อข้อมูลที่ผ่านไปมาระหว่างการเข้ารหัสหรือแพล็ตฟอร์มที่ต่างกัน, ข้อมูลนั้นจะเสี่ยงต่อการผิดพลาดเสียหาย.
|
||||
|
||||
Unicode จะเปลี่ยนแปลงสิ่งเหล่านั้นทั้งหมด!
|
||||
Unicode กำหนดหมายเลขเฉพาะสำหรับแต่ละอักขระ, โดยไม่สนใจว่าเป็นแพล็ตฟอร์มใด, ไม่ขึ้นกับว่าจะเป็นโปรแกรมใดและไม่ว่าจะเป็นภาษาใด. มาตรฐาน Unicode ได้ถูกนำไปใช้โดยผู้นำในอุตสาหกรรม เช่น Apple, HP, IBM, JustSystem, Microsoft, Oracle, SAP, Sun, Sybase, Unisys และอื่นๆ อีกมาก. Unicode เป็นสิ่งที่จำเป็นสำหรับมาตรฐานใหม่ๆ เช่น XML, Java, ECMAScript (JavaScript), LDAP, CORBA 3.0, WML ฯลฯ., และเป็นแนวทางอย่างเป็นทางการในการทำ ISO/IEC 10646. Unicode ได้รับการสนับสนุนในระบบปฏิบัติการจำนวนมาก, บราวเซอร์ใหม่ๆ ทกตัว, และผลิตภัณฑ์อื่นๆ อีกมาก. การเกิดขึ้นของ Unicode Standard และทูลส์ต่างๆ ที่มีในการสนับสนุน Unicode, เป็นหนึ่งในแนวโน้มทางเทคโนโลยีซอฟต์แวร์ระดับโลกที่มีความสำคัญที่สุด.
|
||||
|
||||
การรวม Unicode เข้าไปในระบบไคลเอ็นต์-เซิร์ฟเวอร์ หรือแอ็พพลิเคชันแบบ multi-tiered และเว็บไซต์ จะทำให้เกิดการประหยัดค่าใช้จ่ายมากกว่าการใช้ชุดอักขระแบบเดิม. Unicode ทำให้ผลิตภัณฑ์ซอฟต์แวร์หนึ่งเดียว หรือเว็บไซต์แห่งเดียว รองรับได้หลายแพล็ตฟอร์ม, หลายภาษาและหลายประเทศโดยไม่ต้องทำการรื้อปรับระบบ. Unicode ยังทำให้ข้อมูลสามารถเคลื่อนย้ายไปมาในหลายๆ ระบบโดยไม่เกิดความผิดพลาดเสียหาย.
|
||||
|
||||
เกี่ยวกับ Unicode Consortium
|
||||
Unicode Consortium เป็นองค์กรไม่แสวงหากำไรที่ก่อตั้งขึ้นเพื่อพัฒนา, ขยายและส่งเสริมการใช้ Unicode Standard, ซึ่งกำหนดรูปแบบการแทนค่าของข้อความในผลิตภัณฑ์ซอฟต์แวร์และมาตรฐานใหม่ๆ. สมาชิกของสมาคมเป็นตัวแทนจากบริษัทและองค์กรในอุตสาหกรรมคอมพิวเตอร์และการประมวลผลสารสนเทศ. สมาคมได้รับการสนับสนุนทางการเงินผ่านทางค่าธรรมเนียมของการเป็นสมาชิกเท่านั้น. สมาชิกภาพของ Unicode Consortium เปิดกว้างสำหรับองค์กรหรือบุคคลใดๆ ในโลกที่ต้องการสนับสนุน Unicode Standard และช่วยเหลือการขยายตัวและการนำ Unicode ไปใช้งาน.
|
||||
|
||||
สำหรับข้อมูลเพิ่มเติม, ให้ดูที่ Glossary, Sample Unicode-Enabled Products, Technical Introduction และ Useful Resources.
|
||||
|
||||
เป็นมนุษย์สุดประเสริฐเลิศคุณค่า
|
||||
กว่าบรรดาฝูงสัตว์เดรัจฉาน
|
||||
จงฝ่าฟันพัฒนาวิชาการ
|
||||
อย่าล้างผลาญฤๅเข่นฆ่าบีฑาใคร
|
||||
ไม่ถือโทษโกรธแช่งซัดฮึดฮัดด่า
|
||||
หัดอภัยเหมือนกีฬาอัชฌาสัย
|
||||
ปฏิบัติประพฤติกฎกำหนดใจ
|
||||
พูดจาให้จ๊ะ ๆ จ๋า ๆ น่าฟังเอยฯ
|
||||
|
||||
แหล่งที่มา : สมาคมคอมพิวเตอร์แห่งประเทศไทย
|
||||
|
||||
ฅนฃวด kho khuat and kho khon
|
||||
@TITLECASE@
|
||||
ก๊กเฮง แซ่แต้
|
||||
กชกร ศราทธทัต
|
||||
กติกา อังคสุภณ
|
||||
กนก ธรรมประทีป
|
||||
กนก วงศ์ทองศรี
|
||||
กนกกร ช้างเย็นฉ่ำ
|
||||
กนกฉัตร์ ถาวรนันท์
|
||||
กนกนวล โปษยะนันทน์
|
||||
กนกพร คมคาย
|
||||
กนกพร ตีรเลิศพานิช
|
||||
กนกพร พันทร
|
||||
กนกพร ศรีบัณฑิต
|
||||
กนกพร อติวรรณาพัฒน์
|
||||
กนกพรรณ ศรีวนาภิรมย์
|
||||
กนกรัตน์ เกียรติยิ่งอังศุลี
|
||||
กนกรัตน์ สุธรรมพิทักษ์
|
||||
กนกวรรณ คงคาประเสริฐ
|
||||
กนกวรรณ แซ่เตียว
|
||||
กนกวรรณ บุญประเสริฐ
|
||||
กนกวรรณ รักทรัพย์
|
||||
กนกวรรณ สัจจพงษ์
|
||||
กนกวรรณ อุ้ยวงศ์ไพศาล
|
||||
กนกศักดิ์ ยิ่งยง
|
||||
กนกแก้ว กรสมิต
|
||||
กนิษฐา ทนุถนอมราษฎร์
|
||||
กนิษฐา หวังวิบูลย์กิจ
|
||||
กมล กาญจนโรจน์
|
||||
กมล คัมภีร์
|
||||
กมล เจตน์มงคลรัตน์
|
||||
กมล ชูตระกูลธรรม
|
||||
@SET [[:thai:] \u0E01-\u0E3A\u0E40-\u0E5B]
|
|
@ -0,0 +1,257 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.translit;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import com.ibm.icu.dev.demo.impl.DumbTextComponent;
|
||||
import com.ibm.icu.text.ReplaceableString;
|
||||
import com.ibm.icu.text.Transliterator;
|
||||
|
||||
/**
|
||||
* A subclass of {@link DumbTextComponent} that passes key events through
|
||||
* a {@link com.ibm.icu.text.Transliterator}.
|
||||
*
|
||||
* @author Alan Liu
|
||||
*/
|
||||
public class TransliteratingTextComponent extends DumbTextComponent {
|
||||
|
||||
/**
|
||||
* For serialization
|
||||
*/
|
||||
private static final long serialVersionUID = -8672128213174154047L;
|
||||
|
||||
private static boolean DEBUG = false;
|
||||
|
||||
private Transliterator translit = null;
|
||||
|
||||
// NOTE: DISABLE THE START AND CURSOR UNTIL WE CAN GET IT TO WORK AT ALL
|
||||
|
||||
// Index into getText() where the start of transliteration is.
|
||||
// As we commit text during transliteration, we advance
|
||||
// this.
|
||||
//private int start = 0;
|
||||
|
||||
// Index into getText() where the cursor is; cursor >= start
|
||||
//private int cursor = 0;
|
||||
|
||||
// private static final String COPYRIGHT =
|
||||
// "\u00A9 IBM Corporation 1999. All rights reserved.";
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public TransliteratingTextComponent() {
|
||||
super();
|
||||
/*
|
||||
addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// We get an ActionEvent only when the selection changes
|
||||
resetTransliterationStart();
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link DumbTextComponent} API. Framework method that is called
|
||||
* when a <code>KeyEvent</code> is received. This implementation
|
||||
* runs the new character through the current
|
||||
* <code>Transliterator</code>, if one is set, and inserts the
|
||||
* transliterated text into the buffer.
|
||||
*/
|
||||
protected void handleKeyTyped(KeyEvent e) {
|
||||
char ch = e.getKeyChar();
|
||||
|
||||
if (translit == null) {
|
||||
setKeyStart(-1);
|
||||
super.handleKeyTyped(e);
|
||||
return;
|
||||
}
|
||||
|
||||
transliterate(ch, false);
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
if (translit != null) transliterate('\uFFFF', true);
|
||||
}
|
||||
|
||||
|
||||
protected void transliterate(char ch, boolean flush) {
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// The following case motivates the two lines that recompute
|
||||
// start and cursor below.
|
||||
|
||||
// " "
|
||||
// a b c q r|s t u m m
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
// 0 1 2
|
||||
|
||||
// start 3, cursor 5, sel 6 -> { 0, 3, 2 }
|
||||
// : new int[] { 0, sel - start, cursor - start };
|
||||
|
||||
// sz>99|9
|
||||
|
||||
// " { "
|
||||
// a b c q r 9 9|9 t u m m
|
||||
// 0 1 2 3 4 5 6 7 8 9 a b
|
||||
// 0 1 2 3 4
|
||||
|
||||
// { 3, 5, 4 } -> start 6, cursor 7, sel 8
|
||||
// : start += index[0];
|
||||
// : cursor = start + index[2] - index[0];
|
||||
// ------------------------------------------------------------
|
||||
|
||||
// Need to save start because calls to replaceRange will update
|
||||
// start and cursor.
|
||||
//int saveStart = start;
|
||||
|
||||
int end = flush ? getSelectionEnd() : getSelectionStart();
|
||||
String sourceText = getText().substring(0,end);
|
||||
ReplaceableString buf = new ReplaceableString(sourceText);
|
||||
/*buf.replace(0, 1, getText().substring(start,
|
||||
getSelectionStart()));*/
|
||||
|
||||
Transliterator.Position index = new Transliterator.Position();
|
||||
index.contextLimit = buf.length();
|
||||
index.contextStart = 0;
|
||||
index.start = getKeyStart();
|
||||
if (index.start == -1) index.start = getSelectionStart();
|
||||
index.limit = buf.length();
|
||||
|
||||
// StringBuffer log = null;
|
||||
if (DEBUG) {
|
||||
System.out.println("Transliterator: " + translit.getID());
|
||||
System.out.println("From:\t" + '"' + buf.toString() + '"'
|
||||
+ "; {cs: " + index.contextStart
|
||||
+ ", s: " + index.start
|
||||
+ ", l: " + index.limit
|
||||
+ ", cl: " + index.contextLimit
|
||||
+ "}" + "; '" + ch + "'"
|
||||
+ " " + getKeyStart()
|
||||
);
|
||||
}
|
||||
|
||||
if (flush) {
|
||||
translit.finishTransliteration(buf, index);
|
||||
} else {
|
||||
translit.transliterate(buf, index, ch);
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
System.out.println("To:\t" + '"' + buf.toString() + '"'
|
||||
+ "; {cs: " + index.contextStart
|
||||
+ ", s: " + index.start
|
||||
+ ", l: " + index.limit
|
||||
+ ", cl: " + index.contextLimit
|
||||
+ "}"
|
||||
);
|
||||
System.out.println();
|
||||
}
|
||||
/*
|
||||
buf.replace(buf.length(), buf.length(), String.valueOf(ch));
|
||||
translit.transliterate(buf);
|
||||
*/
|
||||
|
||||
String result = buf.toString();
|
||||
//if (result.equals(sourceText + ch)) return;
|
||||
|
||||
replaceRange(result, 0, getSelectionEnd());
|
||||
setKeyStart(index.start);
|
||||
|
||||
// At this point start has been changed by the callback to
|
||||
// resetTransliteratorStart() via replaceRange() -- so use our
|
||||
// local copy, saveStart.
|
||||
|
||||
// The START index is zero-based. On entry to transliterate(),
|
||||
// it was zero. We can therefore just add it to our original
|
||||
// getText()-based index value of start (in saveStart) to get
|
||||
// the new getText()-based start.
|
||||
// start = saveStart + index.contextStart;
|
||||
|
||||
// Make the cursor getText()-based. The CURSOR index is zero-based.
|
||||
// cursor = start + index.start - index.contextStart;
|
||||
|
||||
/*
|
||||
if (DEBUG) {
|
||||
String out = buf.toString();
|
||||
log.append(out.substring(0, index.contextStart)).
|
||||
append('{').
|
||||
append(out.substring(index.contextStart, index.start)).
|
||||
append('|').
|
||||
append(out.substring(index.start)).
|
||||
append('"');
|
||||
log.append(", {" + index.contextStart + ", " + index.contextLimit + ", " + index.start + "}, ");
|
||||
// log.append("start " + start + ", cursor " + cursor);
|
||||
log.append(", sel " + getSelectionStart());
|
||||
System.out.println(escape(log.toString()));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link com.ibm.icu.text.Transliterator} and direction to
|
||||
* use to process incoming <code>KeyEvent</code>s.
|
||||
* @param t the {@link com.ibm.icu.text.Transliterator} to use
|
||||
*/
|
||||
public void setTransliterator(Transliterator t) {
|
||||
/*
|
||||
if (translit != t) { // [sic] pointer compare ok; singletons
|
||||
resetTransliterationStart();
|
||||
}
|
||||
*/
|
||||
translit = t;
|
||||
}
|
||||
|
||||
public Transliterator getTransliterator() {
|
||||
return translit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the start point at which transliteration begins. This
|
||||
* needs to be done when the user moves the cursor or when the
|
||||
* current {@link com.ibm.icu.text.Transliterator} is changed.
|
||||
*/
|
||||
/*
|
||||
private void resetTransliterationStart() {
|
||||
start = getSelectionStart();
|
||||
cursor = start;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Escape non-ASCII characters as Unicode.
|
||||
* JUST FOR DEBUGGING OUTPUT.
|
||||
*/
|
||||
public static final String escape(String s) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (int i=0; i<s.length(); ++i) {
|
||||
char c = s.charAt(i);
|
||||
if (c >= ' ' && c <= 0x007F) {
|
||||
if (c == '\\') {
|
||||
buf.append("\\\\"); // That is, "\\"
|
||||
} else {
|
||||
buf.append(c);
|
||||
}
|
||||
} else {
|
||||
buf.append("\\u");
|
||||
if (c < 0x1000) {
|
||||
buf.append('0');
|
||||
if (c < 0x100) {
|
||||
buf.append('0');
|
||||
if (c < 0x10) {
|
||||
buf.append('0');
|
||||
}
|
||||
}
|
||||
}
|
||||
buf.append(Integer.toHexString(c));
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,294 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.demo.translit;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.lang.UCharacter;
|
||||
import com.ibm.icu.lang.UScript;
|
||||
import com.ibm.icu.text.Normalizer;
|
||||
import com.ibm.icu.text.Transliterator;
|
||||
import com.ibm.icu.text.UTF16;
|
||||
import com.ibm.icu.text.UnicodeSet;
|
||||
import com.ibm.icu.text.UnicodeSetIterator;
|
||||
|
||||
public class TransliterationChart {
|
||||
public static void main(String[] args) throws IOException {
|
||||
System.out.println("Start");
|
||||
UnicodeSet lengthMarks = new UnicodeSet("[\u09D7\u0B56-\u0B57\u0BD7\u0C56\u0CD5-\u0CD6\u0D57\u0C55\u0CD5]");
|
||||
int[] indicScripts = {
|
||||
UScript.LATIN,
|
||||
UScript.DEVANAGARI,
|
||||
UScript.BENGALI,
|
||||
UScript.GURMUKHI,
|
||||
UScript.GUJARATI,
|
||||
UScript.ORIYA,
|
||||
UScript.TAMIL,
|
||||
UScript.TELUGU,
|
||||
UScript.KANNADA,
|
||||
UScript.MALAYALAM,
|
||||
};
|
||||
String[] names = new String[indicScripts.length];
|
||||
UnicodeSet[] sets = new UnicodeSet[indicScripts.length];
|
||||
Transliterator[] fallbacks = new Transliterator[indicScripts.length];
|
||||
for (int i = 0; i < indicScripts.length; ++i) {
|
||||
names[i] = UScript.getName(indicScripts[i]);
|
||||
sets[i] = new UnicodeSet("[[:" + names[i] + ":]&[[:L:][:M:]]&[:age=3.1:]]");
|
||||
fallbacks[i] = Transliterator.getInstance("any-" + names[i]);
|
||||
}
|
||||
EquivClass eq = new EquivClass(new ReverseComparator());
|
||||
PrintWriter pw = openPrintWriter("transChart.html");
|
||||
pw.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
|
||||
pw.println("<title>Indic Transliteration Chart</title><style>");
|
||||
pw.println("td { text-align: Center; font-size: 200% }");
|
||||
pw.println("tt { font-size: 50% }");
|
||||
pw.println("td.miss { background-color: #CCCCFF }");
|
||||
pw.println("</style></head><body bgcolor='#FFFFFF'>");
|
||||
|
||||
Transliterator anyToLatin = Transliterator.getInstance("any-latin");
|
||||
|
||||
String testString = "\u0946\u093E";
|
||||
|
||||
UnicodeSet failNorm = new UnicodeSet();
|
||||
Set latinFail = new TreeSet();
|
||||
|
||||
for (int i = 0; i < indicScripts.length; ++i) {
|
||||
if (indicScripts[i] == UScript.LATIN) continue;
|
||||
String source = names[i];
|
||||
System.out.println(source);
|
||||
UnicodeSet sourceChars = sets[i];
|
||||
|
||||
for (int j = 0; j < indicScripts.length; ++j) {
|
||||
if (i == j) continue;
|
||||
String target = names[j];
|
||||
Transliterator forward = Transliterator.getInstance(source + '-' + target);
|
||||
Transliterator backward = forward.getInverse();
|
||||
UnicodeSetIterator it = new UnicodeSetIterator(sourceChars);
|
||||
while (it.next()) {
|
||||
if (lengthMarks.contains(it.codepoint)) continue;
|
||||
String s = Normalizer.normalize(it.codepoint,Normalizer.NFC,0);
|
||||
//if (!Normalizer.isNormalized(s,Normalizer.NFC,0)) continue;
|
||||
if (!s.equals(Normalizer.normalize(s,Normalizer.NFD,0))) {
|
||||
failNorm.add(it.codepoint);
|
||||
}
|
||||
String t = fix(forward.transliterate(s));
|
||||
if (t.equals(testString)) {
|
||||
System.out.println("debug");
|
||||
}
|
||||
|
||||
String r = fix(backward.transliterate(t));
|
||||
if (Normalizer.compare(s,r,0) == 0) {
|
||||
if (indicScripts[j] != UScript.LATIN) eq.add(s,t);
|
||||
} else {
|
||||
if (indicScripts[j] == UScript.LATIN) {
|
||||
latinFail.add(s + " - " + t + " - " + r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// collect equivalents
|
||||
pw.println("<table border='1' cellspacing='0'><tr>");
|
||||
for (int i = 0; i < indicScripts.length; ++i) {
|
||||
pw.print("<th width='10%'>" + names[i].substring(0,3) + "</th>");
|
||||
}
|
||||
pw.println("</tr>");
|
||||
|
||||
Iterator rit = eq.getSetIterator(new MyComparator());
|
||||
while(rit.hasNext()) {
|
||||
Set equivs = (Set)rit.next();
|
||||
pw.print("<tr>");
|
||||
Iterator sit = equivs.iterator();
|
||||
String source = (String)sit.next();
|
||||
String item = anyToLatin.transliterate(source);
|
||||
if (item.equals("") || source.equals(item)) item = " ";
|
||||
pw.print("<td>" + item + "</td>");
|
||||
for (int i = 1; i < indicScripts.length; ++i) {
|
||||
sit = equivs.iterator();
|
||||
item = "";
|
||||
while (sit.hasNext()) {
|
||||
String trial = (String)sit.next();
|
||||
if (!sets[i].containsAll(trial)) continue;
|
||||
item = trial;
|
||||
break;
|
||||
}
|
||||
String classString = "";
|
||||
if (item.equals("")) {
|
||||
classString = " class='miss'";
|
||||
String temp = fallbacks[i].transliterate(source);
|
||||
if (!temp.equals("") && !temp.equals(source)) item = temp;
|
||||
}
|
||||
String backup = item.equals("") ? " " : item;
|
||||
pw.print("<td" + classString + " title='" + getName(item, "; ") + "'>"
|
||||
+ backup + "<br><tt>" + Utility.hex(item) + "</tt></td>");
|
||||
}
|
||||
/*
|
||||
Iterator sit = equivs.iterator();
|
||||
while (sit.hasNext()) {
|
||||
String item = (String)sit.next();
|
||||
pw.print("<td>" + item + "</td>");
|
||||
}
|
||||
*/
|
||||
pw.println("</tr>");
|
||||
}
|
||||
pw.println("</table>");
|
||||
if (true) {
|
||||
pw.println("<h2>Failed Normalization</h2>");
|
||||
|
||||
UnicodeSetIterator it = new UnicodeSetIterator(failNorm);
|
||||
UnicodeSet pieces = new UnicodeSet();
|
||||
while (it.next()) {
|
||||
String s = UTF16.valueOf(it.codepoint);
|
||||
String d = Normalizer.normalize(s,Normalizer.NFD,0);
|
||||
pw.println("Norm:" + s + ", " + Utility.hex(s) + " " + UCharacter.getName(it.codepoint)
|
||||
+ "; " + d + ", " + Utility.hex(d) + ", ");
|
||||
pw.println(UCharacter.getName(d.charAt(1)) + "<br>");
|
||||
if (UCharacter.getName(d.charAt(1)).indexOf("LENGTH") >= 0) pieces.add(d.charAt(1));
|
||||
}
|
||||
pw.println(pieces);
|
||||
|
||||
pw.println("<h2>Failed Round-Trip</h2>");
|
||||
Iterator cit = latinFail.iterator();
|
||||
while (cit.hasNext()) {
|
||||
pw.println(cit.next() + "<br>");
|
||||
}
|
||||
}
|
||||
|
||||
pw.println("</table></body></html>");
|
||||
pw.close();
|
||||
System.out.println("Done");
|
||||
}
|
||||
|
||||
public static String fix(String s) {
|
||||
if (s.equals("\u0946\u093E")) return "\u094A";
|
||||
if (s.equals("\u0C46\u0C3E")) return "\u0C4A";
|
||||
if (s.equals("\u0CC6\u0CBE")) return "\u0CCA";
|
||||
|
||||
if (s.equals("\u0947\u093E")) return "\u094B";
|
||||
if (s.equals("\u0A47\u0A3E")) return "\u0A4B";
|
||||
if (s.equals("\u0AC7\u0ABE")) return "\u0ACB";
|
||||
if (s.equals("\u0C47\u0C3E")) return "\u0C4B";
|
||||
if (s.equals("\u0CC7\u0CBE")) return "\u0CCB";
|
||||
|
||||
//return Normalizer.normalize(s,Normalizer.NFD,0);
|
||||
return s;
|
||||
}
|
||||
|
||||
public static PrintWriter openPrintWriter(String fileName) throws IOException {
|
||||
File lf = new File(fileName);
|
||||
System.out.println("Creating file: " + lf.getAbsoluteFile());
|
||||
|
||||
return new PrintWriter(
|
||||
new BufferedWriter(
|
||||
new OutputStreamWriter(
|
||||
new FileOutputStream(fileName), "UTF8"), 4*1024));
|
||||
}
|
||||
|
||||
|
||||
public static String getName(String s, String separator) {
|
||||
int cp;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < s.length(); i += UTF16.getCharCount(cp)) {
|
||||
cp = UTF16.charAt(s,i);
|
||||
if (i != 0) sb.append(separator);
|
||||
sb.append(UCharacter.getName(cp));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static class MyComparator implements Comparator {
|
||||
public int compare(Object o1, Object o2) {
|
||||
Iterator i1 = ((TreeSet) o1).iterator();
|
||||
Iterator i2 = ((TreeSet) o2).iterator();
|
||||
while (i1.hasNext() && i2.hasNext()) {
|
||||
String a = (String)i1.next();
|
||||
String b = (String)i2.next();
|
||||
int result = a.compareTo(b);
|
||||
if (result != 0) return result;
|
||||
}
|
||||
if (i1.hasNext()) return 1;
|
||||
if (i2.hasNext()) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
static class ReverseComparator implements Comparator {
|
||||
public int compare(Object o1, Object o2) {
|
||||
String a = o1.toString();
|
||||
char a1 = a.charAt(0);
|
||||
String b = o2.toString();
|
||||
char b1 = b.charAt(0);
|
||||
if (a1 < 0x900 && b1 > 0x900) return -1;
|
||||
if (a1 > 0x900 && b1 < 0x900) return +1;
|
||||
return a.compareTo(b);
|
||||
}
|
||||
}
|
||||
|
||||
static class EquivClass {
|
||||
EquivClass(Comparator c) {
|
||||
comparator = c;
|
||||
}
|
||||
private HashMap itemToSet = new HashMap();
|
||||
private Comparator comparator;
|
||||
|
||||
void add(Object a, Object b) {
|
||||
Set sa = (Set)itemToSet.get(a);
|
||||
Set sb = (Set)itemToSet.get(b);
|
||||
if (sa == null && sb == null) { // new set!
|
||||
Set s = new TreeSet(comparator);
|
||||
s.add(a);
|
||||
s.add(b);
|
||||
itemToSet.put(a, s);
|
||||
itemToSet.put(b, s);
|
||||
} else if (sa == null) {
|
||||
sb.add(a);
|
||||
} else if (sb == null) {
|
||||
sa.add(b);
|
||||
} else { // merge sets, dumping sb
|
||||
sa.addAll(sb);
|
||||
Iterator it = sb.iterator();
|
||||
while (it.hasNext()) {
|
||||
itemToSet.put(it.next(), sa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MyIterator implements Iterator {
|
||||
private Iterator it;
|
||||
MyIterator (Comparator comp) {
|
||||
TreeSet values = new TreeSet(comp);
|
||||
values.addAll(itemToSet.values());
|
||||
it = values.iterator();
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return it.hasNext();
|
||||
}
|
||||
public Object next() {
|
||||
return it.next();
|
||||
}
|
||||
public void remove() {
|
||||
throw new IllegalArgumentException("can't remove");
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator getSetIterator (Comparator comp) {
|
||||
return new MyIterator(comp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
13
demos/src/com/ibm/icu/dev/demo/translit/demo.bat
Executable file
13
demos/src/com/ibm/icu/dev/demo/translit/demo.bat
Executable file
|
@ -0,0 +1,13 @@
|
|||
REM /*
|
||||
REM *******************************************************************************
|
||||
REM * Copyright (C) 1996-2004, International Business Machines Corporation and *
|
||||
REM * others. All Rights Reserved. *
|
||||
REM *******************************************************************************
|
||||
REM */
|
||||
REM For best results, run the demo as an applet inside of Netscape
|
||||
REM with Bitstream Cyberbit installed.
|
||||
|
||||
REM setup your JDK 1.1.x path and classpath here:
|
||||
call JDK11
|
||||
set CLASSPATH=../translit.jar;%CLASSPATH%
|
||||
javaw Demo
|
34
demos/src/com/ibm/icu/dev/demo/translit/demo.html
Normal file
34
demos/src/com/ibm/icu/dev/demo/translit/demo.html
Normal file
|
@ -0,0 +1,34 @@
|
|||
<!--
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1999-2004, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Transliteration Demo</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<APPLET CODE="com.ibm.demo.translit.DemoApplet.class" WIDTH=140 HEIGHT=33></APPLET>
|
||||
|
||||
<HR>
|
||||
|
||||
If you don't see a button above, then your browser is failing to
|
||||
locate the necessary Java class files.
|
||||
|
||||
<P>
|
||||
|
||||
One way to make this work is to copy this HTML file to
|
||||
<code>icu4j/src</code>, and make sure the Java files in the directories
|
||||
under <code>icu4j/src/com</code> are built. Then open this HTML file
|
||||
using a browser or appletviewer.
|
||||
|
||||
<P>
|
||||
|
||||
For best results, run this demo as an applet within Netscape with
|
||||
Bitstream Cyberbit installed.
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
12
demos/src/com/ibm/icu/dev/demo/translit/package.html
Normal file
12
demos/src/com/ibm/icu/dev/demo/translit/package.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Copyright (C) 2000-2004, International Business Machines Corporation and
|
||||
others. All Rights Reserved.
|
||||
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
Transliterator demo appliation.
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
55
demos/src/com/ibm/icu/dev/demo/translit/thai_test.txt
Normal file
55
demos/src/com/ibm/icu/dev/demo/translit/thai_test.txt
Normal file
|
@ -0,0 +1,55 @@
|
|||
#--------------------------------------------------------------------
|
||||
# Copyright (c) 1999-2004, International Business Machines
|
||||
# Corporation and others. All Rights Reserved.
|
||||
#--------------------------------------------------------------------
|
||||
@UPPERFILTER@
|
||||
Unicode คืออะไร?
|
||||
Unicode กำหนดหมายเลขเฉพาะสำหรับทุกอักขระ
|
||||
โดยไม่สนใจว่าเป็นแพล็ตฟอร์มใด
|
||||
ไม่ขึ้นกับว่าจะเป็นโปรแกรมใด
|
||||
และไม่ว่าจะเป็นภาษาใด
|
||||
|
||||
โดยพื้นฐานแล้ว, คอมพิวเตอร์จะเกี่ยวข้องกับเรื่องของตัวเลข. คอมพิวเตอร์จัดเก็บตัวอักษรและอักขระอื่นๆ โดยการกำหนดหมายเลขให้สำหรับแต่ละตัว. ก่อนหน้าที่๊ Unicode จะถูกสร้างขึ้น, ได้มีระบบ encoding อยู่หลายร้อยระบบสำหรับการกำหนดหมายเลขเหล่านี้. ไม่มี encoding ใดที่มีจำนวนตัวอักขระมากเพียงพอ: ยกตัวอย่างเช่น, เฉพาะในกลุ่มสหภาพยุโรปเพียงแห่งเดียว ก็ต้องการหลาย encoding ในการครอบคลุมทุกภาษาในกลุ่ม. หรือแม้แต่ในภาษาเดี่ยว เช่น ภาษาอังกฤษ ก็ไม่มี encoding ใดที่เพียงพอสำหรับทุกตัวอักษร, เครื่องหมายวรรคตอน และสัญลักษณ์ทางเทคนิคที่ใช้กันอยู่ทั่วไป.
|
||||
|
||||
ระบบ encoding เหล่านี้ยังขัดแย้งซึ่งกันและกัน. นั่นก็คือ, ในสอง encoding สามารถใช้หมายเลขเดียวกันสำหรับตัวอักขระสองตัวที่แตกต่างกัน,หรือใช้หมายเลขต่างกันสำหรับอักขระตัวเดียวกัน. ในระบบคอมพิวเตอร์ (โดยเฉพาะเซิร์ฟเวอร์) ต้องมีการสนับสนุนหลาย encoding; และเมื่อข้อมูลที่ผ่านไปมาระหว่างการเข้ารหัสหรือแพล็ตฟอร์มที่ต่างกัน, ข้อมูลนั้นจะเสี่ยงต่อการผิดพลาดเสียหาย.
|
||||
|
||||
Unicode จะเปลี่ยนแปลงสิ่งเหล่านั้นทั้งหมด!
|
||||
Unicode กำหนดหมายเลขเฉพาะสำหรับแต่ละอักขระ, โดยไม่สนใจว่าเป็นแพล็ตฟอร์มใด, ไม่ขึ้นกับว่าจะเป็นโปรแกรมใดและไม่ว่าจะเป็นภาษาใด. มาตรฐาน Unicode ได้ถูกนำไปใช้โดยผู้นำในอุตสาหกรรม เช่น Apple, HP, IBM, JustSystem, Microsoft, Oracle, SAP, Sun, Sybase, Unisys และอื่นๆ อีกมาก. Unicode เป็นสิ่งที่จำเป็นสำหรับมาตรฐานใหม่ๆ เช่น XML, Java, ECMAScript (JavaScript), LDAP, CORBA 3.0, WML ฯลฯ., และเป็นแนวทางอย่างเป็นทางการในการทำ ISO/IEC 10646. Unicode ได้รับการสนับสนุนในระบบปฏิบัติการจำนวนมาก, บราวเซอร์ใหม่ๆ ทกตัว, และผลิตภัณฑ์อื่นๆ อีกมาก. การเกิดขึ้นของ Unicode Standard และทูลส์ต่างๆ ที่มีในการสนับสนุน Unicode, เป็นหนึ่งในแนวโน้มทางเทคโนโลยีซอฟต์แวร์ระดับโลกที่มีความสำคัญที่สุด.
|
||||
|
||||
การรวม Unicode เข้าไปในระบบไคลเอ็นต์-เซิร์ฟเวอร์ หรือแอ็พพลิเคชันแบบ multi-tiered และเว็บไซต์ จะทำให้เกิดการประหยัดค่าใช้จ่ายมากกว่าการใช้ชุดอักขระแบบเดิม. Unicode ทำให้ผลิตภัณฑ์ซอฟต์แวร์หนึ่งเดียว หรือเว็บไซต์แห่งเดียว รองรับได้หลายแพล็ตฟอร์ม, หลายภาษาและหลายประเทศโดยไม่ต้องทำการรื้อปรับระบบ. Unicode ยังทำให้ข้อมูลสามารถเคลื่อนย้ายไปมาในหลายๆ ระบบโดยไม่เกิดความผิดพลาดเสียหาย.
|
||||
|
||||
เกี่ยวกับ Unicode Consortium
|
||||
Unicode Consortium เป็นองค์กรไม่แสวงหากำไรที่ก่อตั้งขึ้นเพื่อพัฒนา, ขยายและส่งเสริมการใช้ Unicode Standard, ซึ่งกำหนดรูปแบบการแทนค่าของข้อความในผลิตภัณฑ์ซอฟต์แวร์และมาตรฐานใหม่ๆ. สมาชิกของสมาคมเป็นตัวแทนจากบริษัทและองค์กรในอุตสาหกรรมคอมพิวเตอร์และการประมวลผลสารสนเทศ. สมาคมได้รับการสนับสนุนทางการเงินผ่านทางค่าธรรมเนียมของการเป็นสมาชิกเท่านั้น. สมาชิกภาพของ Unicode Consortium เปิดกว้างสำหรับองค์กรหรือบุคคลใดๆ ในโลกที่ต้องการสนับสนุน Unicode Standard และช่วยเหลือการขยายตัวและการนำ Unicode ไปใช้งาน.
|
||||
|
||||
สำหรับข้อมูลเพิ่มเติม, ให้ดูที่ Glossary, Sample Unicode-Enabled Products, Technical Introduction และ Useful Resources.
|
||||
@TITLECASE@
|
||||
ก๊กเฮง แซ่แต้
|
||||
กชกร ศราทธทัต
|
||||
กติกา อังคสุภณ
|
||||
กนก ธรรมประทีป
|
||||
กนก วงศ์ทองศรี
|
||||
กนกกร ช้างเย็นฉ่ำ
|
||||
กนกฉัตร์ ถาวรนันท์
|
||||
กนกนวล โปษยะนันทน์
|
||||
กนกพร คมคาย
|
||||
กนกพร ตีรเลิศพานิช
|
||||
กนกพร พันทร
|
||||
กนกพร ศรีบัณฑิต
|
||||
กนกพร อติวรรณาพัฒน์
|
||||
กนกพรรณ ศรีวนาภิรมย์
|
||||
กนกรัตน์ เกียรติยิ่งอังศุลี
|
||||
กนกรัตน์ สุธรรมพิทักษ์
|
||||
กนกวรรณ คงคาประเสริฐ
|
||||
กนกวรรณ แซ่เตียว
|
||||
กนกวรรณ บุญประเสริฐ
|
||||
กนกวรรณ รักทรัพย์
|
||||
กนกวรรณ สัจจพงษ์
|
||||
กนกวรรณ อุ้ยวงศ์ไพศาล
|
||||
กนกศักดิ์ ยิ่งยง
|
||||
กนกแก้ว กรสมิต
|
||||
กนิษฐา ทนุถนอมราษฎร์
|
||||
กนิษฐา หวังวิบูลย์กิจ
|
||||
กมล กาญจนโรจน์
|
||||
กมล คัมภีร์
|
||||
กมล เจตน์มงคลรัตน์
|
||||
กมล ชูตระกูลธรรม
|
7
eclipse-build/build.properties
Normal file
7
eclipse-build/build.properties
Normal file
|
@ -0,0 +1,7 @@
|
|||
#*******************************************************************************
|
||||
#* Copyright (C) 2010-2011, International Business Machines Corporation and *
|
||||
#* others. All Rights Reserved. *
|
||||
#*******************************************************************************
|
||||
icu4j.plugin.impl.version.string=4.8.0
|
||||
copyright.eclipse=Licensed Materials - Property of IBM \n (C) Copyright IBM Corp. 2000, 2011. All Rights Reserved. \n IBM is a registered trademark of IBM Corp.
|
||||
icu4j.data.version.number=48
|
391
eclipse-build/build.xml
Normal file
391
eclipse-build/build.xml
Normal file
|
@ -0,0 +1,391 @@
|
|||
<!--
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
-->
|
||||
|
||||
<project name="icu4j-eclipse" default="build" basedir=".">
|
||||
<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="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="build-tools" description="Build build-tool classes">
|
||||
<ant dir="${icu4j.build-tools.dir}" inheritAll="false"/>
|
||||
</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="initEclipseHome,initEclipseLauncher,initEclipseOSGiJar,initEclipsePDE"
|
||||
description="Initialize eclipse PDE build environment">
|
||||
<echo message="[PDE build configuration properties]"/>
|
||||
<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}"/>
|
||||
</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="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}"/>
|
||||
</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,build-tools"
|
||||
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>
|
||||
|
||||
<!-- update some source files to change API signatures for backward compatibility support -->
|
||||
<echo message="Updating java source files for eclipse in com.ibm.icu"/>
|
||||
<java classname="com.ibm.icu.dev.tool.docs.CodeMangler"
|
||||
classpath="${icu4j.build-tools.jar}"
|
||||
failonerror="true">
|
||||
<arg line="-dECLIPSE -in ${eclipse.projects.dir}/plugins/com.ibm.icu/src -f @eclipse_mod_classes.txt"/>
|
||||
</java>
|
||||
|
||||
<!-- 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="**/*.cnv"/>
|
||||
<exclude name="**/cnvalias.icu"/>
|
||||
</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.html"
|
||||
todir="${eclipse.projects.dir}/plugins/com.ibm.icu/about_files" />
|
||||
|
||||
<!-- ucd terms -->
|
||||
<copy file="${shared.dir}/licenses/unicode-license.txt"
|
||||
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,build-tools"
|
||||
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>
|
||||
|
||||
<!-- update some source files to change API signatures for backward compatibility support -->
|
||||
<echo message="Updating java source files for eclipse in com.ibm.icu.tests"/>
|
||||
<java classname="com.ibm.icu.dev.tool.docs.CodeMangler"
|
||||
classpath="${icu4j.build-tools.jar}"
|
||||
failonerror="true">
|
||||
<arg line="-dECLIPSE -in ${eclipse.projects.dir}/plugins/com.ibm.icu.tests/src -f @eclipse_mod_test_classes.txt"/>
|
||||
</java>
|
||||
|
||||
<!-- 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.html"
|
||||
todir="${eclipse.projects.dir}/plugins/com.ibm.icu.tests/about_files" />
|
||||
|
||||
<!-- ucd terms -->
|
||||
<copy file="${shared.dir}/licenses/unicode-license.txt"
|
||||
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.html"
|
||||
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.html"
|
||||
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>
|
5
eclipse-build/eclipse_mod_classes.txt
Normal file
5
eclipse-build/eclipse_mod_classes.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Copyright (C) 2011, International Business Machines Corporation and
|
||||
# others. All Rights Reserved.
|
||||
|
||||
com/ibm/icu/lang/UCharacter.java
|
||||
com/ibm/icu/text/DecimalFormat.java
|
7
eclipse-build/eclipse_mod_test_classes.txt
Normal file
7
eclipse-build/eclipse_mod_test_classes.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Copyright (C) 2011, International Business Machines Corporation and
|
||||
# others. All Rights Reserved.
|
||||
|
||||
com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPI.java
|
||||
com/ibm/icu/dev/test/format/NumberFormatTest.java
|
||||
com/ibm/icu/dev/test/serializable/CompatibilityTest.java
|
||||
com/ibm/icu/dev/test/serializable/CoverageTest.java
|
17
eclipse-build/features.template/com.ibm.icu.base/.project
Normal file
17
eclipse-build/features.template/com.ibm.icu.base/.project
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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>
|
|
@ -0,0 +1,20 @@
|
|||
###############################################################################
|
||||
# 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
|
||||
###############################################################################
|
||||
bin.includes =\
|
||||
epl-v10.html,\
|
||||
eclipse_update_120.jpg,\
|
||||
feature.xml,\
|
||||
feature.properties,\
|
||||
license.html
|
||||
outputUpdateJars = true
|
||||
|
||||
generate.plugin@com.ibm.icu.base.source=com.ibm.icu.base
|
||||
|
33
eclipse-build/features.template/com.ibm.icu.base/feature.xml
Normal file
33
eclipse-build/features.template/com.ibm.icu.base/feature.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?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>
|
17
eclipse-build/features.template/com.ibm.icu/.project
Normal file
17
eclipse-build/features.template/com.ibm.icu/.project
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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>
|
20
eclipse-build/features.template/com.ibm.icu/build.properties
Normal file
20
eclipse-build/features.template/com.ibm.icu/build.properties
Normal file
|
@ -0,0 +1,20 @@
|
|||
###############################################################################
|
||||
# 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
|
||||
###############################################################################
|
||||
bin.includes =\
|
||||
epl-v10.html,\
|
||||
eclipse_update_120.jpg,\
|
||||
feature.xml,\
|
||||
feature.properties,\
|
||||
license.html
|
||||
outputUpdateJars = true
|
||||
|
||||
generate.plugin@com.ibm.icu.source=com.ibm.icu
|
||||
|
33
eclipse-build/features.template/com.ibm.icu/feature.xml
Normal file
33
eclipse-build/features.template/com.ibm.icu/feature.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?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>
|
31
eclipse-build/misc/ICUConfig.properties
Normal file
31
eclipse-build/misc/ICUConfig.properties
Normal file
|
@ -0,0 +1,31 @@
|
|||
#*
|
||||
#*******************************************************************************
|
||||
#* 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
|
54
eclipse-build/misc/about_icu.html
Normal file
54
eclipse-build/misc/about_icu.html
Normal file
|
@ -0,0 +1,54 @@
|
|||
<!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=ISO-8859-1"/>
|
||||
<title>About</title>
|
||||
</head>
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>XXXX XX, 2011</p>
|
||||
<h3>License</h3>
|
||||
|
||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
|
||||
indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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 4.8.X.v2011XXXX plug-in</strong> <br/><br/>
|
||||
The plug-in includes software ("ICU4J") developed by International Business Machines
|
||||
Corporation and others.
|
||||
<br/><br/>
|
||||
ICU4J is:
|
||||
<blockquote>
|
||||
Copyright (c) 1995-2011 International Business Machines Corporation and others<br/>
|
||||
All rights reserved.
|
||||
</blockquote>
|
||||
<p>
|
||||
Your use of ICU4J is subject to the terms and conditions of the ICU4J license. A copy of the
|
||||
license is contained in the file <a href="about_files/license.html" target="_blank">about_files/license.html</a>.</p>
|
||||
<p>
|
||||
ICU4J bundles data files imported from the Unicode Character Database and the Locale Data. A copy of the
|
||||
Unicode Data and Software license is contained in the file <a href="about_files/ucdterms.txt"/>about_files/ucdterms.txt</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>
|
51
eclipse-build/misc/about_icu_base.html
Normal file
51
eclipse-build/misc/about_icu_base.html
Normal file
|
@ -0,0 +1,51 @@
|
|||
<!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=ISO-8859-1"/>
|
||||
<title>About</title>
|
||||
</head>
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>XXXX XX, 2011</p>
|
||||
<h3>License</h3>
|
||||
|
||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
|
||||
indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Eclipse Public License Version 1.0 ("EPL"). 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, "Program" 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 ("Redistributor") 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 4.8.X.v2011XXXX base plug-in</strong> <br/><br/>
|
||||
The plug-in includes software ("ICU4J") developed by International Business Machines
|
||||
Corporation and others.
|
||||
<br/><br/>
|
||||
ICU4J is:
|
||||
<blockquote>
|
||||
Copyright (c) 1995-2011 International Business Machines Corporation and others<br/>
|
||||
All rights reserved.
|
||||
</blockquote>
|
||||
<p>
|
||||
Your use of ICU4J is subject to the terms and conditions of the ICU4J license. A copy of the
|
||||
license is contained in the file <a href="about_files/license.html" target="_blank">about_files/license.html</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>
|
28
eclipse-build/pdebuild/allElements.xml
Normal file
28
eclipse-build/pdebuild/allElements.xml
Normal file
|
@ -0,0 +1,28 @@
|
|||
<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>
|
220
eclipse-build/pdebuild/build.properties
Normal file
220
eclipse-build/pdebuild/build.properties
Normal file
|
@ -0,0 +1,220 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2003-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
|
||||
###############################################################################
|
||||
#####################
|
||||
# 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=
|
||||
#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 ISO-8859-1
|
||||
|
||||
# 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.5
|
||||
|
||||
# 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.5
|
||||
|
||||
individualSourceBundles=true
|
161
eclipse-build/pdebuild/customTargets.xml
Normal file
161
eclipse-build/pdebuild/customTargets.xml
Normal file
|
@ -0,0 +1,161 @@
|
|||
<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>
|
|
@ -0,0 +1,7 @@
|
|||
<?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/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1,28 @@
|
|||
<?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>
|
|
@ -0,0 +1,78 @@
|
|||
#Thu Jan 13 17:45:06 EST 2011
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
|
@ -0,0 +1,3 @@
|
|||
#Thu Dec 14 11:51:01 EST 2006
|
||||
eclipse.preferences.version=1
|
||||
internal.default.compliance=default
|
|
@ -0,0 +1,10 @@
|
|||
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: J2SE-1.5
|
|
@ -0,0 +1,17 @@
|
|||
###############################################################################
|
||||
# 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/
|
|
@ -0,0 +1,12 @@
|
|||
###############################################################################
|
||||
# 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
|
|
@ -0,0 +1,359 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,565 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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.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.getWeekendTransition(int)'
|
||||
*/
|
||||
public void testGetWeekendTransition() {
|
||||
Calendar cal = Calendar.getInstance(Locale.US);
|
||||
try {
|
||||
cal.getWeekendTransition(Calendar.WEEKEND_ONSET);
|
||||
fail("expected IllegalArgumentException from getWeekendTransition");
|
||||
}
|
||||
catch (UnsupportedOperationException e) {
|
||||
// ok
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,257 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,454 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,344 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,242 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,286 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,307 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,447 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,202 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,748 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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;
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
28
eclipse-build/plugins.template/com.ibm.icu.base/.project
Normal file
28
eclipse-build/plugins.template/com.ibm.icu.base/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?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>
|
|
@ -0,0 +1,77 @@
|
|||
#Mon Aug 30 14:05:56 EDT 2010
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
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=ignore
|
||||
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=ignore
|
||||
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.5
|
|
@ -0,0 +1,3 @@
|
|||
#Thu Dec 14 11:50:17 EST 2006
|
||||
eclipse.preferences.version=1
|
||||
internal.default.compliance=default
|
|
@ -0,0 +1,15 @@
|
|||
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: J2SE-1.5
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue