Converting Java Code From WebObjects 3.5
This section covers the details of converting any Java code you may have in an existing WebObjects application (see step 3 above). In WebObjects 4, the Java APIs changed considerably. These changes are summarized here:- A two-letter prefix was added to each Java class name so that class names are unique without the package names. The Java class name is now identical to its Objective-C counterpart in almost all cases. For example, Component is now WOComponent, and WebApplication is now WOApplication.
-
The Java package names changed to the following:
com.apple.yellow.eoaccess
com.apple.yellow.eocontrol
com.apple.yellow.foundation
com.apple.yellow.webobjectsNotice that the next.eo package was split into two packages: eoaccess and eocontrol .
-
The basic classes (for arrays, dictionaries, and data) became more like their Foundation counterparts than their Java counterparts. For example, ImmutableVector is now named NSArray and responds to
count
instead of
size
. MutableHashtable is now named NSMutableDictionary and responds to
setObjectForKey
instead of
put
.
Note that for numbers and strings, you still use the classes java.lang.Number and java.lang.String .
Warning: Changing to Foundation-style methods for the dictionary class introduces a subtle change. The Java Hashtable classes take the arguments in the key-value order. For example, the put method takes the key and then the value. NSDictionary takes the value and then the key. The conversion scripts change the order of the arguments for you. Unfortunately, these scripts incorrectly convert uses of get() and put() on java.util.Hashtable objects as well as on objects of other Foundation classes.
- DecimalNumber is no longer available. Use java.math.BigDecimal instead.
- CalendarDate is now named NSGregorianDate.
- The root object is now com.apple.yellow.foundation.NSObject .
-
Delegate interfaces are now declared as inner interfaces of the appropriate class. For example, the DisplayGroupDelegates interface is now
WODisplayGroup.Delegates
.
© 1999 Apple Computer, Inc. (Last Updated 19 Oct 99)