commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Dudziak <>
Subject [betwixt] Why is the name attribute in betwixt's element tag required when used for references to other mapped classes ?
Date Wed, 06 Apr 2005 20:32:56 GMT
Say, I have a class SomeClass that holds an object of a subclass of
the interface SomeInterface:

public class SomeClass
  private SomeInterface obj;
  public SomeInterface getObj()
    return obj;
  public void setObj(SomeInterface obj)
    this.obj = obj;

public interface SomeInterface

public class SomeOtherClassA implements SomeInterface

public class SomeOtherClassB implements SomeInterface

then in the multi-mapping (using betwixt from SVN):

<?xml version="1.0"?>
    <class name="SomeClass">
        <element name="some-class">
            <element name="whatever" property="obj"/>
    <class name="SomeOtherClassA">
        <element name="other-a"/>
    <class name="SomeOtherClassB">
        <element name="other-b"/>

I have to specify the name for the property SomeClass#obj even though
there are mappings for the two sub classes. This leads to the problem
that I cannot get other-a or other-b to appear in the generated XML
since the name 'whatever' is harcoded in the mapping.

Now I did a little test and simply commented out the check for the
name attribute in org.apache.commons.betwixt.digester.ElementRule,
lines 113-116. After this I can omit the name attribute and get
other-a or other-b depending on which type the object has.

My question now is, would it be possible to completely remove the
check for the name attribute in ElementRule ? IMO if it is not given
for fields whose type is not explicitly mapped, the name of the field
could be used when writing the XML attribute for the field. And for
references to other mapped classes, it might be useful to be able to
specify the name, i.e. for forcing the name of the XML sub element,
but most of the time you wouldn't want it there.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message