Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 63916 invoked from network); 16 Nov 2004 08:09:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 16 Nov 2004 08:09:46 -0000 Received: (qmail 97903 invoked by uid 500); 16 Nov 2004 08:09:32 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 97509 invoked by uid 500); 16 Nov 2004 08:09:28 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@cocoon.apache.org Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 96807 invoked by uid 99); 16 Nov 2004 08:09:21 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from [157.193.121.51] (HELO otsrv1.iic.ugent.be) (157.193.121.51) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 16 Nov 2004 00:09:18 -0800 Received: from 192.168.123.145 ([192.168.123.145]) by otsrv1.iic.ugent.be (8.11.6/8.11.6) with ESMTP id iAG789N30650 for ; Tue, 16 Nov 2004 08:08:09 +0100 Subject: Re: [RT] Attribute Rendering and CForms Convertors From: Bruno Dumon To: dev@cocoon.apache.org In-Reply-To: <4191F846.1040200@nada.kth.se> References: <5E091A68F794974CAF431CA31F5AF2CC11E99F@server.bizzdesign.nl> <4187D02F.9090209@nada.kth.se> <418A3C62.7020800@apache.org> <418B4E93.5050808@nada.kth.se> <418B53C3.9020000@mobilebox.pl> <418DF5D1.6060005@gmx.de> <418E4BA0.2000206@mobilebox.pl> <418E8BA9.6040505@gmx.de> <418F7060.3020708@mobilebox.pl> <1100022882.2659.8.camel@localhost.localdomain> <4191F846.1040200@nada.kth.se> Content-Type: text/plain Organization: Outerthought Date: Tue, 16 Nov 2004 09:05:19 +0100 Message-Id: <1100592320.32451.95.camel@yum.site> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 Rubber Turnip www.usr-local-bin.org Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Wed, 2004-11-10 at 12:15 +0100, Daniel Fagerstrom wrote: > CForms Convertor Integration > ---------------------------- > > Here is the Convertor interface: > > public interface Convertor { > > /** > * Converts string representation into the object of convertor's type. > * > * @param formatCache can be null if not needed > */ > ConversionResult convertFromString(String value, Locale locale, FormatCache formatCache); > > String convertToString(Object value, Locale locale, FormatCache formatCache); > > Class getTypeClass(); > > /** > * Generates a bit of information about this convertor (optional). > */ > void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException; > > public interface FormatCache { > public Object get(); > public void store(Object object); > } > } > > The main problem is the ConversionResult. It is a class that in turn > uses some CForms specific stuff, (ValidationError, I18NMessage and > Cosntants). I think the idea of having a ConversionResult is ok, but we > need to make it independent of the rest of CForms. > > AFAICS we don't need the formatCache in a convertion component, each > convertor will only be needed to be defined once The purpose of the formatCache is if a lot of values need to be converted using the same convertor, which is (or can be) the case in selection lists. Java's DateFormat and NumberFormat classes are not thread-safe, so they need to be recreated for each conversion, and this can be quite heavy (eg the number or date formatting pattern must be reparsed each time). The format cache allows to store the prepared Date/NumberFormat instance, but is completely optional. -- Bruno Dumon http://outerthought.org/ Outerthought - Open Source, Java & XML Competence Support Center bruno@outerthought.org bruno@apache.org