View Javadoc
1 /* 2 * Copyright (C) The Apache Software Foundation. All rights reserved. 3 * 4 * This software is published under the terms of the Apache Software License 5 * version 1.1, a copy of which has been included with this distribution in 6 * the LICENSE file. 7 * 8 * $Id: RSSBeanWriter.java,v 1.4 2002/05/28 11:49:29 jstrachan Exp $ 9 */ 10 package org.apache.commons.betwixt; 11 12 import java.io.FileInputStream; 13 import java.io.InputStream; 14 15 import org.apache.commons.betwixt.io.BeanWriter; 16 import org.apache.commons.digester.rss.RSSDigester; 17 18 /*** Reads an RSS file using Digesters's RSS demo then uses Betwixt 19 * to output it as XML again. 20 * 21 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> 22 * @version $Revision: 1.4 $ 23 */ 24 public class RSSBeanWriter extends AbstractTestCase { 25 26 public RSSBeanWriter(String testName) { 27 super(testName); 28 } 29 30 public static void main(String[] args) throws Exception { 31 RSSBeanWriter sample = new RSSBeanWriter("RSS"); 32 sample.run( args ); 33 } 34 35 public void run(String[] args) throws Exception { 36 RSSDigester digester = new RSSDigester(); 37 Object bean = null; 38 if ( args.length > 0 ) { 39 bean = digester.parse( args[0] ); 40 } 41 else { 42 InputStream in = new FileInputStream( getTestFile("src/test/org/apache/commons/betwixt/rss-example.xml") ); 43 bean = digester.parse( in ); 44 in.close(); 45 } 46 47 write( bean ); 48 } 49 50 public void write(Object bean) throws Exception { 51 BeanWriter writer = new BeanWriter(); 52 writer.getXMLIntrospector().setAttributesForPrimitives(false); 53 writer.enablePrettyPrint(); 54 writer.write( bean ); 55 } 56 } 57

This page was automatically generated by Maven