Re: Java datatype library: value object->string conversion
Julian Scheid <[email protected]> Wed, 03 Nov 2004 20:06:18 +0100
| Newsgroups | gmane.text.xml.relaxng.general |
|---|---|
| Message-ID | <[email protected]> |
Kohsuke Kawaguchi wrote: > Julian Scheid wrote: > >> I'm working on a Relax NG implementation which needs to convert data >> values two-way, both string->object and object->string. I'd like to >> use the datatype library interface for this purpose, but I can't seem >> to find a method complementing DataType.createValue(), one that >> converts a value object to a string. Is there a reason for the API's >> read-only design, or am I missing something? > > > I guess it's just because value->string conversion wasn't necessary to > build validators. Thanks for your reply. Is there any interest in extending the scope of the datatype library API to cover code generators in addition to validators? This would require adding the value->string method and, more importantly, one for retrieving the value object type. Something along the lines of: public String createLiteral(Object value, ValidationContext ctx); public Class getValueType(); The latter method alone would be a very helpful addition to the API with regard to code generation. I understand that changing Datatype's definition means breaking compatibility, but what about introducing a subinterface or a separate interface for conversion/generation purposes? I think it would be a pity if code generators couldn't leverage datatype libraries, or would have to jump through hoops only because of this minor limitation. Julian