You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/08/01 05:58:01 UTC

cvs commit: jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io BeanWriter.java

jstrachan    2002/07/31 20:58:01

  Modified:    betwixt/src/java/org/apache/commons/betwixt/io
                        BeanWriter.java
  Log:
  Added some helper methods to make it easier to work with streams.
  
  flush() and close() allow flushing & closing of the underlying stream.
  
  writeXmlDeclaration("<xml version='1.0' encoding='UTF-8' ?>") allows you to output whatever XML declaration you want.
  
  Revision  Changes    Path
  1.9       +26 -0     jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java
  
  Index: BeanWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BeanWriter.java	18 Jul 2002 23:19:07 -0000	1.8
  +++ BeanWriter.java	1 Aug 2002 03:58:01 -0000	1.9
  @@ -183,6 +183,32 @@
           this.writer = writer;
       }
   
  +    /**
  +     * A helper method that allows you to write the XML Declaration.
  +     * This should only be called once before you output any beans.
  +     * 
  +     * @param xmlDeclaration is the XML declaration string typically of
  +     *  the form "&lt;xml version='1.0' encoding='UTF-8' ?&gt;
  +     */
  +    public void writeXmlDeclaration(String xmlDeclaration) throws IOException {
  +        writer.write( xmlDeclaration );
  +        writePrintln();
  +    }
  +    
  +    /**
  +     * Allows output to be flushed on the underlying output stream
  +     */
  +    public void flush() throws IOException {
  +        writer.flush();
  +    }
  +    
  +    /**
  +     * Closes the underlying output stream
  +     */
  +    public void close() throws IOException {
  +        writer.close();
  +    }
  +    
       public void write(Object bean) throws IOException, SAXException, IntrospectionException  {
   
           super.write(bean);
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>