Difference between revisions of "ICU4J"

From Eclipsepedia

Jump to: navigation, search
 
Line 1: Line 1:
ICU4J Migration Guide
+
<strong>ICU4J Migration Guide</strong>
 
Last modified: 2006-04-04
 
Last modified: 2006-04-04
 
This document describes how to adopt ICU4J into your application.
 
This document describes how to adopt ICU4J into your application.
Line 5: Line 5:
 
Migration of application code can be done incrementally, meaning full adoption of all ICU4J function is not necessary to reap the benefits of using ICU4J.  Migration can be done in the following four sequential steps:
 
Migration of application code can be done incrementally, meaning full adoption of all ICU4J function is not necessary to reap the benefits of using ICU4J.  Migration can be done in the following four sequential steps:
  
1. Import changes
+
1. <strong>Import changes </strong>
 
Some classes need only be replaced with the ICU equivalent class by changing the import statement (i.e. change java.* with com.ibm.icu.*).
 
Some classes need only be replaced with the ICU equivalent class by changing the import statement (i.e. change java.* with com.ibm.icu.*).
  
Line 22: Line 22:
 
*platform did not adopt ICU's version of StringTokenizer at this time as it will cause a performance degradation vs. the default java.* implementation
 
*platform did not adopt ICU's version of StringTokenizer at this time as it will cause a performance degradation vs. the default java.* implementation
  
2. Parallel APIs
+
2. <strong>Parallel APIs</strong>
 
In this case, you will want to use the corresponding classes and API’s in place of the ones that are included in the JDK (in the java.* packages).
 
In this case, you will want to use the corresponding classes and API’s in place of the ones that are included in the JDK (in the java.* packages).
  
Line 44: Line 44:
 
Note: classes UCharacter, UResourceBundle and ULocale are not implemented in the replacement plug-in (see below) so if your application’s code needs to work with both the replacement plug-in and the real ICU4J plug-in then you will not be able to adopt these classes at this time.
 
Note: classes UCharacter, UResourceBundle and ULocale are not implemented in the replacement plug-in (see below) so if your application’s code needs to work with both the replacement plug-in and the real ICU4J plug-in then you will not be able to adopt these classes at this time.
  
3. Re-structure
+
3. <strong>Re-structure</strong>
 
Some code needs to be re-written to take utilize ICU function.  Discovering code that needs to be re-structured in this manner will not be as systematic as in the previous two steps.
 
Some code needs to be re-written to take utilize ICU function.  Discovering code that needs to be re-structured in this manner will not be as systematic as in the previous two steps.
  
 
Example: use com.ibm.icu.text.BreakIterator to locate boundaries in text instead of iterating over a string and using java.lang.Character.isLetterOrDigit(string.charAt(idx)).
 
Example: use com.ibm.icu.text.BreakIterator to locate boundaries in text instead of iterating over a string and using java.lang.Character.isLetterOrDigit(string.charAt(idx)).
  
4. Utilize New Features
+
4. <strong>Utilize New Features</strong>
 
ICU adds additional function in some areas that is not provided by the JDK.  In this case, new code would need to be written to take advantage of these new features.   
 
ICU adds additional function in some areas that is not provided by the JDK.  In this case, new code would need to be written to take advantage of these new features.   
  
Line 55: Line 55:
  
  
Replacement Plug-in
+
<strong>Replacement Plug-in</strong>
 
The Eclipse SDK will be adopting the ICU4J APIs for Eclipse 3.2.  The addition of the ICU4J plug-in adds on the order of 3MB worth of code.  Some applications may not want to absorb ICU4J if the priority is size over adopting the ICU4J function.  If this is the case for your application, you can download the replacement plug-in (com.ibm.icu.base) from the build page from which you obtained your Eclipse build, remove the com.ibm.icu plug-in and its source counterpart, and drop in the replacement plug-in.  This is required because the Platform adopted the ICU APIs for 3.2 and so just removing the ICU plug-in will result in compilation errors.  The replacement plug-in is about 100KB in size and simply calls through to the java.* packages (default JDK implementation) of the most commonly used classes and APIs in ICU4J.  The classes that are implemented in the replacement plug-in are as follows:
 
The Eclipse SDK will be adopting the ICU4J APIs for Eclipse 3.2.  The addition of the ICU4J plug-in adds on the order of 3MB worth of code.  Some applications may not want to absorb ICU4J if the priority is size over adopting the ICU4J function.  If this is the case for your application, you can download the replacement plug-in (com.ibm.icu.base) from the build page from which you obtained your Eclipse build, remove the com.ibm.icu plug-in and its source counterpart, and drop in the replacement plug-in.  This is required because the Platform adopted the ICU APIs for 3.2 and so just removing the ICU plug-in will result in compilation errors.  The replacement plug-in is about 100KB in size and simply calls through to the java.* packages (default JDK implementation) of the most commonly used classes and APIs in ICU4J.  The classes that are implemented in the replacement plug-in are as follows:
 
• BreakIterator
 
• BreakIterator
Line 73: Line 73:
  
  
Bugs in ICU4J  
+
<strong>Bugs in ICU4J</strong>
 
Bugs that are found in ICU4J should not be logged against Eclipse products or components, they should be logged against the ICU project at:
 
Bugs that are found in ICU4J should not be logged against Eclipse products or components, they should be logged against the ICU project at:
  
Line 79: Line 79:
  
  
More Info
+
<strong>More Info</strong>
 
For more information about ICU4J visit the official home page:
 
For more information about ICU4J visit the official home page:
  

Revision as of 16:41, 7 April 2006

ICU4J Migration Guide Last modified: 2006-04-04 This document describes how to adopt ICU4J into your application.

Migration of application code can be done incrementally, meaning full adoption of all ICU4J function is not necessary to reap the benefits of using ICU4J. Migration can be done in the following four sequential steps:

1. Import changes Some classes need only be replaced with the ICU equivalent class by changing the import statement (i.e. change java.* with com.ibm.icu.*).

Example: change references of java.text.Collator to com.ibm.icu.text.Collator

This should be done for the following classes: • java.text.BreakIterator • java.text.CollationKey • java.text.Collator • java.text.DateFormat • java.text.DecimalFormat • java.text.NumberFormat • java.text.SimpleDateFormat • java.util.StringTokenizer*

  • platform did not adopt ICU's version of StringTokenizer at this time as it will cause a performance degradation vs. the default java.* implementation

2. Parallel APIs In this case, you will want to use the corresponding classes and API’s in place of the ones that are included in the JDK (in the java.* packages).

Example: replace references of java.lang.Character with class com.ibm.icu.lang.UCharacter

The conversion of java.* classes to com.ibm.icu.* classes should be done as follows: • java.lang.Character -> com.ibm.icu.lang.UCharacter • java.lang.Character$UnicodeBlock -> com.ibm.icu.lang.UCharacter$UnicodeBlock", • java.text.DateFormatSymbols -> com.ibm.icu.text.DateFormatSymbols • java.text.DecimalFormatSymbols -> com.ibm.icu.text.DecimalFormatSymbols • java.text.Format -> com.ibm.icu.text.UFormat • java.text.MessageFormat -> com.ibm.icu.text.MessageFormat • java.util.Calendar -> com.ibm.icu.util.Calendar • java.util.Currency -> com.ibm.icu.util.Currency • java.util.GregorianCalendar -> com.ibm.icu.util.GregorianCalendar • java.util.SimpleTimeZone -> com.ibm.icu.util.SimpleTimeZone • java.util.TimeZone -> com.ibm.icu.util.TimeZone • java.util.Locale -> com.ibm.icu.util.ULocale • java.util.ResourceBundle -> com.ibm.icu.util.UResourceBundle

Note: classes UCharacter, UResourceBundle and ULocale are not implemented in the replacement plug-in (see below) so if your application’s code needs to work with both the replacement plug-in and the real ICU4J plug-in then you will not be able to adopt these classes at this time.

3. Re-structure Some code needs to be re-written to take utilize ICU function. Discovering code that needs to be re-structured in this manner will not be as systematic as in the previous two steps.

Example: use com.ibm.icu.text.BreakIterator to locate boundaries in text instead of iterating over a string and using java.lang.Character.isLetterOrDigit(string.charAt(idx)).

4. Utilize New Features ICU adds additional function in some areas that is not provided by the JDK. In this case, new code would need to be written to take advantage of these new features.

Example: the class com.ibm.icu.text.Transliterator


Replacement Plug-in The Eclipse SDK will be adopting the ICU4J APIs for Eclipse 3.2. The addition of the ICU4J plug-in adds on the order of 3MB worth of code. Some applications may not want to absorb ICU4J if the priority is size over adopting the ICU4J function. If this is the case for your application, you can download the replacement plug-in (com.ibm.icu.base) from the build page from which you obtained your Eclipse build, remove the com.ibm.icu plug-in and its source counterpart, and drop in the replacement plug-in. This is required because the Platform adopted the ICU APIs for 3.2 and so just removing the ICU plug-in will result in compilation errors. The replacement plug-in is about 100KB in size and simply calls through to the java.* packages (default JDK implementation) of the most commonly used classes and APIs in ICU4J. The classes that are implemented in the replacement plug-in are as follows: • BreakIterator • CollationKey • Collator • DateFormat • DateFormatSymbols • DecimalFormat • DecimalFormatSymbols • NumberFormat • SimpleDateFormat • StringTokenizer • Calendar • TimeZone • ULocale • MessageFormat


Bugs in ICU4J Bugs that are found in ICU4J should not be logged against Eclipse products or components, they should be logged against the ICU project at:

http://bugs.icu-project.org/cgi-bin/icu-bugs


More Info For more information about ICU4J visit the official home page:

http://www-306.ibm.com/software/globalization/icu/index.jsp

ICU open source project site:

http://icu.sourceforge.net/