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.
Does this method follow standard java rules of not reallocating of the
array is big enough? Instead of a wrapper class, how about a
getNumberBytesWritten to get the last number of bytes?
> We need a simple ByteArray holder class to be returned for this.
>
> Alan, would this meet your requirements for X3D?
>
I think so. I'm still a week away from moving my code over. Sorry for
the delay.
Having both the byte and stream version will require some extra coding
but its likely worth it for the flexibility. Internally I think I just
handle streams right now.