On Sun, Nov 15, 2009 at 7:26 AM, Christopher Schultz
<[email protected]> wrote:
> Nathan,
>
> Resurrecting this because I'm ready to commit.
>
> On 10/29/2009 3:04 PM, Nathan Bubna wrote:
>> On Thu, Oct 29, 2009 at 8:06 AM, Christopher Schultz
>> <[email protected]> wrote:
>>> Nathan,
>>>
>>> On 10/29/2009 11:02 AM, Christopher Schultz wrote:
>>>> I like re-coding into SimpleDataFormat better.
>>>
>>> D'oh: that's not possible because DateFormat doesn't expose the pattern
>>> it's using, so I'll have to return something unrelated. Hmm. I'm not a
>>> big fan of NULL but it's also not exactly consistent with the API if an
>>> error message is returned.
>>>
>>> Any ideas other than NULL?
>>
>> Not really, because a) it's unlikely to ever occur in practice and b)
>> that's the traditional VelocityTools response to bad inputs.  If you
>> call $date.toLocalizedPattern($invalidInput) then that's little better
>> than $date.noSuchMethod($validinput).  Either way, part of the
>> reference is invalid, and we want to render it as an invalid
>> reference.  Returning null accomplishes that.
>
> While I agree that VelocityTools' traditional response to bad input is
> null, the problem here isn't the user's bad input: instead, it's our
> reliance on an unpublished but highly likely coincidence that DateFormat
> always hands-out SimpleDateFormat objects.

ah, but i didn't mean to imply that it is *just* the standard response
to bad input.  it's the convention for all errors when attempting to
execute a tool method.  it tells the user there's a problem in a
consistent manner, responds to silent notation, is easily caught by an
event handler, and properly blows up when VelocityEngine is running in
the new strict mode.  returning an error string would be inconsistent
and fail to draw the attention of other facilities for error
checking/handling that Velocity provides.

> For patterns other than "simple_date" and stuff like that, I could
> simply construct a new SimpleDateFormat object and use that, but then
> the behavior of toLocalizedPattern would differ from the other methods
> -- that is, "short_date" would work, except when it doesn't :(

yeah, but i think that's acceptable.  do the best we can, return null
when nothing can be done.

> Thanks,
> -chris
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to