treebind
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Treebind] Binding arbitrary data


From: Eric van der Vlist
Subject: [Treebind] Binding arbitrary data
Date: Thu, 12 May 2005 17:39:04 +0200

Hi,

Here comes my first question/suggestion...

In the current version (1.1), the JavaObjectSink class
http://savannah.nongnu.org/cgi-bin/viewcvs/treebind/treebind/src/org/treebind/JavaObjectSink.java
 that bind data into Java objects makes two attempts to bind a data named "foo":

     1. It tries to use a "adder method" (typically a method called
        "addFoo" but that name can be overridden). 
     2. If that fails it tries to use a "setter method" (typically a
        method called "setFoo" but that name can be overridden).

When that fails, the class raises an exception.

To support cases where arbitrary data (which name is not always known in
advance) needs to be binded, we have developed a mechanism based on
"collections" that can, as a fallback, bind a collection of arbitrary
data through a setter method accepting a SimpleCollectionReservoir as
its parameter.

While this seemed pretty useful when we've created this feature, this is
not meeting one of my today's need which is to accept any data in a
class which is not a collection.

The difference is that while the current mechanism accepts:

Class
  + Class
  + Class
  + Collection
    + arbitrary data
    + arbitrary data

I'd like to have :

Class
  + Class
  + arbitrary data
  + Class
  + arbitrary data
  
A simple way to achieve this would be to add a third bind attempt in
JavaObjectSink :

     1. It tries to use a "adder method" (typically a method called
        "addFoo" but that name can be overridden). 
     2. If that fails it tries to use a "setter method" (typically a
        method called "setFoo" but that name can be overridden).
     3. [new] If that fails, it tries to use a "generic adder
        method" (typically a method called "add" but that name can be
        overridden). This method has two parameters (a name and the
        object).

Does that make sense?

Do you have better ideas? suggestions?

Thanks,

Eric
-- 
Lisez-moi sur XMLfr.
                       http://xmlfr.org/index/person/eric+van+der+vlist/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(ISO) RELAX NG   ISBN:0-596-00421-4 http://oreilly.com/catalog/relax
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]