On Tue, October 23, 2007 10:16, Paul Sandoz wrote:
> Florian Rosenberg wrote:
>>> Some possible solutions:
>>>
>>> 1) We could provide a Collection type entity provider that checks if
>>> all
>>> of the objects are JAXB element objects, if so a root element is
>>> written out and then each JAXB element is marshalled.
>>>
>>> 2) A generic collection type class with an entity provider:
>>>
>>> class CollectionType<T> {
>>> Collection<T> c;
>>>
>>> CollectionType(Collection<T> c) { ... }
>>> }
>>>
>>> The entity provider can then create a JAXBElement instance:
>>>
>>> QName q = // work out root element name from c
>>> new JAXBElement(q, CollectionType.class, c)
>>
>> I would go with (1) just for simplicity and it allows the user to stick
>> to
>> his preferred API without used the typed collection.
>
> Right. Since similar classes for 2) i have mentioned will be required
> for an implementation of 1) i think i can expose various things out
> depending on if developers need simplicity, performance or configuration
> of the root element and for each case don't require to create a
> collection class for each entry class.
>
> https://jersey.dev.java.net/issues/show_bug.cgi?id=18
hopefully, I have some time to help on that issues this week...
>> when going for (1)
>> you need to find a name for the root element, eg., customers if the
>> objects in the collection are of type Customer.
>>
>
> Yes, same applies for 2). I need some pluralizer code that given a
> singular word returns the plural. I suppose i could append an 's', know
> of anything better i could use?
I send a link as a response to Mark's posting but I don't now how mature
it is.
appending an "s" as a first draft seems to be fine, but there are a lot of
exceptions, e.g., people has both, a plural and singular sense. some other
exception are:
man -> men
thief -> thieves
person -> people
-Florian