[Yanel-dev] DOM Helper classes.

simon litwan simon.litwan at wyona.com
Mon Sep 29 22:39:30 CEST 2008


Guillaume Déflache schrieb:
> Alec Bickerton schrieb:
>> Are there any similar helper classes in the yanel core that include the
>> functionality shown below.
>>
>> In short :
>> - Create a new DOM object
>> - Create a text element
>> - Convert a DOM into a String.
>>
>> Not xml related but useful.
>> - Stream data
>>
>> If not, then I would like to include these in a new package under
>> org.wyona.util...
>>
>> WDYT?
>>
>>
>> Code below..
>>
>>     private void streamData( InputStream is, OutputStream os, int
>> packetSize  ) throws IOException {
>>         final byte[ ] packet = new byte[ packetSize ];
>>         int c = 0;
>>         while( ( c = is.read( packet )) != -1  ){
>>             os.write( packet );
>>         }
>>     }
>>   
>
> Looks like 
> http://commons.apache.org/io/api-1.4/org/apache/commons/io/IOUtils.html#copy(java.io.InputStream, 
> java.io.OutputStream) to me, with the burden of thinking of a buffer 
> size, but I wonder: do we already (or want to) use Jakarta Commons IO?
yes, i use them in one of our custom project.
>
>
>>     public static final String toString( Document document, boolean
>> isFragment, boolean indent, String charset ) {
>>   
>
> According to the name of this function, this should be for debugging 
> purposes only, right? Then IMHO we do not need the isFragment 
> parameter/feature, as a document cannot be a fragment anyway.
>
>
>>         } catch (Exception e) {
>>           // todo handle this more specifically
>>         }
>>   
>
> I beg you to never do that!!! How would we notice the exception happened?
>>
>>
>>   
>
> Looks fine to me, we might need *NS variants of these functions too.
> Perhaps createDOM could be renamed to createDocument for consistency 
> with the DOM API.
> Also I suggest wrapping ParserConfigurationException into a 
> RuntimeException else using the function will be tedious.

and i'm not sure, but probably we are not the only ones which could find 
this functionalities useful. first i would have a look if someone else 
already made it available under a compatible license.

simon
> ------------------------------------------------------------------------
>
> _______________________________________________
> Yanel-development mailing list
> Yanel-development at wyona.com
> http://lists.wyona.org/cgi-bin/mailman/listinfo/yanel-development
>   



More information about the Yanel-development mailing list