dev@javaserverfaces.java.net

Re: [REVIEW] Fix for spec issue 172

From: Roger Kitain <Roger.Kitain_at_Sun.COM>
Date: Wed, 16 Aug 2006 11:44:01 -0400

I like the verbage and approach.
I've posted another change bundle.

-roger

Robertson, Tony wrote:

> I also don't understand why the "targetClass.getEnumConstants()" is
> used at all.
> If you want to check that the "value" really is one of the enum
> constants,
> then calling "targetClass.isInstance(value)" is sufficient.
> Given that all enums are effectively "final" classes with only private
> constructors, any instance of an enum class must also be a member of the
> "enumConstants" list.
> This seems to be another case where the javadoc comment for this
> interface
> (which is therefore part of the JSF-API spec) is describing an
> implementation
> instead of describing a behaviour.
>
> If you are going to change the javadoc (and therefore the API spec) I
> would
> rather see a clear description of the required "behaviour" only.
> Perhaps something more like this:
>
> <p>Convert the enum constant given by the <code>value</code>
> argument into a String. If no target class argument has been
> provided to the constructor of this instance, throw a
> <code>ConverterException</code> containing the
> {_at_link #ENUM_NO_CLASS_ID} message with proper parameters.
> If the <code>value</code> argument is <code>null</code>,
> return <code>null</code>.
> If the value is an instance of the provided target class,
> Return its string value (<code>value.toString()</code>).
> Otherwise, throw a {_at_link ConverterException} containing the
> {_at_link #ENUM_ID} message with proper parameters.</p>
>
>
> ----------------------------------------------------------
> Date: Tue, 15 Aug 2006 15:40:30 -0500
> From: Jason Lee <lee_at_iecokc.com>
> Subject: [REVIEW] Fix for spec issue 172
>
> Just out of curiosity, why use the break, then the test? Why not do
> this?
>
> for (int i=0; i<enumConstants.length; i++) {
> if (enumConstants[i].equals(value)) {
> return value.toString();
> }
> }
>
> // No match found, so throw an exception
> throw new ConverterException(
> MessageFactory.getMessage(context,
> ENUM_ID,
> value,
> value,
> MessageFactory.getLabel(context,
> component)));
>
> -----
> Jason Lee
> Programmer/Analyst
> _http://www.iecokc.com_
>
>
> > -----Original Message-----
> > From: Roger.Kitain_at_Sun.COM [_mailto:Roger.Kitain_at_Sun.COM_]
> > Sent: Tuesday, August 15, 2006 2:55 PM
> > To: dev_at_javaserverfaces.dev.java.net
> > Subject: [REVIEW] Fix for spec issue 172
> >
> >
> _https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=172_
>
> >
> > Changes attached to issue.
> >
>