Santiago Pericas-Geertsen wrote:
> Hi Paul,
>
> Would it make sense to define specific methods for the built-in
> algorithms? I'm a bit worried about the unnecessary boxing/unboxing of
> returning/taking Object instances.
The built-in alrgorithms have optimized access methods that will be used
by the parsers/serializers. For the SAX parser/serializer the
PrimitiveContentHandler will be used to return specific values.
To some extent implementing the built-in algorithms according to the
same interface as the application-defined algorithms may not be
necessary. However, i have found it a useful exercise to see what is
required, i believe it will also be useful for unit testing purposes to
have everything consistent and also will provide good examples of how to
write such algorithms.
> Also, the methods that take streams
> may be useful too.
>
Yes, these are currently commented out, but they are planned.
Paul.
> -- Santiago
>
> On Feb 9, 2005, at 11:08 AM, Paul Sandoz wrote:
>
>> Hi,
>>
>> I have added a preliminary interface for encoding algorithms.
>>
>> This interface is:
>>
>> public interface EncodingAlgorithm {
>>
>> public Object decodeFromBytes(byte[] b, int start, int length);
>>
>> public byte[] encodeToBytes(Object data, byte[] b, int start);
>>
>> // These method may also be required for application-defined
>> algorithm
>> // void decodeFromInputStream(Object data, InputStream s) throws
>> IOException;
>>
>> // void encodeToOutputStream(Object data, OutputStream s) throws
>> IOException;
>>
>> public Object convertFromCharacters(char[] ch, int start, int
>> length);
>>
>> public char[] convertToCharacters(Object data, char ch[], int start);
>>
>> }
>>
>> This interface is also designed to be used for application defined
>> encoding algorithms if we choose to support the registering of such
>> algorithms with the parser and serializer.
>>
>> The SAX interface EncodingAlgorithmContentHandler supports the writing
>> of an Object according to a URI or an id. There can be a mapping from
>> the URI or id to an EncodingAlgorithm from which an Object can be
>> encoded to produce bytes or vice versa.
>>
>> I think i already need to make one modification to the encodeToBytes
>> method. It is not possible to obtain how many bytes have been written.
>> We need a simple ByteArray holder class to be returned for this.
>>
>> Alan, would this meet your requirements for X3D?
>>
>> Paul.
>>
>> --
>> | ? + ? = To question
>> ----------------\
>> Paul Sandoz
>> x38109
>> +33-4-76188109
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_fi.dev.java.net
>> For additional commands, e-mail: dev-help_at_fi.dev.java.net
>>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109