View Javadoc
1 /* 2 * PROJECT : DAR Runtime and Tools 3 * COPYRIGHT : Copyright (C) 1999-2004 tim.stephenson@enableit.org 4 * LICENSE : GNU LESSER GENERAL PUBLIC LICENSE 5 * Version 2.1, February 1999 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 */ 21 package org.enableit.db.darrt; 22 23 import java.io.IOException; 24 import java.io.InputStream; 25 import java.io.InputStreamReader; 26 27 import org.apache.log4j.Logger; 28 import org.enableit.db.DBException; 29 import org.enableit.db.beans.RowSet; 30 import org.enableit.db.beans.Table; 31 import org.exolab.castor.xml.Unmarshaller; 32 33 34 /*** 35 * @author tim.stephenson 36 */ 37 public class XmlDataParser implements DataParser { 38 private static Logger logger = Logger.getLogger(XmlDataParser.class); 39 40 /*** 41 * Default constructor. 42 */ 43 public XmlDataParser() { 44 } 45 46 /*** 47 * Convert an input stream of CSV data for the specified table into a 48 * structured format of a <code>RowSet</code>. 49 * @param is Any <code>Reader</code> wrapper to input stream. 50 * @param table The name of the target Table for the RowSet. 51 * @return A RowSet instance holding the data from the InputStream. 52 * @throws IOException 53 * @throws DBException 54 */ 55 public RowSet getRowSet(InputStream is, Table table) 56 throws IOException, DBException { 57 logger.info("METHOD_ENTRY: getRowSet"); 58 59 RowSet rows = null; 60 61 try { 62 // Unmarshal rowset ... 63 InputStreamReader isr = new InputStreamReader(is); 64 65 rows = (RowSet) Unmarshaller.unmarshal(RowSet.class, isr); 66 } catch (org.exolab.castor.xml.MarshalException e) { 67 logger.error(e.getMessage(), e); 68 throw new DBException(e.getMessage(), e); 69 } catch (org.exolab.castor.xml.ValidationException e) { 70 logger.error(e.getMessage(), e); 71 throw new DBException(e.getMessage(), e); 72 } 73 74 logger.info("METHOD_EXIT: getRowSetCSV"); 75 76 return rows; 77 } 78 }

This page was automatically generated by Maven