The predefined data type and event encoders described in Working with Data Type and Event Encoders should be sufficient for use with most JavaBeans. If you have more complex requirements, you can write your own type encoders in Java and register them for use by the enhanced JavaBean support. Most custom encoders handle complex data types and so will need to represent the object as a string.
A simple example of a complex object rendered as a string is the java.awt.Rectangle
object, which already has a encoder provided. The Rectangle
type
as four attributes; height
, width
, x
,
and y
coordinates. The RectangleEncoder
used by the
enhanced JavaBean support translates that object into a simple string of four
numbers height width x y
separated by spaces. Conversely, the Rectangle
encoder will understand a string in this format and create a new Rectangle
object from it.
Custom encoders can be used to create encoders for Event objects as well as objects used as arguments and return values to methods.
Writing a Custom Data Type Encoder
Writing a Custom Event Encoder