Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Extra GOODS Type Information
Last updated at 11:55 am UTC on 17 January 2006
The GOODS interface for Squeak doesn't require any manual specification of types for use with Squeak-only clients. However, to interoperate with Java clients using the same data, it's necessary to give the same kind of static type information that Java uses - which fields are ints/Strings/doubles, which are arrays, and so on. This information is stored in instances of KKClassDescriptor, which are built by the #goodsDescriptor class method on Object. To specify type information for one of your classes, you could entirely override #goodsDescriptor; however, it's easier to add/override a few helper methods instead:

#goodsClassName returns the fully qualified class name to be used in the database. The default is just to return the Squeak class name. You'll want to override this if you're trying to match a particular Java class and package.

#goodsFieldDescriptorNamed: is called once for each instance variable in the class. Its default behavior is to check for a class method of the form #[field]Descriptor. To specify the type for an instance variable, add the appropriate method and have it return an instance of a KKFieldContainer subclass. For example, to specify that the 'count' instance variable is an 8 byte signed integer, add

countDescriptor
^ KKSingleFieldContainer longField

as a class method. The possible container types are KKSingleFieldContainer (for normal field values), KKVariableFieldContainer (for variable-sized arrays; only one is possible per class), and KKFixedArrayContainer (for fixed-size arrays). All of the Java field types can be specified, as well as #stringField for strings and #referenceField for pointers. So, for example, an array 'scores' of ints of size 10 would look like

scoresDescriptor
^ (KKFixedArrayContainer intField) arraySize: 10

Note that arrays of strings are not possible as immediate values - use an array of references instead, and full string objects.