velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <geirmagnusso...@yahoo.com>
Subject Re: An extention of ResourceLoader
Date Tue, 13 Nov 2001 11:45:43 GMT
On 11/13/01 6:33 AM, "Vitaly Repetenko" <vit@mtu.ru> wrote:

> 
> 
> Vitaly Repetenko wrote:
> 
>> Good day!
>> 
>> I have a problem with developing an extention of ResourceLoader. I use
>> CLOB to store templates in the db.
>> Clob class has a method getAsciiStream which returns InputStream, but
>> this method does not work with Russian charset.
>> I can not use method getCharacterStream because it returns a Reader
>> stream and ResourceLoader does not work with Reader. I was trying to use
>> a temporary variable (String) and class StringBufferInputStream but this
>> class does not properly convert characters into bytes.
>> Any idea?
>> 
>> Thanks in advance,
>> Vitaly
>> 
>> --
>> To unsubscribe, e-mail:
>> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
>> For additional commands, e-mail:
>> <mailto:velocity-user-help@jakarta.apache.org>
> 
> Good day!
> 
> I have found some solution.
> 
>    public synchronized InputStream getResourceStream( String name )
>        throws ResourceNotFoundException
>    {
>      ...
>                    if (rs.next())
>                    {
>                        Clob clob = rs.getClob(templateColumn);
>                        String s = clob.getSubString(1, (int)clob.length());
> 
>                        return new
> ByteArrayInputStream(s.getBytes(inputEncoding));
>                    }
>       ...
>    }
> 
> But I don't think that this is a good solution.
> Is it possible to have ResourceLoader which can work with a Byte stream and  a
> Character stream?
> 
> Thanks in advance,
> Vitaly

You should be able to do that.  The resource loader just needs to delliver a
stream of bytes.

You have to be a touch careful with things like this - I just discovered the
challenges that dealing with CLOBs in Oracle seems to require non-standard
JDBC code... 

Geir


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message