dev@fi.java.net

Re: StAX factories and TCK

From: Joe Wang <joe.wang_at_sun.com>
Date: Tue, 11 Jan 2005 09:12:48 -0800

Paul Sandoz wrote:

> Joe Wang wrote:
>
>> InputFactory:
>> As discussed with Santiago (see below), when the input is a XML file
>> in the form of a java.io.Reader, InputFactory will convert it into
>> FI format before it can return a stream reader. I've added a
>> "convert" method in tool XML_SAX_FI to transform the xml file into an
>> OutputStream. In the InputFactory, the createXMLStreamReader method
>> will use a PipedOutputStream to call this method
>> (XML_SAX_FI->convert(xml,outputStream)). This is to avoid writing the
>> resulting FI doc out to the file system. The OutputStream will then
>> be used to create a PipedInputStream which will be used to create a
>> stream reader StAXDocumentParser(inputStream, manager) (*for this new
>> constructor, pls see the next email).
>> Frankly, I'm not familiar with Piped streams, only know it
>> conceptually. Will need to test it out. Initially, I thought about
>> writing out temporary FI files, but believed the piped streams would
>> be better.
>>
>
> PipedOutputStream would be used more in the case of asynchronous
> processing.
>
> In your case it should all be synchronous so it should also be
> possible to write/read directly to/from memory using
> ByteArrayInout/OutputStream.
>
This is good to know. I'll try it out.

> Note the warning in the JavaDoc for PipedOutputStream:
>
> "Attempting to use both objects from a single thread is not
> recommended as it may deadlock the thread."
>
I noticed the note too. The convert function will be running in another
thread and the parser created in main thread. I'll test both ByteArray
streams and Piped. I agree with you, ByteArray looks easier and better.

Joe

> So it might be OK but...
>
> Paul.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_fi.dev.java.net
For additional commands, e-mail: dev-help_at_fi.dev.java.net