mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 09:21:03 +00:00
ICU-8022 Created ICU4J 4.6 release branch from trun r29129.
X-SVN-Rev: 29137
This commit is contained in:
commit
fdeab27fbc
1519 changed files with 1627811 additions and 0 deletions
436
.gitattributes
vendored
Normal file
436
.gitattributes
vendored
Normal file
|
@ -0,0 +1,436 @@
|
|||
* 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/plugins.template/com.ibm.icu.tests/META-INF/MANIFEST.MF -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/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
|
321
APIChangeReport.html
Normal file
321
APIChangeReport.html
Normal file
|
@ -0,0 +1,321 @@
|
|||
<!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.4 with ICU4J 4.6</title>
|
||||
<!-- Copyright 2010, IBM, All Rights Reserved. -->
|
||||
</head>
|
||||
<body>
|
||||
<h1>ICU4J API Comparison: ICU4J 4.4 with ICU4J 4.6</h1>
|
||||
|
||||
<hr/>
|
||||
<h2>Removed from ICU4J 4.4</h2>
|
||||
|
||||
<h3>Package com.ibm.icu.text</h3>
|
||||
<ul>
|
||||
<li>(draft) public class <i>IndexCharacters</i></li>
|
||||
</ul>
|
||||
|
||||
<h3>Package com.ibm.icu.util</h3>
|
||||
<ul>
|
||||
ULocale.Builder
|
||||
<ul>
|
||||
<li>(draft) public <i>ULocale.Builder</i>(boolean)</li>
|
||||
<li>(draft) public boolean <i>isLenientVariant</i>()</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
<h2>Deprecated or Obsoleted in ICU4J 4.6</h2>
|
||||
<p>(no API obsoleted)</p>
|
||||
|
||||
<hr/>
|
||||
<h2>Changed in ICU4J 4.6 (old, new)</h2>
|
||||
|
||||
<h3>Package com.ibm.icu.util</h3>
|
||||
<ul>
|
||||
<li> (draft) public class <i>IllformedLocaleException</i> extends java.lang.IllegalArgumentException</br>
|
||||
(draft) public class <i>IllformedLocaleException</i> extends java.lang.RuntimeException</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
<h2>Promoted to stable in ICU4J 4.6</h2>
|
||||
|
||||
<h3>Package com.ibm.icu.lang</h3>
|
||||
<ul>
|
||||
UCharacter
|
||||
<ul>
|
||||
<li>(stable) public static int <i>getCharFromNameAlias</i>(java.lang.String)</li>
|
||||
<li>(stable) public static java.lang.String <i>getNameAlias</i>(int)</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Package com.ibm.icu.text</h3>
|
||||
<ul>
|
||||
<li>(stable) public class <i>FilteredNormalizer2</i></li>
|
||||
<li>(stable) public abstract class <i>LocaleDisplayNames</i></li>
|
||||
<li>(stable) public static final class <i>LocaleDisplayNames.DialectHandling</i></li>
|
||||
<li>(stable) public abstract class <i>Normalizer2</i></li>
|
||||
<li>(stable) public static final class <i>Normalizer2.Mode</i></li>
|
||||
<li>(stable) public class <i>SelectFormat</i></li>
|
||||
<li>(stable) public interface <i>Transform</i></li>
|
||||
<li>(stable) public static final class <i>UnicodeSet.ComparisonStyle</i></li>
|
||||
<li>(stable) public static final class <i>UnicodeSet.SpanCondition</i></li>
|
||||
ArabicShaping
|
||||
<ul>
|
||||
<li>(stable) public static final int LAMALEF_AUTO</li>
|
||||
<li>(stable) public static final int LAMALEF_BEGIN</li>
|
||||
<li>(stable) public static final int LAMALEF_END</li>
|
||||
<li>(stable) public static final int LAMALEF_MASK</li>
|
||||
<li>(stable) public static final int LAMALEF_NEAR</li>
|
||||
<li>(stable) public static final int LAMALEF_RESIZE</li>
|
||||
<li>(stable) public static final int SEEN_MASK</li>
|
||||
<li>(stable) public static final int SEEN_TWOCELL_NEAR</li>
|
||||
<li>(stable) public static final int SHAPE_TAIL_NEW_UNICODE</li>
|
||||
<li>(stable) public static final int SHAPE_TAIL_TYPE_MASK</li>
|
||||
<li>(stable) public static final int SPACES_RELATIVE_TO_TEXT_BEGIN_END</li>
|
||||
<li>(stable) public static final int SPACES_RELATIVE_TO_TEXT_MASK</li>
|
||||
<li>(stable) public static final int TASHKEEL_BEGIN</li>
|
||||
<li>(stable) public static final int TASHKEEL_END</li>
|
||||
<li>(stable) public static final int TASHKEEL_MASK</li>
|
||||
<li>(stable) public static final int TASHKEEL_REPLACE_BY_TATWEEL</li>
|
||||
<li>(stable) public static final int TASHKEEL_RESIZE</li>
|
||||
<li>(stable) public static final int TEXT_DIRECTION_VISUAL_RTL</li>
|
||||
<li>(stable) public static final int YEHHAMZA_MASK</li>
|
||||
<li>(stable) public static final int YEHHAMZA_TWOCELL_NEAR</li>
|
||||
</ul>
|
||||
ChineseDateFormat
|
||||
<ul>
|
||||
<li>(stable) public <i>ChineseDateFormat</i>(java.lang.String, java.lang.String, ULocale)</li>
|
||||
</ul>
|
||||
DateTimePatternGenerator
|
||||
<ul>
|
||||
<li>(stable) public static final int MATCH_ALL_FIELDS_LENGTH</li>
|
||||
<li>(stable) public static final int MATCH_HOUR_FIELD_LENGTH</li>
|
||||
<li>(stable) public static final int MATCH_NO_OPTIONS</li>
|
||||
<li>(stable) public java.lang.String <i>getBestPattern</i>(java.lang.String, int)</li>
|
||||
<li>(stable) public java.lang.String <i>replaceFieldTypes</i>(java.lang.String, java.lang.String, int)</li>
|
||||
</ul>
|
||||
DecimalFormatSymbols
|
||||
<ul>
|
||||
<li>(stable) public static final int CURRENCY_SPC_CURRENCY_MATCH</li>
|
||||
<li>(stable) public static final int CURRENCY_SPC_INSERT</li>
|
||||
<li>(stable) public static final int CURRENCY_SPC_SURROUNDING_MATCH</li>
|
||||
<li>(stable) public java.lang.String <i>getPatternForCurrencySpacing</i>(int, boolean)</li>
|
||||
<li>(stable) public void <i>setPatternForCurrencySpacing</i>(int, boolean, java.lang.String)</li>
|
||||
</ul>
|
||||
UnicodeSet
|
||||
<ul>
|
||||
<li>(stable) public <i>UnicodeSet</i>(int...)</li>
|
||||
<li>(stable) public UnicodeSet <i>addAll</i>(int, int)</li>
|
||||
<li>(stable) public UnicodeSet <i>addAll</i>(java.lang.String...)</li>
|
||||
<li>(stable) public T extends java.util.Collection<java.lang.String> <i>addAllTo</i>(T)</li>
|
||||
<li>(stable) public static T[] <i>addAllTo</i>(java.lang.Iterable<T>, T[])</li>
|
||||
<li>(stable) public static U extends java.util.Collection<T> <i>addAllTo</i>(java.lang.Iterable<T>, U)</li>
|
||||
<li>(stable) public java.lang.String[] <i>addAllTo</i>(java.lang.String[])</li>
|
||||
<li>(stable) public static int <i>compare</i>(int, java.lang.String)</li>
|
||||
<li>(stable) public static int <i>compare</i>(java.lang.Iterable<T>, java.lang.Iterable<T>)</li>
|
||||
<li>(stable) public static int <i>compare</i>(java.lang.String, int)</li>
|
||||
<li>(stable) public static int <i>compare</i>(java.util.Collection<T>, java.util.Collection<T>, UnicodeSet.ComparisonStyle)</li>
|
||||
<li>(stable) public int <i>compareTo</i>(UnicodeSet)</li>
|
||||
<li>(stable) public int <i>compareTo</i>(UnicodeSet, UnicodeSet.ComparisonStyle)</li>
|
||||
<li>(stable) public int <i>compareTo</i>(java.lang.Iterable<java.lang.String>)</li>
|
||||
<li>(stable) public boolean <i>containsAll</i>(java.util.Collection<java.lang.String>)</li>
|
||||
<li>(stable) public boolean <i>containsNone</i>(java.util.Collection<java.lang.String>)</li>
|
||||
<li>(stable) public final boolean <i>containsSome</i>(java.util.Collection<java.lang.String>)</li>
|
||||
<li>(stable) public java.util.Iterator<java.lang.String> <i>iterator</i>()</li>
|
||||
<li>(stable) public UnicodeSet <i>removeAll</i>(java.util.Collection<java.lang.String>)</li>
|
||||
<li>(stable) public UnicodeSet <i>retainAll</i>(java.util.Collection<java.lang.String>)</li>
|
||||
<li>(stable) public int <i>span</i>(java.lang.CharSequence, UnicodeSet.SpanCondition)</li>
|
||||
<li>(stable) public int <i>span</i>(java.lang.CharSequence, int, UnicodeSet.SpanCondition)</li>
|
||||
<li>(stable) public int <i>spanBack</i>(java.lang.CharSequence, UnicodeSet.SpanCondition)</li>
|
||||
<li>(stable) public int <i>spanBack</i>(java.lang.CharSequence, int, UnicodeSet.SpanCondition)</li>
|
||||
<li>(stable) public java.lang.Iterable<java.lang.String> <i>strings</i>()</li>
|
||||
<li>(stable) public static java.lang.String[] <i>toArray</i>(UnicodeSet)</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Package com.ibm.icu.util</h3>
|
||||
<ul>
|
||||
<li>(stable) public class <i>LocaleMatcher</i></li>
|
||||
<li>(stable) public class <i>LocalePriorityList</i></li>
|
||||
<li>(stable) public static class <i>LocalePriorityList.Builder</i></li>
|
||||
Calendar
|
||||
<ul>
|
||||
<li>(stable) public static final int IS_LEAP_MONTH</li>
|
||||
</ul>
|
||||
TimeZone
|
||||
<ul>
|
||||
<li>(stable) public static final int GENERIC_LOCATION</li>
|
||||
<li>(stable) public static final int LONG_GENERIC</li>
|
||||
<li>(stable) public static final int LONG_GMT</li>
|
||||
<li>(stable) public static final int SHORT_COMMONLY_USED</li>
|
||||
<li>(stable) public static final int SHORT_GENERIC</li>
|
||||
<li>(stable) public static final int SHORT_GMT</li>
|
||||
</ul>
|
||||
ULocale
|
||||
<ul>
|
||||
<li>(stable) public java.lang.String <i>getDisplayLanguageWithDialect</i>()</li>
|
||||
<li>(stable) public java.lang.String <i>getDisplayLanguageWithDialect</i>(ULocale)</li>
|
||||
<li>(stable) public static java.lang.String <i>getDisplayLanguageWithDialect</i>(java.lang.String, ULocale)</li>
|
||||
<li>(stable) public static java.lang.String <i>getDisplayLanguageWithDialect</i>(java.lang.String, java.lang.String)</li>
|
||||
<li>(stable) public java.lang.String <i>getDisplayNameWithDialect</i>()</li>
|
||||
<li>(stable) public java.lang.String <i>getDisplayNameWithDialect</i>(ULocale)</li>
|
||||
<li>(stable) public static java.lang.String <i>getDisplayNameWithDialect</i>(java.lang.String, ULocale)</li>
|
||||
<li>(stable) public static java.lang.String <i>getDisplayNameWithDialect</i>(java.lang.String, java.lang.String)</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
<h2>Added in ICU4J 4.6</h2>
|
||||
|
||||
<h3>Package com.ibm.icu.lang</h3>
|
||||
<ul>
|
||||
UCharacter.JoiningGroup
|
||||
<ul>
|
||||
<li>(stable) public static final int TEH_MARBUTA_GOAL</li>
|
||||
</ul>
|
||||
UCharacter.UnicodeBlock
|
||||
<ul>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock ALCHEMICAL_SYMBOLS</li>
|
||||
<li>(stable) public static final int ALCHEMICAL_SYMBOLS_ID</li>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock BAMUM_SUPPLEMENT</li>
|
||||
<li>(stable) public static final int BAMUM_SUPPLEMENT_ID</li>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock BATAK</li>
|
||||
<li>(stable) public static final int BATAK_ID</li>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock BRAHMI</li>
|
||||
<li>(stable) public static final int BRAHMI_ID</li>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D</li>
|
||||
<li>(stable) public static final int CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D_ID</li>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock EMOTICONS</li>
|
||||
<li>(stable) public static final int EMOTICONS_ID</li>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock ETHIOPIC_EXTENDED_A</li>
|
||||
<li>(stable) public static final int ETHIOPIC_EXTENDED_A_ID</li>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock KANA_SUPPLEMENT</li>
|
||||
<li>(stable) public static final int KANA_SUPPLEMENT_ID</li>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock MANDAIC</li>
|
||||
<li>(stable) public static final int MANDAIC_ID</li>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS</li>
|
||||
<li>(stable) public static final int MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS_ID</li>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock PLAYING_CARDS</li>
|
||||
<li>(stable) public static final int PLAYING_CARDS_ID</li>
|
||||
<li>(stable) public static final UCharacter.UnicodeBlock TRANSPORT_AND_MAP_SYMBOLS</li>
|
||||
<li>(stable) public static final int TRANSPORT_AND_MAP_SYMBOLS_ID</li>
|
||||
</ul>
|
||||
UProperty
|
||||
<ul>
|
||||
<li>(draft) public static final int OTHER_PROPERTY_LIMIT</li>
|
||||
<li>(draft) public static final int OTHER_PROPERTY_START</li>
|
||||
<li>(draft) public static final int SCRIPT_EXTENSIONS</li>
|
||||
</ul>
|
||||
UScript
|
||||
<ul>
|
||||
<li>(stable) public static final int BASSA_VAH</li>
|
||||
<li>(stable) public static final int DUPLOYAN_SHORTAND</li>
|
||||
<li>(stable) public static final int ELBASAN</li>
|
||||
<li>(stable) public static final int GRANTHA</li>
|
||||
<li>(stable) public static final int KPELLE</li>
|
||||
<li>(stable) public static final int LOMA</li>
|
||||
<li>(stable) public static final int MANDAIC</li>
|
||||
<li>(stable) public static final int MENDE</li>
|
||||
<li>(stable) public static final int MEROITIC_CURSIVE</li>
|
||||
<li>(stable) public static final int MEROITIC_HIEROGLYPHS</li>
|
||||
<li>(stable) public static final int NABATAEAN</li>
|
||||
<li>(stable) public static final int OLD_NORTH_ARABIAN</li>
|
||||
<li>(stable) public static final int PALMYRENE</li>
|
||||
<li>(stable) public static final int SINDHI</li>
|
||||
<li>(stable) public static final int WARANG_CITI</li>
|
||||
<li>(draft) public static final java.util.BitSet <i>getScriptExtensions</i>(int, java.util.BitSet)</li>
|
||||
<li>(draft) public static final boolean <i>hasScript</i>(int, int)</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Package com.ibm.icu.text</h3>
|
||||
<ul>
|
||||
<li>(draft) public final class <i>AlphabeticIndex</i></li>
|
||||
<li>(draft) public static class <i>AlphabeticIndex.Bucket</i></li>
|
||||
<li>(draft) public static final class <i>AlphabeticIndex.Bucket.LabelType</i></li>
|
||||
<li>(draft) public static class <i>AlphabeticIndex.Record</i></li>
|
||||
<li>(draft) public static final class <i>IDNA.Error</i></li>
|
||||
<li>(draft) public static final class <i>IDNA.Info</i></li>
|
||||
<li>(stable) public class <i>NumberingSystem</i></li>
|
||||
<li>(draft) public class <i>SpoofChecker</i></li>
|
||||
<li>(draft) public static class <i>SpoofChecker.Builder</i></li>
|
||||
<li>(draft) public static class <i>SpoofChecker.CheckResult</i></li>
|
||||
Bidi
|
||||
<ul>
|
||||
<li>(draft) public static final byte NEUTRAL</li>
|
||||
<li>(draft) public static byte <i>getBaseDirection</i>(java.lang.CharSequence)</li>
|
||||
</ul>
|
||||
DecimalFormatSymbols
|
||||
<ul>
|
||||
<li>(draft) public char[] <i>getDigits</i>()</li>
|
||||
</ul>
|
||||
FilteredNormalizer2
|
||||
<ul>
|
||||
<li>(draft) public java.lang.String <i>getDecomposition</i>(int)</li>
|
||||
<li>(draft) public java.lang.Appendable <i>normalize</i>(java.lang.CharSequence, java.lang.Appendable)</li>
|
||||
</ul>
|
||||
IDNA
|
||||
<ul>
|
||||
<li>(draft) public static final int CHECK_BIDI</li>
|
||||
<li>(draft) public static final int CHECK_CONTEXTJ</li>
|
||||
<li>(draft) public static final int NONTRANSITIONAL_TO_ASCII</li>
|
||||
<li>(draft) public static final int NONTRANSITIONAL_TO_UNICODE</li>
|
||||
<li>(draft) public static IDNA <i>getUTS46Instance</i>(int)</li>
|
||||
<li>(draft) public abstract java.lang.StringBuilder <i>labelToASCII</i>(java.lang.CharSequence, java.lang.StringBuilder, IDNA.Info)</li>
|
||||
<li>(draft) public abstract java.lang.StringBuilder <i>labelToUnicode</i>(java.lang.CharSequence, java.lang.StringBuilder, IDNA.Info)</li>
|
||||
<li>(draft) public abstract java.lang.StringBuilder <i>nameToASCII</i>(java.lang.CharSequence, java.lang.StringBuilder, IDNA.Info)</li>
|
||||
<li>(draft) public abstract java.lang.StringBuilder <i>nameToUnicode</i>(java.lang.CharSequence, java.lang.StringBuilder, IDNA.Info)</li>
|
||||
</ul>
|
||||
Normalizer2
|
||||
<ul>
|
||||
<li>(draft) public abstract java.lang.String <i>getDecomposition</i>(int)</li>
|
||||
<li>(draft) public abstract java.lang.Appendable <i>normalize</i>(java.lang.CharSequence, java.lang.Appendable)</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<h3>Package com.ibm.icu.util</h3>
|
||||
<ul>
|
||||
ChineseCalendar
|
||||
<ul>
|
||||
<li>(draft) public <i>ChineseCalendar</i>(int, int, int, int, int)</li>
|
||||
<li>(draft) public <i>ChineseCalendar</i>(int, int, int, int, int, int, int, int)</li>
|
||||
</ul>
|
||||
Currency
|
||||
<ul>
|
||||
<li>(draft) public static boolean <i>isAvailable</i>(java.lang.String, java.util.Date, java.util.Date)</li>
|
||||
</ul>
|
||||
IllformedLocaleException
|
||||
<ul>
|
||||
<li>(draft) public <i>IllformedLocaleException</i>()</li>
|
||||
</ul>
|
||||
LocaleData
|
||||
<ul>
|
||||
<li>(stable) public static final int ES_CURRENCY</li>
|
||||
<li>(stable) public static final int ES_INDEX</li>
|
||||
<li>(stable) public static UnicodeSet <i>getExemplarSet</i>(ULocale, int, int)</li>
|
||||
</ul>
|
||||
ULocale
|
||||
<ul>
|
||||
<li>(draft) public java.util.Set<java.lang.String> <i>getUnicodeLocaleAttributes</i>()</li>
|
||||
</ul>
|
||||
ULocale.Builder
|
||||
<ul>
|
||||
<li>(draft) public ULocale.Builder <i>addUnicodeLocaleAttribute</i>(java.lang.String)</li>
|
||||
<li>(draft) public ULocale.Builder <i>removeUnicodeLocaleAttribute</i>(java.lang.String)</li>
|
||||
</ul>
|
||||
VersionInfo
|
||||
<ul>
|
||||
<li>(stable) public static final VersionInfo UNICODE_6_0</li>
|
||||
<li>(draft) public static void <i>main</i>(java.lang.String[])</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<hr/>
|
||||
<p><i><font size="-1">Contents generated by ReportAPI tool on Thu Nov 11 01:21:40 EST 2010<br/>Copyright (C) 2010, 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-2010, International Business Machines Corporation and *
|
||||
#* others. All Rights Reserved. *
|
||||
#*******************************************************************************
|
||||
api.report.version = 46
|
||||
api.report.prev.version = 44
|
||||
release.file.ver = 4_6
|
||||
|
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>
|
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, International Business Machines Corporation and *
|
||||
#* others. All Rights Reserved. *
|
||||
#*******************************************************************************
|
||||
icu4j.plugin.impl.version.string=4.5.2
|
||||
copyright.eclipse=Licensed Materials - Property of IBM \n (C) Copyright IBM Corp. 2000, 2010. All Rights Reserved. \n IBM is a registered trademark of IBM Corp.
|
||||
icu4j.data.version.number=45
|
208
eclipse-build/build.xml
Normal file
208
eclipse-build/build.xml
Normal file
|
@ -0,0 +1,208 @@
|
|||
<!--
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010, 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"/>
|
||||
<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"
|
||||
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>
|
||||
|
||||
</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"
|
||||
description="Copy com.ibm.icu plug-in project files">
|
||||
|
||||
<delete failonerror="no">
|
||||
<fileset dir="${eclipse.projects.dir}/plugins/com.ibm.icu" />
|
||||
<fileset dir="${eclipse.projects.dir}/features/com.ibm.icu" />
|
||||
</delete>
|
||||
|
||||
<!-- icu source -->
|
||||
<copy toDir="${eclipse.projects.dir}/plugins/com.ibm.icu/src">
|
||||
<fileset dir="${icu4j.collate.dir}/src"/>
|
||||
<fileset dir="${icu4j.core.dir}/src"/>
|
||||
<fileset dir="${icu4j.currdata.dir}/src"/>
|
||||
<fileset dir="${icu4j.langdata.dir}/src"/>
|
||||
<fileset dir="${icu4j.regiondata.dir}/src"/>
|
||||
<fileset dir="${icu4j.translit.dir}/src"/>
|
||||
</copy>
|
||||
|
||||
<!-- overwriting the ICU runtime configuration file for forcing ICU4J plugin to use JDK time zone rules -->
|
||||
<copy file="misc/ICUConfig.properties"
|
||||
toDir="${eclipse.projects.dir}/plugins/com.ibm.icu/src/com/ibm/icu"
|
||||
overwrite="true"/>
|
||||
|
||||
<!-- icu data -->
|
||||
<unjar src="${icu4j.data.jar}" dest="${eclipse.projects.dir}/plugins/com.ibm.icu/src">
|
||||
<patternset>
|
||||
<exclude name="**/*.cnv"/>
|
||||
<exclude name="**/cnvalias.icu"/>
|
||||
</patternset>
|
||||
</unjar>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
</project>
|
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>
|
12
eclipse-build/misc/ICUConfig.properties
Normal file
12
eclipse-build/misc/ICUConfig.properties
Normal file
|
@ -0,0 +1,12 @@
|
|||
#******************************************************************************
|
||||
# Copyright (C) 2008-2009, International Business Machines Corporation and *
|
||||
# others. All Rights Reserved. *
|
||||
#******************************************************************************
|
||||
# This is the properties contains ICU runtime configuration for eclispe plug-in
|
||||
#
|
||||
|
||||
#
|
||||
# The default TimeZone implementation type used by the ICU TimeZone
|
||||
# factory method. [ ICU | JDK ]
|
||||
#
|
||||
com.ibm.icu.util.TimeZone.DefaultTimeZoneType = JDK
|
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>April 8, 2010</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.2.1.v20100408 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-2010 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>April 8, 2010</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.2.1.v20100408 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-2010 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"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
28
eclipse-build/plugins.template/com.ibm.icu.tests/.project
Normal file
28
eclipse-build/plugins.template/com.ibm.icu.tests/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.ibm.icu.tests</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,12 @@
|
|||
#Thu Dec 14 11:51:01 EST 2006
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.3
|
||||
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.assertIdentifier=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
|
||||
org.eclipse.jdt.core.compiler.source=1.3
|
|
@ -0,0 +1,3 @@
|
|||
#Thu Dec 14 11:51:01 EST 2006
|
||||
eclipse.preferences.version=1
|
||||
internal.default.compliance=default
|
|
@ -0,0 +1,11 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: ICU Test Fragment
|
||||
Bundle-SymbolicName: com.ibm.icu.tests
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Vendor: IBM
|
||||
Fragment-Host: com.ibm.icu
|
||||
Bundle-Copyright: @COPYRIGHT@
|
||||
Require-Bundle: org.junit
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.3,
|
||||
CDC-1.0/Foundation-1.0
|
|
@ -0,0 +1,14 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
./icu4jtests.jar,\
|
||||
.classpath,\
|
||||
bin/,\
|
||||
build.properties,\
|
||||
.project
|
||||
src.includes = src/,\
|
||||
build.properties,\
|
||||
.classpath,\
|
||||
.project,\
|
||||
META-INF/
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2005-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import com.ibm.icu.dev.test.TestAll;
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.dev.test.TestFmwk.TestParams;
|
||||
|
||||
//import com.ibm.icu.text.DateFormat;
|
||||
//import com.ibm.icu.util.Calendar;
|
||||
//import com.ibm.icu.util.GregorianCalendar;
|
||||
//import com.ibm.icu.util.TimeZone;
|
||||
//import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class UnitTest extends TestCase {
|
||||
|
||||
public void testBidi() throws Exception {
|
||||
runUtility("Bidi");
|
||||
}
|
||||
|
||||
public void testCalendar() throws Exception {
|
||||
runUtility("Calendar");
|
||||
}
|
||||
|
||||
public void testCollator() throws Exception {
|
||||
runUtility("Collator");
|
||||
}
|
||||
|
||||
public void testCompression() throws Exception {
|
||||
runUtility("Compression");
|
||||
}
|
||||
|
||||
public void testDuration() throws Exception {
|
||||
runUtility("Duration");
|
||||
}
|
||||
|
||||
public void testDiagBigDecimal() throws Exception {
|
||||
runUtility("DiagBigDecimal");
|
||||
}
|
||||
|
||||
public void testFormat() throws Exception {
|
||||
runUtility("Format");
|
||||
}
|
||||
|
||||
public void testImpl() throws Exception {
|
||||
runUtility("Impl");
|
||||
}
|
||||
|
||||
public void testNormalizer() throws Exception {
|
||||
runUtility("Normalizer");
|
||||
}
|
||||
|
||||
public void testProperty() throws Exception {
|
||||
runUtility("Property");
|
||||
}
|
||||
|
||||
public void testRBBI() throws Exception {
|
||||
runUtility("RBBI");
|
||||
}
|
||||
|
||||
public void testSearchTest() throws Exception {
|
||||
runUtility("SearchTest");
|
||||
}
|
||||
|
||||
public void testStringPrep() throws Exception {
|
||||
runUtility("StringPrep");
|
||||
}
|
||||
|
||||
public void testTestCharsetDetector() throws Exception {
|
||||
runUtility("TestCharsetDetector");
|
||||
}
|
||||
|
||||
public void testTestUCharacterIterator() throws Exception {
|
||||
runUtility("TestUCharacterIterator");
|
||||
}
|
||||
|
||||
public void testTimeScale() throws Exception {
|
||||
runUtility("TimeScale");
|
||||
}
|
||||
|
||||
public void testTimeZone() throws Exception {
|
||||
runUtility("TimeZone");
|
||||
}
|
||||
|
||||
public void testTranslit() throws Exception {
|
||||
runUtility("Translit");
|
||||
}
|
||||
|
||||
public void testUtil() throws Exception {
|
||||
runUtility("Util");
|
||||
}
|
||||
|
||||
public void runUtility(String testname) throws Exception {
|
||||
TestParams params = TestParams.create("-n", null);
|
||||
TestFmwk test = new TestAll();
|
||||
test.resolveTarget(params, testname).run();
|
||||
if (params.errorCount > 0) {
|
||||
fail(params.errorSummary.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// sample tests from ICU4J test suite
|
||||
|
||||
// Calendar
|
||||
// public void testCalendarSimple() throws Exception {
|
||||
// TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
|
||||
// GregorianCalendar gc = new GregorianCalendar(tz);
|
||||
// gc.set(2005,9,17,14,15,33);
|
||||
// Date time = gc.getTime();
|
||||
//
|
||||
// final String[] calendars = {
|
||||
// "buddhist", "chinese", "coptic", "ethiopic", "gregorian",
|
||||
// "hebrew", "islamic", "islamic-civil", "japanese"
|
||||
// };
|
||||
// final String[] ustimes = {
|
||||
// "Monday, October 17, 2548 BE 2:15:33 PM PDT",
|
||||
// "Monday 22x78-9-15 2:15:33 PM PDT",
|
||||
// "Monday, Baba 7, 1722 2:15:33 PM PDT",
|
||||
// "Monday, Tekemt 7, 1998 2:15:33 PM PDT",
|
||||
// "Monday, October 17, 2005 2:15:33 PM PDT",
|
||||
// "Monday, Tishri 14, 5766 2:15:33 PM PDT",
|
||||
// "Monday, Ramadan 14, 1426 2:15:33 PM PDT",
|
||||
// "Monday, Ramadan 14, 1426 2:15:33 PM PDT",
|
||||
// "Monday, October 17, 17 Heisei 2:15:33 PM PDT",
|
||||
// };
|
||||
// final String[] detimes = {
|
||||
// "Montag, Oktober 17, 2548 BE 2:15:33 nachm. GMT-07:00",
|
||||
// "Montag 22x78-9-15 2:15:33 nachm. GMT-07:00",
|
||||
// "Montag, 7. Baba 1722 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 7. Tekemt 1998 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 17. Oktober 2005 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 14. Tishri 5766 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 14. Ramadan 1426 14:15 Uhr GMT-07:00",
|
||||
// "Montag, 14. Ramadan 1426 14:15 Uhr GMT-07:00",
|
||||
// "Montag, Oktober 17, 17 Heisei 2:15:33 nachm. GMT-07:00",
|
||||
// };
|
||||
//
|
||||
// ULocale[] locales = {ULocale.US, ULocale.GERMANY };
|
||||
// String[][] times = { ustimes, detimes };
|
||||
// for (int j = 0; j < locales.length; ++j) {
|
||||
// ULocale ul = new ULocale("en_US");
|
||||
// for (int i = 0; i < calendars.length; ++i) {
|
||||
// ul = ul.setKeywordValue("calendar", calendars[i]);
|
||||
// Calendar cal = Calendar.getInstance(ul);
|
||||
// DateFormat fmt = cal.getDateTimeFormat(DateFormat.FULL, DateFormat.FULL, locales[j]);
|
||||
// String result = fmt.format(time);
|
||||
// System.out.println(calendars[i] + ": " + result);
|
||||
// if (!result.equals(times[j][i])) {
|
||||
// fail("calendar: " + calendars[i]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
7
eclipse-build/plugins.template/com.ibm.icu/.classpath
Normal file
7
eclipse-build/plugins.template/com.ibm.icu/.classpath
Normal file
|
@ -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/.project
Normal file
28
eclipse-build/plugins.template/com.ibm.icu/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.ibm.icu</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -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,29 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: com.ibm.icu; singleton:=true
|
||||
Bundle-Version: @BUILD_VERSION@
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
Bundle-Copyright: @COPYRIGHT@
|
||||
Export-Package: com.ibm.icu.lang;base=true;full=true;version="@IMPL_VERSION@",
|
||||
com.ibm.icu.math;base=true;full=true;version="@IMPL_VERSION@",
|
||||
com.ibm.icu.text;base=true;full=true;version="@IMPL_VERSION@",
|
||||
com.ibm.icu.util;base=true;full=true;version="@IMPL_VERSION@",
|
||||
com.ibm.icu.impl;x-internal:=true,
|
||||
com.ibm.icu.impl.data;x-internal:=true,
|
||||
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b;x-internal:=true,
|
||||
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.brkitr;x-internal:=true,
|
||||
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.coll;x-internal:=true,
|
||||
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.curr;x-internal:=true,
|
||||
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.lang;x-internal:=true,
|
||||
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.rbnf;x-internal:=true,
|
||||
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.region;x-internal:=true,
|
||||
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.translit;x-internal:=true,
|
||||
com.ibm.icu.impl.data.icudt@DATA_VERSION_NUMBER@b.zone;x-internal:=true,
|
||||
com.ibm.icu.impl.duration;x-internal:=true,
|
||||
com.ibm.icu.impl.locale;x-internal:=true
|
||||
Eclipse-LazyStart: true
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-ClassPath: icu-data.jar,.
|
||||
Eclipse-ExtensibleAPI: true
|
19
eclipse-build/plugins.template/com.ibm.icu/build.properties
Normal file
19
eclipse-build/plugins.template/com.ibm.icu/build.properties
Normal file
|
@ -0,0 +1,19 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# IBM Corporation - initial API and implementation
|
||||
###############################################################################
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
src.includes = about.html,\
|
||||
about_files/
|
||||
bin.includes = .,\
|
||||
about.html,\
|
||||
about_files/,\
|
||||
plugin.properties,\
|
||||
META-INF/
|
12
eclipse-build/plugins.template/com.ibm.icu/plugin.properties
Normal file
12
eclipse-build/plugins.template/com.ibm.icu/plugin.properties
Normal file
|
@ -0,0 +1,12 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# IBM Corporation - initial API and implementation
|
||||
###############################################################################
|
||||
pluginName = International Components for Unicode for Java (ICU4J)
|
||||
providerName = IBM Corporation
|
7
main/classes/charset/.classpath
Normal file
7
main/classes/charset/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry excluding="**/.svn/" 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-core"/>
|
||||
<classpathentry kind="output" path="out/bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="copy-data,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="copy-data,"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/icu4j-charset/build.xml"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="icu4j-charset"/>
|
||||
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_ANT_PROPERTIES">
|
||||
<mapEntry key="eclipse.running" value="true"/>
|
||||
<mapEntry key="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
</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-charset/build.xml}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
</launchConfiguration>
|
29
main/classes/charset/.project
Normal file
29
main/classes/charset/.project
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>icu4j-charset</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>icu4j-core</project>
|
||||
<project>icu4j-shared</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/copy-data-charset.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,3 @@
|
|||
#Fri Nov 05 14:17:11 EDT 2010
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
343
main/classes/charset/.settings/org.eclipse.jdt.core.prefs
Normal file
343
main/classes/charset/.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,343 @@
|
|||
#Thu Aug 27 17:46:17 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.doc.comment.support=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
|
||||
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.invalidJavadoc=warning
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
|
||||
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.missingJavadocComments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
|
||||
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=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.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.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
|
||||
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
|
10
main/classes/charset/.settings/org.eclipse.jdt.ui.prefs
Normal file
10
main/classes/charset/.settings/org.eclipse.jdt.ui.prefs
Normal file
File diff suppressed because one or more lines are too long
6
main/classes/charset/build.properties
Normal file
6
main/classes/charset/build.properties
Normal file
|
@ -0,0 +1,6 @@
|
|||
#*******************************************************************************
|
||||
#* Copyright (C) 2009, International Business Machines Corporation and *
|
||||
#* others. All Rights Reserved. *
|
||||
#*******************************************************************************
|
||||
shared.dir = ../../shared
|
||||
javac.compilerarg = -Xlint:all,-deprecation,-dep-ann
|
41
main/classes/charset/build.xml
Normal file
41
main/classes/charset/build.xml
Normal file
|
@ -0,0 +1,41 @@
|
|||
<!--
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2009-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
-->
|
||||
<project name="charset" 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, copy-data" 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"/>
|
||||
|
||||
<target name="copy-data" description="Extract pre-built ICU core data files and copy them to the project's binary directory">
|
||||
<unjar src="${icu4j.data.jar}" dest="${bin.dir}">
|
||||
<patternset>
|
||||
<include name="**/*.cnv"/>
|
||||
<include name="**/cnvalias.icu"/>
|
||||
</patternset>
|
||||
</unjar>
|
||||
</target>
|
||||
|
||||
</project>
|
21
main/classes/charset/charset-build.launch
Normal file
21
main/classes/charset/charset-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-charset/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-charset"/>
|
||||
<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.running" value="true"/>
|
||||
<mapEntry key="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
</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_ANT_TARGETS" value="build-all,"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/icu4j-charset/build.xml}"/>
|
||||
<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
|
||||
</launchConfiguration>
|
16
main/classes/charset/manifest.stub
Normal file
16
main/classes/charset/manifest.stub
Normal file
|
@ -0,0 +1,16 @@
|
|||
Manifest-Version: 1.0
|
||||
Specification-Title: International Components for Unicode for Java (charset)
|
||||
Specification-Version: @SPECVERSION@
|
||||
Specification-Vendor: icu-project.org
|
||||
Implementation-Title: International Components for Unicode for Java (charset)
|
||||
Implementation-Version: @IMPLVERSION@
|
||||
Implementation-Vendor: IBM Corporation
|
||||
Implementation-Vendor-Id: com.ibm
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: ICU4J charset
|
||||
Bundle-Description: International Components for Unicode for Java (charset)
|
||||
Bundle-SymbolicName: com.ibm.icu.charset
|
||||
Bundle-Version: @IMPLVERSION@
|
||||
Bundle-Vendor: IBM Corporation
|
||||
Bundle-Copyright: @COPYRIGHT@
|
||||
Bundle-RequiredExecutionEnvironment: @EXECENV@
|
|
@ -0,0 +1,3 @@
|
|||
# Copyright (C) 2006, International Business Machines Corporation and others. All Rights Reserved.
|
||||
# icu4j converters
|
||||
com.ibm.icu.charset.CharsetProviderICU
|
128
main/classes/charset/src/com/ibm/icu/charset/Charset88591.java
Normal file
128
main/classes/charset/src/com/ibm/icu/charset/Charset88591.java
Normal file
|
@ -0,0 +1,128 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.charset;
|
||||
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
|
||||
import com.ibm.icu.text.UnicodeSet;
|
||||
|
||||
class Charset88591 extends CharsetASCII {
|
||||
public Charset88591(String icuCanonicalName, String javaCanonicalName, String[] aliases) {
|
||||
super(icuCanonicalName, javaCanonicalName, aliases);
|
||||
}
|
||||
|
||||
class CharsetDecoder88591 extends CharsetDecoderASCII {
|
||||
public CharsetDecoder88591(CharsetICU cs) {
|
||||
super(cs);
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoopCoreOptimized(ByteBuffer source, CharBuffer target,
|
||||
byte[] sourceArray, char[] targetArray, int oldSource, int offset, int limit) {
|
||||
|
||||
/*
|
||||
* perform 88591 conversion from the source array to the target array. no range check is
|
||||
* necessary.
|
||||
*/
|
||||
for (int i = oldSource; i < limit; i++)
|
||||
targetArray[i + offset] = (char) (sourceArray[i] & 0xff);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoopCoreUnoptimized(ByteBuffer source, CharBuffer target)
|
||||
throws BufferUnderflowException, BufferOverflowException {
|
||||
|
||||
/*
|
||||
* perform 88591 conversion from the source buffer to the target buffer. no range check
|
||||
* is necessary (an exception will be generated to end the loop).
|
||||
*/
|
||||
while (true)
|
||||
target.put((char) (source.get() & 0xff));
|
||||
}
|
||||
}
|
||||
|
||||
class CharsetEncoder88591 extends CharsetEncoderASCII {
|
||||
public CharsetEncoder88591(CharsetICU cs) {
|
||||
super(cs);
|
||||
}
|
||||
|
||||
protected final CoderResult encodeLoopCoreOptimized(CharBuffer source, ByteBuffer target,
|
||||
char[] sourceArray, byte[] targetArray, int oldSource, int offset, int limit,
|
||||
boolean flush) {
|
||||
int i, ch = 0;
|
||||
|
||||
/*
|
||||
* perform 88591 conversion from the source array to the target array, making sure each
|
||||
* char in the source is within the correct range
|
||||
*/
|
||||
for (i = oldSource; i < limit; i++) {
|
||||
ch = (int) sourceArray[i];
|
||||
if ((ch & 0xff00) == 0) {
|
||||
targetArray[i + offset] = (byte) ch;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* if some byte was not in the correct range, we need to deal with this byte by calling
|
||||
* encodeMalformedOrUnmappable and move the source and target positions to reflect the
|
||||
* early termination of the loop
|
||||
*/
|
||||
if ((ch & 0xff00) != 0) {
|
||||
source.position(i + 1);
|
||||
target.position(i + offset);
|
||||
return encodeMalformedOrUnmappable(source, ch, flush);
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
protected final CoderResult encodeLoopCoreUnoptimized(CharBuffer source, ByteBuffer target,
|
||||
boolean flush) throws BufferUnderflowException, BufferOverflowException {
|
||||
int ch;
|
||||
|
||||
/*
|
||||
* perform 88591 conversion from the source buffer to the target buffer, making sure
|
||||
* each char in the source is within the correct range
|
||||
*/
|
||||
|
||||
while (true) {
|
||||
ch = (int) source.get();
|
||||
if ((ch & 0xff00) == 0) {
|
||||
target.put((byte) ch);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if we reach here, it's because a character was not in the correct range, and we need
|
||||
* to deak with this by calling encodeMalformedOrUnmappable.
|
||||
*/
|
||||
return encodeMalformedOrUnmappable(source, ch, flush);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new CharsetDecoder88591(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new CharsetEncoder88591(this);
|
||||
}
|
||||
|
||||
void getUnicodeSetImpl( UnicodeSet setFillIn, int which){
|
||||
setFillIn.add(0,0xff);
|
||||
}
|
||||
}
|
357
main/classes/charset/src/com/ibm/icu/charset/CharsetASCII.java
Normal file
357
main/classes/charset/src/com/ibm/icu/charset/CharsetASCII.java
Normal file
|
@ -0,0 +1,357 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.charset;
|
||||
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
|
||||
import com.ibm.icu.text.UTF16;
|
||||
import com.ibm.icu.text.UnicodeSet;
|
||||
|
||||
class CharsetASCII extends CharsetICU {
|
||||
protected byte[] fromUSubstitution = new byte[] { (byte) 0x1a };
|
||||
|
||||
public CharsetASCII(String icuCanonicalName, String javaCanonicalName, String[] aliases) {
|
||||
super(icuCanonicalName, javaCanonicalName, aliases);
|
||||
maxBytesPerChar = 1;
|
||||
minBytesPerChar = 1;
|
||||
maxCharsPerByte = 1;
|
||||
}
|
||||
|
||||
class CharsetDecoderASCII extends CharsetDecoderICU {
|
||||
|
||||
public CharsetDecoderASCII(CharsetICU cs) {
|
||||
super(cs);
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoop(ByteBuffer source, CharBuffer target, IntBuffer offsets,
|
||||
boolean flush) {
|
||||
if (!source.hasRemaining()) {
|
||||
/* no input, nothing to do */
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
if (!target.hasRemaining()) {
|
||||
/* no output available, can't do anything */
|
||||
return CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
CoderResult cr;
|
||||
int oldSource = source.position();
|
||||
int oldTarget = target.position();
|
||||
|
||||
if (source.hasArray() && target.hasArray()) {
|
||||
/* optimized loop */
|
||||
|
||||
/*
|
||||
* extract arrays from the buffers and obtain various constant values that will be
|
||||
* necessary in the core loop
|
||||
*/
|
||||
byte[] sourceArray = source.array();
|
||||
int sourceOffset = source.arrayOffset();
|
||||
int sourceIndex = oldSource + sourceOffset;
|
||||
int sourceLength = source.limit() - oldSource;
|
||||
|
||||
char[] targetArray = target.array();
|
||||
int targetOffset = target.arrayOffset();
|
||||
int targetIndex = oldTarget + targetOffset;
|
||||
int targetLength = target.limit() - oldTarget;
|
||||
|
||||
int limit = ((sourceLength < targetLength) ? sourceLength : targetLength)
|
||||
+ sourceIndex;
|
||||
int offset = targetIndex - sourceIndex;
|
||||
|
||||
/*
|
||||
* perform the core loop... if it returns null, it must be due to an overflow or
|
||||
* underflow
|
||||
*/
|
||||
cr = decodeLoopCoreOptimized(source, target, sourceArray, targetArray, sourceIndex, offset, limit);
|
||||
if (cr == null) {
|
||||
if (sourceLength <= targetLength) {
|
||||
source.position(oldSource + sourceLength);
|
||||
target.position(oldTarget + sourceLength);
|
||||
cr = CoderResult.UNDERFLOW;
|
||||
} else {
|
||||
source.position(oldSource + targetLength);
|
||||
target.position(oldTarget + targetLength);
|
||||
cr = CoderResult.OVERFLOW;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* unoptimized loop */
|
||||
|
||||
try {
|
||||
/*
|
||||
* perform the core loop... if it throws an exception, it must be due to an
|
||||
* overflow or underflow
|
||||
*/
|
||||
cr = decodeLoopCoreUnoptimized(source, target);
|
||||
|
||||
} catch (BufferUnderflowException ex) {
|
||||
/* all of the source has been read */
|
||||
cr = CoderResult.UNDERFLOW;
|
||||
} catch (BufferOverflowException ex) {
|
||||
/* the target is full */
|
||||
source.position(source.position() - 1); /* rewind by 1 */
|
||||
cr = CoderResult.OVERFLOW;
|
||||
}
|
||||
}
|
||||
|
||||
/* set offsets since the start */
|
||||
if (offsets != null) {
|
||||
int count = target.position() - oldTarget;
|
||||
int sourceIndex = -1;
|
||||
while (--count >= 0) offsets.put(++sourceIndex);
|
||||
}
|
||||
|
||||
return cr;
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoopCoreOptimized(ByteBuffer source, CharBuffer target,
|
||||
byte[] sourceArray, char[] targetArray, int oldSource, int offset, int limit) {
|
||||
int i, ch = 0;
|
||||
|
||||
/*
|
||||
* perform ascii conversion from the source array to the target array, making sure each
|
||||
* byte in the source is within the correct range
|
||||
*/
|
||||
for (i = oldSource; i < limit && (((ch = (sourceArray[i] & 0xff)) & 0x80) == 0); i++)
|
||||
targetArray[i + offset] = (char) ch;
|
||||
|
||||
/*
|
||||
* if some byte was not in the correct range, we need to deal with this byte by calling
|
||||
* decodeMalformedOrUnmappable and move the source and target positions to reflect the
|
||||
* early termination of the loop
|
||||
*/
|
||||
if ((ch & 0x80) != 0) {
|
||||
source.position(i + 1);
|
||||
target.position(i + offset);
|
||||
return decodeMalformedOrUnmappable(ch);
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoopCoreUnoptimized(ByteBuffer source, CharBuffer target)
|
||||
throws BufferUnderflowException, BufferOverflowException {
|
||||
int ch = 0;
|
||||
|
||||
/*
|
||||
* perform ascii conversion from the source buffer to the target buffer, making sure
|
||||
* each byte in the source is within the correct range
|
||||
*/
|
||||
while (((ch = (source.get() & 0xff)) & 0x80) == 0)
|
||||
target.put((char) ch);
|
||||
|
||||
/*
|
||||
* if we reach here, it's because a character was not in the correct range, and we need
|
||||
* to deak with this by calling decodeMalformedOrUnmappable
|
||||
*/
|
||||
return decodeMalformedOrUnmappable(ch);
|
||||
}
|
||||
|
||||
protected CoderResult decodeMalformedOrUnmappable(int ch) {
|
||||
/*
|
||||
* put the guilty character into toUBytesArray and return a message saying that the
|
||||
* character was malformed and of length 1.
|
||||
*/
|
||||
toUBytesArray[0] = (byte) ch;
|
||||
toULength = 1;
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
}
|
||||
|
||||
class CharsetEncoderASCII extends CharsetEncoderICU {
|
||||
|
||||
public CharsetEncoderASCII(CharsetICU cs) {
|
||||
super(cs, fromUSubstitution);
|
||||
implReset();
|
||||
}
|
||||
|
||||
private final static int NEED_TO_WRITE_BOM = 1;
|
||||
|
||||
protected void implReset() {
|
||||
super.implReset();
|
||||
fromUnicodeStatus = NEED_TO_WRITE_BOM;
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer source, ByteBuffer target, IntBuffer offsets,
|
||||
boolean flush) {
|
||||
if (!source.hasRemaining()) {
|
||||
/* no input, nothing to do */
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
if (!target.hasRemaining()) {
|
||||
/* no output available, can't do anything */
|
||||
return CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
CoderResult cr;
|
||||
int oldSource = source.position();
|
||||
int oldTarget = target.position();
|
||||
|
||||
if (fromUChar32 != 0) {
|
||||
/*
|
||||
* if we have a leading character in fromUChar32 that needs to be dealt with, we
|
||||
* need to check for a matching trail character and taking the appropriate action as
|
||||
* dictated by encodeTrail.
|
||||
*/
|
||||
cr = encodeTrail(source, (char) fromUChar32, flush);
|
||||
} else {
|
||||
if (source.hasArray() && target.hasArray()) {
|
||||
/* optimized loop */
|
||||
|
||||
/*
|
||||
* extract arrays from the buffers and obtain various constant values that will
|
||||
* be necessary in the core loop
|
||||
*/
|
||||
char[] sourceArray = source.array();
|
||||
int sourceOffset = source.arrayOffset();
|
||||
int sourceIndex = oldSource + sourceOffset;
|
||||
int sourceLength = source.limit() - oldSource;
|
||||
|
||||
byte[] targetArray = target.array();
|
||||
int targetOffset = target.arrayOffset();
|
||||
int targetIndex = oldTarget + targetOffset;
|
||||
int targetLength = target.limit() - oldTarget;
|
||||
|
||||
int limit = ((sourceLength < targetLength) ? sourceLength : targetLength)
|
||||
+ sourceIndex;
|
||||
int offset = targetIndex - sourceIndex;
|
||||
|
||||
/*
|
||||
* perform the core loop... if it returns null, it must be due to an overflow or
|
||||
* underflow
|
||||
*/
|
||||
cr = encodeLoopCoreOptimized(source, target, sourceArray, targetArray, sourceIndex, offset, limit, flush);
|
||||
if (cr == null) {
|
||||
if (sourceLength <= targetLength) {
|
||||
source.position(oldSource + sourceLength);
|
||||
target.position(oldTarget + sourceLength);
|
||||
cr = CoderResult.UNDERFLOW;
|
||||
} else {
|
||||
source.position(oldSource + targetLength);
|
||||
target.position(oldTarget + targetLength);
|
||||
cr = CoderResult.OVERFLOW;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* unoptimized loop */
|
||||
|
||||
try {
|
||||
/*
|
||||
* perform the core loop... if it throws an exception, it must be due to an
|
||||
* overflow or underflow
|
||||
*/
|
||||
cr = encodeLoopCoreUnoptimized(source, target, flush);
|
||||
|
||||
} catch (BufferUnderflowException ex) {
|
||||
cr = CoderResult.UNDERFLOW;
|
||||
} catch (BufferOverflowException ex) {
|
||||
source.position(source.position() - 1); /* rewind by 1 */
|
||||
cr = CoderResult.OVERFLOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* set offsets since the start */
|
||||
if (offsets != null) {
|
||||
int count = target.position() - oldTarget;
|
||||
int sourceIndex = -1;
|
||||
while (--count >= 0) offsets.put(++sourceIndex);
|
||||
}
|
||||
|
||||
return cr;
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoopCoreOptimized(CharBuffer source, ByteBuffer target,
|
||||
char[] sourceArray, byte[] targetArray, int oldSource, int offset, int limit,
|
||||
boolean flush) {
|
||||
int i, ch = 0;
|
||||
|
||||
/*
|
||||
* perform ascii conversion from the source array to the target array, making sure each
|
||||
* char in the source is within the correct range
|
||||
*/
|
||||
for (i = oldSource; i < limit && (((ch = (int) sourceArray[i]) & 0xff80) == 0); i++)
|
||||
targetArray[i + offset] = (byte) ch;
|
||||
|
||||
/*
|
||||
* if some byte was not in the correct range, we need to deal with this byte by calling
|
||||
* encodeMalformedOrUnmappable and move the source and target positions to reflect the
|
||||
* early termination of the loop
|
||||
*/
|
||||
if ((ch & 0xff80) != 0) {
|
||||
source.position(i + 1);
|
||||
target.position(i + offset);
|
||||
return encodeMalformedOrUnmappable(source, ch, flush);
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoopCoreUnoptimized(CharBuffer source, ByteBuffer target,
|
||||
boolean flush) throws BufferUnderflowException, BufferOverflowException {
|
||||
int ch;
|
||||
|
||||
/*
|
||||
* perform ascii conversion from the source buffer to the target buffer, making sure
|
||||
* each char in the source is within the correct range
|
||||
*/
|
||||
while (((ch = (int) source.get()) & 0xff80) == 0)
|
||||
target.put((byte) ch);
|
||||
|
||||
/*
|
||||
* if we reach here, it's because a character was not in the correct range, and we need
|
||||
* to deak with this by calling encodeMalformedOrUnmappable.
|
||||
*/
|
||||
return encodeMalformedOrUnmappable(source, ch, flush);
|
||||
}
|
||||
|
||||
protected final CoderResult encodeMalformedOrUnmappable(CharBuffer source, int ch, boolean flush) {
|
||||
/*
|
||||
* if the character is a lead surrogate, we need to call encodeTrail to attempt to match
|
||||
* it up with a trail surrogate. if not, the character is unmappable.
|
||||
*/
|
||||
return (UTF16.isSurrogate((char) ch))
|
||||
? encodeTrail(source, (char) ch, flush)
|
||||
: CoderResult.unmappableForLength(1);
|
||||
}
|
||||
|
||||
private final CoderResult encodeTrail(CharBuffer source, char lead, boolean flush) {
|
||||
/*
|
||||
* ASCII doesn't support characters in the BMP, so if handleSurrogates returns null,
|
||||
* we leave fromUChar32 alone (it should store a new codepoint) and call it unmappable.
|
||||
*/
|
||||
CoderResult cr = handleSurrogates(source, lead);
|
||||
if (cr != null) {
|
||||
return cr;
|
||||
} else {
|
||||
//source.position(source.position() - 2);
|
||||
return CoderResult.unmappableForLength(2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new CharsetDecoderASCII(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new CharsetEncoderASCII(this);
|
||||
}
|
||||
|
||||
void getUnicodeSetImpl( UnicodeSet setFillIn, int which){
|
||||
setFillIn.add(0,0x7f);
|
||||
}
|
||||
}
|
1063
main/classes/charset/src/com/ibm/icu/charset/CharsetBOCU1.java
Normal file
1063
main/classes/charset/src/com/ibm/icu/charset/CharsetBOCU1.java
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.charset;
|
||||
|
||||
import com.ibm.icu.text.UnicodeSet;
|
||||
|
||||
/**
|
||||
* The purpose of this class is to set isCESU8 to true in the super class, and to allow the Charset framework to open
|
||||
* the variant UTF-8 converter without extra setup work. CESU-8 encodes/decodes supplementary characters as 6 bytes
|
||||
* instead of the proper 4 bytes.
|
||||
*/
|
||||
class CharsetCESU8 extends CharsetUTF8 {
|
||||
public CharsetCESU8(String icuCanonicalName, String javaCanonicalName, String[] aliases) {
|
||||
super(icuCanonicalName, javaCanonicalName, aliases);
|
||||
}
|
||||
|
||||
|
||||
void getUnicodeSetImpl( UnicodeSet setFillIn, int which){
|
||||
getCompleteUnicodeSet(setFillIn);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,408 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.charset;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.charset.CoderResult;
|
||||
|
||||
/**
|
||||
* <h2> Callback API for CharsetICU API </h2>
|
||||
*
|
||||
* CharsetCallback class defines some error behaviour functions called
|
||||
* by CharsetDecoderICU and CharsetEncoderICU. The class also provides
|
||||
* the facility by which clients can write their own callbacks.
|
||||
*
|
||||
* These functions, although public, should NEVER be called directly.
|
||||
* They should be used as parameters to the onUmappableCharacter() and
|
||||
* onMalformedInput() methods, to set the behaviour of a converter
|
||||
* when it encounters UNMAPPED/INVALID sequences.
|
||||
* Currently the only way to set callbacks is by using CodingErrorAction.
|
||||
* In the future we will provide set methods on CharsetEncoder and CharsetDecoder
|
||||
* that will accept CharsetCallback fields.
|
||||
*
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
|
||||
public class CharsetCallback {
|
||||
/*
|
||||
* FROM_U, TO_U context options for sub callback
|
||||
*/
|
||||
private static final String SUB_STOP_ON_ILLEGAL = "i";
|
||||
|
||||
// /*
|
||||
// * FROM_U, TO_U context options for skip callback
|
||||
// */
|
||||
// private static final String SKIP_STOP_ON_ILLEGAL = "i";
|
||||
|
||||
// /*
|
||||
// * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to ICU (%UXXXX)
|
||||
// */
|
||||
// private static final String ESCAPE_ICU = null;
|
||||
|
||||
/*
|
||||
* FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to JAVA (\\uXXXX)
|
||||
*/
|
||||
private static final String ESCAPE_JAVA = "J";
|
||||
|
||||
/*
|
||||
* FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to C (\\uXXXX \\UXXXXXXXX)
|
||||
* TO_U_CALLBACK_ESCAPE option to escape the character value accoding to C (\\xXXXX)
|
||||
*/
|
||||
private static final String ESCAPE_C = "C";
|
||||
|
||||
/*
|
||||
* FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Decimal escape \htmlonly(&#DDDD;)\endhtmlonly
|
||||
* TO_U_CALLBACK_ESCAPE context option to escape the character value accoding to XML Decimal escape \htmlonly(&#DDDD;)\endhtmlonly
|
||||
*/
|
||||
private static final String ESCAPE_XML_DEC = "D";
|
||||
|
||||
/*
|
||||
* FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Hex escape \htmlonly(&#xXXXX;)\endhtmlonly
|
||||
* TO_U_CALLBACK_ESCAPE context option to escape the character value according to XML Hex escape \htmlonly(&#xXXXX;)\endhtmlonly
|
||||
*/
|
||||
private static final String ESCAPE_XML_HEX = "X";
|
||||
|
||||
/*
|
||||
* FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to Unicode (U+XXXXX)
|
||||
*/
|
||||
private static final String ESCAPE_UNICODE = "U";
|
||||
|
||||
/*
|
||||
* FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to Unicode (U+XXXXX)
|
||||
*/
|
||||
private static final String ESCAPE_CSS2 = "S";
|
||||
|
||||
/**
|
||||
* Decoder Callback interface
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public interface Decoder {
|
||||
/**
|
||||
* This function is called when the bytes in the source cannot be handled,
|
||||
* and this function is meant to handle or fix the error if possible.
|
||||
*
|
||||
* @return Result of decoding action. This returned object is set to an error
|
||||
* if this function could not handle the conversion.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public CoderResult call(CharsetDecoderICU decoder, Object context,
|
||||
ByteBuffer source, CharBuffer target, IntBuffer offsets,
|
||||
char[] buffer, int length, CoderResult cr);
|
||||
}
|
||||
/**
|
||||
* Encoder Callback interface
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public interface Encoder {
|
||||
/**
|
||||
* This function is called when the Unicode characters in the source cannot be handled,
|
||||
* and this function is meant to handle or fix the error if possible.
|
||||
* @return Result of decoding action. This returned object is set to an error
|
||||
* if this function could not handle the conversion.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public CoderResult call(CharsetEncoderICU encoder, Object context,
|
||||
CharBuffer source, ByteBuffer target, IntBuffer offsets,
|
||||
char[] buffer, int length, int cp, CoderResult cr);
|
||||
}
|
||||
/**
|
||||
* Skip callback
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public static final Encoder FROM_U_CALLBACK_SKIP = new Encoder() {
|
||||
public CoderResult call(CharsetEncoderICU encoder, Object context,
|
||||
CharBuffer source, ByteBuffer target, IntBuffer offsets,
|
||||
char[] buffer, int length, int cp, CoderResult cr){
|
||||
if(context==null){
|
||||
return CoderResult.UNDERFLOW;
|
||||
}else if(((String)context).equals(SUB_STOP_ON_ILLEGAL)){
|
||||
if(!cr.isUnmappable()){
|
||||
return cr;
|
||||
}else{
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
}
|
||||
return cr;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Skip callback
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public static final Decoder TO_U_CALLBACK_SKIP = new Decoder() {
|
||||
public CoderResult call(CharsetDecoderICU decoder, Object context,
|
||||
ByteBuffer source, CharBuffer target, IntBuffer offsets,
|
||||
char[] buffer, int length, CoderResult cr){
|
||||
if(context==null){
|
||||
return CoderResult.UNDERFLOW;
|
||||
}else if(((String)context).equals(SUB_STOP_ON_ILLEGAL)){
|
||||
if(!cr.isUnmappable()){
|
||||
return cr;
|
||||
}else{
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
}
|
||||
return cr;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Write substitute callback
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public static final Encoder FROM_U_CALLBACK_SUBSTITUTE = new Encoder(){
|
||||
public CoderResult call(CharsetEncoderICU encoder, Object context,
|
||||
CharBuffer source, ByteBuffer target, IntBuffer offsets,
|
||||
char[] buffer, int length, int cp, CoderResult cr){
|
||||
if(context==null){
|
||||
return encoder.cbFromUWriteSub(encoder, source, target, offsets);
|
||||
}else if(((String)context).equals(SUB_STOP_ON_ILLEGAL)){
|
||||
if(!cr.isUnmappable()){
|
||||
return cr;
|
||||
}else{
|
||||
return encoder.cbFromUWriteSub(encoder, source, target, offsets);
|
||||
}
|
||||
}
|
||||
return cr;
|
||||
}
|
||||
};
|
||||
private static final char[] kSubstituteChar1 = new char[]{0x1A};
|
||||
private static final char[] kSubstituteChar = new char[] {0xFFFD};
|
||||
/**
|
||||
* Write substitute callback
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public static final Decoder TO_U_CALLBACK_SUBSTITUTE = new Decoder() {
|
||||
public CoderResult call(CharsetDecoderICU decoder, Object context,
|
||||
ByteBuffer source, CharBuffer target, IntBuffer offsets,
|
||||
char[] buffer, int length, CoderResult cr){
|
||||
|
||||
CharsetICU cs = (CharsetICU) decoder.charset();
|
||||
/* could optimize this case, just one uchar */
|
||||
if(decoder.invalidCharLength == 1 && cs.subChar1 != 0) {
|
||||
return CharsetDecoderICU.toUWriteUChars(decoder, kSubstituteChar1, 0, 1, target, offsets, source.position());
|
||||
} else {
|
||||
return CharsetDecoderICU.toUWriteUChars(decoder, kSubstituteChar, 0, 1, target, offsets, source.position());
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Stop callback
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public static final Encoder FROM_U_CALLBACK_STOP = new Encoder() {
|
||||
public CoderResult call(CharsetEncoderICU encoder, Object context,
|
||||
CharBuffer source, ByteBuffer target, IntBuffer offsets,
|
||||
char[] buffer, int length, int cp, CoderResult cr){
|
||||
return cr;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Stop callback
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public static final Decoder TO_U_CALLBACK_STOP = new Decoder() {
|
||||
public CoderResult call(CharsetDecoderICU decoder, Object context,
|
||||
ByteBuffer source, CharBuffer target, IntBuffer offsets,
|
||||
char[] buffer, int length, CoderResult cr){
|
||||
return cr;
|
||||
}
|
||||
};
|
||||
private static final int VALUE_STRING_LENGTH = 32;
|
||||
private static final char UNICODE_PERCENT_SIGN_CODEPOINT = 0x0025;
|
||||
private static final char UNICODE_U_CODEPOINT = 0x0055;
|
||||
private static final char UNICODE_X_CODEPOINT = 0x0058;
|
||||
private static final char UNICODE_RS_CODEPOINT = 0x005C;
|
||||
private static final char UNICODE_U_LOW_CODEPOINT = 0x0075;
|
||||
private static final char UNICODE_X_LOW_CODEPOINT = 0x0078;
|
||||
private static final char UNICODE_AMP_CODEPOINT = 0x0026;
|
||||
private static final char UNICODE_HASH_CODEPOINT = 0x0023;
|
||||
private static final char UNICODE_SEMICOLON_CODEPOINT = 0x003B;
|
||||
private static final char UNICODE_PLUS_CODEPOINT = 0x002B;
|
||||
private static final char UNICODE_LEFT_CURLY_CODEPOINT = 0x007B;
|
||||
private static final char UNICODE_RIGHT_CURLY_CODEPOINT = 0x007D;
|
||||
private static final char UNICODE_SPACE_CODEPOINT = 0x0020;
|
||||
/**
|
||||
* Write escape callback
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
public static final Encoder FROM_U_CALLBACK_ESCAPE = new Encoder() {
|
||||
public CoderResult call(CharsetEncoderICU encoder, Object context,
|
||||
CharBuffer source, ByteBuffer target, IntBuffer offsets,
|
||||
char[] buffer, int length, int cp, CoderResult cr){
|
||||
char[] valueString = new char[VALUE_STRING_LENGTH];
|
||||
int valueStringLength = 0;
|
||||
int i = 0;
|
||||
|
||||
cr = CoderResult.UNDERFLOW;
|
||||
|
||||
if (context == null || !(context instanceof String)) {
|
||||
while (i < length) {
|
||||
valueString[valueStringLength++] = UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
|
||||
valueString[valueStringLength++] = UNICODE_U_CODEPOINT; /* adding U */
|
||||
valueStringLength += itou(valueString, valueStringLength, (int)buffer[i++] & UConverterConstants.UNSIGNED_SHORT_MASK, 16, 4);
|
||||
}
|
||||
} else {
|
||||
if (((String)context).equals(ESCAPE_JAVA)) {
|
||||
while (i < length) {
|
||||
valueString[valueStringLength++] = UNICODE_RS_CODEPOINT; /* adding \ */
|
||||
valueString[valueStringLength++] = UNICODE_U_LOW_CODEPOINT; /* adding u */
|
||||
valueStringLength += itou(valueString, valueStringLength, (int)buffer[i++] & UConverterConstants.UNSIGNED_SHORT_MASK, 16, 4);
|
||||
}
|
||||
} else if (((String)context).equals(ESCAPE_C)) {
|
||||
valueString[valueStringLength++] = UNICODE_RS_CODEPOINT; /* adding \ */
|
||||
|
||||
if (length == 2) {
|
||||
valueString[valueStringLength++] = UNICODE_U_CODEPOINT; /* adding U */
|
||||
valueStringLength = itou(valueString, valueStringLength, cp, 16, 8);
|
||||
} else {
|
||||
valueString[valueStringLength++] = UNICODE_U_LOW_CODEPOINT; /* adding u */
|
||||
valueStringLength += itou(valueString, valueStringLength, (int)buffer[0] & UConverterConstants.UNSIGNED_SHORT_MASK, 16, 4);
|
||||
}
|
||||
} else if (((String)context).equals(ESCAPE_XML_DEC)) {
|
||||
valueString[valueStringLength++] = UNICODE_AMP_CODEPOINT; /* adding & */
|
||||
valueString[valueStringLength++] = UNICODE_HASH_CODEPOINT; /* adding # */
|
||||
if (length == 2) {
|
||||
valueStringLength += itou(valueString, valueStringLength, cp, 10, 0);
|
||||
} else {
|
||||
valueStringLength += itou(valueString, valueStringLength, (int)buffer[0] & UConverterConstants.UNSIGNED_SHORT_MASK, 10, 0);
|
||||
}
|
||||
valueString[valueStringLength++] = UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
|
||||
} else if (((String)context).equals(ESCAPE_XML_HEX)) {
|
||||
valueString[valueStringLength++] = UNICODE_AMP_CODEPOINT; /* adding & */
|
||||
valueString[valueStringLength++] = UNICODE_HASH_CODEPOINT; /* adding # */
|
||||
valueString[valueStringLength++] = UNICODE_X_LOW_CODEPOINT; /* adding x */
|
||||
if (length == 2) {
|
||||
valueStringLength += itou(valueString, valueStringLength, cp, 16, 0);
|
||||
} else {
|
||||
valueStringLength += itou(valueString, valueStringLength, (int)buffer[0] & UConverterConstants.UNSIGNED_SHORT_MASK, 16, 0);
|
||||
}
|
||||
valueString[valueStringLength++] = UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
|
||||
} else if (((String)context).equals(ESCAPE_UNICODE)) {
|
||||
valueString[valueStringLength++] = UNICODE_LEFT_CURLY_CODEPOINT; /* adding { */
|
||||
valueString[valueStringLength++] = UNICODE_U_CODEPOINT; /* adding U */
|
||||
valueString[valueStringLength++] = UNICODE_PLUS_CODEPOINT; /* adding + */
|
||||
if (length == 2) {
|
||||
valueStringLength += itou(valueString, valueStringLength,cp, 16, 4);
|
||||
} else {
|
||||
valueStringLength += itou(valueString, valueStringLength, (int)buffer[0] & UConverterConstants.UNSIGNED_SHORT_MASK, 16, 4);
|
||||
}
|
||||
valueString[valueStringLength++] = UNICODE_RIGHT_CURLY_CODEPOINT; /* adding } */
|
||||
} else if (((String)context).equals(ESCAPE_CSS2)) {
|
||||
valueString[valueStringLength++] = UNICODE_RS_CODEPOINT; /* adding \ */
|
||||
valueStringLength += itou(valueString, valueStringLength, cp, 16, 0);
|
||||
/* Always add space character, because the next character might be whitespace,
|
||||
which would erroneously be considered the termination of the escape sequence. */
|
||||
valueString[valueStringLength++] = UNICODE_SPACE_CODEPOINT;
|
||||
} else {
|
||||
while (i < length) {
|
||||
valueString[valueStringLength++] = UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
|
||||
valueString[valueStringLength++] = UNICODE_U_CODEPOINT; /* adding U */
|
||||
valueStringLength += itou(valueString, valueStringLength, (int)buffer[i++] & UConverterConstants.UNSIGNED_SHORT_MASK, 16, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cr = encoder.cbFromUWriteUChars(encoder, CharBuffer.wrap(valueString, 0, valueStringLength), target, offsets);
|
||||
return cr;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Write escape callback
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
public static final Decoder TO_U_CALLBACK_ESCAPE = new Decoder() {
|
||||
public CoderResult call(CharsetDecoderICU decoder, Object context,
|
||||
ByteBuffer source, CharBuffer target, IntBuffer offsets,
|
||||
char[] buffer, int length, CoderResult cr){
|
||||
char[] uniValueString = new char[VALUE_STRING_LENGTH];
|
||||
int valueStringLength = 0;
|
||||
int i = 0;
|
||||
|
||||
if (context == null || !(context instanceof String)) {
|
||||
while (i < length) {
|
||||
uniValueString[valueStringLength++] = UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
|
||||
uniValueString[valueStringLength++] = UNICODE_X_CODEPOINT; /* adding U */
|
||||
valueStringLength += itou(uniValueString, valueStringLength, buffer[i++] & UConverterConstants.UNSIGNED_BYTE_MASK, 16, 2);
|
||||
}
|
||||
} else {
|
||||
if (((String)context).equals(ESCAPE_XML_DEC)) {
|
||||
while (i < length) {
|
||||
uniValueString[valueStringLength++] = UNICODE_AMP_CODEPOINT; /* adding & */
|
||||
uniValueString[valueStringLength++] = UNICODE_HASH_CODEPOINT; /* adding # */
|
||||
valueStringLength += itou(uniValueString, valueStringLength, buffer[i++] & UConverterConstants.UNSIGNED_BYTE_MASK, 10, 0);
|
||||
uniValueString[valueStringLength++] = UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
|
||||
}
|
||||
} else if (((String)context).equals(ESCAPE_XML_HEX)) {
|
||||
while (i < length) {
|
||||
uniValueString[valueStringLength++] = UNICODE_AMP_CODEPOINT; /* adding & */
|
||||
uniValueString[valueStringLength++] = UNICODE_HASH_CODEPOINT; /* adding # */
|
||||
uniValueString[valueStringLength++] = UNICODE_X_LOW_CODEPOINT; /* adding x */
|
||||
valueStringLength += itou(uniValueString, valueStringLength, buffer[i++] & UConverterConstants.UNSIGNED_BYTE_MASK, 16, 0);
|
||||
uniValueString[valueStringLength++] = UNICODE_SEMICOLON_CODEPOINT; /* adding ; */
|
||||
}
|
||||
} else if (((String)context).equals(ESCAPE_C)) {
|
||||
while (i < length) {
|
||||
uniValueString[valueStringLength++] = UNICODE_RS_CODEPOINT; /* adding \ */
|
||||
uniValueString[valueStringLength++] = UNICODE_X_LOW_CODEPOINT; /* adding x */
|
||||
valueStringLength += itou(uniValueString, valueStringLength, buffer[i++] & UConverterConstants.UNSIGNED_BYTE_MASK, 16, 2);
|
||||
}
|
||||
} else {
|
||||
while (i < length) {
|
||||
uniValueString[valueStringLength++] = UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
|
||||
uniValueString[valueStringLength++] = UNICODE_X_CODEPOINT; /* adding X */
|
||||
itou(uniValueString, valueStringLength, buffer[i++] & UConverterConstants.UNSIGNED_BYTE_MASK, 16, 2);
|
||||
valueStringLength += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cr = CharsetDecoderICU.toUWriteUChars(decoder, uniValueString, 0, valueStringLength, target, offsets, 0);
|
||||
|
||||
return cr;
|
||||
}
|
||||
};
|
||||
/***
|
||||
* Java port of uprv_itou() in ICU4C used by TO_U_CALLBACK_ESCAPE and FROM_U_CALLBACK_ESCAPE.
|
||||
* Fills in a char string with the radix-based representation of a number padded with zeroes
|
||||
* to minwidth.
|
||||
*/
|
||||
private static final int itou(char[] buffer, int sourceIndex, int i, int radix, int minwidth) {
|
||||
int length = 0;
|
||||
int digit;
|
||||
int j;
|
||||
char temp;
|
||||
|
||||
do {
|
||||
digit = i % radix;
|
||||
buffer[sourceIndex + length++] = (char)(digit <= 9 ? (0x0030+digit) : (0x0030+digit+7));
|
||||
i = i/radix;
|
||||
} while (i != 0 && (sourceIndex + length) < buffer.length);
|
||||
|
||||
while (length < minwidth) {
|
||||
buffer[sourceIndex + length++] = (char)0x0030; /* zero padding */
|
||||
}
|
||||
/* reverses the string */
|
||||
for (j = 0; j < (length / 2); j++) {
|
||||
temp = buffer[(sourceIndex + length - 1) - j];
|
||||
buffer[(sourceIndex + length-1) -j] = buffer[sourceIndex + j];
|
||||
buffer[sourceIndex + j] = temp;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
/*
|
||||
* No need to create an instance
|
||||
*/
|
||||
private CharsetCallback() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,579 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.charset;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
|
||||
import com.ibm.icu.charset.CharsetMBCS.CharsetDecoderMBCS;
|
||||
import com.ibm.icu.charset.CharsetMBCS.CharsetEncoderMBCS;
|
||||
import com.ibm.icu.lang.UCharacter;
|
||||
import com.ibm.icu.text.UTF16;
|
||||
import com.ibm.icu.text.UnicodeSet;
|
||||
|
||||
class CharsetCompoundText extends CharsetICU {
|
||||
private static final byte[] fromUSubstitution = new byte[] { (byte) 0x3F };
|
||||
private CharsetMBCS gbCharset[];
|
||||
|
||||
private final static byte COMPOUND_TEXT_SINGLE_0 = 0;
|
||||
private final static byte COMPOUND_TEXT_SINGLE_1 = 1;
|
||||
private final static byte COMPOUND_TEXT_SINGLE_2 = 2;
|
||||
private final static byte COMPOUND_TEXT_SINGLE_3 = 3;
|
||||
|
||||
/*private final static byte COMPOUND_TEXT_DOUBLE_1 = 4;
|
||||
private final static byte COMPOUND_TEXT_DOUBLE_2 = 5;
|
||||
private final static byte COMPOUND_TEXT_DOUBLE_3 = 6;
|
||||
private final static byte COMPOUND_TEXT_DOUBLE_4 = 7;
|
||||
private final static byte COMPOUND_TEXT_DOUBLE_5 = 8;
|
||||
private final static byte COMPOUND_TEXT_DOUBLE_6 = 9;
|
||||
private final static byte COMPOUND_TEXT_DOUBLE_7 = 10;
|
||||
|
||||
private final static byte COMPOUND_TEXT_TRIPLE_DOUBLE = 11;*/
|
||||
|
||||
private final static byte IBM_915 = 12;
|
||||
private final static byte IBM_916 = 13;
|
||||
private final static byte IBM_914 = 14;
|
||||
private final static byte IBM_874 = 15;
|
||||
private final static byte IBM_912 = 16;
|
||||
private final static byte IBM_913 = 17;
|
||||
private final static byte ISO_8859_14 = 18;
|
||||
private final static byte IBM_923 = 19;
|
||||
|
||||
private final static byte NUM_OF_CONVERTERS = 20;
|
||||
|
||||
private final static byte SEARCH_LENGTH = 12;
|
||||
|
||||
private final static byte[][] escSeqCcompoundText = {
|
||||
/* Single */
|
||||
{ 0x1B, 0x2D, 0x41 },
|
||||
{ 0x1B, 0x2D, 0x4D },
|
||||
{ 0x1B, 0x2D, 0x46 },
|
||||
{ 0x1B, 0x2D, 0x47 },
|
||||
|
||||
/* Double */
|
||||
{ 0x1B, 0x24, 0x29, 0x41 },
|
||||
{ 0x1B, 0x24, 0x29, 0x42 },
|
||||
{ 0x1B, 0x24, 0x29, 0x43 },
|
||||
{ 0x1B, 0x24, 0x29, 0x44 },
|
||||
{ 0x1B, 0x24, 0x29, 0x47 },
|
||||
{ 0x1B, 0x24, 0x29, 0x48 },
|
||||
{ 0x1B, 0x24, 0x29, 0x49 },
|
||||
|
||||
/* Triple/Double */
|
||||
{ 0x1B, 0x25, 0x47 },
|
||||
|
||||
/*IBM-915*/
|
||||
{ 0x1B, 0x2D, 0x4C },
|
||||
/*IBM-916*/
|
||||
{ 0x1B, 0x2D, 0x48 },
|
||||
/*IBM-914*/
|
||||
{ 0x1B, 0x2D, 0x44 },
|
||||
/*IBM-874*/
|
||||
{ 0x1B, 0x2D, 0x54 },
|
||||
/*IBM-912*/
|
||||
{ 0x1B, 0x2D, 0x42 },
|
||||
/* IBM-913 */
|
||||
{ 0x1B, 0x2D, 0x43 },
|
||||
/* ISO-8859_14 */
|
||||
{ 0x1B, 0x2D, 0x5F },
|
||||
/* IBM-923 */
|
||||
{ 0x1B, 0x2D, 0x62 },
|
||||
};
|
||||
|
||||
private final static byte ESC_START = 0x1B;
|
||||
|
||||
private static boolean isASCIIRange(int codepoint) {
|
||||
if ((codepoint == 0x0000) || (codepoint == 0x0009) || (codepoint == 0x000A) ||
|
||||
(codepoint >= 0x0020 && codepoint <= 0x007f) || (codepoint >= 0x00A0 && codepoint <= 0x00FF)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isIBM915(int codepoint) {
|
||||
if ((codepoint >= 0x0401 && codepoint <= 0x045F) || (codepoint == 0x2116)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isIBM916(int codepoint) {
|
||||
if ((codepoint >= 0x05D0 && codepoint <= 0x05EA) || (codepoint == 0x2017) || (codepoint == 0x203E)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isCompoundS3(int codepoint) {
|
||||
if ((codepoint == 0x060C) || (codepoint == 0x061B) || (codepoint == 0x061F) || (codepoint >= 0x0621 && codepoint <= 0x063A) ||
|
||||
(codepoint >= 0x0640 && codepoint <= 0x0652) || (codepoint >= 0x0660 && codepoint <= 0x066D) || (codepoint == 0x200B) ||
|
||||
(codepoint >= 0x0FE70 && codepoint <= 0x0FE72) || (codepoint == 0x0FE74) || (codepoint >= 0x0FE76 && codepoint <= 0x0FEBE)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isCompoundS2(int codepoint) {
|
||||
if ((codepoint == 0x02BC) || (codepoint == 0x02BD) || (codepoint >= 0x0384 && codepoint <= 0x03CE) || (codepoint == 0x2015)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isIBM914(int codepoint) {
|
||||
if ((codepoint == 0x0100) || (codepoint == 0x0101) || (codepoint == 0x0112) || (codepoint == 0x0113) || (codepoint == 0x0116) || (codepoint == 0x0117) ||
|
||||
(codepoint == 0x0122) || (codepoint == 0x0123) || (codepoint >= 0x0128 && codepoint <= 0x012B) || (codepoint == 0x012E) || (codepoint == 0x012F) ||
|
||||
(codepoint >= 0x0136 && codepoint <= 0x0138) || (codepoint == 0x013B) || (codepoint == 0x013C) || (codepoint == 0x0145) || (codepoint == 0x0146) ||
|
||||
(codepoint >= 0x014A && codepoint <= 0x014D) || (codepoint == 0x0156) || (codepoint == 0x0157) || (codepoint >= 0x0166 && codepoint <= 0x016B) ||
|
||||
(codepoint == 0x0172) || (codepoint == 0x0173)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isIBM874(int codepoint) {
|
||||
if ((codepoint >= 0x0E01 && codepoint <= 0x0E3A) || (codepoint >= 0x0E3F && codepoint <= 0x0E5B)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isIBM912(int codepoint) {
|
||||
if ((codepoint >= 0x0102 && codepoint <= 0x0107) || (codepoint >= 0x010C && codepoint <= 0x0111) || (codepoint >= 0x0118 && codepoint <= 0x011B) ||
|
||||
(codepoint == 0x0139) || (codepoint == 0x013A) || (codepoint == 0x013D) || (codepoint == 0x013E) || (codepoint >= 0x0141 && codepoint <= 0x0144) ||
|
||||
(codepoint == 0x0147) || (codepoint == 0x0147) || (codepoint == 0x0150) || (codepoint == 0x0151) || (codepoint == 0x0154) || (codepoint == 0x0155) ||
|
||||
(codepoint >= 0x0158 && codepoint <= 0x015B) || (codepoint == 0x015E) || (codepoint == 0x015F) || (codepoint >= 0x0160 && codepoint <= 0x0165) ||
|
||||
(codepoint == 0x016E) || (codepoint == 0x016F) || (codepoint == 0x0170) || (codepoint == 0x0171) || (codepoint >= 0x0179 && codepoint <= 0x017E) ||
|
||||
(codepoint == 0x02C7) || (codepoint == 0x02D8) || (codepoint == 0x02D9) || (codepoint == 0x02DB) || (codepoint == 0x02DD)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isIBM913(int codepoint) {
|
||||
if ((codepoint >= 0x0108 && codepoint <= 0x010B) || (codepoint == 0x011C) ||
|
||||
(codepoint == 0x011D) || (codepoint == 0x0120) || (codepoint == 0x0121) ||
|
||||
(codepoint >= 0x0124 && codepoint <= 0x0127) || (codepoint == 0x0134) || (codepoint == 0x0135) ||
|
||||
(codepoint == 0x015C) || (codepoint == 0x015D) || (codepoint == 0x016C) || (codepoint == 0x016D)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isCompoundS1(int codepoint) {
|
||||
if ((codepoint == 0x011E) || (codepoint == 0x011F) || (codepoint == 0x0130) ||
|
||||
(codepoint == 0x0131) || (codepoint >= 0x0218 && codepoint <= 0x021B)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isISO8859_14(int codepoint) {
|
||||
if ((codepoint >= 0x0174 && codepoint <= 0x0177) || (codepoint == 0x1E0A) ||
|
||||
(codepoint == 0x1E0B) || (codepoint == 0x1E1E) || (codepoint == 0x1E1F) ||
|
||||
(codepoint == 0x1E40) || (codepoint == 0x1E41) || (codepoint == 0x1E56) ||
|
||||
(codepoint == 0x1E57) || (codepoint == 0x1E60) || (codepoint == 0x1E61) ||
|
||||
(codepoint == 0x1E6A) || (codepoint == 0x1E6B) || (codepoint == 0x1EF2) ||
|
||||
(codepoint == 0x1EF3) || (codepoint >= 0x1E80 && codepoint <= 0x1E85)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isIBM923(int codepoint) {
|
||||
if ((codepoint == 0x0152) || (codepoint == 0x0153) || (codepoint == 0x0178) || (codepoint == 0x20AC)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static int findNextEsc(ByteBuffer source) {
|
||||
for (int i = source.position(); i < source.limit(); i++) {
|
||||
if (source.get(i) == 0x1B) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return source.limit();
|
||||
}
|
||||
|
||||
private static byte getState(int codepoint) {
|
||||
byte state = -1;
|
||||
|
||||
if (isASCIIRange(codepoint)) {
|
||||
state = COMPOUND_TEXT_SINGLE_0;
|
||||
} else if (isIBM912(codepoint)) {
|
||||
state = IBM_912;
|
||||
}else if (isIBM913(codepoint)) {
|
||||
state = IBM_913;
|
||||
} else if (isISO8859_14(codepoint)) {
|
||||
state = ISO_8859_14;
|
||||
} else if (isIBM923(codepoint)) {
|
||||
state = IBM_923;
|
||||
} else if (isIBM874(codepoint)) {
|
||||
state = IBM_874;
|
||||
} else if (isIBM914(codepoint)) {
|
||||
state = IBM_914;
|
||||
} else if (isCompoundS2(codepoint)) {
|
||||
state = COMPOUND_TEXT_SINGLE_2;
|
||||
} else if (isCompoundS3(codepoint)) {
|
||||
state = COMPOUND_TEXT_SINGLE_3;
|
||||
} else if (isIBM916(codepoint)) {
|
||||
state = IBM_916;
|
||||
} else if (isIBM915(codepoint)) {
|
||||
state = IBM_915;
|
||||
} else if (isCompoundS1(codepoint)) {
|
||||
state = COMPOUND_TEXT_SINGLE_1;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
private static int findStateFromEscSeq(ByteBuffer source) {
|
||||
int state = -1;
|
||||
int sourceIndex = source.position();
|
||||
boolean matchFound = false;
|
||||
int i, n;
|
||||
|
||||
for (i = 0; i < escSeqCcompoundText.length; i++) {
|
||||
for (n = 0; n < escSeqCcompoundText[i].length; n++) {
|
||||
matchFound = true;
|
||||
if (source.get(sourceIndex + n) != escSeqCcompoundText[i][n]) {
|
||||
matchFound = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matchFound) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchFound) {
|
||||
state = i;
|
||||
source.position(sourceIndex + escSeqCcompoundText[i].length);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
public CharsetCompoundText(String icuCanonicalName, String javaCanonicalName, String[] aliases) {
|
||||
super(icuCanonicalName, javaCanonicalName, aliases);
|
||||
|
||||
LoadConverters();
|
||||
|
||||
maxBytesPerChar = 6;
|
||||
minBytesPerChar = 1;
|
||||
maxCharsPerByte = 1;
|
||||
}
|
||||
|
||||
private void LoadConverters() {
|
||||
gbCharset = new CharsetMBCS[NUM_OF_CONVERTERS];
|
||||
|
||||
gbCharset[COMPOUND_TEXT_SINGLE_0] = null;
|
||||
|
||||
for (int i = 1; i < SEARCH_LENGTH; i++) {
|
||||
String name = "icu-internal-compound-";
|
||||
if (i <= 3) {
|
||||
name = name + "s" + i;
|
||||
} else if (i <= 10) {
|
||||
name = name + "d" + (i - 3);
|
||||
} else {
|
||||
name = name + "t";
|
||||
}
|
||||
|
||||
gbCharset[i] = (CharsetMBCS)CharsetICU.forNameICU(name);
|
||||
}
|
||||
|
||||
gbCharset[IBM_915] = (CharsetMBCS)CharsetICU.forNameICU("ibm-915_P100-1995");
|
||||
gbCharset[IBM_916] = (CharsetMBCS)CharsetICU.forNameICU("ibm-916_P100-1995");
|
||||
gbCharset[IBM_914] = (CharsetMBCS)CharsetICU.forNameICU("ibm-914_P100-1995");
|
||||
gbCharset[IBM_874] = (CharsetMBCS)CharsetICU.forNameICU("ibm-874_P100-1995");
|
||||
gbCharset[IBM_912] = (CharsetMBCS)CharsetICU.forNameICU("ibm-912_P100-1995");
|
||||
gbCharset[IBM_913] = (CharsetMBCS)CharsetICU.forNameICU("ibm-913_P100-2000");
|
||||
gbCharset[ISO_8859_14] = (CharsetMBCS)CharsetICU.forNameICU("iso-8859_14-1998");
|
||||
gbCharset[IBM_923] = (CharsetMBCS)CharsetICU.forNameICU("ibm-923_P100-1998");
|
||||
}
|
||||
|
||||
class CharsetEncoderCompoundText extends CharsetEncoderICU {
|
||||
CharsetEncoderMBCS gbEncoder[];
|
||||
|
||||
public CharsetEncoderCompoundText(CharsetICU cs) {
|
||||
super(cs, fromUSubstitution);
|
||||
|
||||
gbEncoder = new CharsetEncoderMBCS[NUM_OF_CONVERTERS];
|
||||
|
||||
for (int i = 0; i < NUM_OF_CONVERTERS; i++) {
|
||||
if (i == 0) {
|
||||
gbEncoder[i] = null;
|
||||
} else {
|
||||
gbEncoder[i] = (CharsetEncoderMBCS)gbCharset[i].newEncoder();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void implReset() {
|
||||
super.implReset();
|
||||
for (int i = 0; i < NUM_OF_CONVERTERS; i++) {
|
||||
if (gbEncoder[i] != null) {
|
||||
gbEncoder[i].implReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush) {
|
||||
CoderResult err = CoderResult.UNDERFLOW;
|
||||
int sourceChar;
|
||||
char []sourceCharArray = { 0x0000 };
|
||||
ByteBuffer tmpTargetBuffer = ByteBuffer.allocate(3);
|
||||
byte[] targetBytes = new byte[10];
|
||||
int targetLength = 0;
|
||||
int currentState = this.fromUnicodeStatus;
|
||||
byte tmpState = 0;
|
||||
int i = 0;
|
||||
boolean gotoGetTrail = false;
|
||||
|
||||
if (!source.hasRemaining())
|
||||
return CoderResult.UNDERFLOW;
|
||||
else if (!target.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
|
||||
/* check if the last codepoint of previous buffer was a lead surrogate */
|
||||
if ((sourceChar = fromUChar32) != 0 && target.hasRemaining()) {
|
||||
// goto getTrail label
|
||||
gotoGetTrail = true;
|
||||
}
|
||||
|
||||
while (source.hasRemaining()) {
|
||||
if (target.hasRemaining()) {
|
||||
if (!gotoGetTrail) {
|
||||
sourceChar = source.get();
|
||||
}
|
||||
|
||||
targetLength = 0;
|
||||
tmpTargetBuffer.position(0);
|
||||
tmpTargetBuffer.limit(3);
|
||||
|
||||
/* check if the char is a First surrogate */
|
||||
if (UTF16.isSurrogate((char)sourceChar) || gotoGetTrail) {
|
||||
if (UTF16.isLeadSurrogate((char)sourceChar) || gotoGetTrail) {
|
||||
// getTrail label
|
||||
/* reset gotoGetTrail flag*/
|
||||
gotoGetTrail = false;
|
||||
|
||||
/* look ahead to find the trail surrogate */
|
||||
if (source.hasRemaining()) {
|
||||
/* test the following code unit */
|
||||
char trail = source.get();
|
||||
source.position(source.position()-1);
|
||||
if (UTF16.isTrailSurrogate(trail)) {
|
||||
source.get();
|
||||
sourceChar = UCharacter.getCodePoint((char)sourceChar, trail);
|
||||
fromUChar32 = 0x00;
|
||||
/* convert this supplementary code point */
|
||||
/* exit this condition tree */
|
||||
} else {
|
||||
/* this is an unmatched lead code unit (1st surrogate) */
|
||||
/* callback(illegal) */
|
||||
err = CoderResult.malformedForLength(1);
|
||||
fromUChar32 = sourceChar;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* no more input */
|
||||
fromUChar32 = sourceChar;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* this is an unmatched trail code unit (2nd surrogate) */
|
||||
/* callback(illegal) */
|
||||
err = CoderResult.malformedForLength(1);
|
||||
fromUChar32 = sourceChar;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tmpState = getState(sourceChar);
|
||||
|
||||
sourceCharArray[0] = (char)sourceChar;
|
||||
|
||||
if (tmpState < 0) {
|
||||
/* Test all available converters */
|
||||
for (i = 1; i < SEARCH_LENGTH; i++) {
|
||||
err = gbEncoder[i].cnvMBCSFromUnicodeWithOffsets(CharBuffer.wrap(sourceCharArray), tmpTargetBuffer, offsets, true);
|
||||
if (!err.isError()) {
|
||||
tmpState = (byte)i;
|
||||
tmpTargetBuffer.limit(tmpTargetBuffer.position());
|
||||
implReset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (tmpState == COMPOUND_TEXT_SINGLE_0) {
|
||||
tmpTargetBuffer.put(0, (byte)sourceChar);
|
||||
tmpTargetBuffer.limit(1);
|
||||
} else {
|
||||
err = gbEncoder[tmpState].cnvMBCSFromUnicodeWithOffsets(CharBuffer.wrap(sourceCharArray), tmpTargetBuffer, offsets, true);
|
||||
if (!err.isError()) {
|
||||
tmpTargetBuffer.limit(tmpTargetBuffer.position());
|
||||
}
|
||||
}
|
||||
if (err.isError()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (currentState != tmpState) {
|
||||
currentState = tmpState;
|
||||
|
||||
/* Write escape sequence if necessary */
|
||||
for (i = 0; i < escSeqCcompoundText[currentState].length; i++) {
|
||||
targetBytes[i] = escSeqCcompoundText[currentState][i];
|
||||
}
|
||||
targetLength = i;
|
||||
}
|
||||
|
||||
for (i = 0; i < tmpTargetBuffer.limit(); i++) {
|
||||
targetBytes[i+targetLength] = tmpTargetBuffer.get(i);
|
||||
}
|
||||
targetLength += i;
|
||||
|
||||
for (i = 0; i < targetLength; i++) {
|
||||
if (target.hasRemaining()) {
|
||||
target.put(targetBytes[i]);
|
||||
} else {
|
||||
err = CoderResult.OVERFLOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err = CoderResult.OVERFLOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (err.isOverflow()) {
|
||||
int m = 0;
|
||||
for (int n = i; n < targetLength; n++) {
|
||||
this.errorBuffer[m++] = targetBytes[n];
|
||||
}
|
||||
this.errorBufferLength = m;
|
||||
}
|
||||
this.fromUnicodeStatus = currentState;
|
||||
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
class CharsetDecoderCompoundText extends CharsetDecoderICU {
|
||||
CharsetDecoderMBCS gbDecoder[];
|
||||
|
||||
public CharsetDecoderCompoundText(CharsetICU cs) {
|
||||
super(cs);
|
||||
gbDecoder = new CharsetDecoderMBCS[NUM_OF_CONVERTERS];
|
||||
|
||||
for (int i = 0; i < NUM_OF_CONVERTERS; i++) {
|
||||
if (i == 0) {
|
||||
gbDecoder[i] = null;
|
||||
} else {
|
||||
gbDecoder[i] = (CharsetDecoderMBCS)gbCharset[i].newDecoder();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void implReset() {
|
||||
super.implReset();
|
||||
for (int i = 0; i < NUM_OF_CONVERTERS; i++) {
|
||||
if (gbDecoder[i] != null) {
|
||||
gbDecoder[i].implReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoop(ByteBuffer source, CharBuffer target, IntBuffer offsets, boolean flush) {
|
||||
CoderResult err = CoderResult.UNDERFLOW;
|
||||
byte[] sourceChar = { 0x00 };
|
||||
int currentState = this.toUnicodeStatus;
|
||||
int tmpState = currentState;
|
||||
CharsetDecoderMBCS decoder;
|
||||
int sourceLimit = source.limit();;
|
||||
|
||||
if (!source.hasRemaining())
|
||||
return CoderResult.UNDERFLOW;
|
||||
else if (!target.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
|
||||
while (source.hasRemaining()) {
|
||||
if (target.hasRemaining()) {
|
||||
sourceChar[0] = source.get(source.position());
|
||||
|
||||
if (sourceChar[0] == ESC_START) {
|
||||
tmpState = findStateFromEscSeq(source);
|
||||
if (tmpState < 0) {
|
||||
err = CoderResult.malformedForLength(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmpState != currentState) {
|
||||
currentState = tmpState;
|
||||
}
|
||||
|
||||
if (currentState == COMPOUND_TEXT_SINGLE_0) {
|
||||
while (source.hasRemaining()) {
|
||||
if (!target.hasRemaining()) {
|
||||
err = CoderResult.OVERFLOW;
|
||||
break;
|
||||
}
|
||||
if (source.get(source.position()) == ESC_START) {
|
||||
break;
|
||||
}
|
||||
if (target.hasRemaining()) {
|
||||
target.put((char)(UConverterConstants.UNSIGNED_BYTE_MASK&source.get()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
source.limit(findNextEsc(source));
|
||||
|
||||
decoder = gbDecoder[currentState];
|
||||
|
||||
err = decoder.decodeLoop(source, target, offsets, true);
|
||||
|
||||
source.limit(sourceLimit);
|
||||
}
|
||||
|
||||
if (err.isError()) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
err = CoderResult.OVERFLOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new CharsetDecoderCompoundText(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new CharsetEncoderCompoundText(this);
|
||||
}
|
||||
|
||||
void getUnicodeSetImpl( UnicodeSet setFillIn, int which){
|
||||
for (int i = 1; i < NUM_OF_CONVERTERS; i++) {
|
||||
gbCharset[i].MBCSGetFilteredUnicodeSetForUnicode(gbCharset[i].sharedData, setFillIn, which, CharsetMBCS.UCNV_SET_FILTER_NONE);
|
||||
}
|
||||
setFillIn.add(0x0000);
|
||||
setFillIn.add(0x0009);
|
||||
setFillIn.add(0x000A);
|
||||
setFillIn.add(0x0020, 0x007F);
|
||||
setFillIn.add(0x00A0, 0x00FF);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,725 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.charset;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.CodingErrorAction;
|
||||
|
||||
import com.ibm.icu.impl.Assert;
|
||||
|
||||
/**
|
||||
* An abstract class that provides framework methods of decoding operations for concrete
|
||||
* subclasses.
|
||||
* In the future this class will contain API that will implement converter sematics of ICU4C.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public abstract class CharsetDecoderICU extends CharsetDecoder{
|
||||
|
||||
int toUnicodeStatus;
|
||||
byte[] toUBytesArray = new byte[128];
|
||||
int toUBytesBegin = 0;
|
||||
int toULength;
|
||||
char[] charErrorBufferArray = new char[128];
|
||||
int charErrorBufferLength;
|
||||
int charErrorBufferBegin;
|
||||
char[] invalidCharBuffer = new char[128];
|
||||
int invalidCharLength;
|
||||
|
||||
/**
|
||||
* Maximum number of indexed bytes
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
protected static final int EXT_MAX_BYTES = 0x1f;
|
||||
|
||||
/* store previous UChars/chars to continue partial matches */
|
||||
byte[] preToUArray = new byte[EXT_MAX_BYTES];
|
||||
int preToUBegin;
|
||||
int preToULength; /* negative: replay */
|
||||
int preToUFirstLength; /* length of first character */
|
||||
int mode;
|
||||
|
||||
Object toUContext = null;
|
||||
private CharsetCallback.Decoder onUnmappableCharacter = CharsetCallback.TO_U_CALLBACK_STOP;
|
||||
private CharsetCallback.Decoder onMalformedInput = CharsetCallback.TO_U_CALLBACK_STOP;
|
||||
CharsetCallback.Decoder toCharErrorBehaviour = new CharsetCallback.Decoder() {
|
||||
public CoderResult call(CharsetDecoderICU decoder, Object context, ByteBuffer source,
|
||||
CharBuffer target, IntBuffer offsets, char[] buffer, int length, CoderResult cr) {
|
||||
if (cr.isUnmappable()) {
|
||||
return onUnmappableCharacter.call(decoder, context, source, target, offsets, buffer,
|
||||
length, cr);
|
||||
} else /* if (cr.isMalformed()) */ {
|
||||
return onMalformedInput.call(decoder, context, source, target, offsets, buffer,
|
||||
length, cr);
|
||||
}
|
||||
// return CharsetCallback.TO_U_CALLBACK_STOP.call(decoder, context, source, target, offsets, buffer, length, cr);
|
||||
}
|
||||
};
|
||||
|
||||
// exist to keep implOnMalformedInput and implOnUnmappableInput from being too recursive
|
||||
private boolean malformedInputCalled = false;
|
||||
private boolean unmappableCharacterCalled = false;
|
||||
|
||||
/*
|
||||
* Construct a CharsetDecorderICU based on the information provided from a CharsetICU object.
|
||||
*
|
||||
* @param cs The CharsetICU object containing information about how to charset to decode.
|
||||
*/
|
||||
CharsetDecoderICU(CharsetICU cs) {
|
||||
super(cs, (1/cs.maxCharsPerByte), cs.maxCharsPerByte);
|
||||
}
|
||||
|
||||
/*
|
||||
* Is this Decoder allowed to use fallbacks? A fallback mapping is a mapping
|
||||
* that will convert a byte sequence to a Unicode codepoint sequence, but
|
||||
* the encoded Unicode codepoint sequence will round trip convert to a different
|
||||
* byte sequence. In ICU, this is can be called a reverse fallback.
|
||||
* @return A boolean
|
||||
*/
|
||||
final boolean isFallbackUsed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback is currently always used by icu4j decoders.
|
||||
*/
|
||||
static final boolean isToUUseFallback() {
|
||||
return isToUUseFallback(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback is currently always used by icu4j decoders.
|
||||
*/
|
||||
static final boolean isToUUseFallback(boolean iUseFallback) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the action to be taken if an illegal sequence is encountered
|
||||
*
|
||||
* @param newAction action to be taken
|
||||
* @exception IllegalArgumentException
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected final void implOnMalformedInput(CodingErrorAction newAction) {
|
||||
// don't run infinitely
|
||||
if (malformedInputCalled)
|
||||
return;
|
||||
|
||||
// if we get a replace, do not let the nio replace
|
||||
if (newAction == CodingErrorAction.REPLACE) {
|
||||
malformedInputCalled = true;
|
||||
super.onMalformedInput(CodingErrorAction.IGNORE);
|
||||
malformedInputCalled = false;
|
||||
}
|
||||
|
||||
onMalformedInput = getCallback(newAction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the action to be taken if an illegal sequence is encountered
|
||||
*
|
||||
* @param newAction action to be taken
|
||||
* @exception IllegalArgumentException
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected final void implOnUnmappableCharacter(CodingErrorAction newAction) {
|
||||
// dont run infinitely
|
||||
if (unmappableCharacterCalled)
|
||||
return;
|
||||
|
||||
// if we get a replace, do not let the nio replace
|
||||
if (newAction == CodingErrorAction.REPLACE) {
|
||||
unmappableCharacterCalled = true;
|
||||
super.onUnmappableCharacter(CodingErrorAction.IGNORE);
|
||||
unmappableCharacterCalled = false;
|
||||
}
|
||||
|
||||
onUnmappableCharacter = getCallback(newAction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the callback encoder method and context to be used if an illegal sequence is encounterd.
|
||||
* You would normally call this twice to set both the malform and unmappable error. In this case,
|
||||
* newContext should remain the same since using a different newContext each time will negate the last
|
||||
* one used.
|
||||
* @param err CoderResult
|
||||
* @param newCallback CharsetCallback.Encoder
|
||||
* @param newContext Object
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
public final void setToUCallback(CoderResult err, CharsetCallback.Decoder newCallback, Object newContext) {
|
||||
if (err.isMalformed()) {
|
||||
onMalformedInput = newCallback;
|
||||
} else if (err.isUnmappable()) {
|
||||
onUnmappableCharacter = newCallback;
|
||||
} else {
|
||||
/* Error: Only malformed and unmappable are handled. */
|
||||
}
|
||||
|
||||
if (toUContext == null || !toUContext.equals(newContext)) {
|
||||
toUContext = newContext;
|
||||
}
|
||||
}
|
||||
|
||||
private static CharsetCallback.Decoder getCallback(CodingErrorAction action){
|
||||
if(action==CodingErrorAction.REPLACE){
|
||||
return CharsetCallback.TO_U_CALLBACK_SUBSTITUTE;
|
||||
}else if(action==CodingErrorAction.IGNORE){
|
||||
return CharsetCallback.TO_U_CALLBACK_SKIP;
|
||||
}else /* if(action==CodingErrorAction.REPORT) */ {
|
||||
return CharsetCallback.TO_U_CALLBACK_STOP;
|
||||
}
|
||||
}
|
||||
private final ByteBuffer EMPTY = ByteBuffer.allocate(0);
|
||||
/**
|
||||
* Flushes any characters saved in the converter's internal buffer and
|
||||
* resets the converter.
|
||||
* @param out action to be taken
|
||||
* @return result of flushing action and completes the decoding all input.
|
||||
* Returns CoderResult.UNDERFLOW if the action succeeds.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected final CoderResult implFlush(CharBuffer out) {
|
||||
return decode(EMPTY, out, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the to Unicode mode of converter
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected void implReset() {
|
||||
toUnicodeStatus = 0 ;
|
||||
toULength = 0;
|
||||
charErrorBufferLength = 0;
|
||||
charErrorBufferBegin = 0;
|
||||
|
||||
/* store previous UChars/chars to continue partial matches */
|
||||
preToUBegin = 0;
|
||||
preToULength = 0; /* negative: replay */
|
||||
preToUFirstLength = 0;
|
||||
|
||||
mode = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes one or more bytes. The default behaviour of the converter
|
||||
* is stop and report if an error in input stream is encountered.
|
||||
* To set different behaviour use @see CharsetDecoder.onMalformedInput()
|
||||
* This method allows a buffer by buffer conversion of a data stream.
|
||||
* The state of the conversion is saved between calls to convert.
|
||||
* Among other things, this means multibyte input sequences can be
|
||||
* split between calls. If a call to convert results in an Error, the
|
||||
* conversion may be continued by calling convert again with suitably
|
||||
* modified parameters.All conversions should be finished with a call to
|
||||
* the flush method.
|
||||
* @param in buffer to decode
|
||||
* @param out buffer to populate with decoded result
|
||||
* @return Result of decoding action. Returns CoderResult.UNDERFLOW if the decoding
|
||||
* action succeeds or more input is needed for completing the decoding action.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected CoderResult decodeLoop(ByteBuffer in,CharBuffer out){
|
||||
if(in.remaining() < toUCountPending()){
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
// if (!in.hasRemaining()) {
|
||||
// toULength = 0;
|
||||
// return CoderResult.UNDERFLOW;
|
||||
// }
|
||||
|
||||
in.position(in.position() + toUCountPending());
|
||||
|
||||
/* do the conversion */
|
||||
CoderResult ret = decode(in, out, null, false);
|
||||
|
||||
// ok was there input held in the previous invocation of decodeLoop
|
||||
// that resulted in output in this invocation?
|
||||
in.position(in.position() - toUCountPending());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implements the ICU semantic for decode operation
|
||||
* @param in The input byte buffer
|
||||
* @param out The output character buffer
|
||||
* @return Result of decoding action. Returns CoderResult.UNDERFLOW if the decoding
|
||||
* action succeeds or more input is needed for completing the decoding action.
|
||||
*/
|
||||
abstract CoderResult decodeLoop(ByteBuffer in, CharBuffer out, IntBuffer offsets, boolean flush);
|
||||
|
||||
/*
|
||||
* Implements the ICU semantic for decode operation
|
||||
* @param source The input byte buffer
|
||||
* @param target The output character buffer
|
||||
* @param offsets
|
||||
* @param flush true if, and only if, the invoker can provide no
|
||||
* additional input bytes beyond those in the given buffer.
|
||||
* @return Result of decoding action. Returns CoderResult.UNDERFLOW if the decoding
|
||||
* action succeeds or more input is needed for completing the decoding action.
|
||||
*/
|
||||
final CoderResult decode(ByteBuffer source, CharBuffer target, IntBuffer offsets, boolean flush) {
|
||||
|
||||
/* check parameters */
|
||||
if (target == null || source == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure that the buffer sizes do not exceed the number range for
|
||||
* int32_t because some functions use the size (in units or bytes)
|
||||
* rather than comparing pointers, and because offsets are int32_t values.
|
||||
*
|
||||
* size_t is guaranteed to be unsigned and large enough for the job.
|
||||
*
|
||||
* Return with an error instead of adjusting the limits because we would
|
||||
* not be able to maintain the semantics that either the source must be
|
||||
* consumed or the target filled (unless an error occurs).
|
||||
* An adjustment would be sourceLimit=t+0x7fffffff; for example.
|
||||
*/
|
||||
/*agljport:fix
|
||||
if(
|
||||
((size_t)(sourceLimit-s)>(size_t)0x7fffffff && sourceLimit>s) ||
|
||||
((size_t)(targetLimit-t)>(size_t)0x3fffffff && targetLimit>t)
|
||||
) {
|
||||
*err=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
/* flush the target overflow buffer */
|
||||
if (charErrorBufferLength > 0) {
|
||||
int i = 0;
|
||||
do {
|
||||
if (!target.hasRemaining()) {
|
||||
/* the overflow buffer contains too much, keep the rest */
|
||||
int j = 0;
|
||||
|
||||
do {
|
||||
charErrorBufferArray[j++] = charErrorBufferArray[i++];
|
||||
} while (i < charErrorBufferLength);
|
||||
|
||||
charErrorBufferLength = (byte) j;
|
||||
return CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
/* copy the overflow contents to the target */
|
||||
target.put(charErrorBufferArray[i++]);
|
||||
if (offsets != null) {
|
||||
offsets.put(-1); /* no source index available for old output */
|
||||
}
|
||||
} while (i < charErrorBufferLength);
|
||||
|
||||
/* the overflow buffer is completely copied to the target */
|
||||
charErrorBufferLength = 0;
|
||||
}
|
||||
|
||||
if (!flush && !source.hasRemaining() && toULength == 0 && preToULength >= 0) {
|
||||
/* the overflow buffer is emptied and there is no new input: we are done */
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not simply return with a buffer overflow error if
|
||||
* !flush && t==targetLimit
|
||||
* because it is possible that the source will not generate any output.
|
||||
* For example, the skip callback may be called;
|
||||
* it does not output anything.
|
||||
*/
|
||||
|
||||
return toUnicodeWithCallback(source, target, offsets, flush);
|
||||
}
|
||||
|
||||
/* Currently, we are not using offsets in ICU4J. */
|
||||
/* private void updateOffsets(IntBuffer offsets,int length, int sourceIndex, int errorInputLength) {
|
||||
int limit;
|
||||
int delta, offset;
|
||||
|
||||
if(sourceIndex>=0) {
|
||||
/*
|
||||
* adjust each offset by adding the previous sourceIndex
|
||||
* minus the length of the input sequence that caused an
|
||||
* error, if any
|
||||
*/
|
||||
/* delta=sourceIndex-errorInputLength;
|
||||
} else {
|
||||
/*
|
||||
* set each offset to -1 because this conversion function
|
||||
* does not handle offsets
|
||||
*/
|
||||
/* delta=-1;
|
||||
}
|
||||
limit=offsets.position()+length;
|
||||
if(delta==0) {
|
||||
/* most common case, nothing to do */
|
||||
/* } else if(delta>0) {
|
||||
/* add the delta to each offset (but not if the offset is <0) */
|
||||
/* while(offsets.position()<limit) {
|
||||
offset=offsets.get(offsets.position());
|
||||
if(offset>=0) {
|
||||
offsets.put(offset+delta);
|
||||
}
|
||||
//FIXME: ++offsets;
|
||||
}
|
||||
} else /* delta<0 */ /* {
|
||||
/*
|
||||
* set each offset to -1 because this conversion function
|
||||
* does not handle offsets
|
||||
* or the error input sequence started in a previous buffer
|
||||
*/
|
||||
/* while(offsets.position()<limit) {
|
||||
offsets.put(-1);
|
||||
}
|
||||
}
|
||||
} */
|
||||
final CoderResult toUnicodeWithCallback(ByteBuffer source, CharBuffer target, IntBuffer offsets, boolean flush){
|
||||
|
||||
int sourceIndex;
|
||||
int errorInputLength;
|
||||
boolean converterSawEndOfInput, calledCallback;
|
||||
//int t=target.position();
|
||||
int s=source.position();
|
||||
/* variables for m:n conversion */
|
||||
ByteBuffer replayArray = ByteBuffer.allocate(EXT_MAX_BYTES);
|
||||
int replayArrayIndex = 0;
|
||||
|
||||
ByteBuffer realSource=null;
|
||||
boolean realFlush=false;
|
||||
int realSourceIndex=0;
|
||||
|
||||
|
||||
CoderResult cr = CoderResult.UNDERFLOW;
|
||||
|
||||
/* get the converter implementation function */
|
||||
sourceIndex=0;
|
||||
|
||||
if(preToULength>=0) {
|
||||
/* normal mode */
|
||||
} else {
|
||||
/*
|
||||
* Previous m:n conversion stored source units from a partial match
|
||||
* and failed to consume all of them.
|
||||
* We need to "replay" them from a temporary buffer and convert them first.
|
||||
*/
|
||||
realSource=source;
|
||||
realFlush=flush;
|
||||
realSourceIndex=sourceIndex;
|
||||
//UConverterUtility.uprv_memcpy(replayArray, replayBegin, preToUArray, preToUBegin, -preToULength);
|
||||
replayArray.put(preToUArray,0, -preToULength);
|
||||
source=replayArray;
|
||||
source.position(0);
|
||||
source.limit(replayArrayIndex-preToULength);
|
||||
flush=false;
|
||||
sourceIndex=-1;
|
||||
preToULength=0;
|
||||
}
|
||||
|
||||
/*
|
||||
* loop for conversion and error handling
|
||||
*
|
||||
* loop {
|
||||
* convert
|
||||
* loop {
|
||||
* update offsets
|
||||
* handle end of input
|
||||
* handle errors/call callback
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
for(;;) {
|
||||
|
||||
/* convert */
|
||||
cr = decodeLoop(source, target, offsets, flush);
|
||||
|
||||
/*
|
||||
* set a flag for whether the converter
|
||||
* successfully processed the end of the input
|
||||
*
|
||||
* need not check cnv->preToULength==0 because a replay (<0) will cause
|
||||
* s<sourceLimit before converterSawEndOfInput is checked
|
||||
*/
|
||||
converterSawEndOfInput= (cr.isUnderflow() && flush && source.remaining()==0 && toULength == 0);
|
||||
|
||||
/* no callback called yet for this iteration */
|
||||
calledCallback=false;
|
||||
|
||||
/* no sourceIndex adjustment for conversion, only for callback output */
|
||||
errorInputLength=0;
|
||||
|
||||
/*
|
||||
* loop for offsets and error handling
|
||||
*
|
||||
* iterates at most 3 times:
|
||||
* 1. to clean up after the conversion function
|
||||
* 2. after the callback
|
||||
* 3. after the callback again if there was truncated input
|
||||
*/
|
||||
for(;;) {
|
||||
/* update offsets if we write any */
|
||||
/* Currently offsets are not being used in ICU4J */
|
||||
/* if(offsets!=null) {
|
||||
|
||||
int length=(target.position()-t);
|
||||
if(length>0) {
|
||||
updateOffsets(offsets, length, sourceIndex, errorInputLength);
|
||||
|
||||
|
||||
/*
|
||||
* if a converter handles offsets and updates the offsets
|
||||
* pointer at the end, then pArgs->offset should not change
|
||||
* here;
|
||||
* however, some converters do not handle offsets at all
|
||||
* (sourceIndex<0) or may not update the offsets pointer
|
||||
*/
|
||||
//TODO: pArgs->offsets=offsets+=length;
|
||||
/* }
|
||||
|
||||
if(sourceIndex>=0) {
|
||||
sourceIndex+=(source.position()-s);
|
||||
}
|
||||
|
||||
} */
|
||||
|
||||
if(preToULength<0) {
|
||||
/*
|
||||
* switch the source to new replay units (cannot occur while replaying)
|
||||
* after offset handling and before end-of-input and callback handling
|
||||
*/
|
||||
if(realSource==null)
|
||||
{
|
||||
realSource=source;
|
||||
realFlush=flush;
|
||||
realSourceIndex=sourceIndex;
|
||||
|
||||
//UConverterUtility.uprv_memcpy(replayArray, replayBegin, preToUArray, preToUBegin, -preToULength);
|
||||
replayArray.put(preToUArray,0, -preToULength);
|
||||
// reset position
|
||||
replayArray.position(0);
|
||||
|
||||
source=replayArray;
|
||||
source.limit(replayArrayIndex-preToULength);
|
||||
flush=false;
|
||||
if((sourceIndex+=preToULength)<0) {
|
||||
sourceIndex=-1;
|
||||
}
|
||||
|
||||
preToULength=0;
|
||||
} else {
|
||||
/* see implementation note before _fromUnicodeWithCallback() */
|
||||
//agljport:todo U_ASSERT(realSource==NULL);
|
||||
Assert.assrt(realSource==null);
|
||||
}
|
||||
}
|
||||
|
||||
/* update pointers */
|
||||
s=source.position();
|
||||
//t=target.position();
|
||||
|
||||
if(cr.isUnderflow()) {
|
||||
if(s<source.limit())
|
||||
{
|
||||
/*
|
||||
* continue with the conversion loop while there is still input left
|
||||
* (continue converting by breaking out of only the inner loop)
|
||||
*/
|
||||
break;
|
||||
} else if(realSource!=null) {
|
||||
/* switch back from replaying to the real source and continue */
|
||||
source = realSource;
|
||||
flush=realFlush;
|
||||
sourceIndex=realSourceIndex;
|
||||
realSource=null;
|
||||
break;
|
||||
} else if(flush && toULength>0) {
|
||||
/*
|
||||
* the entire input stream is consumed
|
||||
* and there is a partial, truncated input sequence left
|
||||
*/
|
||||
|
||||
/* inject an error and continue with callback handling */
|
||||
cr = CoderResult.malformedForLength(toULength);
|
||||
calledCallback=false; /* new error condition */
|
||||
} else {
|
||||
/* input consumed */
|
||||
if(flush) {
|
||||
/*
|
||||
* return to the conversion loop once more if the flush
|
||||
* flag is set and the conversion function has not
|
||||
* successfully processed the end of the input yet
|
||||
*
|
||||
* (continue converting by breaking out of only the inner loop)
|
||||
*/
|
||||
if(!converterSawEndOfInput) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* reset the converter without calling the callback function */
|
||||
implReset();
|
||||
}
|
||||
|
||||
/* done successfully */
|
||||
return cr;
|
||||
}
|
||||
}
|
||||
|
||||
/* U_FAILURE(*err) */
|
||||
{
|
||||
|
||||
if( calledCallback || cr.isOverflow() ||
|
||||
(cr.isMalformed() && cr.isUnmappable())
|
||||
) {
|
||||
/*
|
||||
* the callback did not or cannot resolve the error:
|
||||
* set output pointers and return
|
||||
*
|
||||
* the check for buffer overflow is redundant but it is
|
||||
* a high-runner case and hopefully documents the intent
|
||||
* well
|
||||
*
|
||||
* if we were replaying, then the replay buffer must be
|
||||
* copied back into the UConverter
|
||||
* and the real arguments must be restored
|
||||
*/
|
||||
if(realSource!=null) {
|
||||
int length;
|
||||
Assert.assrt(preToULength==0);
|
||||
length = source.limit() - source.position();
|
||||
if(length>0) {
|
||||
//UConverterUtility.uprv_memcpy(preToUArray, preToUBegin, pArgs.sourceArray, pArgs.sourceBegin, length);
|
||||
source.get(preToUArray, preToUBegin, length);
|
||||
preToULength=(byte)-length;
|
||||
}
|
||||
|
||||
source=realSource;
|
||||
flush=realFlush;
|
||||
}
|
||||
return cr;
|
||||
}
|
||||
}
|
||||
|
||||
/* copy toUBytes[] to invalidCharBuffer[] */
|
||||
errorInputLength=invalidCharLength=toULength;
|
||||
if(errorInputLength>0) {
|
||||
copy(toUBytesArray, 0, invalidCharBuffer, 0, errorInputLength);
|
||||
}
|
||||
|
||||
/* set the converter state to deal with the next character */
|
||||
toULength=0;
|
||||
|
||||
/* call the callback function */
|
||||
cr = toCharErrorBehaviour.call(this, toUContext, source, target, offsets, invalidCharBuffer, errorInputLength, cr);
|
||||
/*
|
||||
* loop back to the offset handling
|
||||
*
|
||||
* this flag will indicate after offset handling
|
||||
* that a callback was called;
|
||||
* if the callback did not resolve the error, then we return
|
||||
*/
|
||||
calledCallback=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the number of chars held in the converter's internal state
|
||||
* because more input is needed for completing the conversion. This function is
|
||||
* useful for mapping semantics of ICU's converter interface to those of iconv,
|
||||
* and this information is not needed for normal conversion.
|
||||
* @return The number of chars in the state. -1 if an error is encountered.
|
||||
*/
|
||||
/*public*/ int toUCountPending() {
|
||||
if(preToULength > 0){
|
||||
return preToULength ;
|
||||
} else if(preToULength < 0){
|
||||
return -preToULength;
|
||||
} else if(toULength > 0){
|
||||
return toULength;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void copy(byte[] src, int srcOffset, char[] dst, int dstOffset, int length) {
|
||||
for(int i=srcOffset; i<length; i++){
|
||||
dst[dstOffset++]=(char)(src[srcOffset++] & UConverterConstants.UNSIGNED_BYTE_MASK);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* ONLY used by ToU callback functions.
|
||||
* This function will write out the specified characters to the target
|
||||
* character buffer.
|
||||
* @return A CoderResult object that contains the error result when an error occurs.
|
||||
*/
|
||||
static final CoderResult toUWriteUChars( CharsetDecoderICU cnv,
|
||||
char[] ucharsArray, int ucharsBegin, int length,
|
||||
CharBuffer target, IntBuffer offsets, int sourceIndex) {
|
||||
|
||||
CoderResult cr = CoderResult.UNDERFLOW;
|
||||
|
||||
/* write UChars */
|
||||
if(offsets==null) {
|
||||
while(length>0 && target.hasRemaining()) {
|
||||
target.put(ucharsArray[ucharsBegin++]);
|
||||
--length;
|
||||
}
|
||||
|
||||
} else {
|
||||
/* output with offsets */
|
||||
while(length>0 && target.hasRemaining()) {
|
||||
target.put(ucharsArray[ucharsBegin++]);
|
||||
offsets.put(sourceIndex);
|
||||
--length;
|
||||
}
|
||||
}
|
||||
/* write overflow */
|
||||
if(length>0) {
|
||||
cnv.charErrorBufferLength= 0;
|
||||
cr = CoderResult.OVERFLOW;
|
||||
do {
|
||||
cnv.charErrorBufferArray[cnv.charErrorBufferLength++]=ucharsArray[ucharsBegin++];
|
||||
} while(--length>0);
|
||||
}
|
||||
return cr;
|
||||
}
|
||||
/*
|
||||
* This function will write out the Unicode substitution character to the
|
||||
* target character buffer.
|
||||
* Sub classes to override this method if required
|
||||
* @param decoder
|
||||
* @param source
|
||||
* @param target
|
||||
* @param offsets
|
||||
* @return A CoderResult object that contains the error result when an error occurs.
|
||||
*/
|
||||
/* Note: Currently, this method is not being used because the callback method calls toUWriteUChars with
|
||||
* the substitution characters. Will leave in here for the time being. To be removed later. (4.0)
|
||||
*/
|
||||
/*CoderResult cbToUWriteSub(CharsetDecoderICU decoder,
|
||||
ByteBuffer source, CharBuffer target,
|
||||
IntBuffer offsets){
|
||||
String sub = decoder.replacement();
|
||||
CharsetICU cs = (CharsetICU) decoder.charset();
|
||||
if (decoder.invalidCharLength==1 && cs.subChar1 != 0x00) {
|
||||
char[] subArr = new char[] { 0x1a };
|
||||
return CharsetDecoderICU.toUWriteUChars(decoder, subArr, 0, sub
|
||||
.length(), target, offsets, source.position());
|
||||
} else {
|
||||
return CharsetDecoderICU.toUWriteUChars(decoder, sub.toCharArray(),
|
||||
0, sub.length(), target, offsets, source.position());
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
|
@ -0,0 +1,920 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2009, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.charset;
|
||||
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.CodingErrorAction;
|
||||
|
||||
import com.ibm.icu.impl.Assert;
|
||||
import com.ibm.icu.lang.UCharacter;
|
||||
import com.ibm.icu.text.UTF16;
|
||||
|
||||
/**
|
||||
* An abstract class that provides framework methods of decoding operations for concrete
|
||||
* subclasses.
|
||||
* In the future this class will contain API that will implement converter semantics of ICU4C.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public abstract class CharsetEncoderICU extends CharsetEncoder {
|
||||
|
||||
/* this is used in fromUnicode DBCS tables as an "unassigned" marker */
|
||||
static final char MISSING_CHAR_MARKER = '\uFFFF';
|
||||
|
||||
byte[] errorBuffer = new byte[30];
|
||||
|
||||
int errorBufferLength = 0;
|
||||
|
||||
/** these are for encodeLoopICU */
|
||||
int fromUnicodeStatus;
|
||||
|
||||
int fromUChar32;
|
||||
|
||||
boolean useSubChar1;
|
||||
|
||||
boolean useFallback;
|
||||
|
||||
/* maximum number of indexed UChars */
|
||||
static final int EXT_MAX_UCHARS = 19;
|
||||
|
||||
/* store previous UChars/chars to continue partial matches */
|
||||
int preFromUFirstCP; /* >=0: partial match */
|
||||
|
||||
char[] preFromUArray = new char[EXT_MAX_UCHARS];
|
||||
|
||||
int preFromUBegin;
|
||||
|
||||
int preFromULength; /* negative: replay */
|
||||
|
||||
char[] invalidUCharBuffer = new char[2];
|
||||
|
||||
int invalidUCharLength;
|
||||
|
||||
Object fromUContext;
|
||||
|
||||
private CharsetCallback.Encoder onUnmappableInput = CharsetCallback.FROM_U_CALLBACK_STOP;
|
||||
|
||||
private CharsetCallback.Encoder onMalformedInput = CharsetCallback.FROM_U_CALLBACK_STOP;
|
||||
|
||||
CharsetCallback.Encoder fromCharErrorBehaviour = new CharsetCallback.Encoder() {
|
||||
public CoderResult call(CharsetEncoderICU encoder, Object context,
|
||||
CharBuffer source, ByteBuffer target, IntBuffer offsets,
|
||||
char[] buffer, int length, int cp, CoderResult cr) {
|
||||
if (cr.isUnmappable()) {
|
||||
return onUnmappableInput.call(encoder, context, source, target,
|
||||
offsets, buffer, length, cp, cr);
|
||||
} else /* if (cr.isMalformed()) */ {
|
||||
return onMalformedInput.call(encoder, context, source, target,
|
||||
offsets, buffer, length, cp, cr);
|
||||
}
|
||||
// return CharsetCallback.FROM_U_CALLBACK_STOP.call(encoder, context, source, target, offsets, buffer, length, cp, cr);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Construcs a new encoder for the given charset
|
||||
*
|
||||
* @param cs
|
||||
* for which the decoder is created
|
||||
* @param replacement
|
||||
* the substitution bytes
|
||||
*/
|
||||
CharsetEncoderICU(CharsetICU cs, byte[] replacement) {
|
||||
super(cs, (cs.minBytesPerChar + cs.maxBytesPerChar) / 2,
|
||||
cs.maxBytesPerChar, replacement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Encoder allowed to use fallbacks? A fallback mapping is a mapping
|
||||
* that will convert a Unicode codepoint sequence to a byte sequence, but
|
||||
* the encoded byte sequence will round trip convert to a different
|
||||
* Unicode codepoint sequence.
|
||||
* @return true if the converter uses fallback, false otherwise.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
public boolean isFallbackUsed() {
|
||||
return useFallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this Encoder can use fallbacks?
|
||||
* @param usesFallback true if the user wants the converter to take
|
||||
* advantage of the fallback mapping, false otherwise.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
public void setFallbackUsed(boolean usesFallback) {
|
||||
useFallback = usesFallback;
|
||||
}
|
||||
|
||||
/*
|
||||
* Use fallbacks from Unicode to codepage when useFallback or for private-use code points
|
||||
* @param c A codepoint
|
||||
*/
|
||||
final boolean isFromUUseFallback(int c) {
|
||||
return (useFallback)
|
||||
|| (UCharacter.getType(c) == UCharacter.PRIVATE_USE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use fallbacks from Unicode to codepage when useFallback or for private-use code points
|
||||
*/
|
||||
static final boolean isFromUUseFallback(boolean iUseFallback, int c) {
|
||||
return (iUseFallback)
|
||||
|| (UCharacter.getType(c) == UCharacter.PRIVATE_USE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the action to be taken if an illegal sequence is encountered
|
||||
*
|
||||
* @param newAction
|
||||
* action to be taken
|
||||
* @exception IllegalArgumentException
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected void implOnMalformedInput(CodingErrorAction newAction) {
|
||||
onMalformedInput = getCallback(newAction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the action to be taken if an illegal sequence is encountered
|
||||
*
|
||||
* @param newAction
|
||||
* action to be taken
|
||||
* @exception IllegalArgumentException
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected void implOnUnmappableCharacter(CodingErrorAction newAction) {
|
||||
onUnmappableInput = getCallback(newAction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the callback encoder method and context to be used if an illegal sequence is encountered.
|
||||
* You would normally call this twice to set both the malform and unmappable error. In this case,
|
||||
* newContext should remain the same since using a different newContext each time will negate the last
|
||||
* one used.
|
||||
* @param err CoderResult
|
||||
* @param newCallback CharsetCallback.Encoder
|
||||
* @param newContext Object
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
public final void setFromUCallback(CoderResult err, CharsetCallback.Encoder newCallback, Object newContext) {
|
||||
if (err.isMalformed()) {
|
||||
onMalformedInput = newCallback;
|
||||
} else if (err.isUnmappable()) {
|
||||
onUnmappableInput = newCallback;
|
||||
} else {
|
||||
/* Error: Only malformed and unmappable are handled. */
|
||||
}
|
||||
|
||||
if (fromUContext == null || !fromUContext.equals(newContext)) {
|
||||
setFromUContext(newContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets fromUContext used in callbacks.
|
||||
*
|
||||
* @param newContext Object
|
||||
* @exception IllegalArgumentException The object is an illegal argument for UContext.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
public final void setFromUContext(Object newContext) {
|
||||
fromUContext = newContext;
|
||||
}
|
||||
|
||||
private static CharsetCallback.Encoder getCallback(CodingErrorAction action) {
|
||||
if (action == CodingErrorAction.REPLACE) {
|
||||
return CharsetCallback.FROM_U_CALLBACK_SUBSTITUTE;
|
||||
} else if (action == CodingErrorAction.IGNORE) {
|
||||
return CharsetCallback.FROM_U_CALLBACK_SKIP;
|
||||
} else /* if (action == CodingErrorAction.REPORT) */ {
|
||||
return CharsetCallback.FROM_U_CALLBACK_STOP;
|
||||
}
|
||||
}
|
||||
|
||||
private static final CharBuffer EMPTY = CharBuffer.allocate(0);
|
||||
|
||||
/**
|
||||
* Flushes any characters saved in the converter's internal buffer and
|
||||
* resets the converter.
|
||||
* @param out action to be taken
|
||||
* @return result of flushing action and completes the decoding all input.
|
||||
* Returns CoderResult.UNDERFLOW if the action succeeds.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected CoderResult implFlush(ByteBuffer out) {
|
||||
return encode(EMPTY, out, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the from Unicode mode of converter
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected void implReset() {
|
||||
errorBufferLength = 0;
|
||||
fromUnicodeStatus = 0;
|
||||
fromUChar32 = 0;
|
||||
fromUnicodeReset();
|
||||
}
|
||||
|
||||
private void fromUnicodeReset() {
|
||||
preFromUBegin = 0;
|
||||
preFromUFirstCP = UConverterConstants.U_SENTINEL;
|
||||
preFromULength = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes one or more chars. The default behaviour of the
|
||||
* converter is stop and report if an error in input stream is encountered.
|
||||
* To set different behaviour use @see CharsetEncoder.onMalformedInput()
|
||||
* @param in buffer to decode
|
||||
* @param out buffer to populate with decoded result
|
||||
* @return result of decoding action. Returns CoderResult.UNDERFLOW if the decoding
|
||||
* action succeeds or more input is needed for completing the decoding action.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
|
||||
if (!in.hasRemaining() && this.errorBufferLength == 0) { // make sure the errorBuffer is empty
|
||||
// The Java framework should have already substituted what was left.
|
||||
fromUChar32 = 0;
|
||||
//fromUnicodeReset();
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
in.position(in.position() + fromUCountPending());
|
||||
/* do the conversion */
|
||||
CoderResult ret = encode(in, out, null, false);
|
||||
setSourcePosition(in);
|
||||
/* No need to reset to keep the proper state of the encoder.
|
||||
if (ret.isUnderflow() && in.hasRemaining()) {
|
||||
// The Java framework is going to substitute what is left.
|
||||
//fromUnicodeReset();
|
||||
} */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implements ICU semantics of buffer management
|
||||
* @param source
|
||||
* @param target
|
||||
* @param offsets
|
||||
* @return A CoderResult object that contains the error result when an error occurs.
|
||||
*/
|
||||
abstract CoderResult encodeLoop(CharBuffer source, ByteBuffer target,
|
||||
IntBuffer offsets, boolean flush);
|
||||
|
||||
/*
|
||||
* Implements ICU semantics for encoding the buffer
|
||||
* @param source The input character buffer
|
||||
* @param target The output byte buffer
|
||||
* @param offsets
|
||||
* @param flush true if, and only if, the invoker can provide no
|
||||
* additional input bytes beyond those in the given buffer.
|
||||
* @return A CoderResult object that contains the error result when an error occurs.
|
||||
*/
|
||||
final CoderResult encode(CharBuffer source, ByteBuffer target,
|
||||
IntBuffer offsets, boolean flush) {
|
||||
|
||||
/* check parameters */
|
||||
if (target == null || source == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure that the buffer sizes do not exceed the number range for
|
||||
* int32_t because some functions use the size (in units or bytes)
|
||||
* rather than comparing pointers, and because offsets are int32_t values.
|
||||
*
|
||||
* size_t is guaranteed to be unsigned and large enough for the job.
|
||||
*
|
||||
* Return with an error instead of adjusting the limits because we would
|
||||
* not be able to maintain the semantics that either the source must be
|
||||
* consumed or the target filled (unless an error occurs).
|
||||
* An adjustment would be targetLimit=t+0x7fffffff; for example.
|
||||
*/
|
||||
|
||||
/* flush the target overflow buffer */
|
||||
if (errorBufferLength > 0) {
|
||||
byte[] overflowArray;
|
||||
int i, length;
|
||||
|
||||
overflowArray = errorBuffer;
|
||||
length = errorBufferLength;
|
||||
i = 0;
|
||||
do {
|
||||
if (target.remaining() == 0) {
|
||||
/* the overflow buffer contains too much, keep the rest */
|
||||
int j = 0;
|
||||
|
||||
do {
|
||||
overflowArray[j++] = overflowArray[i++];
|
||||
} while (i < length);
|
||||
|
||||
errorBufferLength = (byte) j;
|
||||
return CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
/* copy the overflow contents to the target */
|
||||
target.put(overflowArray[i++]);
|
||||
if (offsets != null) {
|
||||
offsets.put(-1); /* no source index available for old output */
|
||||
}
|
||||
} while (i < length);
|
||||
|
||||
/* the overflow buffer is completely copied to the target */
|
||||
errorBufferLength = 0;
|
||||
}
|
||||
|
||||
if (!flush && source.remaining() == 0 && preFromULength >= 0) {
|
||||
/* the overflow buffer is emptied and there is no new input: we are done */
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not simply return with a buffer overflow error if
|
||||
* !flush && t==targetLimit
|
||||
* because it is possible that the source will not generate any output.
|
||||
* For example, the skip callback may be called;
|
||||
* it does not output anything.
|
||||
*/
|
||||
|
||||
return fromUnicodeWithCallback(source, target, offsets, flush);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation note for m:n conversions
|
||||
*
|
||||
* While collecting source units to find the longest match for m:n conversion,
|
||||
* some source units may need to be stored for a partial match.
|
||||
* When a second buffer does not yield a match on all of the previously stored
|
||||
* source units, then they must be "replayed", i.e., fed back into the converter.
|
||||
*
|
||||
* The code relies on the fact that replaying will not nest -
|
||||
* converting a replay buffer will not result in a replay.
|
||||
* This is because a replay is necessary only after the _continuation_ of a
|
||||
* partial match failed, but a replay buffer is converted as a whole.
|
||||
* It may result in some of its units being stored again for a partial match,
|
||||
* but there will not be a continuation _during_ the replay which could fail.
|
||||
*
|
||||
* It is conceivable that a callback function could call the converter
|
||||
* recursively in a way that causes another replay to be stored, but that
|
||||
* would be an error in the callback function.
|
||||
* Such violations will cause assertion failures in a debug build,
|
||||
* and wrong output, but they will not cause a crash.
|
||||
*/
|
||||
final CoderResult fromUnicodeWithCallback(CharBuffer source,
|
||||
ByteBuffer target, IntBuffer offsets, boolean flush) {
|
||||
int sBufferIndex;
|
||||
int sourceIndex;
|
||||
int errorInputLength;
|
||||
boolean converterSawEndOfInput, calledCallback;
|
||||
|
||||
/* variables for m:n conversion */
|
||||
CharBuffer replayArray = CharBuffer.allocate(EXT_MAX_UCHARS);
|
||||
int replayArrayIndex = 0;
|
||||
CharBuffer realSource;
|
||||
boolean realFlush;
|
||||
|
||||
CoderResult cr = CoderResult.UNDERFLOW;
|
||||
|
||||
/* get the converter implementation function */
|
||||
sourceIndex = 0;
|
||||
|
||||
if (preFromULength >= 0) {
|
||||
/* normal mode */
|
||||
realSource = null;
|
||||
realFlush = false;
|
||||
} else {
|
||||
/*
|
||||
* Previous m:n conversion stored source units from a partial match
|
||||
* and failed to consume all of them.
|
||||
* We need to "replay" them from a temporary buffer and convert them first.
|
||||
*/
|
||||
realSource = source;
|
||||
realFlush = flush;
|
||||
|
||||
//UConverterUtility.uprv_memcpy(replayArray, replayArrayIndex, preFromUArray, 0, -preFromULength*UMachine.U_SIZEOF_UCHAR);
|
||||
replayArray.put(preFromUArray, 0, -preFromULength);
|
||||
source = replayArray;
|
||||
source.position(replayArrayIndex);
|
||||
source.limit(replayArrayIndex - preFromULength); //preFromULength is negative, see declaration
|
||||
flush = false;
|
||||
|
||||
preFromULength = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* loop for conversion and error handling
|
||||
*
|
||||
* loop {
|
||||
* convert
|
||||
* loop {
|
||||
* update offsets
|
||||
* handle end of input
|
||||
* handle errors/call callback
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
for (;;) {
|
||||
/* convert */
|
||||
cr = encodeLoop(source, target, offsets, flush);
|
||||
/*
|
||||
* set a flag for whether the converter
|
||||
* successfully processed the end of the input
|
||||
*
|
||||
* need not check cnv.preFromULength==0 because a replay (<0) will cause
|
||||
* s<sourceLimit before converterSawEndOfInput is checked
|
||||
*/
|
||||
converterSawEndOfInput = (cr.isUnderflow() && flush
|
||||
&& source.remaining() == 0 && fromUChar32 == 0);
|
||||
|
||||
/* no callback called yet for this iteration */
|
||||
calledCallback = false;
|
||||
|
||||
/* no sourceIndex adjustment for conversion, only for callback output */
|
||||
errorInputLength = 0;
|
||||
|
||||
/*
|
||||
* loop for offsets and error handling
|
||||
*
|
||||
* iterates at most 3 times:
|
||||
* 1. to clean up after the conversion function
|
||||
* 2. after the callback
|
||||
* 3. after the callback again if there was truncated input
|
||||
*/
|
||||
for (;;) {
|
||||
/* update offsets if we write any */
|
||||
/* Currently offsets are not being used in ICU4J */
|
||||
/* if (offsets != null) {
|
||||
int length = target.remaining();
|
||||
if (length > 0) {
|
||||
|
||||
/*
|
||||
* if a converter handles offsets and updates the offsets
|
||||
* pointer at the end, then offset should not change
|
||||
* here;
|
||||
* however, some converters do not handle offsets at all
|
||||
* (sourceIndex<0) or may not update the offsets pointer
|
||||
*/
|
||||
/* offsets.position(offsets.position() + length);
|
||||
}
|
||||
|
||||
if (sourceIndex >= 0) {
|
||||
sourceIndex += (int) (source.position());
|
||||
}
|
||||
} */
|
||||
|
||||
if (preFromULength < 0) {
|
||||
/*
|
||||
* switch the source to new replay units (cannot occur while replaying)
|
||||
* after offset handling and before end-of-input and callback handling
|
||||
*/
|
||||
if (realSource == null) {
|
||||
realSource = source;
|
||||
realFlush = flush;
|
||||
|
||||
//UConverterUtility.uprv_memcpy(replayArray, replayArrayIndex, preFromUArray, 0, -preFromULength*UMachine.U_SIZEOF_UCHAR);
|
||||
replayArray.put(preFromUArray, 0, -preFromULength);
|
||||
|
||||
source = replayArray;
|
||||
source.position(replayArrayIndex);
|
||||
source.limit(replayArrayIndex - preFromULength);
|
||||
flush = false;
|
||||
if ((sourceIndex += preFromULength) < 0) {
|
||||
sourceIndex = -1;
|
||||
}
|
||||
|
||||
preFromULength = 0;
|
||||
} else {
|
||||
/* see implementation note before _fromUnicodeWithCallback() */
|
||||
//agljport:todo U_ASSERT(realSource==NULL);
|
||||
Assert.assrt(realSource == null);
|
||||
}
|
||||
}
|
||||
|
||||
/* update pointers */
|
||||
sBufferIndex = source.position();
|
||||
if (cr.isUnderflow()) {
|
||||
if (sBufferIndex < source.limit()) {
|
||||
/*
|
||||
* continue with the conversion loop while there is still input left
|
||||
* (continue converting by breaking out of only the inner loop)
|
||||
*/
|
||||
break;
|
||||
} else if (realSource != null) {
|
||||
/* switch back from replaying to the real source and continue */
|
||||
source = realSource;
|
||||
flush = realFlush;
|
||||
sourceIndex = source.position();
|
||||
realSource = null;
|
||||
break;
|
||||
} else if (flush && fromUChar32 != 0) {
|
||||
/*
|
||||
* the entire input stream is consumed
|
||||
* and there is a partial, truncated input sequence left
|
||||
*/
|
||||
|
||||
/* inject an error and continue with callback handling */
|
||||
//err[0]=ErrorCode.U_TRUNCATED_CHAR_FOUND;
|
||||
cr = CoderResult.malformedForLength(1);
|
||||
calledCallback = false; /* new error condition */
|
||||
} else {
|
||||
/* input consumed */
|
||||
if (flush) {
|
||||
/*
|
||||
* return to the conversion loop once more if the flush
|
||||
* flag is set and the conversion function has not
|
||||
* successfully processed the end of the input yet
|
||||
*
|
||||
* (continue converting by breaking out of only the inner loop)
|
||||
*/
|
||||
if (!converterSawEndOfInput) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* reset the converter without calling the callback function */
|
||||
implReset();
|
||||
}
|
||||
|
||||
/* done successfully */
|
||||
return cr;
|
||||
}
|
||||
}
|
||||
|
||||
/*U_FAILURE(*err) */
|
||||
{
|
||||
|
||||
if (calledCallback || cr.isOverflow()
|
||||
|| (!cr.isMalformed() && !cr.isUnmappable())) {
|
||||
/*
|
||||
* the callback did not or cannot resolve the error:
|
||||
* set output pointers and return
|
||||
*
|
||||
* the check for buffer overflow is redundant but it is
|
||||
* a high-runner case and hopefully documents the intent
|
||||
* well
|
||||
*
|
||||
* if we were replaying, then the replay buffer must be
|
||||
* copied back into the UConverter
|
||||
* and the real arguments must be restored
|
||||
*/
|
||||
if (realSource != null) {
|
||||
int length;
|
||||
|
||||
//agljport:todo U_ASSERT(cnv.preFromULength==0);
|
||||
|
||||
length = source.remaining();
|
||||
if (length > 0) {
|
||||
//UConverterUtility.uprv_memcpy(preFromUArray, 0, sourceArray, pArgs.sourceBegin, length*UMachine.U_SIZEOF_UCHAR);
|
||||
source.get(preFromUArray, 0, length);
|
||||
preFromULength = (byte) -length;
|
||||
}
|
||||
source = realSource;
|
||||
flush = realFlush;
|
||||
}
|
||||
return cr;
|
||||
}
|
||||
}
|
||||
|
||||
/* callback handling */
|
||||
{
|
||||
int codePoint;
|
||||
|
||||
/* get and write the code point */
|
||||
codePoint = fromUChar32;
|
||||
errorInputLength = UTF16.append(invalidUCharBuffer, 0,
|
||||
fromUChar32);
|
||||
invalidUCharLength = errorInputLength;
|
||||
|
||||
/* set the converter state to deal with the next character */
|
||||
fromUChar32 = 0;
|
||||
|
||||
/* call the callback function */
|
||||
cr = fromCharErrorBehaviour.call(this, fromUContext,
|
||||
source, target, offsets, invalidUCharBuffer,
|
||||
invalidUCharLength, codePoint, cr);
|
||||
}
|
||||
|
||||
/*
|
||||
* loop back to the offset handling
|
||||
*
|
||||
* this flag will indicate after offset handling
|
||||
* that a callback was called;
|
||||
* if the callback did not resolve the error, then we return
|
||||
*/
|
||||
calledCallback = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ascertains if a given Unicode code point (32bit value for handling surrogates)
|
||||
* can be converted to the target encoding. If the caller wants to test if a
|
||||
* surrogate pair can be converted to target encoding then the
|
||||
* responsibility of assembling the int value lies with the caller.
|
||||
* For assembling a code point the caller can use UTF16 class of ICU4J and do something like:
|
||||
* <pre>
|
||||
* while(i<mySource.length){
|
||||
* if(UTF16.isLeadSurrogate(mySource[i])&& i+1< mySource.length){
|
||||
* if(UTF16.isTrailSurrogate(mySource[i+1])){
|
||||
* int temp = UTF16.charAt(mySource,i,i+1,0);
|
||||
* if(!((CharsetEncoderICU) myConv).canEncode(temp)){
|
||||
* passed=false;
|
||||
* }
|
||||
* i++;
|
||||
* i++;
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* or
|
||||
* <pre>
|
||||
* String src = new String(mySource);
|
||||
* int i,codepoint;
|
||||
* boolean passed = false;
|
||||
* while(i<src.length()){
|
||||
* codepoint = UTF16.charAt(src,i);
|
||||
* i+= (codepoint>0xfff)? 2:1;
|
||||
* if(!(CharsetEncoderICU) myConv).canEncode(codepoint)){
|
||||
* passed = false;
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param codepoint Unicode code point as int value
|
||||
* @return true if a character can be converted
|
||||
*/
|
||||
/* TODO This is different from Java's canEncode(char) API.
|
||||
* ICU's API should implement getUnicodeSet,
|
||||
* and override canEncode(char) which queries getUnicodeSet.
|
||||
* The getUnicodeSet should return a frozen UnicodeSet or use a fillin parameter, like ICU4C.
|
||||
*/
|
||||
/*public boolean canEncode(int codepoint) {
|
||||
return true;
|
||||
}*/
|
||||
/**
|
||||
* Overrides super class method
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public boolean isLegalReplacement(byte[] repl) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes out the specified output bytes to the target byte buffer or to converter internal buffers.
|
||||
* @param cnv
|
||||
* @param bytesArray
|
||||
* @param bytesBegin
|
||||
* @param bytesLength
|
||||
* @param out
|
||||
* @param offsets
|
||||
* @param sourceIndex
|
||||
* @return A CoderResult object that contains the error result when an error occurs.
|
||||
*/
|
||||
static final CoderResult fromUWriteBytes(CharsetEncoderICU cnv,
|
||||
byte[] bytesArray, int bytesBegin, int bytesLength, ByteBuffer out,
|
||||
IntBuffer offsets, int sourceIndex) {
|
||||
|
||||
//write bytes
|
||||
int obl = bytesLength;
|
||||
CoderResult cr = CoderResult.UNDERFLOW;
|
||||
int bytesLimit = bytesBegin + bytesLength;
|
||||
try {
|
||||
for (; bytesBegin < bytesLimit;) {
|
||||
out.put(bytesArray[bytesBegin]);
|
||||
bytesBegin++;
|
||||
}
|
||||
// success
|
||||
bytesLength = 0;
|
||||
} catch (BufferOverflowException ex) {
|
||||
cr = CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
if (offsets != null) {
|
||||
while (obl > bytesLength) {
|
||||
offsets.put(sourceIndex);
|
||||
--obl;
|
||||
}
|
||||
}
|
||||
//write overflow
|
||||
cnv.errorBufferLength = bytesLimit - bytesBegin;
|
||||
if (cnv.errorBufferLength > 0) {
|
||||
int index = 0;
|
||||
while (bytesBegin < bytesLimit) {
|
||||
cnv.errorBuffer[index++] = bytesArray[bytesBegin++];
|
||||
}
|
||||
cr = CoderResult.OVERFLOW;
|
||||
}
|
||||
return cr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the number of chars held in the converter's internal state
|
||||
* because more input is needed for completing the conversion. This function is
|
||||
* useful for mapping semantics of ICU's converter interface to those of iconv,
|
||||
* and this information is not needed for normal conversion.
|
||||
* @return The number of chars in the state. -1 if an error is encountered.
|
||||
*/
|
||||
/*public*/int fromUCountPending() {
|
||||
if (preFromULength > 0) {
|
||||
return UTF16.getCharCount(preFromUFirstCP) + preFromULength;
|
||||
} else if (preFromULength < 0) {
|
||||
return -preFromULength;
|
||||
} else if (fromUChar32 > 0) {
|
||||
return 1;
|
||||
} else if (preFromUFirstCP > 0) {
|
||||
return UTF16.getCharCount(preFromUFirstCP);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param source
|
||||
*/
|
||||
private final void setSourcePosition(CharBuffer source) {
|
||||
|
||||
// ok was there input held in the previous invocation of encodeLoop
|
||||
// that resulted in output in this invocation?
|
||||
source.position(source.position() - fromUCountPending());
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the codepage substitution character.
|
||||
* Subclasses to override this method.
|
||||
* For stateful converters, it is typically necessary to handle this
|
||||
* specificially for the converter in order to properly maintain the state.
|
||||
* @param source The input character buffer
|
||||
* @param target The output byte buffer
|
||||
* @param offsets
|
||||
* @return A CoderResult object that contains the error result when an error occurs.
|
||||
*/
|
||||
CoderResult cbFromUWriteSub(CharsetEncoderICU encoder, CharBuffer source,
|
||||
ByteBuffer target, IntBuffer offsets) {
|
||||
CharsetICU cs = (CharsetICU) encoder.charset();
|
||||
byte[] sub = encoder.replacement();
|
||||
if (cs.subChar1 != 0 && encoder.invalidUCharBuffer[0] <= 0xff) {
|
||||
return CharsetEncoderICU.fromUWriteBytes(encoder,
|
||||
new byte[] { cs.subChar1 }, 0, 1, target, offsets, source
|
||||
.position());
|
||||
} else {
|
||||
return CharsetEncoderICU.fromUWriteBytes(encoder, sub, 0,
|
||||
sub.length, target, offsets, source.position());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the characters to target.
|
||||
* @param source The input character buffer
|
||||
* @param target The output byte buffer
|
||||
* @param offsets
|
||||
* @return A CoderResult object that contains the error result when an error occurs.
|
||||
*/
|
||||
CoderResult cbFromUWriteUChars(CharsetEncoderICU encoder,
|
||||
CharBuffer source, ByteBuffer target, IntBuffer offsets) {
|
||||
CoderResult cr = CoderResult.UNDERFLOW;
|
||||
|
||||
/* This is a fun one. Recursion can occur - we're basically going to
|
||||
* just retry shoving data through the same converter. Note, if you got
|
||||
* here through some kind of invalid sequence, you maybe should emit a
|
||||
* reset sequence of some kind. Since this IS an actual conversion,
|
||||
* take care that you've changed the callback or the data, or you'll
|
||||
* get an infinite loop.
|
||||
*/
|
||||
|
||||
int oldTargetPosition = target.position();
|
||||
int offsetIndex = source.position();
|
||||
|
||||
cr = encoder.encode(source, target, null, false); /* no offsets and no flush */
|
||||
|
||||
if (offsets != null) {
|
||||
while (target.position() != oldTargetPosition) {
|
||||
offsets.put(offsetIndex);
|
||||
oldTargetPosition++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Note, if you did something like used a stop subcallback, things would get interesting.
|
||||
* In fact, here's where we want to return the partially consumed in-source!
|
||||
*/
|
||||
if (cr.isOverflow()) {
|
||||
/* Overflowed target. Now, we'll write into the charErrorBuffer.
|
||||
* It's a fixed size. If we overflow it...Hm
|
||||
*/
|
||||
|
||||
/* start the new target at the first free slot in the error buffer */
|
||||
int errBuffLen = encoder.errorBufferLength;
|
||||
ByteBuffer newTarget = ByteBuffer.wrap(encoder.errorBuffer);
|
||||
newTarget.position(errBuffLen); /* set the position at the end of the error buffer */
|
||||
encoder.errorBufferLength = 0;
|
||||
|
||||
encoder.encode(source, newTarget, null, false);
|
||||
|
||||
encoder.errorBuffer = newTarget.array();
|
||||
encoder.errorBufferLength = newTarget.position();
|
||||
}
|
||||
|
||||
return cr;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Handles a common situation where a character has been read and it may be
|
||||
* a lead surrogate followed by a trail surrogate. This method can change
|
||||
* the source position and will modify fromUChar32.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* If <code>null</code> is returned, then there was success in reading a
|
||||
* surrogate pair, the codepoint is stored in <code>fromUChar32</code> and
|
||||
* <code>fromUChar32</code> should be reset (to 0) after being read.
|
||||
* </p>
|
||||
*
|
||||
* @param source
|
||||
* The encoding source.
|
||||
* @param lead
|
||||
* A character that may be the first in a surrogate pair.
|
||||
* @return <code>CoderResult.malformedForLength(1)</code> or
|
||||
* <code>CoderResult.UNDERFLOW</code> if there is a problem, or
|
||||
* <code>null</code> if there isn't.
|
||||
* @see #handleSurrogates(CharBuffer, char)
|
||||
* @see #handleSurrogates(CharBuffer, int, char)
|
||||
* @see #handleSurrogates(char[], int, int, char)
|
||||
*/
|
||||
final CoderResult handleSurrogates(CharBuffer source, char lead) {
|
||||
if (!UTF16.isLeadSurrogate(lead)) {
|
||||
fromUChar32 = lead;
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
|
||||
if (!source.hasRemaining()) {
|
||||
fromUChar32 = lead;
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
char trail = source.get();
|
||||
|
||||
if (!UTF16.isTrailSurrogate(trail)) {
|
||||
fromUChar32 = lead;
|
||||
source.position(source.position() - 1);
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
|
||||
fromUChar32 = UCharacter.getCodePoint(lead, trail);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Same as <code>handleSurrogates(CharBuffer, char)</code>, but with arrays. As an added
|
||||
* requirement, the calling method must also increment the index if this method returns
|
||||
* <code>null</code>.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param source
|
||||
* The encoding source.
|
||||
* @param lead
|
||||
* A character that may be the first in a surrogate pair.
|
||||
* @return <code>CoderResult.malformedForLength(1)</code> or
|
||||
* <code>CoderResult.UNDERFLOW</code> if there is a problem, or <code>null</code> if
|
||||
* there isn't.
|
||||
* @see #handleSurrogates(CharBuffer, char)
|
||||
* @see #handleSurrogates(CharBuffer, int, char)
|
||||
* @see #handleSurrogates(char[], int, int, char)
|
||||
*/
|
||||
final CoderResult handleSurrogates(char[] sourceArray, int sourceIndex,
|
||||
int sourceLimit, char lead) {
|
||||
if (!UTF16.isLeadSurrogate(lead)) {
|
||||
fromUChar32 = lead;
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
|
||||
if (sourceIndex >= sourceLimit) {
|
||||
fromUChar32 = lead;
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
char trail = sourceArray[sourceIndex];
|
||||
|
||||
if (!UTF16.isTrailSurrogate(trail)) {
|
||||
fromUChar32 = lead;
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
|
||||
fromUChar32 = UCharacter.getCodePoint(lead, trail);
|
||||
return null;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue