commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randall Lucas <rlu...@tercent.net>
Subject Re: betwixt - java.util.List read/write problems
Date Mon, 14 Apr 2003 06:40:00 GMT

Hi Betwixters,

I've discovered the source of the first issue I report below.

The problem is in the capitalization of names, which appears to depend 
upon the presence of an adder method for a collection property.

When a List property exists with only getThings / setThings methods (no 
addThing method), it appears that the constituents of the List are 
output with capitalized names; in the example below, it would be:

<Dataset>
  <columns>
   <Column />
  </columns>
</Dataset>

However, adding the addThing method causes the output to become:

<Dataset>
  <columns>
   <column />
  </columns>
</Dataset>

(nb the "c" vs. "C" in the singular [c|C]olumn element)

As may be obvious to the Betwixt dev team and experienced users, the 
presence/absence of the wrapper element was moot (as long as the adder 
method appeared in the base bean, things were fine either way).  Also, 
only the top-level bean need be registered; registering the child bean 
types (in this example, Column) is not necessary.  Write IDs is 
likewise unrelated.

This may be an expected outcome, but I think it more likely that there 
is something in the XMLIntrospectionHelper and/or DefaultPluralStemmer 
which begins non-adder-having, Collection property singulars with a 
capital letter.

WRT point (2.) below, note that having the adder method in the root 
Bean type does /not/ fix the fact that writeEmptyElements == false 
seems to prevent the List from being written entirely.

Best,

Randall

On Monday, April 14, 2003, at 12:49 AM, Randall Lucas wrote:

> Hi Betwixt users/developers,
>
> Please advise if these are novice usage issues (and if so, suggested 
> resolutions) or if I should enter these as bugs:
>
> 1. I can't seem to get Betwixt to read in a nested set of beans 
> contained in a java.util.List, although it does write out just fine.  
> What happens is that although the beans that are members of the List 
> are properly written out, upon being read back in, the List-level 
> collection wrapper element is marked as empty.  This seems to be the 
> case whether or not I have writeIDs enabled, whether I use the wrapper 
> element or no wrapper.
>
> class Dataset {
> 	String getShortName / setShortName(String shortName);
> 	List getColumns / setColumns (List columns);
> }
>
> processed via:
>
>             beanWriter.write(ds); //with writeIDs == false
>
> gives:
>
>   <Dataset>
>     <columns>
>       <Column>
>         <columnName>someColumnName</columnName>
>       </Column>
>       <Column>
>         <columnName>someOtherColumnName</columnName>
>       </Column>
>     <shortName>someDatasetName</shortName>
>   </Dataset>
>
> However, reading back in the output (and subsequently writing it 
> [also, checking explicitly with getXXX() on the read-in object]) gives 
> me, again edited for brevity:
>
>   <Dataset>
>     <columns />
>     <shortName>someDatasetName</shortName>
>   </Dataset>
>
> I am registering the xml paths for the object classes with the bean 
> reader using "Dataset" for Dataset.class and  "Dataset/columns/Column" 
> for Column.class.  Ought I to register "Dataset/columns" as a List 
> somehow?  I've tried registering "Dataset/columns" as an ArrayList 
> (since that's instantiable) but it gives the same result.
>
> I've also tried adding to class Dataset an addColumn(Column column) 
> method, with no difference in results.
>
> 2. A related problem, more likely a dev issue / bug, is that when 
> write empty elements is set to false, a java.util.List property 
> containing nested Beans is NOT written out at all.  To draw on the 
> example class in (1.) above, the output of the first, valid Dataset 
> object doesn't write any Column objects when writeEmptyElements is 
> false.
>
> Best,
>
> Randall
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


Mime
View raw message